tests: extract tid filtering and secure logging tests 48/288448/15
authorMarek Szulc <m.szulc3@samsung.com>
Thu, 16 Feb 2023 13:06:44 +0000 (14:06 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Fri, 12 Jan 2024 22:08:20 +0000 (23:08 +0100)
Change-Id: I1af81435c729504510692bf39e7cbed67262dcd8

Makefile.am
configure.ac
packaging/dlog.spec
tests/dlog_test.in
tests/dlog_test_tid_filtering_secure_logging.in [new file with mode: 0644]

index 9d163e4..d4c54b7 100644 (file)
@@ -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_cpu
+bin_SCRIPTS = dlog_test dlog_test_header dlog_test_daemon_early_quit dlog_test_tid_filtering_secure_logging dlog_cpu
 
 
 
index a8c2c80..ee07914 100644 (file)
@@ -89,6 +89,7 @@ AC_CONFIG_FILES([Makefile dlog.pc dlogutil.pc dlog-redirect-stdout.pc]
                 [run-unittest.sh:tests/dlog_coverage.in]
                 [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_cpu:tests/dlog_cpu.in]
                 [README.testsuite:tests/README.testsuite.in]
                 [units/dlog_logger.service]
index 0acacf8..1a124da 100644 (file)
@@ -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_tid_filtering_secure_logging
 %{_bindir}/dlog_cpu
 /usr/share/doc/dlog/README.testsuite
 %{_libexecdir}/libdlog/perf_libdlog
index 512d30c..a06302f 100644 (file)
@@ -725,42 +725,13 @@ if [ "$quick" -ne 1 ]; then
                dlogutil -db kmsg -v raw | grep -Fm1 "$last_dmesg" >/dev/null && ok || fail
        fi
 
-       LOG_DETAILS="testing if pid filtering works"
-       dlogsend -b main -t DLOG_TESTSUITE pidTEST &
-       sleep 1
-       line=$(dlogutil -v raw -d --pid $!)
-       [ "$line" = "pidTEST" ] && ok || fail
-
-       LOG_DETAILS="testing if tid filtering works"
-       dlogsend -b main -t DLOG_TESTSUITE tidTEST &
-       sleep 1
-       line=$(dlogutil -v raw -d --tid $!) #dlogsend is a single threaded app so tid is the same as pid
-       [ "$line" = "tidTEST" ] && ok || fail
-
-       mv $DLOG_CONFIG_PATH $DLOG_CONFIG_PATH.1
-       LOG_DETAILS="testing if secure logging works (1/2)"
-       grep -v enable_secure_logs $DLOG_CONFIG_PATH.1 > $DLOG_CONFIG_PATH
-       echo "enable_secure_logs=1" >> $DLOG_CONFIG_PATH
-       dlogutil -c
-       dlogsend -zb main -t DLOG_TESTSUITE secure &
-       sleep 1
-       dlogsend -b main -t DLOG_TESTSUITE insecure &
-       sleep 1
-       line=$(dlogutil -v raw -d | head -n1)
-       [ "$line" = "secure" ] && ok || fail
-       LOG_DETAILS="testing if secure logging works (2/2)"
-       grep -v enable_secure_logs $DLOG_CONFIG_PATH.1 > $DLOG_CONFIG_PATH
-       echo "enable_secure_logs=0" >> $DLOG_CONFIG_PATH
-       dlogutil -c
-       dlogsend -zb main -t DLOG_TESTSUITE secure &
-       sleep 1
-       dlogsend -b main -t DLOG_TESTSUITE insecure &
-       sleep 1
-       line=$(dlogutil -v raw -d | head -n1)
-       [ "$line" = "insecure" ] && ok || fail
-       mv $DLOG_CONFIG_PATH.1 $DLOG_CONFIG_PATH
+       dlog_test_tid_filtering_secure_logging $type
 fi
 
+dlog_logger -t 0 &
+LOGGER=$!
+sleep 1
+
 dlogsend -b main -t DLOG_TESTSUITE_TAG0 -pI tagTEST0
 dlogsend -b main -t DLOG_TESTSUITE_TAG1 -pI tagTEST1
 dlogsend -b main -t DLOG_TESTSUITE_TAG2 -pF tagTEST2
diff --git a/tests/dlog_test_tid_filtering_secure_logging.in b/tests/dlog_test_tid_filtering_secure_logging.in
new file mode 100644 (file)
index 0000000..31c1dcb
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+source dlog_test_header
+
+trap cleanup 0
+
+export DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.test"
+
+if [ $LOGGER -eq -1 ]; then
+       dlog_logger -t 0 &
+       LOGGER=$!
+       sleep 1
+fi
+
+LOG_DETAILS="testing if pid filtering works"
+dlogsend -b main -t DLOG_TESTSUITE pidTEST &
+sleep 1
+line=$(dlogutil -v raw -d --pid $!)
+[ "$line" = "pidTEST" ] && ok || fail
+
+LOG_DETAILS="testing if tid filtering works"
+dlogsend -b main -t DLOG_TESTSUITE tidTEST &
+sleep 1
+line=$(dlogutil -v raw -d --tid $!) #dlogsend is a single threaded app so tid is the same as pid
+[ "$line" = "tidTEST" ] && ok || fail
+
+mv $DLOG_CONFIG_PATH $DLOG_CONFIG_PATH.1
+LOG_DETAILS="testing if secure logging works (1/2)"
+grep -v enable_secure_logs $DLOG_CONFIG_PATH.1 > $DLOG_CONFIG_PATH
+echo "enable_secure_logs=1" >> $DLOG_CONFIG_PATH
+dlogutil -c
+dlogsend -zb main -t DLOG_TESTSUITE secure &
+sleep 1
+dlogsend -b main -t DLOG_TESTSUITE insecure &
+sleep 1
+line=$(dlogutil -v raw -d | head -n1)
+[ "$line" = "secure" ] && ok || fail
+LOG_DETAILS="testing if secure logging works (2/2)"
+grep -v enable_secure_logs $DLOG_CONFIG_PATH.1 > $DLOG_CONFIG_PATH
+echo "enable_secure_logs=0" >> $DLOG_CONFIG_PATH
+dlogutil -c
+dlogsend -zb main -t DLOG_TESTSUITE secure &
+sleep 1
+dlogsend -b main -t DLOG_TESTSUITE insecure &
+sleep 1
+line=$(dlogutil -v raw -d | head -n1)
+[ "$line" = "insecure" ] && ok || fail
+mv $DLOG_CONFIG_PATH.1 $DLOG_CONFIG_PATH
+
+if [ $LOGGER -ne -1 ]; then
+       kill $LOGGER > /dev/null
+       sleep 1
+fi