summaryrefslogtreecommitdiffstats
path: root/common/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'common/scripts')
-rwxr-xr-xcommon/scripts/test_can_modules.sh144
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