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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2010-03-08 06:16:23 +01:00
|
|
|
msg_test="assert-msg-test"
|
|
|
|
if [ -e ".libs/lt-$msg_test" ]; then
|
|
|
|
msg_test="lt-$msg_test"
|
|
|
|
fi
|
2009-12-22 11:09:20 +01:00
|
|
|
echo_v "Running gdb on assert-msg-test"
|
2010-03-08 06:16:23 +01:00
|
|
|
OUT=$(gdb --batch --ex run --ex "print (char*) __glib_assert_msg" .libs/$msg_test 2> $error_out) || \
|
2009-12-22 11:09:20 +01:00
|
|
|
fail "failed to run gdb"
|
|
|
|
|
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."
|