Check for segfault and illegal instruction when expecting an error
authorFrédéric Moulins <ffrrrr@gmail.com>
Tue, 26 Aug 2008 10:28:00 +0000 (12:28 +0200)
committerFelix <nbd@openwrt.org>
Tue, 26 Aug 2008 10:31:34 +0000 (12:31 +0200)
When an error is expected, fail the test when return code is :
* 139: segmentation fault
* 132: illegal instruction

test/tests.sh

index ae064f1..15a4744 100644 (file)
@@ -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