[hackers] [scc] [tests] Add scripts to run error tests || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 6 Mar 2017 15:44:38 +0100 (CET)

commit c82048c4f93d643ebe8ae0788de5dae808f2f91e
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Mar 6 15:42:50 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Mar 6 15:42:50 2017 +0100

    [tests] Add scripts to run error tests

diff --git a/tests/error/0001-sanity.c b/tests/error/0001-sanity.c
index 5057227..e7eaf3c 100644
--- a/tests/error/0001-sanity.c
+++ b/tests/error/0001-sanity.c
_AT_@ -1,5 +1,7 @@
 /*
-PATTERN: undefined symbol FOO
+PATTERN:
+0001-sanity.c:9: error: 'FOO' undeclared
+.
 */
 
 int main()
diff --git a/tests/error/0002-missinginclude.c b/tests/error/0002-missinginclude.c
index 1580fd2..133757c 100644
--- a/tests/error/0002-missinginclude.c
+++ b/tests/error/0002-missinginclude.c
_AT_@ -1 +1,7 @@
+/*
+PATTERN:
+0002-missinginclude.c:7: error: included file 'MISSING.h' not found
+.
+*/
+
 #include "MISSING.h"
diff --git a/tests/error/0003-junkinclude.c b/tests/error/0003-junkinclude.c
index cba91a8..67854c5 100644
--- a/tests/error/0003-junkinclude.c
+++ b/tests/error/0003-junkinclude.c
_AT_@ -1,6 +1,7 @@
 /*
-PATTERN: bar
-PATTERN: junk
+PATTERN:
+0003-junkinclude.c:7: error: trailing characters after preprocessor directive
+.
 */
 
 #include "0003-junkinclude.c" bar
diff --git a/tests/error/0004-macroredef.c b/tests/error/0004-macroredef.c
index 28ed85c..5c26f16 100644
--- a/tests/error/0004-macroredef.c
+++ b/tests/error/0004-macroredef.c
_AT_@ -1,6 +1,7 @@
 /*
-PATTERN: redefinition
-PATTERN: 7
+PATTERN:
+0004-macroredef.c:8: warning: 'X' redefined
+.
 */
 
 #define X 1
diff --git a/tests/error/0005-fmacro.c b/tests/error/0005-fmacro.c
index ca22ea7..d749ca4 100644
--- a/tests/error/0005-fmacro.c
+++ b/tests/error/0005-fmacro.c
_AT_@ -1,6 +1,7 @@
-
 /*
-PATTERN: expected
+PATTERN:
+0005-fmacro.c:7: error: macro arguments must be identifiers
+.
 */
 
 #define X(
diff --git a/tests/error/0006-endif.c b/tests/error/0006-endif.c
index 7ccc5c6..0497695 100644
--- a/tests/error/0006-endif.c
+++ b/tests/error/0006-endif.c
_AT_@ -1,6 +1,7 @@
-
 /*
-PATTERN: endif
+PATTERN:
+0006-endif.c:7: error: #endif without #if
+.
 */
 
 #endif
diff --git a/tests/error/0007-unmatchedcppif.c b/tests/error/0007-unmatchedcppif.c
index dfcf8b4..f2bd949 100644
--- a/tests/error/0007-unmatchedcppif.c
+++ b/tests/error/0007-unmatchedcppif.c
_AT_@ -1,5 +1,7 @@
 /*
-PATTERN: endif
+PATTERN:
+
+.
 */
 
 #ifdef FOO
diff --git a/tests/error/0008-unmatchedcppelse.c b/tests/error/0008-unmatchedcppelse.c
index 657efbb..9361dfb 100644
--- a/tests/error/0008-unmatchedcppelse.c
+++ b/tests/error/0008-unmatchedcppelse.c
_AT_@ -1,6 +1,7 @@
-
 /*
-PATTERN: else
+PATTERN:
+0008-unmatchedcppelse.c:7: error: #else without #ifdef/ifndef
+.
 */
 
 #else
diff --git a/tests/error/0009-unmatchedcppelif.c b/tests/error/0009-unmatchedcppelif.c
index 17c5791..9d4d6ae 100644
--- a/tests/error/0009-unmatchedcppelif.c
+++ b/tests/error/0009-unmatchedcppelif.c
_AT_@ -1,6 +1,7 @@
-
 /*
-PATTERN: elif
+PATTERN:
+
+.
 */
 
 #elif 1
diff --git a/tests/error/0010-extraelif.c b/tests/error/0010-extraelif.c
index acfb7c5..17e8ad8 100644
--- a/tests/error/0010-extraelif.c
+++ b/tests/error/0010-extraelif.c
_AT_@ -1,6 +1,7 @@
-
 /*
-PATTERN: elif
+PATTERN:
+
+.
 */
 
 #if 1
diff --git a/tests/error/0011-extraelse.c b/tests/error/0011-extraelse.c
index 3fac326..a6a582e 100644
--- a/tests/error/0011-extraelse.c
+++ b/tests/error/0011-extraelse.c
_AT_@ -1,6 +1,7 @@
-
 /*
-PATTERN: else
+PATTERN:
+
+.
 */
 
 #if 1
diff --git a/tests/error/0012-ifnoexpr.c b/tests/error/0012-ifnoexpr.c
index a43836d..b0cf508 100644
--- a/tests/error/0012-ifnoexpr.c
+++ b/tests/error/0012-ifnoexpr.c
_AT_@ -1,5 +1,8 @@
 /*
-PATTERN: expression
+PATTERN:
+0012-ifnoexpr.c:7: error: unexpected '
+'
+.
 */
 
 #if
