fixed up the rest of the tests, added rudimentary makefile(s)

This commit is contained in:
mrdudz 2014-11-22 18:28:05 +01:00
parent 20072a379c
commit 6144063a6d
36 changed files with 272 additions and 16 deletions

1
test/.gitignore vendored
View File

@ -1,2 +1,3 @@
*.o
*.prg
*.out

16
test/Makefile Normal file
View File

@ -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

42
test/err/Makefile Normal file
View File

@ -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

View File

@ -4,6 +4,8 @@
!!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
*/
#include <stdio.h>
int up[15], down[15], rows[8], x[8];
void queens(int c);
void print(void);

62
test/ref/Makefile Normal file
View File

@ -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

View File

@ -5,6 +5,8 @@
!!AUTHOR!!
*/
#include <stdio.h>
long a; /* must be static life */
long b; /* must be static life */

View File

@ -13,6 +13,8 @@ optimizations. If I remove the struct inside f() it compiles fine ?!?
Best, Oliver
*/
#include <stdio.h>
void f(void){struct{int i;}d;}
struct{void(*p)(void);}s={f};

View File

@ -5,6 +5,8 @@
!!AUTHOR!!
*/
#include <stdio.h>
/*
cc65 doesn't compile this, if i use the "-O"-option.
but it works with "while(!0)"; instead of "for(;;);"

View File

@ -5,6 +5,8 @@
!!AUTHOR!!
*/
#include <stdio.h>
/*
there is a bug in the preprocessor (i think) ... the following works
(compiles) correctly:

View File

@ -5,6 +5,8 @@
!!AUTHOR!!
*/
#include "common.h"
struct Record {
struct Record *PtrComp;
int x;

View File

@ -5,6 +5,8 @@
!!AUTHOR!! Oliver Schmidt
*/
#include <stdio.h>
/*
After spending a "little" time I finally succeeded in isolating an
(maybe THE) optimizer bug causing Contiki to fail.

View File

@ -18,6 +18,8 @@
*/
#include <stdio.h>
int foo=0,bar=2;
int main(void)

View File

@ -5,6 +5,8 @@
!!AUTHOR!! Johan Kotlinski
*/
#include <stdio.h>
/*
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.

View File

@ -5,6 +5,8 @@
!!AUTHOR!! Johan Kotlinski
*/
#include <stdio.h>
/*
...gives "test.c(2): Error: Variable `foo' has unknown size" using -Cl.
Is it really unknown?

View File

@ -8,6 +8,8 @@
test2 and test3 will result in an endless loop (SVN version: 4974M)
*/
#include <stdio.h>
#define OPENTEST()
#define CLOSETEST()

View File

@ -8,11 +8,16 @@
cf - print character frequencies
*/
#include "common.h"
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
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;
}

19
test/ref/cf.in Executable file
View File

@ -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

View File

@ -4,6 +4,7 @@
!!LICENCE!! Public Domain
*/
#include "common.h"
#include <limits.h>
#include <ctype.h>

22
test/ref/common.h Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#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

View File

@ -4,6 +4,9 @@
!!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
*/
#include "common.h"
#include <stdio.h>
signed char c;
signed short s;
signed int i;

View File

@ -4,6 +4,8 @@
!!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
*/
#include "common.h"
#ifdef NO_BITFIELDS
main()

View File

@ -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;

View File

@ -5,6 +5,8 @@
!!AUTHOR!! Groepaz/Hitmen
*/
#include <stdio.h>
int main(void)
{
#if 1

View File

@ -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 !

View File

@ -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

View File

@ -4,6 +4,7 @@
!!LICENCE!! public domain
*/
#include "common.h"
#include <stdio.h>
/*
@ -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;
}

View File

@ -4,6 +4,7 @@
!!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
*/
#include "common.h"
#include <stdio.h>
int main(void)

View File

@ -4,6 +4,7 @@
!!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
*/
#include "common.h"
#include <stdarg.h>
#ifndef NO_FUNCS_TAKE_STRUCTS

View File

@ -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;

View File

@ -4,6 +4,7 @@
!!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
*/
#include "common.h"
#include <limits.h>
#ifdef NO_IMPLICIT_FUNC_PROTOTYPES

View File

@ -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;
}

17
test/ref/wf1.in Normal file
View File

@ -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

View File

@ -6,6 +6,8 @@
/*#define STANDALONE*/
#include "common.h"
#ifndef YACCDBG
#include <stdio.h>
@ -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;
}

1
test/ref/yacc.in Executable file
View File

@ -0,0 +1 @@
x=(e+1)*3/(3+7)

View File

@ -5,6 +5,8 @@
!!AUTHOR!! Groepaz/Hitmen
*/
#include <stdio.h>
# define YYTYPE char
struct yywork
{

View File

@ -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