Makefile.test.common 4.7 KB

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