tests: Add crash-manager dbus notify system test 75/210275/2
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 17 Jul 2019 11:29:15 +0000 (13:29 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 18 Jul 2019 11:15:39 +0000 (13:15 +0200)
Change-Id: I3e3c4669df4dd36edecd02c2fb245f455b76b4c5

packaging/crash-worker_system-tests.spec
tests/system/CMakeLists.txt
tests/system/dbus_notify/dbus_notify.sh.template [new file with mode: 0644]

index b082f56..2caa93e 100644 (file)
@@ -59,6 +59,7 @@ cd tests/system
 %{_libdir}/crash-worker_system-tests/cmp_backtraces/cp.sh
 %{_libdir}/crash-worker_system-tests/crash_root_path/crash_root_path.sh
 %{_libdir}/crash-worker_system-tests/critical_process/critical_process.sh
+%{_libdir}/crash-worker_system-tests/dbus_notify/dbus_notify.sh
 %{_libdir}/crash-worker_system-tests/dump_systemstate_extras/dump_systemstate_extras.sh
 %{_libdir}/crash-worker_system-tests/extra_script/extra_script.sh
 %{_libdir}/crash-worker_system-tests/info_file/info_file.sh
index da31257..7db25e2 100644 (file)
@@ -38,6 +38,7 @@ configure_test("log_dump_crash_root_path")
 configure_test("dump_systemstate_extras")
 configure_test("livedumper")
 configure_test("extra_script")
+configure_test("dbus_notify")
 
 get_property(TESTS_LIST GLOBAL PROPERTY TMP_TESTS_LIST)
 
diff --git a/tests/system/dbus_notify/dbus_notify.sh.template b/tests/system/dbus_notify/dbus_notify.sh.template
new file mode 100644 (file)
index 0000000..c7e7349
--- /dev/null
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# Check the report type change in the config file
+
+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"
+#   string "/opt/usr/share/crash/dump//sleep_2782_20150101113723.zip"
+#   int32 2782
+#   int32 2782
+#   array [
+#      dict entry(
+#         string "arm.pc"
+#         variant             uint32 3069275660
+#      )
+#      dict entry(
+#         string "arm.lr"
+#         variant             uint32 3070220008
+#      )
+#   ]
+
+( ${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
+}
+
+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
+
+               if egrep "string \"/opt/usr/share/crash/dump.*kenny" $TMPFILE; then
+                       score=$(($score + 1))
+               fi
+
+               if egrep "string \"${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny" $TMPFILE; then
+                       score=$(($score + 1))
+               fi
+
+               if [ $score -eq 3 ]; then
+                       exit_with_code "SUCCESS" ${SUCCESS_CODE}
+               fi
+       fi
+
+       sleep 1
+done
+
+exit_with_code "FAIL: dbus signal does not match" ${FAIL_CODE}