From: Joerg Vehlow <lkml@jv-coder.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 1/3] tst_test.sh: Add tst_require_module command
Date: Tue, 10 Dec 2019 09:04:17 +0100 [thread overview]
Message-ID: <20191210080419.128773-2-lkml@jv-coder.de> (raw)
In-Reply-To: <20191210080419.128773-1-lkml@jv-coder.de>
From: Joerg Vehlow <joerg.vehlow@aox-tech.de>
Adds a new library function tst_require_module, that can be used, when a
test needs a module dynamically at runtime
Signed-off-by: Joerg Vehlow <joerg.vehlow@aox-tech.de>
---
doc/test-writing-guidelines.txt | 3 +++
testcases/lib/tst_test.sh | 39 +++++++++++++++++++--------------
2 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 546bb7a49..3360f0920 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -2184,6 +2184,9 @@ module in a few possible paths.
If module was found the path to it will be stored into '$TST_MODPATH'
variable, if module wasn't found the test will exit with 'TCONF'.
+Alternatively the 'tst_require_module()' function can be used to do the same
+at runtime.
+
2.3.3 Optional command line parameters
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 70c1ef2e3..afee6aac5 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -461,6 +461,27 @@ _tst_require_root()
fi
}
+tst_require_module()
+{
+ local _tst_module=$1
+
+ for tst_module in "$_tst_module" \
+ "$LTPROOT/testcases/bin/$_tst_module" \
+ "$TST_STARTWD/$_tst_module"; do
+
+ if [ -f "$tst_module" ]; then
+ TST_MODPATH="$tst_module"
+ break
+ fi
+ done
+
+ if [ -n "$TST_MODPATH" ]; then
+ tst_res TINFO "Found module at '$TST_MODPATH'"
+ else
+ tst_brk TCONF "Failed to find module '$_tst_module'"
+ fi
+}
+
tst_run()
{
local _tst_i
@@ -552,23 +573,7 @@ tst_run()
TST_DEVICE_FLAG=1
fi
- if [ -n "$TST_NEEDS_MODULE" ]; then
- for tst_module in "$TST_NEEDS_MODULE" \
- "$LTPROOT/testcases/bin/$TST_NEEDS_MODULE" \
- "$TST_STARTWD/$TST_NEEDS_MODULE"; do
-
- if [ -f "$tst_module" ]; then
- TST_MODPATH="$tst_module"
- break
- fi
- done
-
- if [ -z "$TST_MODPATH" ]; then
- tst_brk TCONF "Failed to find module '$TST_NEEDS_MODULE'"
- else
- tst_res TINFO "Found module at '$TST_MODPATH'"
- fi
- fi
+ [ -n "$TST_NEEDS_MODULE" ] && tst_require_module "$TST_NEEDS_MODULE"
if [ -n "$TST_SETUP" ]; then
$TST_SETUP
--
2.20.1
next prev parent reply other threads:[~2019-12-10 8:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-10 8:04 [LTP] [PATCH v4] lsmod01: Add kernel module Joerg Vehlow
2019-12-10 8:04 ` Joerg Vehlow [this message]
2019-12-10 8:04 ` [LTP] [PATCH v4 2/3] tst_test.sh: Make public tst_require_root command public Joerg Vehlow
2019-12-10 8:04 ` [LTP] [PATCH v4 3/3] lsmod01: Add kernel module Joerg Vehlow
2020-03-05 13:08 ` Petr Vorel
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=20191210080419.128773-2-lkml@jv-coder.de \
--to=lkml@jv-coder.de \
--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