From 16749747cc5827b346b818a947b360c060d7667f Mon Sep 17 00:00:00 2001 From: Le-Tin Date: Wed, 1 Sep 2021 10:54:43 +0000 Subject: gtest_dlt_daemon_gateway: fix gtest build failed Add gtest and gtest_main libraries if we don't install gtest package in system Create a new message fillter config file when running gtest gateway shell script set type of control message is CONTROL_MESSAGE_ON_DEMAND when testing dlt_gateway_send_control_message function Signed-off-by: Le-Tin --- tests/CMakeLists.txt | 14 +++++++++----- tests/gtest_dlt_daemon_gateway.cpp | 1 + tests/gtest_dlt_daemon_gateway.sh | 8 +++++--- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ccf6e03..a461891 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,8 +8,12 @@ configure_file(${PROJECT_SOURCE_DIR}/tests/testfile.dlt ${PROJECT_BINARY_DIR}/te configure_file(${PROJECT_SOURCE_DIR}/tests/testfilter.txt ${PROJECT_BINARY_DIR}/tests COPYONLY) configure_file(${PROJECT_SOURCE_DIR}/tests/testfile_filetransfer.txt ${PROJECT_BINARY_DIR}/tests COPYONLY) -set(GTEST_LIBS gtest gtest_main) -set(GTEST_LIBS ${GTEST_LIBS} CACHE STRING "Gtest libraries") +if("${GTEST_BOTH_LIBRARIES}" STREQUAL "") + set(GTEST_LIBS gtest gtest_main) + set(GTEST_LIBS ${GTEST_LIBS} CACHE STRING "Gtest libraries") +else() + set(GTEST_LIBS ${GTEST_BOTH_LIBRARIES}) +endif() if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(LIBRARIES "") @@ -17,9 +21,9 @@ else() set(LIBRARIES socket) endif() -set(DLT_LIBRARIES dlt ${GTEST_BOTH_LIBRARIES} ${LIBRARIES}) -set(DLT_DAEMON_LIBRARIES dlt_daemon ${GTEST_BOTH_LIBRARIES} ${LIBRARIES}) -set(DLT_CONTROL_LIBRARIES dlt dlt_control_common_lib ${GTEST_BOTH_LIBRARIES}) +set(DLT_LIBRARIES dlt ${GTEST_LIBS} ${LIBRARIES}) +set(DLT_DAEMON_LIBRARIES dlt_daemon ${GTEST_LIBS} ${LIBRARIES}) +set(DLT_CONTROL_LIBRARIES dlt dlt_control_common_lib ${GTEST_LIBS}) #Receiver used for QTs. add_test() is not required add_executable(dlt_test_receiver dlt_test_receiver.c) diff --git a/tests/gtest_dlt_daemon_gateway.cpp b/tests/gtest_dlt_daemon_gateway.cpp index 5bdefac..418ed86 100644 --- a/tests/gtest_dlt_daemon_gateway.cpp +++ b/tests/gtest_dlt_daemon_gateway.cpp @@ -121,6 +121,7 @@ TEST(t_dlt_gateway_send_control_message, Normal) (void) dlt_gateway_init(&daemon_local, 0); daemon_local.pGateway.connections->p_control_msgs->id = DLT_SERVICE_ID_GET_LOG_INFO; + daemon_local.pGateway.connections->p_control_msgs->type = CONTROL_MESSAGE_ON_DEMAND; EXPECT_EQ(DLT_RETURN_OK, dlt_gateway_send_control_message(daemon_local.pGateway.connections, daemon_local.pGateway.connections->p_control_msgs, NULL, 0)); diff --git a/tests/gtest_dlt_daemon_gateway.sh b/tests/gtest_dlt_daemon_gateway.sh index 5b7951d..5a357b3 100755 --- a/tests/gtest_dlt_daemon_gateway.sh +++ b/tests/gtest_dlt_daemon_gateway.sh @@ -169,8 +169,10 @@ setupTest() echo "SendControl=0x03,0x13" >>$tmpPath/dlt_gateway.conf echo "SendSerialHeader=0" >>$tmpPath/dlt_gateway.conf echo "NOFiles=1" >>$tmpPath/dlt_gateway.conf + return 0 } + # # Function: -startDaemons() # @@ -184,7 +186,7 @@ startDaemons() { DLT_PASSIVE_SHM_NAME="" tmpPath=/tmp - dlt-daemon -d + dlt-daemon -c $tmpPath/dlt_passive.conf & sleep 1 # Check if the dlt shm file exist (DLT_SHM_ENABLE=ON) @@ -192,7 +194,7 @@ startDaemons() DLT_PASSIVE_SHM_NAME="-s dlt-shm-passive" fi - dlt-daemon -d -p 3495 -c $tmpPath/dlt.conf $DLT_PASSIVE_SHM_NAME + dlt-daemon -p 3495 -c $tmpPath/dlt.conf $DLT_PASSIVE_SHM_NAME & return 0 } @@ -212,7 +214,7 @@ checkDaemonStart() if [ $total -ne '2' ]; then echo "Initialization of dlt-daemon instances failed" - exit + exit 1 fi } -- cgit v1.2.1