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