shithub: scc

Download patch

ref: 50340afa8a166091644dc72230dabff7a132ac11
parent: 0c1157ab7b327eb24b8692a5889ba5fe76a2aacc
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Jan 11 06:09:29 EST 2016

Split output and errors in tests

It was a bit ugly to have stderr mixed with stdout.
This new form allows a better understanding of what
is the actual output of the program.

--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -17,7 +17,7 @@
 	ln -f cc1 cpp
 
 test:
-	cd tests && ./chktest.sh
+	cd tests && ./chktest.sh *.c
 
 clean:
 	rm -f $(OBJS)
--- a/cc1/tests/chktest.sh
+++ b/cc1/tests/chktest.sh
@@ -1,22 +1,26 @@
 #!/bin/sh
 
 out=/tmp/$$.out
+err=/tmp/$$.err
 chk=/tmp/$$.chk
+tst=/tmp/$$.tst
 
-trap "rm -f $out $chk" EXIT INT QUIT HUP
+trap "rm -f $out $chk $err $tst" EXIT INT QUIT HUP
 rm -f test.log
 
-for i in *.c
+for i
 do
-	rm -f $out $chk
-	awk '/^name:/    {printf "Running %s ", $2}
-	     /^output:$/ {copyon=1; next}
-	     /^\*\//     {copyon=0; next}
-	     copyon==1   {print > "'$chk'"}' $i
+	rm -f $chk
+	awk '/^name:/            {printf "Running %s ", $2}
+	     /^error:$/          {copyon=1; next}
+	     /^$/ || /^output:$/ {next;}
+	     /^\*\//             {copyon=0; next}
+	     copyon==1           {print > "'$chk'"}' $i
 
-	../cc1 -I. -w $i > $out 2>&1
+	../cc1 -I. -w $i > $out 2>$err
 	echo $i >> test.log
-	if diff -c $chk $out >> test.log
+	cat $err $out > $tst
+	if diff -c $chk $tst >> test.log
 	then
 		echo [OK]
 	else
--- a/cc1/tests/test001.c
+++ b/cc1/tests/test001.c
@@ -1,6 +1,8 @@
 /*
 name: TEST001
 description: Basic hello world test
+error:
+
 output:
 F3	I	P	E
 X4	F3	printf
@@ -11,6 +13,7 @@
 	X4	"68656C6C6F20776F726C640A	'P	pP	cI
 	r	#I0
 }
+
 */
 
 #include <stdio.h>
--- a/cc1/tests/test002.c
+++ b/cc1/tests/test002.c
@@ -1,6 +1,8 @@
 /*
 name: TEST002
 description: Test forward references before definition of types
+error:
+
 output:
 G4	P	x
 F7	I
@@ -25,6 +27,7 @@
 	b
 L13
 }
+
 */
 
 struct S *x;
--- a/cc1/tests/test003.c
+++ b/cc1/tests/test003.c
@@ -1,6 +1,8 @@
 /*
 name: TEST003
 description: Select function to call inside ternary operator
+error:
+
 output:
 F1	I
 G2	F1	foo
@@ -18,6 +20,7 @@
 \
 	r	G2	cI
 }
+
 */
 
 int
--- a/cc1/tests/test004.c
+++ b/cc1/tests/test004.c
@@ -1,6 +1,8 @@
 /*
 name: TEST004
 description: Test integer operations
+error:
+
 output:
 F1	I	E
 G2	F1	main
@@ -27,6 +29,7 @@
 L4
 	r	#I0
 }
+
 */
 
 int
--- a/cc1/tests/test005.c
+++ b/cc1/tests/test005.c
@@ -1,6 +1,8 @@
 /*
 name: TEST005
 description: Test unary integer operations
+error:
+
 output:
 F1	I	E
 G2	F1	main
@@ -17,6 +19,7 @@
 L4
 	r	#I0
 }
+
 */
 
 
--- a/cc1/tests/test006.c
+++ b/cc1/tests/test006.c
@@ -1,10 +1,12 @@
 /*
 name: TEST006
 description: Basic test for if
-output:
+error:
 test006.c:6: warning: conditional expression is constant
 test006.c:8: warning: conditional expression is constant
 test006.c:11: warning: conditional expression is constant
+
+output:
 G1	K	c
 F2	I	E
 G3	F2	main
@@ -32,6 +34,7 @@
 L5
 	r	#I1
 }
+
 */
 
 char c;
