• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- Makefile -*-
2
3# Usage: make test.N.report
4#
5# COUNT can be over-ridden to change the number of tests generated per
6# file, and TESTARGS is used to change the type generation. Make sure
7# to 'make clean' after changing either of these parameters.
8
9TESTARGS := --no-unsigned --no-vector --no-complex --no-bool
10
11COUNT := 1
12TIMEOUT := 5
13
14CFLAGS := -std=gnu99
15
16X_COMPILER := gcc
17X_LL_CFLAGS := -emit-llvm -S
18Y_COMPILER := clang
19Y_LL_CFLAGS := -emit-llvm -S
20CC := gcc
21
22###
23
24ABITESTGEN := ../ABITestGen.py
25
26ifndef VERBOSE
27  Verb := @
28endif
29
30.PHONY: test.%.report
31test.%.report: temps/test.%.xx.diff temps/test.%.xy.diff temps/test.%.yx.diff temps/test.%.yy.diff
32	@ok=1;\
33	for t in $^; do \
34		if [ -s $$t ]; then \
35			echo "TEST $*: $$t failed"; \
36			ok=0;\
37		fi; \
38	done; \
39	if [ $$ok -eq 1 ]; then \
40		true; \
41	else \
42		false; \
43	fi
44
45
46.PHONY: test.%.defs-report
47test.%.defs-report: temps/test.%.defs.diff
48	@for t in $^; do \
49		if [ -s $$t ]; then \
50			echo "TEST $*: $$t failed"; \
51			cat $$t; \
52		fi; \
53	done
54
55.PHONY: test.%.build
56test.%.build: temps/test.%.ref temps/test.%.xx temps/test.%.xy temps/test.%.yx temps/test.%.yy temps/test.%.x.defs temps/test.%.y.defs
57	@true
58
59###
60
61# Diffs and output
62
63.PRECIOUS: temps/.dir
64
65.PRECIOUS: temps/test.%.xx.diff
66temps/test.%.xx.diff: temps/test.%.ref.out temps/test.%.xx.out
67	$(Verb) diff $^ > $@ || true
68.PRECIOUS: temps/test.%.xy.diff
69temps/test.%.xy.diff: temps/test.%.ref.out temps/test.%.xy.out
70	$(Verb) diff $^ > $@ || true
71.PRECIOUS: temps/test.%.yx.diff
72temps/test.%.yx.diff: temps/test.%.ref.out temps/test.%.yx.out
73	$(Verb) diff $^ > $@ || true
74.PRECIOUS: temps/test.%.yy.diff
75temps/test.%.yy.diff: temps/test.%.ref.out temps/test.%.yy.out
76	$(Verb) diff $^ > $@ || true
77.PRECIOUS: temps/test.%.defs.diff
78temps/test.%.defs.diff: temps/test.%.x.defs temps/test.%.y.defs
79	$(Verb) zipdifflines \
80	  --replace "%struct.T[0-9]+" "%struct.s" \
81	  --replace "%union.T[0-9]+" "%struct.s" \
82	  --replace "byval align [0-9]+" "byval" \
83	  $^ > $@
84
85.PRECIOUS: temps/test.%.out
86temps/test.%.out: temps/test.%
87	-$(Verb) ./$< > $@
88
89# Executables
90
91.PRECIOUS: temps/test.%.ref
92temps/test.%.ref: temps/test.%.driver.ref.o temps/test.%.a.ref.o temps/test.%.b.ref.o
93	$(Verb) $(CC) $(CFLAGS) $(CC_CFLAGS) -O3 -o $@ $^
94.PRECIOUS: temps/test.%.xx
95temps/test.%.xx: temps/test.%.driver.ref.o temps/test.%.a.x.o temps/test.%.b.x.o
96	$(Verb) $(CC) $(CFLAGS) $(CC_CFLAGS) -O3  -o $@ $^
97.PRECIOUS: temps/test.%.xy
98temps/test.%.xy: temps/test.%.driver.ref.o temps/test.%.a.x.o temps/test.%.b.y.o
99	$(Verb) $(CC) $(CFLAGS) $(CC_CFLAGS) -O3  -o $@ $^
100.PRECIOUS: temps/test.%.yx
101temps/test.%.yx: temps/test.%.driver.ref.o temps/test.%.a.y.o temps/test.%.b.x.o
102	$(Verb) $(CC) $(CFLAGS) $(CC_CFLAGS) -O3  -o $@ $^
103.PRECIOUS: temps/test.%.yy
104temps/test.%.yy: temps/test.%.driver.ref.o temps/test.%.a.y.o temps/test.%.b.y.o
105	$(Verb) $(CC) $(CFLAGS) $(CC_CFLAGS) -O3  -o $@ $^
106
107# Object files
108
109.PRECIOUS: temps/test.%.ref.o
110temps/test.%.ref.o: inputs/test.%.c temps/.dir
111	$(Verb) $(CC) -c $(CFLAGS) $(CC_CFLAGS) -o $@ $<
112.PRECIOUS: temps/test.%.x.o
113temps/test.%.x.o: inputs/test.%.c temps/.dir
114	$(Verb) $(X_COMPILER) -c $(CFLAGS) $(X_CFLAGS) -o $@ $<
115.PRECIOUS: temps/test.%.y.o
116temps/test.%.y.o: inputs/test.%.c temps/.dir
117	$(Verb) $(Y_COMPILER) -c $(CFLAGS) $(Y_CFLAGS) -o $@ $<
118
119.PRECIOUS: temps/test.%.x.defs
120temps/test.%.x.defs: temps/test.%.a.x.ll temps/.dir
121	-$(Verb) -grep '^define ' $< > $@
122.PRECIOUS: temps/test.%.y.defs
123temps/test.%.y.defs: temps/test.%.a.y.ll temps/.dir
124	-$(Verb) -grep '^define ' $< > $@
125
126.PRECIOUS: temps/test.%.a.x.ll
127temps/test.%.a.x.ll: inputs/test.%.a.c temps/.dir
128	$(Verb) $(X_COMPILER) $(CFLAGS) $(X_LL_CFLAGS) $(X_CFLAGS) -o $@ $<
129.PRECIOUS: temps/test.%.b.x.ll
130temps/test.%.b.x.ll: inputs/test.%.b.c temps/.dir
131	$(Verb) $(X_COMPILER) $(CFLAGS) $(X_LL_CFLAGS) $(X_CFLAGS) -o $@ $<
132.PRECIOUS: temps/test.%.a.y.ll
133temps/test.%.a.y.ll: inputs/test.%.a.c temps/.dir
134	$(Verb) $(Y_COMPILER) $(CFLAGS) $(Y_LL_CFLAGS) $(Y_CFLAGS) -o $@ $<
135.PRECIOUS: temps/test.%.b.y.ll
136temps/test.%.b.y.ll: inputs/test.%.b.c temps/.dir
137	$(Verb) $(Y_COMPILER) $(CFLAGS) $(Y_LL_CFLAGS) $(Y_CFLAGS) -o $@ $<
138
139# Input generation
140
141.PHONY: test.%.top
142test.%.top: inputs/test.%.a.c inputs/test.%.b.c inputs/test.%.driver.c
143	@true
144
145.PRECIOUS: inputs/test.%.a.c inputs/test.%.b.c inputs/test.%.driver.c
146inputs/test.%.a.c: test.%.generate
147	@true
148inputs/test.%.b.c: test.%.generate
149	@true
150inputs/test.%.driver.c: test.%.generate
151	@true
152
153.PHONY: test.%.generate
154.PRECIOUS: inputs/.dir
155test.%.generate: $(ABITESTGEN) inputs/.dir
156	$(Verb) $(ABITESTGEN) $(TESTARGS) -o inputs/test.$*.a.c -T inputs/test.$*.b.c -D inputs/test.$*.driver.c --min=$(shell expr $* '*' $(COUNT))  --count=$(COUNT)
157
158# Cleaning
159
160clean-temps:
161	$(Verb) rm -rf temps
162
163clean:
164	$(Verb) rm -rf temps inputs
165
166# Etc.
167
168%/.dir:
169	$(Verb) mkdir -p $* > /dev/null
170	$(Verb) $(DATE) > $@
171