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