diff options
author | Corentin LABBE <clabbe@baylibre.com> | 2019-11-27 10:58:26 +0100 |
---|---|---|
committer | Corentin LABBE <clabbe@baylibre.com> | 2019-11-27 11:40:19 +0100 |
commit | bf2a5d6e8537c5e8d6203232cc0037d57d503e4e (patch) | |
tree | 2303934ff258f99bd508254df4b9d3b37ab99cdf /common/scripts | |
parent | 925a46030494ef05e4a737130ea66a74f85b30ed (diff) |
SPEC-2996: rework the CAN modules tests
The CAN modules tests have lots of redundant code, let's add some
function for probing/removing modules.
Furthermore, some tests cannot work with busybox ip, I adds some tests
for it.
When reworking the tests, I have removed the "lsmod |grep can" tests
which was of no value.
I have also removed all sleep which was undocumented(probably for some
log flushing), if something need them I will re-add it with comment.
Bug-AGL: SPEC-2996
Change-Id: I2e8a109d799c58726d848814fd4c21a9fbd2eef5
Signed-off-by: Corentin LABBE <clabbe@baylibre.com>
Diffstat (limited to 'common/scripts')
-rwxr-xr-x | common/scripts/test_can_modules.sh | 144 |
1 files changed, 55 insertions, 89 deletions
diff --git a/common/scripts/test_can_modules.sh b/common/scripts/test_can_modules.sh index 6fe4b02..9a5a6bd 100755 --- a/common/scripts/test_can_modules.sh +++ b/common/scripts/test_can_modules.sh @@ -15,111 +15,77 @@ if [ ! -e /sys/class/net/can1 ];then lava-test-case canconfig_can0 --result skip exit 0 fi -lsmod | grep can -if [ $? -eq 0 ];then - lava-test-case show_can_modules --result pass -else - lava-test-case show_can_modules --result fail -fi - -sleep 4 - -rmmod can_raw -if [ $? -eq 0 ];then - lava-test-case unload_can_raw_module --result pass -else - lava-test-case unload_can_raw_module --result fail -fi - -rmmod can -if [ $? -eq 0 ];then - lava-test-case unload_can_module --result pass -else - lava-test-case unload_can_module --result fail -fi -rmmod c_can_platform +# remove module "$1" +remove_module() { + lsmod | grep -q "^$1[[:space:]]" + if [ $? -ne 0 ];then + lava-test-case unload_$1_module --result skip + return 0 + fi + rmmod $1 + if [ $? -eq 0 ];then + lava-test-case unload_$1_module --result pass + else + lava-test-case unload_$1_module --result fail + fi +} + +modprobe_module() { + modprobe $1 + if [ $? -eq 0 ];then + lava-test-case load_$1_module --result pass + else + lava-test-case load_$1_module --result fail + fi +} + +remove_module can_raw + +remove_module can + +remove_module c_can_platform + +remove_module c_can + +remove_module can_dev unload_can_dev_module + +ip -V | grep -q -i BusyBox if [ $? -eq 0 ];then - lava-test-case unload_c_can_platform_module --result pass -else - lava-test-case unload_c_can_platform_module --result fail -fi - -rmmod c_can -if [ $? -eq 0 ];then - lava-test-case unload_c_can_module --result pass -else - lava-test-case unload_c_can_module --result fail -fi - -rmmod can_dev -if [ $? -eq 0 ];then - lava-test-case unload_can_dev_module --result pass -else - lava-test-case unload_can_dev_module --result fail -fi - -sleep 5 - -ip link set can0 type can bitrate 50000 -if [ $? -eq 0 ];then - lava-test-case canconfig_can0 --result fail -else - lava-test-case canconfig_can0 --result pass -fi - - -sleep 5 - -modprobe can -if [ $? -eq 0 ];then - lava-test-case load_can_module --result pass + lava-test-case canconfig_can0 --result skip else - lava-test-case load_can_module --result fail + ip link set can0 type can bitrate 50000 + if [ $? -eq 0 ];then + lava-test-case canconfig_can0 --result fail + else + lava-test-case canconfig_can0 --result pass + fi fi -modprobe can_raw -x=$? -sleep 5 -if [ $x -eq 0 ];then - lava-test-case load_can_raw_module --result pass -else - lava-test-case load_can_raw_module --result fail -fi -sleep 3 +modprobe_module can -modprobe c_can -if [ $? -eq 0 ];then - lava-test-case load_c_can_module --result pass -else - lava-test-case load_c_can_module --result fail -fi +modprobe_module can_raw -modprobe c_can_platform -if [ $? -eq 0 ];then - lava-test-case load_c_can_platform_module --result pass -else - lava-test-case load_c_can_platform_module --result fail -fi +modprobe_module c_can -modprobe can_dev -if [ $? -eq 0 ];then - lava-test-case load_can_dev_module --result pass -else - lava-test-case load_can_dev_module --result fail -fi +modprobe_module c_can_platform -sleep 5 +modprobe_module can_dev #Make sure always that the can interface is down before #starting the config step. ip link set can0 down -ip link set can0 type can bitrate 50000 +ip -V | grep -q -i BusyBox if [ $? -eq 0 ];then - lava-test-case canconfig_can0 --result pass + lava-test-case canconfig_can0 --result skip else - lava-test-case canconfig_can0 --result fail + ip link set can0 type can bitrate 50000 + if [ $? -eq 0 ];then + lava-test-case canconfig_can0 --result pass + else + lava-test-case canconfig_can0 --result fail + fi fi sleep 3 |