Add system test for legacy signal 55/222955/2
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 21 Jan 2020 11:25:41 +0000 (12:25 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 21 Jan 2020 14:08:33 +0000 (15:08 +0100)
Change-Id: If4e2d007ebac2de6a11d64137c9d93e5efc75b6d

tests/system/CMakeLists.txt
tests/system/dbus_notify_legacy/dbus_notify_legacy.sh.template [new file with mode: 0644]

index b5423c1..44a1b1c 100644 (file)
@@ -32,6 +32,7 @@ configure_test("dump_systemstate_extras")
 configure_test("livedumper")
 configure_test("extra_script")
 configure_test("dbus_notify")
+configure_test("dbus_notify_legacy")
 configure_test("output_param")
 configure_test("libcrash-service")
 configure_test("full_core")
diff --git a/tests/system/dbus_notify_legacy/dbus_notify_legacy.sh.template b/tests/system/dbus_notify_legacy/dbus_notify_legacy.sh.template
new file mode 100644 (file)
index 0000000..946e9c3
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+# Check the support for old-style DBus notification signal
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+# We are looking for following signal - example for `sleep` command:
+#
+# signal time=1420079847.594970 sender=:1.82 -> destination=(null destination) serial=2 path=/Org/Tizen/System/Crash/Crash; interface=org.tizen.system.crash.Crash; member=ProcessCrashed
+#   string "sleep"
+#   string "/usr/bin/sleep"
+#   string "sleep"
+#   string "sleep"
+#
+# Note! Regular programs (Unix sleep, tests-provided kenny) are not enough to check all fields of the signal.
+#       Complete test, with appid & pkgid checks, would require building proper "Tizen Application".
+
+CONF_DIR=/etc/crash-manager.conf.d
+CONF_FILE=${CONF_DIR}/system-test-dbus-notify-legacy.conf
+
+mount -o rw,remount /
+
+mkdir -p $CONF_DIR
+rm -f $CONF_FILE || :
+cat <<EOF >$CONF_FILE
+[CrashManager]
+UseLegacyNotification=true
+EOF
+
+( ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+  pid=$!
+  sleep 2
+  kill -6 $pid ) &
+
+TMPFILE=$(mktemp /tmp/dbus_notify.XXXXXX)
+dbus-monitor --system type=signal,path=/Org/Tizen/System/Crash/Crash,interface=org.tizen.system.crash.Crash,member=ProcessCrashed > $TMPFILE &
+monpid=$!
+
+cleanup()
+{
+       kill $monpid
+       rm -f $TMPFILE
+       rm -f $CONF_FILE
+}
+
+trap cleanup 0
+
+sleep 3
+
+PATTERN='path=/Org/Tizen/System/Crash/Crash; interface=org\.tizen\.system\.crash\.Crash; member=ProcessCrashed'
+for i in $(seq 1 10); do
+       score=0
+       if egrep "$PATTERN" $TMPFILE; then
+               if egrep "string \"kenny" $TMPFILE; then
+                       score=$(($score + 1))
+               fi
+
+               # legacy signal must not have the report_path and additional metadata
+
+               if ! egrep "string \"/opt/usr/share/crash/dump.*kenny" $TMPFILE; then
+                       score=$(($score + 1))
+               fi
+
+               if ! egrep -A1 "string \"sys.signal" $TMPFILE; then
+                       score=$(($score + 1))
+               fi
+
+               if [ $score -eq 3 ]; then
+                       exit_ok
+               fi
+       fi
+
+       sleep 1
+done
+
+fail "legacy dbus signal does not match"