diff --git a/tests/error/0013-macro.c b/tests/error/0013-macro.c
index d892a8e..34e6c5c 100644
--- a/tests/error/0013-macro.c
+++ b/tests/error/0013-macro.c
_AT_@ -1,5 +1,7 @@
 /*
-PATTERN: macro
+PATTERN:
+0013-macro.c:9: error: macro "X" received 0 arguments, but it takes 1
+.
 */
 
 #define X(A, ...) 0
diff --git a/tests/error/0014-macro.c b/tests/error/0014-macro.c
index 1cf645a..732c372 100644
--- a/tests/error/0014-macro.c
+++ b/tests/error/0014-macro.c
_AT_@ -1,5 +1,7 @@
 /*
-PATTERN: macro
+PATTERN:
+0014-macro.c:9: error: macro "X" received 1 arguments, but it takes 0
+.
 */
 
 #define X() 0
diff --git a/tests/error/0015-macro.c b/tests/error/0015-macro.c
index 7317859..df2b8aa 100644
--- a/tests/error/0015-macro.c
+++ b/tests/error/0015-macro.c
_AT_@ -1,5 +1,7 @@
 /*
-PATTERN: macro argument
+PATTERN:
+
+.
 */
 
 #define X(A, A) 0
diff --git a/tests/error/0016-arrayinitsize.c b/tests/error/0016-arrayinitsize.c
index c739cef..8472183 100644
--- a/tests/error/0016-arrayinitsize.c
+++ b/tests/error/0016-arrayinitsize.c
_AT_@ -1,5 +1,7 @@
 /*
-PATTERN: incorrect
+PATTERN:
+
+.
 */
 
 int x[2] = {1, 2, 3};
diff --git a/tests/error/0017-duplicatefunc.c b/tests/error/0017-duplicatefunc.c
index 81d3d19..8ae909d 100644
--- a/tests/error/0017-duplicatefunc.c
+++ b/tests/error/0017-duplicatefunc.c
_AT_@ -1,3 +1,8 @@
+/*
+PATTERN:
+0017-duplicatefunc.c:15: error: redefinition of 'main'
+.
+*/
 
 int
 main()
diff --git a/tests/error/0018-voidparam.c b/tests/error/0018-voidparam.c
index 2167a26..ce07ff8 100644
--- a/tests/error/0018-voidparam.c
+++ b/tests/error/0018-voidparam.c
_AT_@ -1,3 +1,10 @@
+/*
+PATTERN:
+0018-voidparam.c:27: error: a named argument is requiered before '...'
+.
+*/
+
+
 int
 a(void, int i)
 {
diff --git a/tests/error/Makefile b/tests/error/Makefile
new file mode 100644
index 0000000..a71126d
--- /dev/null
+++ b/tests/error/Makefile
_AT_@ -0,0 +1,9 @@
+
+all: tests
+
+tests:
+ CFLAGS='' SCCEXECPATH=../../bin PATH=../../bin:$$PATH ./chktest.sh < scc-tests.lst
+
+clean:
+ rm -f *.as *.o *.ir *.qbe *core
+
diff --git a/tests/error/chktest.sh b/tests/error/chktest.sh
new file mode 100755
index 0000000..c39e3f8
--- /dev/null
+++ b/tests/error/chktest.sh
_AT_@ -0,0 +1,19 @@
+#!/bin/sh
+
+err=/tmp/$$.err
+chk=/tmp/$$.chk
+
+trap "tabs -8;rm -f a.out *.o $err" 0 1 2 3 15
+tabs 40
+ulimit -c 0
+
+while read i state
+do
+ printf "%s\t" $i
+ printf "%s" $state
+
+ scc $CFLAGS -w -c "$i" 2> $err
+ echo '/^PATTERN/+;/\./-p' | ed -s $i > $chk
+ diff -c $chk $err >> test.log && echo [OK] || echo [FAILED]
+ rm -f *.o
+done
diff --git a/tests/error/scc-tests.lst b/tests/error/scc-tests.lst
new file mode 100644
index 0000000..b96f72c
--- /dev/null
+++ b/tests/error/scc-tests.lst
_AT_@ -0,0 +1,18 @@
+0001-sanity.c
+0002-missinginclude.c
+0003-junkinclude.c
+0004-macroredef.c
+0005-fmacro.c
+0006-endif.c
+0007-unmatchedcppif.c [TODO]
+0008-unmatchedcppelse.c
+0009-unmatchedcppelif.c [TODO]
+0010-extraelif.c [TODO]
+0011-extraelse.c [TODO]
+0012-ifnoexpr.c [TODO]
+0013-macro.c
+0014-macro.c
+0015-macro.c [TODO]
+0016-arrayinitsize.c [TODO]
+0017-duplicatefunc.c
+0018-voidparam.c [TODO]
diff --git a/tests/error/update.sh b/tests/error/update.sh
new file mode 100755
index 0000000..cead3da
--- /dev/null
+++ b/tests/error/update.sh
_AT_@ -0,0 +1,11 @@
+#!/bin/sh
+# See LICENSE file for copyright and license details.
+
+for i
+do
+ (echo '/^PATTERN/+;/^\./-c'
+ scc $CFLAGS -w -c $i 2>&1
+ printf ".\nw\n"
+ echo w) |
+ ed -s $i
+done
Received on Mon Mar 06 2017 - 15:44:38 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 06 2017 - 15:48:27 CET