[kdbus] KDBUS_ITEM_PAYLOAD_OFF items are (once again) relative to msg header
[platform/upstream/glib.git] / tests / run-assert-msg-test.sh
1 #! /bin/sh
2
3 fail ()
4 {
5   echo "Test failed: $*"
6   exit 1
7 }
8
9 echo_v ()
10 {
11   if [ "$verbose" = "1" ]; then
12     echo "$*"
13   fi
14 }
15
16 error_out=/dev/null
17 if [ "$1" = "-v" ]; then
18   verbose=1
19   error_out=/dev/stderr
20 fi  
21
22 if [ -z "$LIBTOOL" ]; then
23   if [ -f ../libtool ]; then
24     LIBTOOL=../libtool
25   else
26     LIBTOOL=libtool
27   fi
28 fi
29
30 echo_v "Running assert-msg-test"
31 OUT=$(./assert-msg-test 2>&1) && fail "assert-msg-test should abort"
32 echo "$OUT" | grep -q '^GLib:ERROR:.*assert-msg-test.c:.*:.*main.*: assertion failed: (42 < 0)' || \
33   fail "does not print assertion message"
34
35 if ! type gdb >/dev/null 2>&1; then
36   echo_v "Skipped (no gdb installed)"
37   exit 0
38 fi
39
40 echo_v "Running gdb on assert-msg-test"
41 OUT=$($LIBTOOL --mode=execute gdb --batch -x ${srcdir:-.}/assert-msg-test.gdb ./assert-msg-test 2> $error_out) || fail "failed to run gdb"
42
43 echo_v "Checking if assert message is in __glib_assert_msg"
44 if ! echo "$OUT" | grep -q '^$1.*"GLib:ERROR:.*assert-msg-test.c:.*:.*main.*: assertion failed: (42 < 0)"'; then
45   fail "__glib_assert_msg does not have assertion message"
46 fi
47
48 echo_v "All tests passed."