From 12c5b22102873e303e540f886489831461d54ea9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Moulins?= Date: Tue, 26 Aug 2008 12:28:00 +0200 Subject: [PATCH] Check for segfault and illegal instruction when expecting an error When an error is expected, fail the test when return code is : * 139: segmentation fault * 132: illegal instruction --- test/tests.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/tests.sh b/test/tests.sh index ae064f1..15a4744 100644 --- a/test/tests.sh +++ b/test/tests.sh @@ -40,10 +40,21 @@ assertSameFile() { echo "----" } } +assertNotSegFault() +{ + [ $1 -eq 139 ] && fail "Returned with 139: segmentation fault (SIGSEGV)!!!" +} +assertNotIllegal() +{ + [ $1 -eq 132 ] && fail "Returned with 132: Illegal instruction (SIGILL)!!!" +} assertFailWithNoReturn() { local test="$1" value=$( $test ) - assertFalse "'$test' does not fail" $? + rv=$? + assertFalse "'$test' does not fail" $rv + assertNotSegFault $rv + assertNotIllegal $rv assertNull "'$test' returns '$value'" "$value" } EOF -- 2.41.1