crash-manager: Always emit new style ProcessCrashedEx
[platform/core/system/crash-worker.git] / tests / system / dbus_notify / dbus_notify.sh.template
1 #!/bin/bash
2
3 # Check the report type change in the config file
4
5 if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
6     CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
7 fi
8
9 . ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
10
11 # We are looking for following signal - example for `sleep` command:
12 #
13 # 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
14 #   string "sleep"
15 #   string "/usr/bin/sleep"
16 #   string "sleep"
17 #   string "sleep"
18 #   string "/opt/usr/share/crash/dump//sleep_2782_20150101113723.zip"
19 #   int32 2782
20 #   int32 2782
21 #   array [
22 #      dict entry(
23 #         string "arm.pc"
24 #         variant             uint32 3069275660
25 #      )
26 #      dict entry(
27 #         string "arm.lr"
28 #         variant             uint32 3070220008
29 #      )
30 #      dict entry(
31 #         string "sys.signal"
32 #         variant             int32 6
33 #      )
34 #      dict entry(
35 #         string "sys.tid.comm"
36 #         variant             string "sleep"
37 #      )
38 #   ]
39
40 ( ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
41   pid=$!
42   sleep 2
43   kill -6 $pid ) &
44
45 TMP1=$(mktemp /tmp/dbus_notify.XXXXXX)
46 TMP2=$(mktemp /tmp/dbus_notify.XXXXXX)
47 dbus-monitor --system type=signal,path=/Org/Tizen/System/Crash/Crash,interface=org.tizen.system.crash.Crash,member=ProcessCrashed > $TMP1 &
48 monpid1=$!
49 dbus-monitor --system type=signal,path=/Org/Tizen/System/Crash/Crash,interface=org.tizen.system.crash.Crash,member=ProcessCrashedEx > $TMP2 &
50 monpid2=$!
51
52 cleanup()
53 {
54         kill $monpid1 $monpid2
55         rm -f $TMP1 $TMP2
56 }
57
58 trap cleanup 0
59
60 sleep 3
61 wait_for_app crash-manager
62
63 for TMPFILE in $TMP1 $TMP2; do
64         PATTERN="path=/Org/Tizen/System/Crash/Crash; interface=org\.tizen\.system\.crash\.Crash; member=ProcessCrashed"
65         score=0
66         if egrep "$PATTERN" $TMPFILE; then
67                 if egrep "string \"kenny" $TMPFILE; then
68                         score=$(($score + 1))
69                 fi
70
71                 if egrep "string \"/opt/usr/share/crash/dump.*kenny" $TMPFILE; then
72                         score=$(($score + 1))
73                 fi
74
75                 if egrep "string \"${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny" $TMPFILE; then
76                         score=$(($score + 1))
77                 fi
78
79                 if egrep -A1 "string \"sys.signal" $TMPFILE | grep 'int32 6'; then
80                         score=$(($score + 1))
81                 fi
82
83                 if egrep -A1 "string \"sys.tid.comm" $TMPFILE | egrep 'variant.*string \"kenny\"'; then
84                         score=$(($score + 1))
85                 fi
86
87                 if egrep 'ProcessCrashed\b' $TMPFILE; then
88                         has_process_crashed=yes
89                 fi
90
91                 if egrep 'ProcessCrashedEx\b' $TMPFILE; then
92                         has_process_crashed_ex=yes
93                 fi
94
95                 if [ $score -eq 5 ]; then
96                         continue
97                 fi
98         fi
99
100         fail "dbus signal does not match"
101 done
102
103 [ x$has_process_crashed = xyes ] && [ x$has_process_crashed_ex = xyes ] || fail "necessary signals not matched (ProcessCrashed and ProcessCrashedEx)"
104
105 exit_ok