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