[PATCH]: Separate out compile and run steps while running tests.
Khem Raj
kraj at mvista.com
Fri Mar 2 20:37:37 UTC 2007
Khem Raj wrote:
> Hi
>
> The attached patch does the following.
>
> It introduces two new targets namely compile and run.
> make compile will just build the tests and make run will run them.
> Currently these two steps are intertwined and thought we
> have COMPILE_ONLY and CHECK_ONLY flags to control the makefile
> behavior but it seems not to be running correctly.
>
> Secondly it introduces a new step to test installed uclibc. This is
> controlled by makefile variable TEST_INSTALLED_UCLIBC
> when this variable is defined then all tests are compiled and run
> against installed uclibc in /lib
>
> I have not updated the documentation. I wanted to see if this patch is
> worthwhile before I do that part.
>
> I have tested it on x86 and arm with different configurations seems to
> work well.
>
> Comments? Views? reviews
>
> Thanks
>
> ------------------------------------------------------------------------
>
> Index: test/Test.mak
> ===================================================================
> --- test/Test.mak (revision 17939)
> +++ test/Test.mak (working copy)
> @@ -23,10 +23,7 @@
>
> 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,72 @@
> TARGETS += $(G_TARGETS)
> endif
> CLEAN_TARGETS := $(U_TARGETS) $(G_TARGETS)
> +COMPILE_TARGETS := $(TARGETS)
> +TARGETS += $(SHELL_TESTS)
>
> -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 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 "$<.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" ; \
> + 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" ; \
> + $(WRAPPER) $(WRAPPER_$(patsubst %_glibc,%,$<)) \
> + ./$< $(OPTS) $(OPTS_$(patsubst %_glibc,%,$<)) &> "$<.out" ; \
> ret=$$? ; \
> - expected_ret="$(RET_$(patsubst %_glibc,%,$@))" ; \
> + expected_ret="$(RET_$(patsubst %_glibc,%,$<))" ; \
> test -z "$$expected_ret" && export expected_ret=0 ; \
> if ! test $$ret -eq $$expected_ret ; then \
> - $(RM) $@ ; \
> + $(RM) $< ; \
> echo "ret == $$ret ; expected_ret == $$expected_ret" ; \
> - cat "$@.out" ; \
> + cat "$<.out" ; \
> exit 1 ; \
> fi
> - $(SCAT) "$@.out"
> + $(SCAT) "$<.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: $(TARGETS)
> +ifeq ($(shell echo "$(SHELL_TESTS)"|grep "$<"),)
> $(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
>
> %.so: %.c
> $(showlink)
> @@ -112,4 +109,4 @@
> $(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
> Index: test/Rules.mak
> ===================================================================
> --- test/Rules.mak (revision 17939)
> +++ test/Rules.mak (working copy)
> @@ -10,10 +10,11 @@
> #
>
> top_builddir ?= ../
> +
> TESTDIR=$(top_builddir)test/
>
> include $(top_builddir)/Rules.mak
> -
> +ifndef TEST_INSTALLED_UCLIBC
> ifdef UCLIBC_LDSO
> ifeq (,$(findstring /,$(UCLIBC_LDSO)))
> UCLIBC_LDSO := $(top_builddir)lib/$(UCLIBC_LDSO)
> @@ -21,7 +22,7 @@
> else
> UCLIBC_LDSO := $(firstword $(wildcard $(top_builddir)lib/ld*))
> endif
> -
> +endif
> #--------------------------------------------------------
> # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
> LC_ALL:= C
> @@ -96,8 +97,14 @@
> HOST_LDFLAGS += -static
> endif
> LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
> +UCLIBC_LDSO_ABSPATH=$(shell pwd)
> +ifdef TEST_INSTALLED_UCLIBC
> +LDFLAGS += -Wl,-rpath,./
> +UCLIBC_LDSO_ABSPATH=/lib
> +endif
> +
> ifeq ($(findstring -static,$(LDFLAGS)),)
> -LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO)
> + LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO_ABSPATH)/$(UCLIBC_LDSO)
> endif
>
>
> @@ -123,7 +130,7 @@
> pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
> pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
> pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
> -pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $@
> +pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $<
> sil_showclean =
> sil_showdiff = true
> sil_showlink = true
> @@ -131,7 +138,7 @@
> ver_showclean =
> ver_showdiff = true echo
> ver_showlink = true echo
> -ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $@\n$(banner)\n"
> +ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $<\n$(banner)\n"
> do_showclean = $($(DISP)_showclean)
> do_showdiff = $($(DISP)_showdiff)
> do_showlink = $($(DISP)_showlink)
> Index: test/Makefile
> ===================================================================
> --- test/Makefile (revision 17939)
> +++ test/Makefile (working copy)
> @@ -29,20 +29,32 @@
> DIRS := $(filter-out math,$(DIRS))
>
>
> -test check all: subdirs
> +test check all: run
>
> +run: compile subdirs_run
> +
> +compile:subdirs_compile
> +
> tags:
> ctags -R
>
> clean: subdirs_clean
>
> subdirs: $(patsubst %, _dir_%, $(DIRS))
> +subdirs_compile: $(patsubst %, _dircompile_%, $(DIRS))
> +subdirs_run: $(patsubst %, _dirrun_%, $(DIRS))
> subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
>
> $(patsubst %, _dir_%, $(DIRS)) : dummy
> $(Q)$(MAKE) -C $(patsubst _dir_%, %, $@)
>
> +$(patsubst %, _dirrun_%, $(DIRS)) : dummy
> + $(Q)$(MAKE) -C $(patsubst _dirrun_%, %, $@) run
> +
> +$(patsubst %, _dircompile_%, $(DIRS)) : dummy
> + $(Q)$(MAKE) -C $(patsubst _dircompile_%, %, $@) compile
> +
> $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
> $(Q)$(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
>
> -.PHONY: all check clean dummy subdirs subdirs_clean test
> +.PHONY: all check clean dummy subdirs_compile subdirs_run subdirs subdirs_clean test run compile
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Here is second try. The above patch compiled the tests correctly but did
not run them correctly. I also modified test/README this time to reflect
the changes.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diff
Url: http://lists.busybox.net/pipermail/uclibc/attachments/20070302/afc55211/attachment.diff
More information about the uClibc
mailing list