From 73695191bd5d16b57315a5f82f2f20a762ad22dd Mon Sep 17 00:00:00 2001 From: Marek Szulc Date: Thu, 16 Feb 2023 14:29:26 +0100 Subject: [PATCH] tests: extract backend autodetection test to a separate file Change-Id: I8a27f0dbf7a2196513a1910a70f23b34d1b2ae7b --- Makefile.am | 2 +- configure.ac | 1 + packaging/dlog.spec | 1 + tests/dlog_test.in | 23 ++++++----------------- tests/dlog_test_backend_autodetection.in | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 tests/dlog_test_backend_autodetection.in diff --git a/Makefile.am b/Makefile.am index d4c54b7..cd35b1d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -970,7 +970,7 @@ modulesloadddir = /usr/lib/modules/modules-load.d modulesloadd_DATA = \ configs/tizen-modules-dlog-zero-copy.conf -bin_SCRIPTS = dlog_test dlog_test_header dlog_test_daemon_early_quit dlog_test_tid_filtering_secure_logging dlog_cpu +bin_SCRIPTS = dlog_test dlog_test_header dlog_test_daemon_early_quit dlog_test_tid_filtering_secure_logging dlog_test_backend_autodetection dlog_cpu diff --git a/configure.ac b/configure.ac index ee07914..4a34b49 100644 --- a/configure.ac +++ b/configure.ac @@ -90,6 +90,7 @@ AC_CONFIG_FILES([Makefile dlog.pc dlogutil.pc dlog-redirect-stdout.pc] [dlog_test_header:tests/dlog_test_header.in] [dlog_test_daemon_early_quit:tests/dlog_test_daemon_early_quit.in] [dlog_test_tid_filtering_secure_logging:tests/dlog_test_tid_filtering_secure_logging.in] + [dlog_test_backend_autodetection:tests/dlog_test_backend_autodetection.in] [dlog_cpu:tests/dlog_cpu.in] [README.testsuite:tests/README.testsuite.in] [units/dlog_logger.service] diff --git a/packaging/dlog.spec b/packaging/dlog.spec index 1a124da..15d881e 100644 --- a/packaging/dlog.spec +++ b/packaging/dlog.spec @@ -316,6 +316,7 @@ chsmack -e 'System' %{_libexecdir}/dlog-log-critical %{_bindir}/dlog_test %{_bindir}/dlog_test_header %{_bindir}/dlog_test_daemon_early_quit +%{_bindir}/dlog_test_backend_autodetection %{_bindir}/dlog_test_tid_filtering_secure_logging %{_bindir}/dlog_cpu /usr/share/doc/dlog/README.testsuite diff --git a/tests/dlog_test.in b/tests/dlog_test.in index a06302f..eabca49 100644 --- a/tests/dlog_test.in +++ b/tests/dlog_test.in @@ -1117,28 +1117,13 @@ DLOG_CONFIG_PATH=$DLOG_PREV_PATH if [ "$quick" -ne 1 ]; then if [ "$type" != "zero-copy" ]; then # Backend autodection and logger daemon stuff don't really work on zero-copy - PREAUTODETECT_CONFIG_PATH=$DLOG_CONFIG_PATH - DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.autodetect" kill $LOGGER > /dev/null sleep 1 - if [ "$type" = "logger" ]; then - dlogutil -cb main - fi - dlog_logger -t 0 & - LOGGER=$! - sleep 1 - - LOG_DETAILS="testing if backend autodetection works properly (1/2)" - dlogsend -b main -t DLOG_AUTODETECT "xd" && ok || fail - sleep 1 - DLOG_CONFIG_PATH=$PREAUTODETECT_CONFIG_PATH - LOG_DETAILS="testing if backend autodetection works properly (2/2)" - [ "$(dlogutil -db main -v raw)" = "xd" ] && ok || fail + dlog_test_backend_autodetection $type - kill $LOGGER > /dev/null - sleep 1 rm "$TESTDIR"/test* + dlog_logger -t 0 & LOGGER=$! sleep 1 @@ -1208,6 +1193,10 @@ if [ "$quick" -ne 1 ]; then sleep 1 fi + dlog_logger -t 0 & + LOGGER=$! + sleep 1 + LOG_DETAILS="testing if the library works with multithreaded app" dlogutil -f $TESTDIR/dlog_mt_test & MT_TEST=$! diff --git a/tests/dlog_test_backend_autodetection.in b/tests/dlog_test_backend_autodetection.in new file mode 100644 index 0000000..f8baf0d --- /dev/null +++ b/tests/dlog_test_backend_autodetection.in @@ -0,0 +1,32 @@ +#!/bin/sh + +source dlog_test_header + +trap cleanup 0 + +if [ "$1" = "zero-copy" ]; then + echo "zero-copy not supported for this test" + exit 1 +fi + +PREAUTODETECT_CONFIG_PATH=$DLOG_CONFIG_PATH +export DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.autodetect" +TESTDIR=/var/lib/dlog-tests + +if [ "$type" = "logger" ]; then + dlogutil -cb main +fi +dlog_logger -t 0 & +LOGGER=$! +sleep 1 + +LOG_DETAILS="testing if backend autodetection works properly (1/2)" +dlogsend -b main -t DLOG_AUTODETECT "xd" && ok || fail +sleep 1 + +export DLOG_CONFIG_PATH=$PREAUTODETECT_CONFIG_PATH +LOG_DETAILS="testing if backend autodetection works properly (2/2)" +[ "$(dlogutil -db main -v raw)" = "xd" ] && ok || fail + +kill $LOGGER > /dev/null +sleep 1 \ No newline at end of file -- 2.7.4