testsuite: add logger backend tests 89/180089/7
authorMaciej Slodczyk <m.slodczyk2@partner.samsung.com>
Wed, 23 May 2018 12:25:29 +0000 (14:25 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 30 May 2018 11:38:29 +0000 (13:38 +0200)
Change-Id: I722182f1d9c3a1c49df77e62df13c8517a9b38bd
Signed-off-by: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
Makefile.am
configs/99-dlog-logger.disable-platform-logging-for-testsuite.conf [new file with mode: 0644]
configs/dlog-logger.conf.test [new file with mode: 0644]
configs/dlog-pipe.conf.test [moved from configs/dlog.conf.test with 100% similarity]
configure.ac
packaging/dlog.spec
tests/dlog_test.in [moved from tests/dlog_test_pipe.in with 85% similarity]

index 8ffe188..6d6b815 100644 (file)
@@ -195,7 +195,9 @@ usrlibtmpfilesd_DATA = configs/dlog-run.conf
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = dlog.pc
 
-data_DATA = configs/dlog.conf.test
+data_DATA = \
+       configs/dlog-pipe.conf.test \
+       configs/dlog-logger.conf.test
 
 unitdir = $(prefix)/lib/systemd/system
 nodist_unit_DATA = configs/dlog_logger.service
@@ -208,9 +210,10 @@ sysconf_DATA = configs/dlog.conf
 dlogconfdir = $(sysconfdir)/dlog.conf.d
 dlogconf_DATA = \
        configs/20-pipe.conf \
-       configs/25-logger.conf
+       configs/25-logger.conf \
+       configs/99-dlog-logger.disable-platform-logging-for-testsuite.conf
 
-bin_SCRIPTS = dlog_test_pipe
+bin_SCRIPTS = dlog_test
 
 dox::
        doxygen
diff --git a/configs/99-dlog-logger.disable-platform-logging-for-testsuite.conf b/configs/99-dlog-logger.disable-platform-logging-for-testsuite.conf
new file mode 100644 (file)
index 0000000..766cab6
--- /dev/null
@@ -0,0 +1 @@
+plog=0
diff --git a/configs/dlog-logger.conf.test b/configs/dlog-logger.conf.test
new file mode 100644 (file)
index 0000000..86fb27b
--- /dev/null
@@ -0,0 +1,41 @@
+##### Settings used by the logging library
+backend=logger
+main=/dev/log_main
+apps=/dev/log_events
+system=/dev/log_system
+radio=/dev/log_radio
+
+main_size=1048576
+apps_size=1048576
+system_size=1048576
+radio_size=1048576
+
+plog=1
+debugmode=1
+limiter=0
+limiter|*|*=allow
+kmsg=/dev/null
+syslog=/dev/null
+
+kmsg_write_sock=/run/dlog/kmsg.wr
+syslog_write_sock=/run/dlog/syslog.wr
+
+kmsg_ctl_sock=/run/dlog/kmsg.ctl
+syslog_ctl_sock=/run/dlog/syslog.ctl
+
+kmsg_write_sock_rights=0222
+syslog_write_sock_rights=0222
+
+kmsg_ctl_sock_rights=0222
+syslog_ctl_sock_rights=0222
+
+kmsg_size=1048576
+syslog_size=1048576
+
+util_sorting_time_window=1000
+
+dlog_logger_conf_system=dlogutil -b system -r 2048 -n 1 -f /var/log/dlog/system -v recv_realtime *:I
+dlog_logger_conf_main=dlogutil -b main -r 1024 -n 1 -f /var/log/dlog/main -v recv_realtime *:W
+dlog_logger_conf_radio=dlogutil -b radio -r 256 -n 1 -f /var/log/dlog/radio -v recv_realtime
+dlog_logger_conf_kmsg=dlogutil -b kmsg -r 1024 -n 1 -f /var/log/dlog/kernel -v rwtime
+util_sorting_buffer_size=8192
index cb763c9..94e859a 100644 (file)
@@ -55,7 +55,7 @@ AC_SUBST([DLOG_SERVER_GROUP], "$dlog_server_group")
 AC_SUBST([datadir])
 AC_SUBST([libexecdir])
 AC_CONFIG_FILES([Makefile dlog.pc]
-                [dlog_test_pipe:tests/dlog_test_pipe.in]
+                [dlog_test:tests/dlog_test.in]
                 [configs/dlog_logger.service])
 AC_OUTPUT
 
index e9625c4..ce53c72 100644 (file)
@@ -212,11 +212,27 @@ fi
 
 %files -n dlog-tests
 %manifest dlog.manifest
-%{_bindir}/dlog_test_pipe
+%{_bindir}/dlog_test
 %{_libexecdir}/libdlog/perf_libdlog
 %{_libexecdir}/libdlog/test_libdlog
-%{_datadir}/dlog.conf.test
+%{_datadir}/dlog-pipe.conf.test
+%{_datadir}/dlog-logger.conf.test
+%{_sysconfdir}/dlog.conf.d/99-dlog-logger.disable-platform-logging-for-testsuite.conf
 %dir %attr(755,log,log) /var/lib/dlog-tests
 
 %post -n dlog-tests
 chsmack -a System /var/lib/dlog-tests
+echo "Warning! Installation of dlog-tests will break platform logging."
+echo "This is done intentionally, to make logger backend testing possible."
+echo "To restore normal behavior, please uninstall dlog-tests package."
+echo ""
+echo "A reboot is required to properly configure logger backend for testing."
+secs=15
+while [ $secs -gt 0 ]; do
+   echo -ne "Will reboot in $secs\033[0K\r"
+   sleep 1
+   : $((secs--))
+done
+sleep 1
+echo -e "Rebooting target."
+reboot
similarity index 85%
rename from tests/dlog_test_pipe.in
rename to tests/dlog_test.in
index 77fd0b5..8368d20 100644 (file)
@@ -36,14 +36,32 @@ ok(){
        LOG_DETAILS=
 }
 
-export DLOG_CONFIG_PATH="@datadir@/dlog.conf.test"
+if [ $# -ne 1 ]; then
+       echo "usage: $0 pipe|logger"
+       exit 1
+fi
+
+if [ "$1" == "pipe" ]; then
+       type="pipe"
+elif [ "$1" == "logger" ]; then
+       type="logger"
+else
+       echo "usage: $0 pipe|logger"
+       exit 1
+fi
+
+export DLOG_CONFIG_PATH="@datadir@/dlog-$type.conf.test"
 PATH=$PATH:@libexecdir@/libdlog/
 
+# Start the daemon
+if [ $type == "pipe" ]; then
+       dlog_logger -b 99 -t 0 &
+       LOGGER=$!
+       sleep 1
+fi
 
-# Start the daemon, add some logs
-dlog_logger -b 99 -t 0 &
-LOGGER=$!
-sleep 1
+# put 100 log entries in the "main" buffer
+dlogutil -c
 test_libdlog 100
 sleep 1
 
@@ -58,32 +76,32 @@ LOG_DETAILS="testing if -u argument is parsed properly"
 dlogutil -du dummy &> /dev/null && fail || ok
 
 LOG_DETAILS="testing if limiting printed log entries to less than exists in the buffer returns proper value"
-if [ $(dlogutil -t  20 | wc -l) -eq  20 ]; then ok; else fail; fi # less logs than currently in buffer
+if [ $(dlogutil -b main -t  20 | wc -l) -eq  20 ]; then ok; else fail; fi # less logs than currently in buffer
 
 LOG_DETAILS="testing if limiting printed log entries to more than exists in the buffer returns proper value"
-if [ $(dlogutil -t 200 | wc -l) -eq 100 ]; then ok; else fail; fi # more
+if [ $(dlogutil -b main -t 200 | wc -l) -eq 100 ]; then ok; else fail; fi # more
 
 LOG_DETAILS="testing if dlogutil returns exact amount of entries as there is in the buffer"
-if [ $(dlogutil -d     | wc -l) -eq 100 ]; then ok; else fail; fi # exactly
+if [ $(dlogutil -b main -d     | wc -l) -eq 100 ]; then ok; else fail; fi # exactly
 
 LOG_DETAILS="testing if reading from  dummy buffer returns an error as expected"
 dlogutil -b nonexistent_buffer &> /dev/null && fail || ok
 
-LOG_DETAILS="testing if reading from \"apps\" buffer returns zero entries (logs are in the \"main\" buffer)"
-if [ $(dlogutil -d -b apps | wc -l) -eq 0 ]; then ok; else fail; fi
+LOG_DETAILS="testing if reading from \"system\" buffer returns zero entries (logs are in the \"main\" buffer)"
+if [ $(dlogutil -d -b system | wc -l) -eq 0 ]; then ok; else fail; fi
 
 LOG_DETAILS="testing if dlogutil -c empties all buffers"
 dlogutil -c && ok || fail
 
 LOG_DETAILS="testing if writing entries to empty buffer and reading them returns proper amount of entries"
 test_libdlog 10
-if [ $(dlogutil -d | wc -l) -eq 10 ]; then ok; else fail; fi # should be 10, not 110
+if [ $(dlogutil -b main -d | wc -l) -eq 10 ]; then ok; else fail; fi # should be 10, not 110
 
 LOG_DETAILS="testing if filters work"
-if [ $(dlogutil -d *:E | wc -l) -eq 5 ]; then ok; else fail; fi # half of current logs (test_libdlog alternates between error and info log levels)
+if [ $(dlogutil -b main -d *:E | wc -l) -eq 5 ]; then ok; else fail; fi # half of current logs (test_libdlog alternates between error and info log levels)
 
 LOG_DETAILS="testing if adding \"silent\" filter works"
-if [ $(dlogutil -s -d | wc -l) -eq 0 ]; then ok; else fail; fi
+if [ $(dlogutil -b main -s -d | wc -l) -eq 0 ]; then ok; else fail; fi
 
 LOG_DETAILS="testing if reading buffer size returns proper exit code"
 dlogutil -g &> /dev/null && ok || fail
@@ -208,7 +226,7 @@ done
 sleep 60
 
 # collect data and analyze timestamps
-lines=`dlogutil -d -v recv_realtime`
+lines=`dlogutil -b main -d -v recv_realtime`
 while read line; do
        time=`echo $line | awk '{split($0, l, " "); print l[2]}'`
        ts=`date +%s%N -d $time`