scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit c82048c4f93d643ebe8ae0788de5dae808f2f91e
parent a2de2d7a1220d2e98c6afcf28e0978d71f69bb6f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  6 Mar 2017 15:42:50 +0100

[tests] Add scripts to run error tests

Diffstat:
Mtests/error/0001-sanity.c | 4+++-
Mtests/error/0002-missinginclude.c | 6++++++
Mtests/error/0003-junkinclude.c | 5+++--
Mtests/error/0004-macroredef.c | 5+++--
Mtests/error/0005-fmacro.c | 5+++--
Mtests/error/0006-endif.c | 5+++--
Mtests/error/0007-unmatchedcppif.c | 4+++-
Mtests/error/0008-unmatchedcppelse.c | 5+++--
Mtests/error/0009-unmatchedcppelif.c | 5+++--
Mtests/error/0010-extraelif.c | 5+++--
Mtests/error/0011-extraelse.c | 5+++--
Mtests/error/0012-ifnoexpr.c | 5++++-
Mtests/error/0013-macro.c | 4+++-
Mtests/error/0014-macro.c | 4+++-
Mtests/error/0015-macro.c | 4+++-
Mtests/error/0016-arrayinitsize.c | 4+++-
Mtests/error/0017-duplicatefunc.c | 5+++++
Mtests/error/0018-voidparam.c | 7+++++++
Atests/error/Makefile | 9+++++++++
Atests/error/chktest.sh | 19+++++++++++++++++++
Atests/error/scc-tests.lst | 18++++++++++++++++++
Atests/error/update.sh | 11+++++++++++
22 files changed, 121 insertions(+), 23 deletions(-)

diff --git a/tests/error/0001-sanity.c b/tests/error/0001-sanity.c @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -1,5 +1,7 @@ /* -PATTERN: endif +PATTERN: + +. */ #ifdef FOO diff --git a/tests/error/0008-unmatchedcppelse.c b/tests/error/0008-unmatchedcppelse.c @@ -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 @@ -1,6 +1,7 @@ - /* -PATTERN: elif +PATTERN: + +. */ #elif 1 diff --git a/tests/error/0010-extraelif.c b/tests/error/0010-extraelif.c @@ -1,6 +1,7 @@ - /* -PATTERN: elif +PATTERN: + +. */ #if 1 diff --git a/tests/error/0011-extraelse.c b/tests/error/0011-extraelse.c @@ -1,6 +1,7 @@ - /* -PATTERN: else +PATTERN: + +. */ #if 1 diff --git a/tests/error/0012-ifnoexpr.c b/tests/error/0012-ifnoexpr.c @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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