Skip to content

Commit 223fd70

Browse files
committed
lib/tst_test.sh: add TST_NEEDS_DRIVERS parameter
The drivers are checked with 'tst_check_drivers' command. Signed-off-by: Alexey Kodanev <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]>
1 parent 1f70b0a commit 223fd70

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

doc/test-writing-guidelines.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,7 @@ simply by setting right '$TST_NEEDS_FOO'.
16621662
| 'TST_NEEDS_CMDS' | String with command names that has to be present for
16631663
the test (see below).
16641664
| 'TST_NEEDS_MODULE' | Test module name needed for the test (see below).
1665+
| 'TST_NEEDS_DRIVERS'| Checks kernel drivers support for the test.
16651666
|=============================================================================
16661667

16671668
Checking for presence of commands

testcases/lib/tst_test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,18 @@ tst_check_cmds()
302302
return 0
303303
}
304304

305+
tst_test_drivers()
306+
{
307+
[ $# -eq 0 ] && return 0
308+
309+
local drv
310+
311+
drv="$(tst_check_drivers $@ 2>&1)"
312+
313+
[ $? -ne 0 ] && tst_brk TCONF "$drv driver not available"
314+
return 0
315+
}
316+
305317
tst_is_int()
306318
{
307319
[ "$1" -eq "$1" ] 2>/dev/null
@@ -349,6 +361,7 @@ tst_run()
349361
OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
350362
NEEDS_ROOT|NEEDS_TMPDIR|NEEDS_DEVICE|DEVICE);;
351363
NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);;
364+
NEEDS_DRIVERS);;
352365
IPV6|IPVER|TEST_DATA|TEST_DATA_IFS);;
353366
RETRY_FUNC|RETRY_FN_EXP_BACKOFF);;
354367
*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
@@ -386,6 +399,7 @@ tst_run()
386399
fi
387400

388401
tst_test_cmds $TST_NEEDS_CMDS
402+
tst_test_drivers $TST_NEEDS_DRIVERS
389403

390404
if [ -n "$TST_MIN_KVER" ]; then
391405
tst_kvcmp -lt "$TST_MIN_KVER" && \

0 commit comments

Comments
 (0)