summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Ejdestig <martin.ejdestig@volvocars.com>2020-12-14 01:43:52 +0100
committerGitHub <noreply@github.com>2020-12-14 09:43:52 +0900
commit8f5e3dc0f3134ea2fdaffd13a16464b1a2f2ecd4 (patch)
treecd371956f6098d4d7e9e0937a929e87e5e5f0f71 /tests
parent329ba78deb40558df30aa8731928c9887197d30b (diff)
downloadDLT-daemon-8f5e3dc0f3134ea2fdaffd13a16464b1a2f2ecd4.tar.gz
Add support for logging with VSOCK (#255)
For more information about VSOCK, see "man vsock" ( https://man7.org/linux/man-pages/man7/vsock.7.html ). Makes it possible for processes in a virtual machine to log directly in DLT running on host without setting up a network connection between guest and host. It is also probably more efficient. Have not done any performance measurements (not main reason for patch), but no forwarding is required as when running DLT in a multi-node setup. When building dlt-daemon for host, WITH_DLT_DAEMON_VSOCK_IPC should be enabled for daemon to listen on incoming VSOCK requests. Local communication method between applications and daemon is still determined with DLT_IPC. When building for guest, WITH_DLT_LIB_VSOCK_IPC should be enabled and DLT_IPC will be ignored, which will make libdlt open a VSOCK socket to the deamon for logging messages. VSOCK can be tested without a virtual machine. Since VMADDR_CID_HOST is used by libdlt when connecting, see vsock man page, clients can be run on host to test VSOCK communication. Some modifications has been done to be able to handle logging through FIFO pipe and socket in the same build of dlt-daemon: - dlt_receiver_init/free_unix_socket() is renamed to dlt_receiver_init/free_global_buffer() and used for FIFO as well. Also fixes memory leak since dlt_receiver_free_unix_socket() was used regardless of whether DLT_USE_UNIX_SOCKET was defined or not. - Pass type to dlt_receiver_init() instead of dlt_receiver_receive(). And remove preprocessor conditionals for handling DLT_CONNECTION_APP_MSG in dlt_daemon_process_user_messages(). Also fixes wrong enum type being passed to dlt_receiver_receive() in dlt_client.c (DltClient::mode was used as a DltReceiverType enum but it is a DltClientMode enum). - Add a flag to DltDaemonApplication to indicate whether file descriptor is "owned" by the DltDaemonApplication or not. When dlt_daemon_application_add() is called due to message received on a socket, fd is passed as an argument (app does not own fd). For FIFO, a per application FIFO is opened (app owns the fd). Also fixes so that user handle is reset for both application and all its contexts when resetting any. Prevents fd from being used by accident after it has been closed. dlt_mkdir_recursive() is moved to src/daemon since it is only used in the daemon. Minimizes use of DLT_USE_UNIX_SOCKET_IPC. Other bugfixes: - Call DLT_SEM_FREE() if setting socket to O_NONBLOCK fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). - Close socket if dlt_receiver_init() fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/gtest_dlt_daemon_offline_log.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/gtest_dlt_daemon_offline_log.cpp b/tests/gtest_dlt_daemon_offline_log.cpp
index 0bd4d5e..be6404c 100644
--- a/tests/gtest_dlt_daemon_offline_log.cpp
+++ b/tests/gtest_dlt_daemon_offline_log.cpp
@@ -1649,7 +1649,7 @@ TEST(t_dlt_logstorage_sync_msg_cache, null)
int connectServer(void)
{
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
int sockfd, portno;
struct sockaddr_in serv_addr;
struct hostent *server;
@@ -1668,7 +1668,7 @@ int connectServer(void)
close(sockfd);
return -1;
}
-#else
+#else /* DLT_DAEMON_USE_FIFO_IPC */
char filename[1024];
int sockfd;
snprintf(filename, 1024, "/tmp/dltpipes/dlt%d", getpid());
@@ -1687,7 +1687,7 @@ int connectServer(void)
int main(int argc, char **argv)
{
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
pid_t cpid;
cpid = fork();
@@ -1758,7 +1758,7 @@ int main(int argc, char **argv)
::testing::FLAGS_gtest_break_on_failure = false;
/* ::testing::FLAGS_gtest_filter = "t_dlt_event_handler_register_connection*"; */
return RUN_ALL_TESTS();
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
}
#endif