[Fuego] [PATCH v2] Add test cases for commands of module-init-tools.

Tim.Bird at sony.com Tim.Bird at sony.com
Wed Nov 14 22:41:40 UTC 2018


Sorry for the slow response.  See comments inline below.

> -----Original Message-----
> From: Wang Mingyu on Tuesday, September 18, 2018 8:58 AM

There should be some text in the commit body here.

> 
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
>  .../Functional.module-init-tools/fuego_test.sh     | 29 +++++++++++++++

Fuego test names should use underscores and not dashes.
Please change this to Functional.module_init_tools
See http://fuegotest.org/wiki/Fuego_naming_rules


>  .../module-init-tools_test.sh                      |  4 ++
>  .../tests/Functional.module-init-tools/parser.py   | 22 +++++++++++
>  .../tests/Functional.module-init-tools/spec.json   |  7 ++++
>  .../tests/module-init-tools_depmod.sh              | 29 +++++++++++++++
>  .../tests/module-init-tools_insmod.sh              | 40 ++++++++++++++++++++
>  .../tests/module-init-tools_lsmod.sh               | 39 ++++++++++++++++++++
>  .../tests/module-init-tools_modinfo.sh             | 18 +++++++++
>  .../tests/module-init-tools_modprobe.sh            | 35 ++++++++++++++++++
>  .../tests/module-init-tools_rmmod.sh               | 43
> ++++++++++++++++++++++
>  10 files changed, 266 insertions(+)
>  create mode 100644 engine/tests/Functional.module-init-
> tools/fuego_test.sh
>  create mode 100755 engine/tests/Functional.module-init-tools/module-init-
> tools_test.sh
>  create mode 100644 engine/tests/Functional.module-init-tools/parser.py
>  create mode 100644 engine/tests/Functional.module-init-tools/spec.json
>  create mode 100644 engine/tests/Functional.module-init-
> tools/tests/module-init-tools_depmod.sh
>  create mode 100644 engine/tests/Functional.module-init-
> tools/tests/module-init-tools_insmod.sh
>  create mode 100644 engine/tests/Functional.module-init-
> tools/tests/module-init-tools_lsmod.sh
>  create mode 100644 engine/tests/Functional.module-init-
> tools/tests/module-init-tools_modinfo.sh
>  create mode 100644 engine/tests/Functional.module-init-
> tools/tests/module-init-tools_modprobe.sh
>  create mode 100644 engine/tests/Functional.module-init-
> tools/tests/module-init-tools_rmmod.sh
> 
> diff --git a/engine/tests/Functional.module-init-tools/fuego_test.sh
> b/engine/tests/Functional.module-init-tools/fuego_test.sh
> new file mode 100644
> index 0000000..ac18334
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/fuego_test.sh
> @@ -0,0 +1,29 @@
> +function test_pre_check {
> +    is_on_target_path depmod PROGRAM_DEPMOD
> +    assert_define PROGRAM_DEPMOD "Missing 'depmod' program on target
> board"
> +    is_on_target_path insmod PROGRAM_INSMOD
> +    assert_define PROGRAM_INSMOD "Missing 'insmod' program on target
> board"
> +    is_on_target_path lsmod PROGRAM_LSMOD
> +    assert_define PROGRAM_LSMOD "Missing 'lsmod' program on target
> board"
> +    is_on_target_path rmmod PROGRAM_RMMOD
> +    assert_define PROGRAM_RMMOD "Missing 'rmmod' program on target
> board"
> +    is_on_target_path modinfo PROGRAM_MODINFO
> +    assert_define PROGRAM_MODINFO "Missing 'modinfo' program on
> target board"
> +    is_on_target_path modprobe PROGRAM_MODPROBE
> +    assert_define PROGRAM_MODPROBE "Missing 'modprobe' program on
> target board"
Please switch these to assert_has_program

Also, I think you need a NEED_ROOT=1 somewhere.
I believe many of these tests will not run without root privileges (depmod?)

> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/module-init-tools_test.sh
> $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put $FUEGO_CORE/engine/scripts/fuego_board_function_lib.sh
> $BOARD_TESTDIR/fuego.$TESTDIR
> +    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    ./module-init-tools_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/engine/tests/Functional.module-init-tools/module-init-
> tools_test.sh b/engine/tests/Functional.module-init-tools/module-init-
> tools_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/module-init-tools_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/engine/tests/Functional.module-init-tools/parser.py
> b/engine/tests/Functional.module-init-tools/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/parser.py
> @@ -0,0 +1,22 @@
> +#!/usr/bin/python
> +# See common.py for description of command-line arguments
> +
> +import os, sys, collections
> +
> +sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
> +import common as plib
> +
> +measurements = {}
> +measurements = collections.OrderedDict()
> +
> +regex_string = '^ -> (.*): TEST-(.*)$'
> +matches = plib.parse_log(regex_string)
> +
> +if matches:
> +    for m in matches:
> +        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
> +
> +# split the output for each testcase
> +plib.split_output_per_testcase(regex_string, measurements)
> +
> +sys.exit(plib.process(measurements))
> diff --git a/engine/tests/Functional.module-init-tools/spec.json
> b/engine/tests/Functional.module-init-tools/spec.json
> new file mode 100644
> index 0000000..8e45a5d
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/spec.json
> @@ -0,0 +1,7 @@
> +{
> +    "testName": "Functional.module-init-tools",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> +
> diff --git a/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_depmod.sh b/engine/tests/Functional.module-init-
> tools/tests/module-init-tools_depmod.sh
> new file mode 100644
> index 0000000..c80f0aa
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_depmod.sh
> @@ -0,0 +1,29 @@
> +#!/bin/sh
> +
> +#  In target, run command depmod.
> +#  option: none
> +
> +test="depmod"
> +
> +test_krnl_rel=$(uname -r)
> +
> +if [ -f /lib/modules/$test_krnl_rel/modules.dep ]
> +then
> +    mv /lib/modules/$test_krnl_rel/modules.dep
> /lib/modules/$test_krnl_rel/modules.dep_bak
> +fi
> +
> +depmod
> +
> +if ls -l /lib/modules/$test_krnl_rel/modules.dep
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ -e /lib/modules/$test_krnl_rel/modules.dep_bak ]
> +then
> +    mv /lib/modules/$test_krnl_rel/modules.dep_bak
> /lib/modules/$test_krnl_rel/modules.dep
> +else
> +    rm /lib/modules/$test_krnl_rel/modules.de

Missing a 'p' at the end of this filename.

> +fi
> diff --git a/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_insmod.sh b/engine/tests/Functional.module-init-tools/tests/module-
> init-tools_insmod.sh
> new file mode 100644
> index 0000000..443c088
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_insmod.sh
> @@ -0,0 +1,40 @@
> +#!/bin/sh
> +
> +#  In target, run command insmod.
> +#  option: none
> +
> +test="insmod"
> +
> +tst_mod_file="ko file of module"
> +tst_mod_flag=0
> +
> +if modinfo uvesafb

How was this chosen as the module to use?  I only have this module on
2 of my boards (both x86_64).

Is there another module that is more common?

It would be difficult, but maybe we should provide a stub module
ourselves: fuego_stub.ko, and build it and put it on the target.
 
> +then
> +    tst_mod_file=$(modinfo uvesafb | sed -n 1p | cut -d' ' -f8)
Please use 'head' instead of sed here, to get the first line of the
output.

> +else
> +    echo " -> module uvesafb is not exist."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +mkdir test_dir
> +cp $tst_mod_file test_dir/
> +
> +if lsmod | grep uvesafb
> +then
> +    tst_mod_flag=1
> +    rmmod $tst_mod_file
> +fi
> +
> +if insmod test_dir/*.ko
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +if [ $tst_mod_flag=0 ]
> +then
> +    rmmod $tst_mod_file
> +fi
> +rm -fr test_dir
> diff --git a/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_lsmod.sh b/engine/tests/Functional.module-init-tools/tests/module-
> init-tools_lsmod.sh
> new file mode 100644
> index 0000000..77acb18
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_lsmod.sh
> @@ -0,0 +1,39 @@
> +#!/bin/sh
> +
> +#  In target, run command lsmod.
> +#  option: none
> +
> +test="lsmod"
> +
> +tst_mod_file="ko file of module"
> +
> +if modinfo uvesafb
> +then
> +    tst_mod_file=$(modinfo uvesafb | sed -n 1p | cut -d' ' -f8)
Please use head here instead of sed to get first line of output.

> +else
> +    echo " -> module uvesafb is not exist."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if lsmod | grep uvesafb
> +then
> +    echo " -> $test: TEST-PASS"
> +    exit
> +fi
> +
> +mkdir test_dir
> +cp $tst_mod_file test_dir/
> +
> +insmod test_dir/*.ko
> +
> +if lsmod | grep uvesafb
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +rmmod $tst_mod_file
> +rm -fr test_dir
> +
> diff --git a/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_modinfo.sh b/engine/tests/Functional.module-init-
> tools/tests/module-init-tools_modinfo.sh
> new file mode 100644
> index 0000000..4265887
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_modinfo.sh
> @@ -0,0 +1,18 @@
> +#!/bin/sh
> +
> +#  In target, run command modinfo.
> +#  option: none
> +
> +test="modinfo"
> +
> +tst_mod_file="ko file of module"
> +tst_mod_flag=0
> +
> +if modinfo uvesafb | grep "filename"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> module uvesafb is not exist."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> diff --git a/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_modprobe.sh b/engine/tests/Functional.module-init-
> tools/tests/module-init-tools_modprobe.sh
> new file mode 100644
> index 0000000..13823f9
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_modprobe.sh
> @@ -0,0 +1,35 @@
> +#!/bin/sh
> +
> +#  In target, run command modprobe.
> +#  option: modprobe
> +
> +test="modprobe"
> +
> +tst_mod_file="ko file of module"
> +tst_mod_flag=0
> +test_krnl_rel=$(uname -r)
> +
> +if modinfo uvesafb
> +then
> +    tst_mod_file=$(modinfo uvesafb | sed -n 1p | cut -d' ' -f8)
> +else
> +    echo " -> module uvesafb is not exist."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if modprobe -D uvesafb | grep "insmod $tst_mod_file"
> +then
> +    echo " -> $test: modprobe -D is succeeded."
> +else
> +    echo " -> $test: modprobe -D is failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if cat /lib/modules/$test_krnl_rel/modules.dep | grep "uvesafb.ko"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_rmmod.sh b/engine/tests/Functional.module-init-tools/tests/module-
> init-tools_rmmod.sh
> new file mode 100644
> index 0000000..bdd2d30
> --- /dev/null
> +++ b/engine/tests/Functional.module-init-tools/tests/module-init-
> tools_rmmod.sh
> @@ -0,0 +1,43 @@
> +#!/bin/sh
> +
> +#  In target, run command rmmod.
> +#  option: none
> +
> +test="rmmod"
> +
> +tst_mod_file="ko file of module"
> +tst_mod_flag=0
> +
> +if modinfo uvesafb
> +then
> +    tst_mod_file=$(modinfo uvesafb | sed -n 1p | cut -d' ' -f8)
> +else
> +    echo " -> module uvesafb is not exist."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +mkdir test_dir
> +cp $tst_mod_file test_dir/
> +
> +if lsmod | grep uvesafb
> +then
> +    tst_mod_flag=1
> +fi
> +
> +insmod test_dir/*.ko
> +
> +rmmod $tst_mod_file
> +
> +if lsmod | grep uvesafb
> +then
> +    echo " -> $test: TEST-FAIL"
> +else
> +    echo " -> $test: TEST-PASS"
> +fi
> +
> +if [ $tst_mod_flag=1 ]
> +then
> +    insmod $tst_mod_file
> +fi
> +rm -fr test_dir
> --
> 1.8.3.1

Thanks for working on this.
Please address my comments and re-submit.

Thanks,
 -- Tim



More information about the Fuego mailing list