commit 2bee5e38261775e54c94508a6955f0bbfa28e51c
parent ee56849c612b6cb6ee27e6f647254967ebdd6981
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:
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]'