summaryrefslogtreecommitdiff
path: root/test/Test.mak
diff options
context:
space:
mode:
Diffstat (limited to 'test/Test.mak')
-rw-r--r--test/Test.mak77
1 files changed, 40 insertions, 37 deletions
diff --git a/test/Test.mak b/test/Test.mak
index a5bc968c7..a3a9c463b 100644
--- a/test/Test.mak
+++ b/test/Test.mak
@@ -23,10 +23,7 @@ include ../Rules.mak
U_TARGETS := $(TESTS)
G_TARGETS := $(patsubst %,%_glibc,$(U_TARGETS))
-U_TARGETS += $(U_TESTS)
-G_TARGETS += $(G_TESTS)
-TARGETS := $(SHELL_TESTS)
ifeq ($(GLIBC_ONLY),)
TARGETS += $(U_TARGETS)
endif
@@ -34,72 +31,78 @@ ifeq ($(UCLIBC_ONLY),)
TARGETS += $(G_TARGETS)
endif
CLEAN_TARGETS := $(U_TARGETS) $(G_TARGETS)
+COMPILE_TARGETS := $(TARGETS)
+TARGETS += $(SHELL_TESTS)
+RUN_TARGETS := $(patsubst %,%.exe,$(TARGETS))
-test check all: $(TARGETS)
- @true
-
-$(TARGETS): Makefile $(TESTDIR)Makefile $(TESTDIR)Rules.mak $(TESTDIR)Test.mak
-$(U_TARGETS): $(patsubst %,%.c,$(U_TARGETS))
-$(G_TARGETS): $(patsubst %_glibc,%.c,$(G_TARGETS))
+define binary_name
+$(patsubst %.exe,%,$@)
+endef
define diff_test
$(Q)\
- for x in "$@.out" "$(patsubst %_glibc,%,$@).out" ; do \
- test -e "$$x.good" && $(do_showdiff) "$@.out" "$$x.good" && exec diff -u "$@.out" "$$x.good" ; \
+ for x in "$(binary_name).out" "$(patsubst %_glibc,%,$(binary_name)).out" ; do \
+ test -e "$$x.good" && $(do_showdiff) "$(binary_name).out" "$$x.good" && exec diff -u "$(binary_name).out" "$$x.good" ; \
done ; \
true
endef
define uclibc_glibc_diff_test
$(Q)\
- test -z "$(DODIFF_$(patsubst %_glibc,%,$@))" && exec true ; \
- uclibc_out="$@.out" ; \
- glibc_out="$(patsubst %_glibc,%,$@).out" ; \
+ test -z "$(DODIFF_$(patsubst %_glibc,%,$(binary_name)))" && exec true ; \
+ uclibc_out="$(binary_name).out" ; \
+ glibc_out="$(patsubst %_glibc,%,$(binary_name)).out" ; \
$(do_showdiff) $$uclibc_out $$glibc_out ; \
exec diff -u "$$uclibc_out" "$$glibc_out"
endef
define exec_test
$(showtest)
$(Q)\
- $(WRAPPER) $(WRAPPER_$(patsubst %_glibc,%,$@)) \
- ./$@ $(OPTS) $(OPTS_$(patsubst %_glibc,%,$@)) &> "$@.out" ; \
+ $(WRAPPER) $(WRAPPER_$(patsubst %_glibc,%,$(binary_name))) \
+ ./$(binary_name) $(OPTS) $(OPTS_$(patsubst %_glibc,%,$(binary_name))) &> "$(binary_name).out" ; \
ret=$$? ; \
- expected_ret="$(RET_$(patsubst %_glibc,%,$@))" ; \
+ expected_ret="$(RET_$(patsubst %_glibc,%,$(binary_name)))" ; \
test -z "$$expected_ret" && export expected_ret=0 ; \
if ! test $$ret -eq $$expected_ret ; then \
- $(RM) $@ ; \
+ $(RM) $(binary_name) ; \
echo "ret == $$ret ; expected_ret == $$expected_ret" ; \
- cat "$@.out" ; \
+ cat "$(binary_name).out" ; \
exit 1 ; \
fi
- $(SCAT) "$@.out"
+ $(SCAT) "$(binary_name).out"
endef
-$(U_TARGETS):
-ifeq ($(CHECK_ONLY),)
- $(showlink)
- $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c $@.c -o $@.o
- $(Q)$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$@)
-endif
-ifeq ($(COMPILE_ONLY),)
+test check all: run
+run: $(RUN_TARGETS) compile
+$(RUN_TARGETS): $(TARGETS)
+ifeq ($(shell echo "$(SHELL_TESTS)"|grep "$(binary_name)"),)
$(exec_test)
$(diff_test)
+ifeq ($(UCLIBC_ONLY),)
+ $(uclibc_glibc_diff_test)
+endif
endif
-$(G_TARGETS):
+compile: $(COMPILE_TARGETS)
+
+G_TARGET_SRCS := $(patsubst %,%.c,$(G_TARGETS))
+U_TARGET_SRCS := $(patsubst %,%.c,$(U_TARGETS))
+
+$(MAKE_SRCS): Makefile $(TESTDIR)Makefile $(TESTDIR)Rules.mak $(TESTDIR)Test.mak
+
+$(U_TARGETS): $(U_TARGET_SRCS) $(MAKE_SRCS)
+ $(showlink)
+ $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c $@.c -o $@.o
+ $(Q)$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$@)
+
+$(G_TARGETS): $(U_TARGET_SRCS) $(MAKE_SRCS)
$(showlink)
$(Q)$(HOSTCC) $(HOST_CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(patsubst %_glibc,%,$@)) -c $(patsubst %_glibc,%,$@).c -o $@.o
$(Q)$(HOSTCC) $(HOST_LDFLAGS) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$(patsubst %_glibc,%,$@))
-ifeq ($(COMPILE_ONLY),)
- $(exec_test)
- $(diff_test)
- $(uclibc_glibc_diff_test)
-endif
+
shell_%:
-ifeq ($(COMPILE_ONLY),)
$(showtest)
- $(Q)$(SHELL) $(patsubst shell_%,%.sh,$@)
-endif
+ $(Q)$(SHELL) $(patsubst shell_%,%.sh,$(binary_name))
%.so: %.c
$(showlink)
@@ -112,4 +115,4 @@ clean:
$(showclean)
$(Q)$(RM) *.a *.o *.so *~ core *.out *.gdb $(CLEAN_TARGETS) $(EXTRA_CLEAN)
-.PHONY: all check clean test
+.PHONY: all check clean test run compile