2009-12-22 11:09:20 +01:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
fail ()
|
|
|
|
{
|
|
|
|
echo "Test failed: $*"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
echo_v ()
|
|
|
|
{
|
|
|
|
if [ "$verbose" = "1" ]; then
|
|
|
|
echo "$*"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
error_out=/dev/null
|
|
|
|
if [ "$1" = "-v" ]; then
|
|
|
|
verbose=1
|
|
|
|
error_out=/dev/stderr
|
|
|
|
fi
|
|
|
|
|
2012-11-19 22:18:55 +01:00
|
|
|
if [ -z "$LIBTOOL" ]; then
|
|
|
|
if [ -f ../libtool ]; then
|
|
|
|
LIBTOOL=../libtool
|
|
|
|
else
|
|
|
|
LIBTOOL=libtool
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2009-12-22 11:09:20 +01:00
|
|
|
echo_v "Running assert-msg-test"
|
|
|
|
OUT=$(./assert-msg-test 2>&1) && fail "assert-msg-test should abort"
|
2011-10-24 19:43:11 +02:00
|
|
|
echo "$OUT" | grep -q '^ERROR:.*assert-msg-test.c:.*:.*main.*: assertion failed: (42 < 0)' || \
|
2009-12-22 11:09:20 +01:00
|
|
|
fail "does not print assertion message"
|
|
|
|
|
|
|
|
if ! type gdb >/dev/null 2>&1; then
|
|
|
|
echo_v "Skipped (no gdb installed)"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo_v "Running gdb on assert-msg-test"
|
2013-01-15 05:25:05 +01:00
|
|
|
OUT=$($LIBTOOL --mode=execute gdb --batch -x ${srcdir:-.}/assert-msg-test.gdb ./assert-msg-test 2> $error_out) || fail "failed to run gdb"
|
2009-12-22 11:09:20 +01:00
|
|
|
|
2010-01-26 11:22:31 +01:00
|
|
|
echo_v "Checking if assert message is in __glib_assert_msg"
|
2011-10-24 19:43:11 +02:00
|
|
|
if ! echo "$OUT" | grep -q '^$1.*"ERROR:.*assert-msg-test.c:.*:.*main.*: assertion failed: (42 < 0)"'; then
|
2010-01-26 11:22:31 +01:00
|
|
|
fail "__glib_assert_msg does not have assertion message"
|
2009-12-22 11:09:20 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo_v "All tests passed."
|