ref: 0c28f70ffebef1de8db8339c56487f8dfe6a9e58
parent: dafc7b4128023928611008473fd07e0ab7a0bbd8
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Sep 1 12:11:42 EDT 2018
[tests/libc] Integrate expected output in the c files it is better to have only one file per test.
--- a/tests/libc/execute/0001-abort.c
+++ b/tests/libc/execute/0001-abort.c
@@ -3,6 +3,12 @@
#include <signal.h>
#include <stdlib.h>
+/*
+output:
+aborting
+end:
+*/
+
void
handler(int dummy)
{
--- a/tests/libc/execute/0001-abort.txt
+++ /dev/null
@@ -1,1 +1,0 @@
-aborting
--- a/tests/libc/execute/0002-assert.c
+++ b/tests/libc/execute/0002-assert.c
@@ -4,6 +4,13 @@
#include <stdio.h>
#include <stdlib.h>
+/*
+output:
+First assert
+Second assert, that must fail
+end:
+*/
+
void
handler(int dummy)
{
--- a/tests/libc/execute/0002-assert.txt
+++ /dev/null
@@ -1,2 +1,0 @@
-First assert
-Second assert, that must fail
--- a/tests/libc/execute/0003-assert.c
+++ b/tests/libc/execute/0003-assert.c
@@ -1,6 +1,13 @@
#include <assert.h>
#include <stdio.h>
+/*
+output:
+First assert
+Second assert, that must fail
+end:
+*/
+
int
main()
{
--- a/tests/libc/execute/0003-assert.txt
+++ /dev/null
@@ -1,2 +1,0 @@
-First assert
-Second assert, that must fail
--- a/tests/libc/execute/0004-abort.c
+++ b/tests/libc/execute/0004-abort.c
@@ -3,6 +3,12 @@
#include <signal.h>
#include <stdlib.h>
+/*
+output:
+aborting
+end:
+*/
+
int
main(void)
{
--- a/tests/libc/execute/0004-abort.txt
+++ /dev/null
@@ -1,1 +1,0 @@
-aborting
--- a/tests/libc/execute/chktest.sh
+++ b/tests/libc/execute/chktest.sh
@@ -1,8 +1,9 @@
#!/bin/sh
file=${1?' empty input file'}
-tmp=`mktemp`
-#trap "rm -f a.out $tmp" 0 1 2 3 15
+tmp1=`mktemp`
+tmp2=`mktemp`
+trap "rm -f a.out $tmp1 $tmp2" 0 1 2 3 15
ulimit -c 0
rm -f test.log
@@ -12,8 +13,9 @@
(echo $i
./cc.sh $CFLAGS $i.c
- ./a.out > $tmp
- diff -u $tmp $i.txt) >> test.log 2>&1 &&
+ echo '/^output:$/+;/^end:$/-'w $tmp1 | ed -s $i.c
+ ./a.out > $tmp2
+ diff -u $tmp1 $tmp2) >> test.log 2>&1 &&
printf '[PASS]' || printf '[FAIL]'
printf '%s: %s\n' "$state" "$i"
done < $file