1 # SPDX-License-Identifier: LGPL-2.1-or-later
2 # See Notices.txt for copyright information
3 .PHONY
: all tests
clean fix-tests
5 CC
= powerpc64le-linux-gnu-gcc
6 CXX
= powerpc64le-linux-gnu-g
++
7 CFLAGS
= -O3
-Iinclude
-g0
-mno-altivec
-mno-vsx
8 CXXFLAGS
= -std
=gnu
++17
12 TESTS_SOURCE
:= $(wildcard tests
/*/test.
cpp) $(wildcard tests
/*/test.c
)
13 TESTS_DIR
:= $(dir $(TESTS_SOURCE
))
14 TESTS_BUILD_DIR
:= $(addprefix build
/,$(TESTS_DIR
))
15 TESTS_DIFF
:= $(addsuffix diff.txt
,$(TESTS_BUILD_DIR
))
16 TESTS_FILTERED_OUT
:= $(addsuffix filtered-out.s
,$(TESTS_BUILD_DIR
))
21 build
/tests
/%/out.s
: tests
/%/test.
cpp Makefile | build
/tests
/%/
22 $(CXX
) -S
$(CFLAGS
) $(CXXFLAGS
) $< -o
$@
24 build
/tests
/%/out.s
: tests
/%/test.c Makefile | build
/tests
/%/
25 $(CC
) -S
$(CFLAGS
) $< -o
$@
27 build
/tests
/%/filtered-out.s
: build
/tests
/%/out.s Makefile
28 sed
's/\(^\t.ident\t"\).*"/\1GCC"/' < $< > $@
30 build
/tests
/%/diff.txt
: tests
/%/expected.s build
/tests
/%/filtered-out.s Makefile
31 diff
-u
$< build
/$(dir $<)filtered-out.s
> $@ || true
33 .PRECIOUS
: build
/tests
/%/out.s build
/tests
/%/filtered-out.s build
/tests
/%/
38 if
[ -s
"$$i" -o
! -e
"$$i" ]; then \
39 echo
"Test failed: $$i" >&2; \
40 head
-n
10 "$$i" >&2; \
41 failed
=$$((failed
+ 1)); \
44 if
[ $$((failed
)) != 0 ]; then \
45 echo
"$$failed test(s) failed" >&2; \
48 echo
"all tests passed"; \
51 fix-tests
: $(TESTS_FILTERED_OUT
)
52 @for i in
$(TESTS_FILTERED_OUT
); do \
53 target
="$$(dirname "$${i
##build/}")/expected.s"; \
55 [ "$(FORCE_FIX_TESTS)" = "$$target" ] || status
="$$(git status --porcelain "$$target")"; \
56 if
[ -z
"$$status" ]; then \
57 cp
-v
"$$i" "$$target"; \
58 elif
! cmp
"$$i" "$$target"; then \
59 echo
"$$target has uncommitted changes, not overwriting -- commit changes or run make with FORCE_FIX_TESTS=$$target" >&2; \