diff --git a/test/.gitignore b/test/.gitignore index 5baabe900..ccdd4aef5 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,2 +1,3 @@ *.o *.prg +*.out diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 000000000..4c03f2cd5 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,16 @@ + +# toplevel makefile for the regression tests + +MAKE := make --no-print-dir + +.PHONY: all clean + +all: + @$(MAKE) -C val all + @$(MAKE) -C ref all + @$(MAKE) -C err all + +clean: + @$(MAKE) -C val clean + @$(MAKE) -C ref clean + @$(MAKE) -C err clean diff --git a/test/err/Makefile b/test/err/Makefile new file mode 100644 index 000000000..6f919b3d1 --- /dev/null +++ b/test/err/Makefile @@ -0,0 +1,42 @@ + +# makefile for the tests that MUST NOT compile + +CC65FLAGS = -t sim6502 + +CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65) + +RM := rm -f + +.PHONY: all + +TESTS := $(patsubst %.c,%.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.o.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.os.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.osi.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.osir.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.oi.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.oir.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.or.prg,$(wildcard *.c)) + +all: $(TESTS) + +%.prg: %.c + ! $(CL65) $(CC65FLAGS) $< -o $@ +%.o.prg: %.c + ! $(CL65) $(CC65FLAGS) $< -o $@ +%.os.prg: %.c + ! $(CL65) $(CC65FLAGS) $< -o $@ +%.osi.prg: %.c + ! $(CL65) $(CC65FLAGS) $< -o $@ +%.osir.prg: %.c + ! $(CL65) $(CC65FLAGS) $< -o $@ +%.oi.prg: %.c + ! $(CL65) $(CC65FLAGS) $< -o $@ +%.oir.prg: %.c + ! $(CL65) $(CC65FLAGS) $< -o $@ +%.or.prg: %.c + ! $(CL65) $(CC65FLAGS) $< -o $@ +clean: + @$(RM) *.o + @$(RM) *.prg diff --git a/test/ref/8q.c b/test/ref/8q.c index afbe41c64..e8bd1ca2e 100644 --- a/test/ref/8q.c +++ b/test/ref/8q.c @@ -4,6 +4,8 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include + int up[15], down[15], rows[8], x[8]; void queens(int c); void print(void); diff --git a/test/ref/Makefile b/test/ref/Makefile new file mode 100644 index 000000000..85cbb9bd8 --- /dev/null +++ b/test/ref/Makefile @@ -0,0 +1,62 @@ + +# makefile for the regression tests that generate output which has to be +# compared with reference output + +CC65FLAGS = -t sim6502 +SIM65FLAGS = -x 200000000 + +CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) +SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65) + +RM := rm -f + +.PHONY: all + +TESTS := $(patsubst %.c,%.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.o.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.os.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.osi.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.osir.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.oi.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.oir.prg,$(wildcard *.c)) +TESTS += $(patsubst %.c,%.or.prg,$(wildcard *.c)) + +all: $(TESTS) + +%.prg: %.c + $(CL65) $(CC65FLAGS) $< -o $@ + $(SIM65) $(SIM65FLAGS) $@ > $*.out + +%.o.prg: %.c + $(CL65) $(CC65FLAGS) $< -o $@ + $(SIM65) $(SIM65FLAGS) $@ > $*.out + +%.os.prg: %.c + $(CL65) $(CC65FLAGS) $< -o $@ + $(SIM65) $(SIM65FLAGS) $@ > $*.out + +%.osi.prg: %.c + $(CL65) $(CC65FLAGS) $< -o $@ + $(SIM65) $(SIM65FLAGS) $@ > $*.out + +%.osir.prg: %.c + $(CL65) $(CC65FLAGS) $< -o $@ + $(SIM65) $(SIM65FLAGS) $@ > $*.out + +%.oi.prg: %.c + $(CL65) $(CC65FLAGS) $< -o $@ + $(SIM65) $(SIM65FLAGS) $@ > $*.out + +%.oir.prg: %.c + $(CL65) $(CC65FLAGS) $< -o $@ + $(SIM65) $(SIM65FLAGS) $@ > $*.out + +%.or.prg: %.c + $(CL65) $(CC65FLAGS) $< -o $@ + $(SIM65) $(SIM65FLAGS) $@ > $*.out + +clean: + @$(RM) *.o + @$(RM) *.prg + @$(RM) *.out + @$(RM) *.ref diff --git a/test/ref/cc65080227.c b/test/ref/cc65080227.c index 4dd454b98..78afbb2c2 100644 --- a/test/ref/cc65080227.c +++ b/test/ref/cc65080227.c @@ -5,6 +5,8 @@ !!AUTHOR!! */ +#include + long a; /* must be static life */ long b; /* must be static life */ diff --git a/test/ref/cc65080328.c b/test/ref/cc65080328.c index 11ef73514..630638f3d 100644 --- a/test/ref/cc65080328.c +++ b/test/ref/cc65080328.c @@ -13,6 +13,8 @@ optimizations. If I remove the struct inside f() it compiles fine ?!? Best, Oliver */ +#include + void f(void){struct{int i;}d;} struct{void(*p)(void);}s={f}; diff --git a/test/ref/cc65090111.c b/test/ref/cc65090111.c index f515716f7..be889a608 100644 --- a/test/ref/cc65090111.c +++ b/test/ref/cc65090111.c @@ -5,6 +5,8 @@ !!AUTHOR!! */ +#include + /* cc65 doesn't compile this, if i use the "-O"-option. but it works with "while(!0)"; instead of "for(;;);" diff --git a/test/ref/cc65090124.c b/test/ref/cc65090124.c index fef22268f..3f8279b27 100644 --- a/test/ref/cc65090124.c +++ b/test/ref/cc65090124.c @@ -5,6 +5,8 @@ !!AUTHOR!! */ +#include + /* there is a bug in the preprocessor (i think) ... the following works (compiles) correctly: diff --git a/test/ref/cc65090726.c b/test/ref/cc65090726.c index fb4773afb..b260f0afd 100644 --- a/test/ref/cc65090726.c +++ b/test/ref/cc65090726.c @@ -5,6 +5,8 @@ !!AUTHOR!! */ +#include "common.h" + struct Record { struct Record *PtrComp; int x; diff --git a/test/ref/cc65090910.c b/test/ref/cc65090910.c index c8e5ce934..6ac5d9dcb 100644 --- a/test/ref/cc65090910.c +++ b/test/ref/cc65090910.c @@ -5,6 +5,8 @@ !!AUTHOR!! Oliver Schmidt */ +#include + /* After spending a "little" time I finally succeeded in isolating an (maybe THE) optimizer bug causing Contiki to fail. diff --git a/test/ref/cc65090913.c b/test/ref/cc65090913.c index a319fec50..da6e37ef3 100644 --- a/test/ref/cc65090913.c +++ b/test/ref/cc65090913.c @@ -18,6 +18,8 @@ */ +#include + int foo=0,bar=2; int main(void) diff --git a/test/ref/cc65091007.c b/test/ref/cc65091007.c index 1c69e02f9..31f725f8b 100644 --- a/test/ref/cc65091007.c +++ b/test/ref/cc65091007.c @@ -5,6 +5,8 @@ !!AUTHOR!! Johan Kotlinski */ +#include + /* This produces the compiler error "test.c(9): Error: Assignment to const" Shouldn't be an error, should it? baz is const, bar isn't. diff --git a/test/ref/cc65091022.c b/test/ref/cc65091022.c index 222253992..25d197c11 100644 --- a/test/ref/cc65091022.c +++ b/test/ref/cc65091022.c @@ -5,6 +5,8 @@ !!AUTHOR!! Johan Kotlinski */ +#include + /* ...gives "test.c(2): Error: Variable `foo' has unknown size" using -Cl. Is it really unknown? diff --git a/test/ref/cc65110211.c b/test/ref/cc65110211.c index 76b3f4a70..83be84b67 100644 --- a/test/ref/cc65110211.c +++ b/test/ref/cc65110211.c @@ -8,6 +8,8 @@ test2 and test3 will result in an endless loop (SVN version: 4974M) */ +#include + #define OPENTEST() #define CLOSETEST() diff --git a/test/ref/cf.c b/test/ref/cf.c index 951f31295..66fb42b10 100644 --- a/test/ref/cf.c +++ b/test/ref/cf.c @@ -8,11 +8,16 @@ cf - print character frequencies */ +#include "common.h" + #include #include #include +FILE *in; + #define INFILE "cf.in" +#define GETCHAR() fgetc(in) #ifndef NO_FLOATS float f[0x100]; @@ -35,6 +40,11 @@ char *argv[]; signed cutoff; #endif + in = fopen(INFILE, "rb"); + if (in == NULL) { + return EXIT_FAILURE; + } + if (argc <= 1) #ifndef NO_FLOATS cutoff = 0.0; @@ -176,6 +186,6 @@ char *argv[]; #endif } } - + fclose(in); return 0; } diff --git a/test/ref/cf.in b/test/ref/cf.in new file mode 100755 index 000000000..1b0a6f23a --- /dev/null +++ b/test/ref/cf.in @@ -0,0 +1,19 @@ +start cf.input > +The sky above the port was the color of television, tuned +to a dead channel. +"It's not like I'm using," Case heard someone say, as he +shouldered his way through the crowd around the door of the +Chat. "It's like my body's developed this massive drug deficiency." +It was a Sprawl voice and a Sprawl joke. The Chatsubo +was a bar for professional expatriates; you could drink there +for a week and never hear two words in Japanese. +Ratz was tending bar, his prosthetic arm jerking monotonously +as he filled a tray of glasses with draft Kirin. He saw +Case and smiled, his teeth a web work of East European steel +and brown decay. Case found a place at the bar, between the +unlikely tan on one of Lonny Zone's whores and the crisp naval +uniform of a tall African whose cheekbones were ridged with +Joe boys," Ratz said, shoving a draft across the bar with his +good hand. "Maybe some business with you, Case?" +Case shrugged. The girl to his right giggled and nudged +< end cf.input \ No newline at end of file diff --git a/test/ref/charconst.c b/test/ref/charconst.c index 1aa9f8e3f..65ebc70be 100644 --- a/test/ref/charconst.c +++ b/test/ref/charconst.c @@ -4,6 +4,7 @@ !!LICENCE!! Public Domain */ +#include "common.h" #include #include diff --git a/test/ref/common.h b/test/ref/common.h new file mode 100644 index 000000000..dada61a14 --- /dev/null +++ b/test/ref/common.h @@ -0,0 +1,22 @@ + +#include +#include + +#define NO_OLD_FUNC_DECL +#define NO_TYPELESS_INT +#define NO_TYPELESS_INT_PTR +#define MAIN_RETURNS_INT +#define NO_IMPLICIT_FUNC_PROTOTYPES +#define NO_FLOATS +#define NO_WCHAR +#define NO_EMPTY_FUNC_ARGS +#define NO_SLOPPY_STRUCT_INIT +#define NO_FUNCS_TAKE_STRUCTS +#define NO_FUNCS_RETURN_STRUCTS +#define CAST_STRUCT_PTR +#define NO_TYPELESS_STRUCT_PTR +#define NO_IMPLICIT_FUNCPTR_CONV +#define SIZEOF_INT_16BIT +#define SIZEOF_LONG_32BIT +#define UNSIGNED_CHARS +#define UNSIGNED_BITFIELDS diff --git a/test/ref/cvt.c b/test/ref/cvt.c index ed7b6084e..841c1b3b2 100644 --- a/test/ref/cvt.c +++ b/test/ref/cvt.c @@ -4,6 +4,9 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include "common.h" +#include + signed char c; signed short s; signed int i; diff --git a/test/ref/fields.c b/test/ref/fields.c index 794a81924..83bee82b7 100644 --- a/test/ref/fields.c +++ b/test/ref/fields.c @@ -4,6 +4,8 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include "common.h" + #ifdef NO_BITFIELDS main() diff --git a/test/ref/init.c b/test/ref/init.c index dc3f28a81..5a5816753 100644 --- a/test/ref/init.c +++ b/test/ref/init.c @@ -4,12 +4,13 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include "common.h" /* todo: add back conditional stuff here ! */ typedef struct { int codes[3]; char name[6]; } Word; -#ifdef NO_IMPLICIT_FUNC_PROTOTYPES - +#ifdef NO_IMPLICIT_FUNC_PROTOTYPES + #ifdef NO_OLD_FUNC_DECL f(); void g(Word *p); @@ -42,8 +43,8 @@ Word words[] = { /*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/ int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } }; -int *y[] = { x[0], x[1], x[2], 0 }; - +int *y[] = { x[0], x[1], x[2], 0 }; + main() { int i, j; diff --git a/test/ref/minimal.c b/test/ref/minimal.c index 5aa3c5f4f..b2e2d9d8f 100644 --- a/test/ref/minimal.c +++ b/test/ref/minimal.c @@ -5,6 +5,8 @@ !!AUTHOR!! Groepaz/Hitmen */ +#include + int main(void) { #if 1 diff --git a/test/ref/otccex.c b/test/ref/otccex.c index a967e4805..f3d6c71ec 100644 --- a/test/ref/otccex.c +++ b/test/ref/otccex.c @@ -4,6 +4,8 @@ !!LICENCE!! GPL (?), read COPYING.GPL */ +#include "common.h" + /* * Sample OTCC C example. You can uncomment the first line and install * otcc in /usr/local/bin to make otcc scripts ! diff --git a/test/ref/paranoia.c b/test/ref/paranoia.c index 3616c9391..e9a47dd71 100644 --- a/test/ref/paranoia.c +++ b/test/ref/paranoia.c @@ -4,11 +4,14 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include "common.h" + #ifdef NO_FLOATS main() { printf("NO_FLOATS\n\r"); + return 0; } #else diff --git a/test/ref/pointer2.c b/test/ref/pointer2.c index 69d04a989..d8c064ef3 100644 --- a/test/ref/pointer2.c +++ b/test/ref/pointer2.c @@ -4,6 +4,7 @@ !!LICENCE!! public domain */ +#include "common.h" #include /* @@ -101,11 +102,11 @@ static void test30(void) cc65 seems to have problems here aswell ;/ */ -int main(void) { +int main(void) { test1(); test2(); test30(); test31(); /* test32(); */ - return 0; + return 0; } diff --git a/test/ref/spill.c b/test/ref/spill.c index 2aedf0c8c..56b03d6a7 100644 --- a/test/ref/spill.c +++ b/test/ref/spill.c @@ -4,6 +4,7 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include "common.h" #include int main(void) diff --git a/test/ref/stdarg.c b/test/ref/stdarg.c index b476cf338..295a2ccad 100644 --- a/test/ref/stdarg.c +++ b/test/ref/stdarg.c @@ -4,6 +4,7 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include "common.h" #include #ifndef NO_FUNCS_TAKE_STRUCTS diff --git a/test/ref/struct.c b/test/ref/struct.c index ccd74953f..a0f181e96 100644 --- a/test/ref/struct.c +++ b/test/ref/struct.c @@ -4,6 +4,8 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include "common.h" + typedef struct point { int x,y; } point; typedef struct rect { point pt1, pt2; } rect; diff --git a/test/ref/switch.c b/test/ref/switch.c index 1fc315d90..0821d29ee 100644 --- a/test/ref/switch.c +++ b/test/ref/switch.c @@ -4,6 +4,7 @@ !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC */ +#include "common.h" #include #ifdef NO_IMPLICIT_FUNC_PROTOTYPES diff --git a/test/ref/wf1.c b/test/ref/wf1.c index 3e9c80fb2..0539d8398 100644 --- a/test/ref/wf1.c +++ b/test/ref/wf1.c @@ -11,6 +11,9 @@ #define MAXWORDS 250 +FILE *in; +#define getchar() fgetc(in) + struct node { int count; /* frequency count */ @@ -122,11 +125,17 @@ int main(void) struct node *root; char word[20]; + in = fopen("wf1.in","rb"); + if (in == NULL) { + return EXIT_FAILURE; + } + root = 0; next = 0; while (getword(word)) lookup(word, &root)->count++; tprint(root); + fclose(in); return 0; } diff --git a/test/ref/wf1.in b/test/ref/wf1.in new file mode 100644 index 000000000..3e50fbac8 --- /dev/null +++ b/test/ref/wf1.in @@ -0,0 +1,17 @@ +The sky above the port was the color of television, tuned +to a dead channel. +"It's not like I'm using," Case heard someone say, as he +shouldered his way through the crowd around the door of the +Chat. "It's like my body's developed this massive drug deficiency." +It was a Sprawl voice and a Sprawl joke. The Chatsubo +was a bar for professional expatriates; you could drink there +for a week and never hear two words in Japanese. +Ratz was tending bar, his prosthetic arm jerking monotonously +as he filled a tray of glasses with draft Kirin. He saw +Case and smiled, his teeth a web work of East European steel +and brown decay. Case found a place at the bar, between the +unlikely tan on one of Lonny Zone's whores and the crisp naval +uniform of a tall African whose cheekbones were ridged with +Joe boys," Ratz said, shoving a draft across the bar with his +good hand. "Maybe some business with you, Case?" +Case shrugged. The girl to his right giggled and nudged diff --git a/test/ref/yacc.c b/test/ref/yacc.c index 3baefd348..5768f80d0 100644 --- a/test/ref/yacc.c +++ b/test/ref/yacc.c @@ -6,6 +6,8 @@ /*#define STANDALONE*/ +#include "common.h" + #ifndef YACCDBG #include @@ -19,6 +21,9 @@ #endif +FILE *infile, *outfile; +#define getchar() fgetc(infile) + /* hack the original tables to work with both petscii and ascii */ #define CHARSETHACK @@ -61,7 +66,6 @@ int yymorfg; extern char *yysptr, yysbuf[]; int yytchar; -/*FILE *yyin ={stdin}, *yyout ={stdout};*/ #define yyin infile #define yyout outfile @@ -665,7 +669,13 @@ yyunput(c) main() { printf("main start\n"); + infile = fopen("yacc.in","rb"); + if (infile == NULL) { + return EXIT_FAILURE; + } + outfile = stdout; yyparse(); + fclose(infile); printf("main end\n"); return 0; } diff --git a/test/ref/yacc.in b/test/ref/yacc.in new file mode 100755 index 000000000..0b89df5d7 --- /dev/null +++ b/test/ref/yacc.in @@ -0,0 +1 @@ +x=(e+1)*3/(3+7) diff --git a/test/ref/yacc2.c b/test/ref/yacc2.c index c62fca34a..78d654ded 100644 --- a/test/ref/yacc2.c +++ b/test/ref/yacc2.c @@ -5,6 +5,8 @@ !!AUTHOR!! Groepaz/Hitmen */ +#include + # define YYTYPE char struct yywork { diff --git a/test/val/Makefile b/test/val/Makefile index 5f93e1c34..0e4a6e94c 100644 --- a/test/val/Makefile +++ b/test/val/Makefile @@ -1,5 +1,8 @@ +# makefile for the regression tests that return an error code on failure + CC65FLAGS = -t sim6502 +SIM65FLAGS = -x 200000000 CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65) SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65) @@ -21,35 +24,35 @@ all: $(TESTS) %.prg: %.c $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $@ + $(SIM65) $(SIM65FLAGS) $@ %.o.prg: %.c $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $@ + $(SIM65) $(SIM65FLAGS) $@ %.os.prg: %.c $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $@ + $(SIM65) $(SIM65FLAGS) $@ %.osi.prg: %.c $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $@ + $(SIM65) $(SIM65FLAGS) $@ %.osir.prg: %.c $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $@ + $(SIM65) $(SIM65FLAGS) $@ %.oi.prg: %.c $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $@ + $(SIM65) $(SIM65FLAGS) $@ %.oir.prg: %.c $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $@ + $(SIM65) $(SIM65FLAGS) $@ %.or.prg: %.c $(CL65) $(CC65FLAGS) $< -o $@ - $(SIM65) $@ + $(SIM65) $(SIM65FLAGS) $@ clean: @$(RM) *.o