--- a/cc1/tests/test007.c
+++ b/cc1/tests/test007.c
@@ -1,6 +1,8 @@
 /*
 name: TEST007
 description: basic while test
+error:
+
 output:
 F1	I	E
 G2	F1	main
@@ -18,6 +20,7 @@
 L5
 	r	A3
 }
+
 */
 
 int
--- a/cc1/tests/test008.c
+++ b/cc1/tests/test008.c
@@ -1,6 +1,8 @@
 /*
 name: TEST008
 description: Basic do while loop
+error:
+
 output:
 F1	I	E
 G2	F1	main
@@ -22,6 +24,7 @@
 L7
 	r	A3	#I14	-I
 }
+
 */
 
 int 
--- a/cc1/tests/test009.c
+++ b/cc1/tests/test009.c
@@ -1,6 +1,8 @@
 /*
 name: TEST009
 description: Basic test for loops
+error:
+
 output:
 F1	I	E
 G2	F1	main
@@ -21,6 +23,7 @@
 L7
 	r	#I0
 }
+
 */
 
 int 
--- a/cc1/tests/test010.c
+++ b/cc1/tests/test010.c
@@ -1,10 +1,12 @@
 /*
 name: TEST010
 description: Test for continue and break statements
-output:
+error:
 test010.c:9: warning: conditional expression is constant
 test010.c:11: warning: conditional expression is constant
 test010.c:31: warning: conditional expression is constant
+
+output:
 F1	I	E
 G2	F1	main
 {
@@ -57,6 +59,7 @@
 L16
 	r	A3	#IF	-I
 }
+
 */
 
 #line 1
--- a/cc1/tests/test011.c
+++ b/cc1/tests/test011.c
@@ -1,9 +1,11 @@
 /*
 name: TEST011
 description: Basic test for goto
-output:
+error:
 test011.c:14: warning: 'foo' defined but not used
 test011.c:14: warning: 'start' defined but not used
+
+output:
 F1	I	E
 G2	F1	main
 {
@@ -18,6 +20,7 @@
 	j	L5
 	r	#I1
 }
+
 */
 
 #line 1
--- a/cc1/tests/test012.c
+++ b/cc1/tests/test012.c
@@ -1,8 +1,10 @@
 /*
 name: TEST012
 description: Basic switch test
-output:
+error:
 test012.c:39: warning: 'foo' defined but not used
+
+output:
 F1	I	E
 G2	F1	main
 {
@@ -69,6 +71,7 @@
 	f	L26
 L22
 }
+
 */
 
 #line 1
--- a/cc1/tests/test013.c
+++ b/cc1/tests/test013.c
@@ -4,6 +4,8 @@
 comments: This test depends of the configuration in the type system.
           With the current configuration char is equal to unsigned char,
           short is equal to int, and unsigned short is equal to unsigned.
+error:
+
 output:
 G1	I	a
 G2	N	b
@@ -131,6 +133,7 @@
 	G11	G10	gN	:N
 	G11	G9	gN	:N
 }
+
 */
 
 int a;
--- a/cc1/tests/test014.c
+++ b/cc1/tests/test014.c
@@ -1,7 +1,7 @@
 /*
 name: TEST014
 description: Basic storage class test
-output:
+error:
 test014.c:16: warning: 'a' defined but not used
 test014.c:16: warning: 'k' defined but not used
 test014.c:16: warning: 'j' defined but not used
@@ -11,6 +11,15 @@
 test014.c:22: warning: 'par' defined but not used
 test014.c:27: warning: 'par' defined but not used
 test014.c:29: error: incorrect storage class for file-scope declaration
+test014.c:29: error: invalid storage class for function 'd'
+test014.c:32: error: bad storage class in function parameter
+test014.c:33: error: invalid storage class for function 'func4'
+test014.c:34: error: invalid type specification
+test014.c:35: warning: 'f' defined but not used
+test014.c:35: warning: 'par' defined but not used
+test014.c:38: error: conflicting types for 'd'
+
+output:
 G1	I	a
 Y2	K	b
 X3	I	c
@@ -37,13 +46,7 @@
 R16	I	par
 \
 }
-test014.c:29: error: invalid storage class for function 'd'
-test014.c:32: error: bad storage class in function parameter
-test014.c:33: error: invalid storage class for function 'func4'
-test014.c:34: error: invalid type specification
-test014.c:35: warning: 'f' defined but not used
-test014.c:35: warning: 'par' defined but not used
-test014.c:38: error: conflicting types for 'd'
+
 */
 
 #line 1
