summaryrefslogtreecommitdiffstats
path: root/common/scripts/test_can_modules.sh
blob: 9a5a6bd2a0e8fd6feaba63bf81cc8cf3d4e6ee92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh

if [ ! -e /sys/class/net/can1 ];then
	lava-test-case show_can_modules --result skip
	lava-test-case unload_can_raw_module --result skip
	lava-test-case unload_can_module --result skip
	lava-test-case unload_c_can_platform_module --result skip
	lava-test-case unload_c_can_module --result skipp
	lava-test-case unload_can_dev_module --result skip
	lava-test-case canconfig_can0 --result skip
	lava-test-case load_can_module --result skip
	lava-test-case load_can_raw_module --result skip
	lava-test-case load_c_can_module --result skip
	lava-test-case load_can_dev_module --result skip
	lava-test-case canconfig_can0 --result skip
        exit 0
fi

# 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 canconfig_can0 --result skip
else
	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_module can

modprobe_module can_raw

modprobe_module c_can

modprobe_module c_can_platform

modprobe_module can_dev

#Make sure always that the can interface is down before
#starting the config step.
ip link set can0 down

ip -V | grep -q -i BusyBox
if [ $? -eq 0 ];then
	lava-test-case canconfig_can0 --result skip
else
	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