From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/1] lib: Add test for tst_check_driver()
Date: Mon, 25 Jan 2021 14:17:48 +0100 [thread overview]
Message-ID: <YA7E/Co4QS4fcv92@yuki.lan> (raw)
In-Reply-To: <20210125095814.31741-1-pvorel@suse.cz>
Hi!
Good test.
With a minor fix:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> lib/newlib_tests/shell/tst_check_driver.sh | 64 ++++++++++++++++++++++
> 1 file changed, 64 insertions(+)
> create mode 100755 lib/newlib_tests/shell/tst_check_driver.sh
>
> diff --git a/lib/newlib_tests/shell/tst_check_driver.sh b/lib/newlib_tests/shell/tst_check_driver.sh
> new file mode 100755
> index 000000000..1d438700b
> --- /dev/null
> +++ b/lib/newlib_tests/shell/tst_check_driver.sh
> @@ -0,0 +1,64 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 Petr Vorel <pvorel@suse.cz>
> +
> +TST_TESTFUNC=test
> +TST_SETUP=setup
> +TST_CNT=3
> +TST_NEEDS_CMDS="tst_check_drivers find grep head sed"
> +. tst_test.sh
> +
> +MODULES_DIR="${MODULES_DIR:-/lib/modules/$(uname -r)}"
> +
> +setup()
> +{
> + tst_res TINFO "using modules directory '$MODULES_DIR'"
> +
> + [ -d "$MODULES_DIR" ] || \
> + tst_brk TCONF "modules directory '$MODULES_DIR' missing"
> +}
> +
> +get_name()
> +{
> + local path="$1"
> + local drv
> +
> + echo $path | sed 's/.*\/\([^/]\+\)\.ko.*/\1/'
> +}
> +
> +test1()
> +{
> + local drv
> +
> + for drv in $(find $MODULES_DIR | grep -E '_[^/]+\.ko' | head -3); do
> + drv="$(get_name $drv)"
> + EXPECT_PASS tst_check_drivers $drv
> +
> + drv="$(echo $drv | sed 's/_/-/g')"
> + EXPECT_PASS tst_check_drivers $drv
> + done
> +}
> +
> +test2()
> +{
> + tst_res TINFO "check non-existing module detection"
> + EXPECT_FAIL tst_check_drivers not-existing-kernel-module
> +}
> +
> +test3()
> +{
> + local f="$MODULES_DIR/modules.builtin"
> + local drv
> +
> + tst_res TINFO "check built-in module detection"
> +
> + [ -f "$f" ] || \
> + tst_brk TCONF "missing '$f'"
> +
> + for drv in $(head -3 $f); do
> + drv="$(get_name $drv)"
> + EXPECT_PASS tst_check_drivers "$(get_name $drv)"
^
Just $drv?
> + done
> +}
> +
> +tst_run
--
Cyril Hrubis
chrubis@suse.cz
prev parent reply other threads:[~2021-01-25 13:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-25 9:58 [LTP] [PATCH 1/1] lib: Add test for tst_check_driver() Petr Vorel
2021-01-25 13:17 ` Cyril Hrubis [this message]
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=YA7E/Co4QS4fcv92@yuki.lan \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.