--- a/cc1/tests/test015.c
+++ b/cc1/tests/test015.c
@@ -1,8 +1,10 @@
 /*
 name: TEST015
 description: Stress namespace mechanism
+error:
+test015.c:55: error: label 's' already defined
+
 output:
-test015.c:52: error: label 's' already defined
 S8	s2
 M9	I	s
 S5	s1
@@ -21,6 +23,7 @@
 	r	A17
 	r	A16	M11	.S5	M6	.I	A16	M11	.S5	M10	.S8	M9	.I	+I
 L15
+
 */
 
 typedef struct s s;
--- a/cc1/tests/test016.c
+++ b/cc1/tests/test016.c
@@ -1,8 +1,11 @@
 /*
 name: TEST016
 description: Basic pointer test
-output:
+error:
 test016.c:43: error: redefinition of 'func2'
+test016.c:47: error: incompatible types when assigning
+
+output:
 G1	I	g
 F2	I
 G3	F2	func1
@@ -39,7 +42,7 @@
 	A11	#P0	:P
 	r	A10
 }
-test016.c:47: error: incompatible types when assigning
+
 */
 
 #line 1
--- a/cc1/tests/test017.c
+++ b/cc1/tests/test017.c
@@ -1,6 +1,8 @@
 /*
 name: TEST017
 description: Basic test about pointers and structs
+error:
+
 output:
 F9	I	E
 G10	F9	main
@@ -24,6 +26,7 @@
 L14
 	r	#I0
 }
+
 */
 
 #line 1
--- a/cc1/tests/test018.c
+++ b/cc1/tests/test018.c
@@ -1,6 +1,8 @@
 /*
 name: TEST018
 description: Basic test for arrays
+error:
+
 output:
 F1	I	E
 G2	F1	main
@@ -31,6 +33,7 @@
 L16
 	r	#I0
 }
+
 */
 
 #line 1
--- a/cc1/tests/test019.c
+++ b/cc1/tests/test019.c
@@ -2,9 +2,11 @@
 /*
 name: TEST019
 description: Basic test of constant folding in integer arithmetic operations
-output:
+error:
 test019.c:13: warning: division by 0
 test019.c:14: warning: division by 0
+
+output:
 F1	I
 G2	F1	main
 {
@@ -30,6 +32,7 @@
 	A3	#I1	:I
 	A3	#I0	:I
 }
+
 */
 
 #line 1
--- a/cc1/tests/test020.c
+++ b/cc1/tests/test020.c
@@ -2,9 +2,11 @@
 /*
 name: TEST020
 description: Basic test for integer algebraic identities
+error:
+test020.c:84: warning: division by 0
+test020.c:85: warning: division by 0
+
 output:
-test020.c:81: warning: division by 0
-test020.c:82: warning: division by 0
 F1	I
 G2	F1	main
 {
@@ -42,6 +44,7 @@
 	A3	A3	#I0	/I	:I
 	A3	A3	#I0	%I	:I
 }
+
 */
 
 int
--- a/cc1/tests/test021.c
+++ b/cc1/tests/test021.c
@@ -3,6 +3,8 @@
 name: TEST021
 description: Basic test for char constants
 comments: This test is done for z80 implementation
+error:
+
 output:
 F1	I
 G2	F1	main
@@ -21,6 +23,7 @@
 	A4	#C1	:C
 	A4	#C41	:C
 }
+
 */
 
 int
--- a/cc1/tests/test022.c
+++ b/cc1/tests/test022.c
@@ -3,6 +3,8 @@
 name: TEST022
 description: Basic test for int constants
 comments: This test is done for z80 data types
+error:
+
 output:
 F1	I
 G2	F1	main
@@ -28,6 +30,7 @@
 	A4	#N0	:N
 	r	#I0
 }
