shithub: scc

Download patch

ref: c532c555d5558685f629ea918ae612d5413543cd
parent: de505b2650948c2f4ada5368eaf8a019cf1099bc
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Sep 1 11:51:22 EDT 2018

[tests/libc] Add test 0004-assert.c

Some small changes are done to all the other tests too.

--- a/tests/libc/execute/0001-abort.c
+++ b/tests/libc/execute/0001-abort.c
@@ -1,4 +1,4 @@
-
+#include <assert.h>
 #include <stdio.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -13,9 +13,9 @@
 main(void)
 {
 	printf("aborting\n");
-	signal(SIGABRT, handler);
+	assert(signal(SIGABRT, handler) != SIG_ERR);
 	abort();
 	printf("borning\n");
 
-	return 1;
+	return 0;
 }
--- a/tests/libc/execute/0002-assert.c
+++ b/tests/libc/execute/0002-assert.c
@@ -1,9 +1,11 @@
 
 #include <assert.h>
 #include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 void
-handler(void)
+handler(int dummy)
 {
 	_Exit(0);
 }
@@ -14,7 +16,7 @@
 	int i;
 	char c;
 
-	signal(SIGABRT, handler);
+	assert(signal(SIGABRT, handler) != SIG_ERR);
 
 	printf("First assert\n");
 	assert(sizeof(i) >= sizeof(c));
@@ -22,5 +24,5 @@
 	printf("Second assert, that must fail\n");
 	assert(sizeof(i) < sizeof(c));
 
-	return 1;
+	return 0;
 }
--- a/tests/libc/execute/0003-assert.c
+++ b/tests/libc/execute/0003-assert.c
@@ -1,5 +1,5 @@
 #include <assert.h>
-#include <signal.h>
+#include <stdio.h>
 
 int
 main()
--- a/tests/libc/execute/chktest.sh
+++ b/tests/libc/execute/chktest.sh
@@ -8,14 +8,12 @@
 
 while read i state
 do
-	rm -f a.out
+	rm -f a.out *.o
 
-	(echo
-	 echo $i
-	 ./cc.sh $CFLAGS $i.c &&
-	 ./a.out > $tmp &&
-	 cat $tmp
-	 diff -u $tmp $i.txt) > test.log 2>&1 &&
+	(echo $i
+	 ./cc.sh $CFLAGS $i.c
+	 ./a.out > $tmp
+	 diff -u $tmp $i.txt) >> test.log 2>&1 &&
 	printf '[PASS]' || printf '[FAIL]'
 	printf '%s: %s\n' "$state" "$i"
 done < $file
--- a/tests/libc/execute/libc-tests.lst
+++ b/tests/libc/execute/libc-tests.lst
@@ -1,3 +1,4 @@
 0001-abort
 0002-assert
 0003-assert
+0004-abort