mbox series

[RFC,0/1] selftests/run_kselftest.sh: make each test individually selectable

Message ID 20200309101256.868-1-liuhangbin@gmail.com (mailing list archive)
Headers show
Series selftests/run_kselftest.sh: make each test individually selectable | expand

Message

Hangbin Liu March 9, 2020, 10:12 a.m. UTC
Hi, this patch enhanced the run_kselftest.sh to make the tests individually
selectable. I'm not sure the if I could add the reuslt in the patch commit,
as the log is too long. So I just put the result to the cover-letter:

Note: I use `tr -s "/-" "_"` to cover the path name in tests to function name.
e.g. networking/timestamping -> networking_timestamping. I'm not sure if it's
legal in Makefile.

Before the patch:

]# ./kselftest_install.sh /tmp/kselftests
]# cat /tmp/kselftests/run_kselftest.sh
#!/bin/sh
BASE_DIR=$(realpath $(dirname $0))
cd $BASE_DIR
. ./kselftest/runner.sh
ROOT=$PWD
if [ "$1" = "--summary" ]; then
  logfile=$BASE_DIR/output.log
  cat /dev/null > $logfile
fi
[ -w /dev/kmsg ] && echo "kselftest: Running tests in android" >> /dev/kmsg
cd android
run_many        \
        "run.sh"
cd $ROOT
...<snip>...
[ -w /dev/kmsg ] && echo "kselftest: Running tests in zram" >> /dev/kmsg
cd zram
run_many        \
        "zram.sh"
cd $ROOT

After the patch:
]# ./kselftest_install.sh /tmp/kselftests
]# cat /tmp/kselftests/run_kselftest.sh
#!/bin/sh
BASE_DIR=$(realpath $(dirname $0))
. ./kselftest/runner.sh
TESTS="android ...<snip>... zram"

run_android()
{
        [ -w /dev/kmsg ] && echo "kselftest: Running tests in android" >> /dev/kmsg
        cd android
        run_many        \
                "run.sh"
        cd $ROOT
}

...<snip>...

run_zram()
{
        [ -w /dev/kmsg ] && echo "kselftest: Running tests in zram" >> /dev/kmsg
        cd zram
        run_many        \
                "zram.sh"
        cd $ROOT
}

usage()
{
        cat <<EOF
usage: ${0##*/} OPTS
        -s | --summary          Only print summary info and put detailed log in output.log
        -t | --tests            Test name you want to run specifically
        -h | --help             Show this usage info
EOF
}

while true; do
        case "$1" in
        -s | --summary ) logfile=$BASE_DIR/output.log; cat /dev/null > $logfile; shift ;;
        -t | --tests ) TESTS=$2; shift 2 ;;
        -h | --help ) usage; exit 0;;
        "" ) break;;
        * ) usage; exit 1;;
        esac
done

cd $BASE_DIR
ROOT=$PWD
for test in $TESTS; do
        run_$test
done


Hangbin Liu (1):
  selftests/run_kselftest.sh: make each test individually selectable

 tools/testing/selftests/Makefile | 48 +++++++++++++++++++++++++-------
 tools/testing/selftests/lib.mk   |  2 +-
 2 files changed, 39 insertions(+), 11 deletions(-)

Comments

Shuah March 13, 2020, 7:42 p.m. UTC | #1
Hi Hangbin,

On 3/9/20 4:12 AM, Hangbin Liu wrote:
> Hi, this patch enhanced the run_kselftest.sh to make the tests individually
> selectable. I'm not sure the if I could add the reuslt in the patch commit,
> as the log is too long. So I just put the result to the cover-letter:
> 
> Note: I use `tr -s "/-" "_"` to cover the path name in tests to function name.
> e.g. networking/timestamping -> networking_timestamping. I'm not sure if it's
> legal in Makefile.


Please add this to the patch change log. Please run get_maintainers
script before sending the patch. My email address you used is very
old.

Please include how to run and update the documentation as well.

thanks,
-- Shuah
Hangbin Liu March 15, 2020, 3:27 a.m. UTC | #2
On Fri, Mar 13, 2020 at 01:42:52PM -0600, shuah wrote:
> Hi Hangbin,
> 
> On 3/9/20 4:12 AM, Hangbin Liu wrote:
> > Hi, this patch enhanced the run_kselftest.sh to make the tests individually
> > selectable. I'm not sure the if I could add the reuslt in the patch commit,
> > as the log is too long. So I just put the result to the cover-letter:
> > 
> > Note: I use `tr -s "/-" "_"` to cover the path name in tests to function name.
> > e.g. networking/timestamping -> networking_timestamping. I'm not sure if it's
> > legal in Makefile.
> 
> 
> Please add this to the patch change log. Please run get_maintainers
> script before sending the patch. My email address you used is very
> old.
> 
> Please include how to run and update the documentation as well.

OK, I will, thanks for the feedback and sorry for the inconvenient.

Regards
Hangbin