scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 5fb4a0688927828adc8a459dc9cf4fdd20b78ffb
parent e377940ca3d8880ef9da63a534c9a580916f2692
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  1 Oct 2021 18:43:09 +0200

tests/libc: Fix 0001-abort test case

The test 0001-abort was failling but the shell script
was reporting it like passing. The test itself was
not robust enough and the shell script was not considering
the error stream, being blind to assert failed but catched
with a signal handler.

Diffstat:
Mtests/libc/execute/0001-abort.c | 7+++++--
Mtests/libc/execute/chktest.sh | 2+-
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/libc/execute/0001-abort.c b/tests/libc/execute/0001-abort.c @@ -9,10 +9,12 @@ aborting end: */ +int ret = 1; + void handler(int dummy) { - _Exit(0); + _Exit(ret); } int @@ -20,8 +22,9 @@ main(void) { printf("aborting\n"); assert(signal(SIGABRT, handler) != SIG_ERR); + ret = 0; abort(); printf("borning\n"); - return 0; + return 1; } diff --git a/tests/libc/execute/chktest.sh b/tests/libc/execute/chktest.sh @@ -15,7 +15,7 @@ do (echo $i ./cc.sh $CFLAGS -o $i $i.c echo '/^output:$/+;/^end:$/-'w $tmp1 | ed -s $i.c - ./$i > $tmp2 2>> test.log + ./$i > $tmp2 2>&1 diff -u $tmp1 $tmp2) >> test.log 2>&1 && printf '[PASS]' || printf '[FAIL]'