ref: e4f0fe727ff7969419f79b778d272a6a658ce3a2
parent: 339c577e4428f7beefd82ce7eaa0d54a0e28c386
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Mar 6 10:42:50 EST 2017
[tests] Add scripts to run error tests
--- 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()
--- a/tests/error/0002-missinginclude.c
+++ b/tests/error/0002-missinginclude.c
@@ -1,1 +1,7 @@
+/*
+PATTERN:
+0002-missinginclude.c:7: error: included file 'MISSING.h' not found
+.
+*/
+
#include "MISSING.h"
--- 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
--- 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
--- 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(
--- 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
--- a/tests/error/0007-unmatchedcppif.c
+++ b/tests/error/0007-unmatchedcppif.c
@@ -1,5 +1,7 @@
/*
-PATTERN: endif
+PATTERN:
+
+.
*/
#ifdef FOO
--- 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
--- a/tests/error/0009-unmatchedcppelif.c
+++ b/tests/error/0009-unmatchedcppelif.c
@@ -1,6 +1,7 @@
-
/*
-PATTERN: elif
+PATTERN:
+
+.
*/
#elif 1
--- a/tests/error/0010-extraelif.c
+++ b/tests/error/0010-extraelif.c
@@ -1,6 +1,7 @@
-
/*
-PATTERN: elif
+PATTERN:
+
+.
*/
#if 1
--- a/tests/error/0011-extraelse.c
+++ b/tests/error/0011-extraelse.c
@@ -1,6 +1,7 @@
-
/*
-PATTERN: else
+PATTERN:
+
+.
*/
#if 1
--- 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
--- 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
--- 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
--- 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
--- 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};
--- 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()
--- 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)
{
--- /dev/null
+++ b/tests/error/Makefile
@@ -1,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
+
--- /dev/null
+++ b/tests/error/chktest.sh
@@ -1,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
--- /dev/null
+++ b/tests/error/scc-tests.lst
@@ -1,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]
--- /dev/null
+++ b/tests/error/update.sh
@@ -1,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