]> pilppa.com Git - uci.git/commitdiff
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 ae064f1090038986e1c398a99b240b781cd88fa0..15a4744a152e6448ed5a18249eca9ec45e20ac8f 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