From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [RFC PATCH 1/3] make: Add make check{,-c,-shell} targets
Date: Fri, 4 Jun 2021 16:49:05 +0200 [thread overview]
Message-ID: <YLo9YXWrWweICm81@yuki> (raw)
In-Reply-To: <20210603183827.24339-2-pvorel@suse.cz>
Hi!
> For testing C and shell API.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Makefile | 21 ++++++++++++++++++++-
> include/mk/generic_leaf_target.inc | 25 ++++++++++++++++++++++---
> include/mk/generic_trunk_target.inc | 4 ++--
> lib/newlib_tests/Makefile | 8 ++++++++
> 4 files changed, 52 insertions(+), 6 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 56812d77b..acea4551e 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -75,10 +75,14 @@ endif
> INSTALL_TARGETS += $(COMMON_TARGETS)
> CLEAN_TARGETS += $(COMMON_TARGETS) lib libs
> BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS))
> +TEST_TARGETS := lib
> +TEST_SHELL_TARGETS := lib
>
> CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS))
> INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS))
> MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
> +TEST_TARGETS := $(addsuffix -check-c,$(TEST_TARGETS))
> +TEST_SHELL_TARGETS := $(addsuffix -check-shell,$(TEST_SHELL_TARGETS))
>
> # There's no reason why we should run `all' twice. Otherwise we're just wasting
> # 3+ mins of useful CPU cycles on a modern machine, and even more time on an
> @@ -113,6 +117,14 @@ $(filter-out include-clean,$(CLEAN_TARGETS))::
> -$(MAKE) -C "$(subst -clean,,$@)" \
> -f "$(abs_top_srcdir)/$(subst -clean,,$@)/Makefile" clean
>
> +$(TEST_TARGETS): lib-all
> + $(MAKE) -C "$(subst -check-c,,$@)" \
> + -f "$(abs_top_srcdir)/$(subst -check-c,,$@)/Makefile" check-c
> +
> +$(TEST_SHELL_TARGETS):
> + $(MAKE) -C "$(subst -check-shell,,$@)" \
> + -f "$(abs_top_srcdir)/$(subst -check-shell,,$@)/Makefile" check-shell
> +
> # Just like everything depends on include-all / -install, we need to get rid
> # of include last to ensure that things won't be monkey screwed up. Only do
> # this if we're invoking clean or a subclean directly though.
> @@ -189,8 +201,15 @@ INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS))
>
> $(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir)
>
> +.PHONY: check check-c check-shell
> +
> +## Check
> +check-c: $(TEST_TARGETS)
> +check-shell: $(TEST_SHELL_TARGETS)
> +check: check-c check-shell
> +
> ## Install
> -install: $(INSTALL_TARGETS)
> +install: lib-all $(INSTALL_TARGETS)
>
> ## Help
> .PHONY: help
> diff --git a/include/mk/generic_leaf_target.inc b/include/mk/generic_leaf_target.inc
> index 64953f89a..d53623456 100644
> --- a/include/mk/generic_leaf_target.inc
> +++ b/include/mk/generic_leaf_target.inc
> @@ -63,8 +63,12 @@
> # real files or directories). This will automatically append
> # adds the .o suffix to all files referenced by
> # $(MAKE_TARGETS)) to CLEAN_TARGETS, if MAKE_TARGETS wasn't
> -# defined (see
> -# $(MAKE_TARGETS)).
> +# defined (see $(MAKE_TARGETS)).
> +#
> +# $(TEST_TARGETS) : LTP C API tests.
> +#
> +# $(TEST_SHELL_TARGETS) : LTP shell API tests.
> +#
> # $(INSTALL_MODE) : What mode should we using when calling
> # install(1)?
> #
> @@ -92,7 +96,7 @@
> # INSTALL_DIR := $(libdir)
> #
>
> -.PHONY: all clean install
> +.PHONY: all check-c check-shell clean install
>
> ifneq ($(strip $(MAKE_TARGETS)),)
> $(MAKE_TARGETS) += $(HOST_MAKE_TARGETS)
> @@ -102,6 +106,21 @@ $(MAKE_TARGETS): | $(MAKE_DEPS)
>
> all: $(MAKE_TARGETS)
>
> +check-c: $(TEST_TARGETS)
> + @set -e; echo; echo "===== Test C API ====="; \
> + for i in $(TEST_TARGETS); do \
> + echo; echo "* $$i"; \
> + echo "PATH $(top_srcdir)/testcases/lib:$$PATH"; \
> + PATH="$(top_srcdir)/testcases/lib:$$PATH" ./$$i || [ $$? -eq 32 ]; \
> + done
> +
> +check-shell: $(TEST_SHELL_TARGETS)
> + @set -e; echo; echo "===== Test shell API ====="; \
> + for i in $(TEST_SHELL_TARGETS); do \
> + echo; echo "* $$i"; \
> + PATH="$(abs_top_srcdir)/testcases/lib:$(abs_top_builddir)/testcases/lib:$$PATH" $(abs_srcdir)/$$i || [ $$? -eq 32 ]; \
> + done
> +
> clean:: $(CLEAN_DEPS)
> -$(RM) -f -r $(CLEAN_TARGETS)
>
> diff --git a/include/mk/generic_trunk_target.inc b/include/mk/generic_trunk_target.inc
> index fc59f944f..d195fe3bd 100644
> --- a/include/mk/generic_trunk_target.inc
> +++ b/include/mk/generic_trunk_target.inc
> @@ -48,7 +48,7 @@
>
> include $(top_srcdir)/include/mk/functions.mk
>
> -RECURSIVE_TARGETS ?= all install
> +RECURSIVE_TARGETS ?= all check check-c check-shell install
If you add a target to RECURSIVE_TARGETS such target automatically
traverses directories, that what the target is for. See the rule at the
end of the generic_trunk_target.inc. Which means that you redefine
targets if you define the same targets to loop and run the tests above.
I guess that you want add another target that depends on check targets
to actually run the tests?
Maybe:
check-c: check-c-run
check-c-run: $(TEST_TARGETS)
for i in $(TEST_TARGETS); do
...
done
in order to run the tests.
In this case the check* targets would be used for directory traversal
and the check-c-run would be used to run the tests.
> $(eval $(get_make_dirs))
>
> @@ -71,7 +71,7 @@ trunk-install: $(INSTALL_FILES)
> # Avoid creating duplicate .PHONY references to all, clean, and install. IIRC,
> # I've seen some indeterministic behavior when one does this in the past with
> # GNU Make...
> -.PHONY: $(filter-out $(RECURSIVE_TARGETS),all clean install)
> +.PHONY: $(filter-out $(RECURSIVE_TARGETS),all check clean install)
The check is already in RECURSIVE_TARGETS
> all: trunk-all
>
> clean:: trunk-clean
> diff --git a/lib/newlib_tests/Makefile b/lib/newlib_tests/Makefile
> index 30ca6810c..182ef5689 100644
> --- a/lib/newlib_tests/Makefile
> +++ b/lib/newlib_tests/Makefile
> @@ -19,5 +19,13 @@ ifeq ($(ANDROID),1)
> FILTER_OUT_MAKE_TARGETS += test08
> endif
>
> +# C API tests (which exit 0)
> +TEST_TARGETS += test0[579] test1[2568] test_exec test_timer
> +TEST_TARGETS += tst_bool_expr tst_res_hexd tst_strstatus
> +TEST_TARGETS += tst_fuzzy_sync0[1-2]
> +
> +# shell API tests (which exit 0)
> +TEST_SHELL_TARGETS += shell/tst_check_driver.sh
> +TEST_SHELL_TARGETS += shell/net/*.sh
>
> include $(top_srcdir)/include/mk/generic_leaf_target.mk
> --
> 2.31.1
>
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2021-06-04 14:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 18:38 [LTP] [RFC PATCH 0/3] build: make check target Petr Vorel
2021-06-03 18:38 ` [LTP] [RFC PATCH 1/3] make: Add make check{,-c,-shell} targets Petr Vorel
2021-06-04 14:49 ` Cyril Hrubis [this message]
2021-06-04 16:56 ` Petr Vorel
2021-06-04 18:01 ` Enji Cooper
2021-06-04 18:49 ` Petr Vorel
2021-06-03 18:38 ` [LTP] [RFC PATCH 2/3] build.sh: Add support for make check Petr Vorel
2021-06-03 18:38 ` [LTP] [RFC PATCH 3/3] CI: Run also " Petr Vorel
2021-06-04 14:43 ` [LTP] [RFC PATCH 0/3] build: make check target Richard Palethorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YLo9YXWrWweICm81@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox