summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Test.mak122
1 files changed, 83 insertions, 39 deletions
diff --git a/test/Test.mak b/test/Test.mak
index 6e1ced516..687366b7c 100644
--- a/test/Test.mak
+++ b/test/Test.mak
@@ -1,20 +1,22 @@
# Common makefile rules for tests
#
-# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
-# This program is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Library General Public License as published by the Free
-# Software Foundation; either version 2 of the License, or (at your option) any
-# later version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Library General Public License
-# along with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+ifeq ($(TESTS),)
+TESTS := $(patsubst %.c,%,$(wildcard *.c))
+endif
+ifneq ($(TESTS_DISABLED),)
+TESTS := $(filter-out $(TESTS_DISABLED),$(TESTS))
+endif
+ifeq ($(SHELL_TESTS),)
+SHELL_TESTS := $(patsubst %.sh,shell_%,$(wildcard *.sh))
+endif
+
+ifneq ($(filter-out test,$(TESTS)),$(TESTS))
+$(error Sanity check: cannot have a test named "test.c")
+endif
include ../Rules.mak
@@ -23,44 +25,86 @@ G_TARGETS := $(patsubst %,%_glibc,$(U_TARGETS))
U_TARGETS += $(U_TESTS)
G_TARGETS += $(G_TESTS)
-TARGETS =
+TARGETS := $(SHELL_TESTS)
ifeq ($(GLIBC_ONLY),)
TARGETS += $(U_TARGETS)
endif
ifeq ($(UCLIBC_ONLY),)
TARGETS += $(G_TARGETS)
endif
+CLEAN_TARGETS := $(U_TARGETS) $(G_TARGETS)
-all: $(TARGETS)
+test check all: $(TARGETS)
-$(TARGETS): Makefile $(TESTDIR)Rules.mak $(TESTDIR)Test.mak
+$(TARGETS): Makefile $(TESTDIR)Makefile $(TESTDIR)Rules.mak $(TESTDIR)Test.mak
$(U_TARGETS): $(patsubst %,%.c,$(U_TARGETS))
$(G_TARGETS): $(patsubst %_glibc,%.c,$(G_TARGETS))
-$(U_TARGETS):
- -@ echo "----------------------------"
- -@ echo "Compiling $@ vs uClibc: "
- -@ echo " "
- $(CC) $(CFLAGS) -c $@.c -o $@.o
- $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
- $$WRAPPER_$@ ./$@ $$OPTS_$@ ; \
+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" ; \
+ done ; \
+ true
+endef
+define uclibc_glibc_diff_test
+ $(Q)\
+ test -z "$(DODIFF_$(patsubst %_glibc,%,$@))" && exec true ; \
+ uclibc_out="$@.out" ; \
+ glibc_out="$(patsubst %_glibc,%,$@).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" ; \
ret=$$? ; \
- test -z "$$RET_$@" && export RET_$@=0 ; \
- test $$ret -eq $$RET_$@
- -@ echo " "
+ expected_ret="$(RET_$(patsubst %_glibc,%,$@))" ; \
+ test -z "$$expected_ret" && export expected_ret=0 ; \
+ if ! test $$ret -eq $$expected_ret ; then \
+ $(RM) $@ ; \
+ cat "$@.out" ; \
+ exec false ; \
+ fi
+ $(SCAT) "$@.out"
+endef
+
+$(U_TARGETS):
+ $(showlink)
+ $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c $@.c -o $@.o
+ $(Q)$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$@)
+ifeq ($(COMPILE_ONLY),)
+ $(exec_test)
+ $(diff_test)
+endif
$(G_TARGETS):
- -@ echo "----------------------------"
- -@ echo "Compiling $@ vs glibc: "
- -@ echo " "
- $(HOSTCC) $(GLIBC_CFLAGS) -c $(patsubst %_glibc,%,$@).c -o $@.o
- $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
- $(STRIPTOOL) -x -R .note -R .comment $@
- $$WRAPPER_$(patsubst %_glibc,%,$@) ./$@ $$OPTS_$(patsubst %_glibc,%,$@) ; \
- ret=$$? ; \
- test -z "$$RET_$(patsubst %_glibc,%,$@)" && export RET_$(patsubst %_glibc,%,$@)=0 ; \
- test $$ret -eq $$RET_$(patsubst %_glibc,%,$@)
- -@ echo " "
+ $(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
+
+%.so: %.c
+ $(showlink)
+ $(Q)$(CC) \
+ $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(patsubst %_glibc,%,$@)) \
+ -fPIC -shared $< -o $@ -Wl,-soname,$@ \
+ $(LDFLAGS) $(EXTRA_LIBS) $(LDFLAGS_$(patsubst %_glibc,%,$@))
clean:
- $(RM) *.[oa] *~ core $(TARGETS)
+ $(showclean)
+ $(Q)$(RM) *.a *.o *.so *~ core *.out *.gdb $(CLEAN_TARGETS) $(EXTRA_CLEAN)
+
+.PHONY: all check clean test