+
 */
 
 int
--- a/cc1/tests/test023.c
+++ b/cc1/tests/test023.c
@@ -3,6 +3,8 @@
 name: TEST023
 description: Basic test for long constants
 comments: This test is done for z80 data types
+error:
+
 output:
 F1	I
 G2	F1	main
@@ -28,6 +30,7 @@
 	A4	#Z0	:Z
 	r	#I0
 }
+
 */
 
 int
--- a/cc1/tests/test024.c
+++ b/cc1/tests/test024.c
@@ -3,6 +3,8 @@
 name: TEST024
 description: Basic test for long long constants
 comments: This test is done for z80 data types
+error:
+
 output:
 F1	I
 G2	F1	main
@@ -26,6 +28,7 @@
 	A4	#O0	:O
 	r	#I0
 }
+
 */
 
 int
--- a/cc1/tests/test025.c
+++ b/cc1/tests/test025.c
@@ -2,6 +2,8 @@
 /*
 name: TEST025
 descritpion: Test of ifdef and ifndef
+error:
+
 output:
 G1	I	a
 G2	I	b
@@ -13,6 +15,7 @@
 G8	I	f_
 G9	I	h
 G10	I	i
+
 */
 
 #define FOO
--- a/cc1/tests/test026.c
+++ b/cc1/tests/test026.c
@@ -2,6 +2,8 @@
 /*
 name: TEST026
 descritpion: Test of predefined cpp macros
+error:
+
 output:
 F2	I
 G3	F2	main
@@ -10,12 +12,13 @@
 A4	I	y
 A6	P	p
 	A6	"746573743032362E63	'P	:P
-	A4	#I1E	:I
+	A4	#I21	:I
 	A4	#I1	:I
 	A4	#I1	:I
 	A4	#I1	:I
 	A4	#I1	:I
 }
+
 */
 
 #define x(y)  (y)
--- a/cc1/tests/test027.c
+++ b/cc1/tests/test027.c
@@ -2,6 +2,8 @@
 /*
 name: TEST027
 description: Test of cpp stringizer
+error:
+
 output:
 F2	I
 G3	F2	main
@@ -11,6 +13,7 @@
 	A5	"68656C6C6F20697320626574746572207468616E20627965	'P	:P
 	r	A5	@K	gI
 }
+
 */
 
 #define x(y) #y
--- a/cc1/tests/test028.c
+++ b/cc1/tests/test028.c
@@ -2,6 +2,8 @@
 /*
 name: TEST028
 description: Test of reinterpretation in define
+error:
+
 output:
 F5	P
 G6	F5	foo
@@ -9,6 +11,7 @@
 \
 	r	"6869	'P
 }
+
 */
 
 
--- a/cc1/tests/test029.c
+++ b/cc1/tests/test029.c
@@ -5,8 +5,11 @@
 comments: f(2) will expand to 2*g, which will expand to 2*f, and in this
           moment f will not be expanded because the macro definition is
           a function alike macro, and in this case there is no arguments.
+error:
+test029.c:37: error: redefinition of 'f1'
+test029.c:38: error: 'f' undeclared
+
 output:
-test029.c:34: error: redefinition of 'f1'
 F2	I
 G3	F2	f1
 {
@@ -14,7 +17,7 @@
 A4	I	f
 	A4	#I2	*I
 }
-test029.c:35: error: 'f' undeclared
+
 */
 
 
