From: Hangbin Liu <liuhangbin@gmail.com>
To: linux-kselftest@vger.kernel.org
Cc: Shuah Khan <shuahkh@osg.samsung.com>, Hangbin Liu <liuhangbin@gmail.com>
Subject: [RFC PATCH 1/1] selftests/run_kselftest.sh: make each test individually selectable
Date: Mon, 9 Mar 2020 18:12:56 +0800 [thread overview]
Message-ID: <20200309101256.868-2-liuhangbin@gmail.com> (raw)
In-Reply-To: <20200309101256.868-1-liuhangbin@gmail.com>
Currently, after generating run_kselftest.sh, there is no way to choose
which test we could run. All the tests are listed together and we have
to run all every time. This patch enhanced the run_kselftest.sh to make
the tests individually selectable.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
tools/testing/selftests/Makefile | 48 +++++++++++++++++++++++++-------
tools/testing/selftests/lib.mk | 2 +-
2 files changed, 39 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 6ec503912bea..3d4bc0071849 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -220,13 +220,9 @@ ifdef INSTALL_PATH
@# Ask all targets to emit their test scripts
echo "#!/bin/sh" > $(ALL_SCRIPT)
echo "BASE_DIR=\$$(realpath \$$(dirname \$$0))" >> $(ALL_SCRIPT)
- echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
echo ". ./kselftest/runner.sh" >> $(ALL_SCRIPT)
- echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
- echo "if [ \"\$$1\" = \"--summary\" ]; then" >> $(ALL_SCRIPT)
- echo " logfile=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
- echo " cat /dev/null > \$$logfile" >> $(ALL_SCRIPT)
- echo "fi" >> $(ALL_SCRIPT)
+ echo "TESTS=\"$(TARGETS)\"" | tr -s "/-" "_" >> $(ALL_SCRIPT)
+ echo "" >> $(ALL_SCRIPT);
@# While building run_kselftest.sh skip also non-existent TARGET dirs:
@# they could be the result of a build failure and should NOT be
@@ -234,15 +230,47 @@ ifdef INSTALL_PATH
for TARGET in $(TARGETS); do \
BUILD_TARGET=$$BUILD/$$TARGET; \
[ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \
- echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
- echo "cd $$TARGET" >> $(ALL_SCRIPT); \
- echo -n "run_many" >> $(ALL_SCRIPT); \
+ echo "run_$$TARGET()" | tr -s "/-" "_" >> $(ALL_SCRIPT); \
+ echo "{" >> $(ALL_SCRIPT); \
+ echo -e "\t[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
+ echo -e "\tcd $$TARGET" >> $(ALL_SCRIPT); \
+ echo -en "\trun_many" >> $(ALL_SCRIPT); \
echo -n "Emit Tests for $$TARGET\n"; \
$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
echo "" >> $(ALL_SCRIPT); \
- echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
+ echo -e "\tcd \$$ROOT" >> $(ALL_SCRIPT); \
+ echo "}" >> $(ALL_SCRIPT); \
+ echo "" >> $(ALL_SCRIPT); \
done;
+ echo "usage()" >> $(ALL_SCRIPT);
+ echo "{" >> $(ALL_SCRIPT);
+ echo -e "\tcat <<EOF" >> $(ALL_SCRIPT);
+ echo "usage: \$${0##*/} OPTS" >> $(ALL_SCRIPT);
+ echo -e "\t-s | --summary\t\tOnly print summary info and put detailed log in output.log" >> $(ALL_SCRIPT);
+ echo -e "\t-t | --tests\t\tTest name you want to run specifically" >> $(ALL_SCRIPT);
+ echo -e "\t-h | --help\t\tShow this usage info" >> $(ALL_SCRIPT);
+ echo "EOF" >> $(ALL_SCRIPT);
+ echo "}" >> $(ALL_SCRIPT);
+ echo "" >> $(ALL_SCRIPT);
+
+ echo "while true; do" >> $(ALL_SCRIPT);
+ echo -e "\tcase \"\$$1\" in" >> $(ALL_SCRIPT);
+ echo -e "\t-s | --summary ) logfile=\$$BASE_DIR/output.log; cat /dev/null > \$$logfile; shift ;;" >> $(ALL_SCRIPT);
+ echo -e "\t-t | --tests ) TESTS=\$$2; shift 2 ;;" >> $(ALL_SCRIPT);
+ echo -e "\t-h | --help ) usage; exit 0;;" >> $(ALL_SCRIPT);
+ echo -e "\t\"\" ) break;;" >> $(ALL_SCRIPT);
+ echo -e "\t* ) usage; exit 1;;" >> $(ALL_SCRIPT);
+ echo -e "\tesac" >> $(ALL_SCRIPT);
+ echo "done" >> $(ALL_SCRIPT);
+ echo "" >> $(ALL_SCRIPT);
+
+ echo "cd \$$BASE_DIR" >> $(ALL_SCRIPT)
+ echo "ROOT=\$$PWD" >> $(ALL_SCRIPT)
+
+ echo "for test in \$$TESTS; do" >> $(ALL_SCRIPT); \
+ echo -e "\trun_\$$test" >> $(ALL_SCRIPT); \
+ echo "done" >> $(ALL_SCRIPT); \
chmod u+x $(ALL_SCRIPT)
else
$(error Error: set INSTALL_PATH to use install)
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 3ed0134a764d..c352d6dab91d 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -110,7 +110,7 @@ emit_tests:
for TEST in $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS); do \
BASENAME_TEST=`basename $$TEST`; \
echo " \\"; \
- echo -n " \"$$BASENAME_TEST\""; \
+ echo -ne "\t\t\"$$BASENAME_TEST\""; \
done; \
# define if isn't already. It is undefined in make O= case.
--
2.19.2
next prev parent reply other threads:[~2020-03-09 10:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 10:12 [RFC PATCH 0/1] selftests/run_kselftest.sh: make each test individually selectable Hangbin Liu
2020-03-09 10:12 ` Hangbin Liu [this message]
2020-03-13 19:42 ` shuah
2020-03-15 3:27 ` Hangbin Liu
2020-03-16 7:26 ` [RFC PATCHv2] " Hangbin Liu
2020-09-10 1:20 ` Hangbin Liu
2020-09-10 14:10 ` Shuah Khan
2020-09-11 8:30 ` [PATCHv3] " Hangbin Liu
2020-09-14 2:17 ` [PATCHv4 kselftest next] " Hangbin Liu
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=20200309101256.868-2-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuahkh@osg.samsung.com \
/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