--- a/cc1/tests/test030.c
+++ b/cc1/tests/test030.c
@@ -2,6 +2,8 @@
 /*
 name: TEST030
 description: Basic test for vararg functions
+error:
+
 output:
 F13	I	S2	P	I	E
 G14	F13	f1
@@ -31,6 +33,7 @@
 	G14	A18	pS2	A18	'P	pP	#I2	pI	#I1	pI	A18	pS2	A18	'P	pP	cI
 	r	#I0
 }
+
 */
 
 struct foo {
--- a/cc1/tests/test031.c
+++ b/cc1/tests/test031.c
@@ -2,18 +2,10 @@
 /*
 name: TEST031
 description: Test concatenation in preprocessor
+error:
+ 
 output:
-F5	I
-G6	F5	main
-{
-\
-A7	I	foo
-A8	I	bar
-A9	I	foobar
-	A9	A7	A8	+I	:I
-	A9	A7	A8	+I	:I
-	r	#I0
-}
+ 
 */
 
 #define CAT(x,y) x ## y
--- a/cc1/tests/test032.c
+++ b/cc1/tests/test032.c
@@ -2,6 +2,8 @@
 /*
 name: TEST032
 description: test special characters @ and $ in macro definitions
+error:
+
 output:
 F3	I
 G4	F3	main
@@ -11,6 +13,7 @@
 	A6	"54686973206973206120737472696E672024206F722023206F72202323616E64206974206973206F6B2021	'P	:P
 	r	A6	#P0	!I
 }
+
 */
 
 #define M1(x) "This is a string $ or # or ##" ## #x
--- a/cc1/tests/test033.c
+++ b/cc1/tests/test033.c
@@ -1,8 +1,11 @@
 /*
 name: TEST033
 description: test for #if defined()
+error:
+
 output:
 G1	I	c
+
 */
 
 #if defined(FOO)
--- a/cc1/tests/test034.c
+++ b/cc1/tests/test034.c
@@ -2,8 +2,11 @@
 /*
 name: TEST034
 description: Basic test for incomplete structures
+error:
+test034.c:48: error: declared variable 'bar' of incomplete type
+test034.c:48: error: redeclaration of 'bar'
+
 output:
-test034.c:45: error: declared variable 'bar' of incomplete type
 X3	S2	x
 F4	I	E
 X5	F4	foo
@@ -20,7 +23,7 @@
 	r	X3	M9	.I
 }
 X13	S11	bar2
-test034.c:45: error: redeclaration of 'bar'
+
 */
 
 extern struct X x;
--- a/cc1/tests/test035.c
+++ b/cc1/tests/test035.c
@@ -2,6 +2,8 @@
 /*
 name: TEST035
 description: Basic test for enumerations
+error:
+
 output:
 F6	I	E
 G7	F6	main
@@ -23,6 +25,7 @@
 L12
 	r	#I0
 }
+
 */
 
 enum E {
--- a/cc1/tests/test036.c
+++ b/cc1/tests/test036.c
@@ -2,8 +2,10 @@
 /*
 name: TEST036
 description: Duff's device
+error:
+test036.c:63: warning: type defaults to 'int' in declaration
+
 output:
-test036.c:60: warning: type defaults to 'int' in declaration
 F4	I	E
 G5	F4	send
 {
@@ -48,6 +50,7 @@
 	v	L10	#I0
 L8
 }
+
 */
 
 /* Disgusting, no?  But it compiles and runs just fine.  I feel a combination of
--- a/cc1/tests/test037.c
+++ b/cc1/tests/test037.c
@@ -3,10 +3,12 @@
 name: TEST037
 description: Basic sizeof test
 comments: This test is based in z80 sizes
+error:
+test037.c:32: warning: conditional expression is constant
+test037.c:34: warning: conditional expression is constant
+test037.c:36: warning: conditional expression is constant
+
 output:
-test037.c:29: warning: conditional expression is constant
-test037.c:31: warning: conditional expression is constant
-test037.c:33: warning: conditional expression is constant
 F1	I	E
 G2	F1	main
 {
@@ -22,6 +24,7 @@
 L5
 	r	#I0
 }
+
 */
 
 int main()
--- a/cc1/tests/test038.c
+++ b/cc1/tests/test038.c
@@ -2,8 +2,10 @@
 /*
 name: TEST038
 description: Basic test for tentative definitions
+error:
+test038.c:48: error: redeclaration of 'x'
+
 output:
-test038.c:45: error: redeclaration of 'x'
 G1	I	x
 (
 	#I0
@@ -22,6 +24,7 @@
 	G1	#I0	:I
 	r	G1
 }
+
 */
 
 int x;
--- a/cc1/tests/test039.c
+++ b/cc1/tests/test039.c
@@ -3,6 +3,8 @@
 name: TEST039
 description: Test of integer constants
 comments: This test is done for z80 sizes
+error:
+
 output:
 F1	I
 G2	F1	main
@@ -29,6 +31,7 @@
 	A8	#O1	:O
 	r	#I0
 }
+
 */
 
 int
--- a/cc1/tests/test040.c
+++ b/cc1/tests/test040.c
@@ -1,6 +1,8 @@
 /*
 name: TEST040
 description: Test for bug parsing typenames in struct definition
+error:
+
 output:
 F8	I
 G9	F8	main
@@ -13,6 +15,7 @@
 A10	S2	List
 	r	A10	M4	.I
 }
+
 */
 
 typedef struct List List;
--- a/cc1/tests/test041.c
+++ b/cc1/tests/test041.c
@@ -1,8 +1,15 @@
 /*
 name: TEST041
 description: Test for bug parsing ternary operators
+error:
+test041.c:51: error: type mismatch in conditional expression
+test041.c:51: error: incompatible types when assigning
+test041.c:52: error: used struct/union type value where scalar is required
+test041.c:53: warning: 'i' defined but not used
+test041.c:53: warning: 'foo' defined but not used
+test041.c:53: warning: 's' defined but not used
+
 output:
-test041.c:48: error: type mismatch in conditional expression
 F1	I
 G2	F1	main
 {
@@ -22,11 +29,7 @@
 	A5	A3	#I0	!I	A8	#P0	?P	:P
 	A5	A3	#I0	!I	A5	#P0	?P	:P
 	A5	A3	#I0	!I	#P0	A5	?P	:P
-test041.c:48: error: incompatible types when assigning
-test041.c:49: error: used struct/union type value where scalar is required
-test041.c:50: warning: 'i' defined but not used
-test041.c:50: warning: 'foo' defined but not used
-test041.c:50: warning: 's' defined but not used
+
 */
    
 int
--- a/cc1/tests/test042.c
+++ b/cc1/tests/test042.c
@@ -1,8 +1,10 @@
 /*
 name: TEST042
 description: Test for bug parsing ternary operators
+error:
+test042.c:22: error: bad type convertion requested
+
 output:
-test042.c:19: error: bad type convertion requested
 F1	I
 G2	F1	main
 {
@@ -9,6 +11,7 @@
 \
 F3	0
 X4	F3	f
+
 */
 
 int
--- a/cc1/tests/test043.c
+++ b/cc1/tests/test043.c
@@ -1,6 +1,8 @@
 /*
 name: TEST043
 description: Test for double typedef (taken from plan9 kernel)
+error:
+
 output:
 F4	0
 S2	Clock0link
@@ -14,6 +16,7 @@
 	G9	M6	.P	@F4	c0
 	r	#I0
 }
+
 */
 
 typedef struct Clock0link Clock0link;
--- a/cc1/tests/test044.c
+++ b/cc1/tests/test044.c
@@ -1,12 +1,15 @@
 /*
 name: TEST044
 description: Test of corner cases in #if
+error:
+test044.c:17: warning: division by 0
+test044.c:21: warning: division by 0
+test044.c:25: warning: division by 0
+test044.c:31: error: parameter of #if is not an integer constant expression
+test044.c:32: error: #error  3 != (1,2,3)
+
 output:
-test044.c:14: warning: division by 0
-test044.c:18: warning: division by 0
-test044.c:22: warning: division by 0
-test044.c:28: error: parameter of #if is not an integer constant expression
-test044.c:29: error: #error  3 != (1,2,3)
+
 */
 
 /* These should be accepted */
--- a/cc1/tests/update.sh
+++ b/cc1/tests/update.sh
@@ -1,5 +1,10 @@
 #!/bin/sh
 
+out=/tmp/$$.out
+err=/tmp/$$.err
+
+trap "rm -f $out $err" EXIT INT QUIT HUP
+
 case $# in
 0)
 	echo "usage: update.sh test ..." >&2
@@ -8,9 +13,13 @@
 *)
 	for i
 	do
-		(echo '/^output/+;/^\*\//-c'
-		../cc1 -I./ -w $1 2>&1
-		printf ".\nw\n") | ed -s $1
+		../cc1 -I./ -w $i  >$out 2>$err
+		(echo '/^error/+;/^output/-c'
+		cat $err
+		printf "\n.\n"
+		echo '/^output/+;/^\*\//-c'
+		cat $out
+		printf "\n.\nw\n") | ed -s $i
 	done
 	;;
 esac