aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorkhouloud touil <ktouil@baylibre.com>2018-06-22 14:26:49 +0200
committerkhouloud touil <ktouil@baylibre.com>2018-07-02 16:29:01 +0200
commitd69c057664659f8139781c5e3b548d96228b722f (patch)
treecd1f0fb9ee6b6690d235dc091015848ffdb1767f /common
parent11575952ece456be4e07c5f24ead3cf8783ddcba (diff)
CAN bus tests
This commit for testing CAN modules, sending and receiving frames, showing stats and and testing suitable bitrates for transmission. The "test_can_loopback_mode" test can be run on a board with one interface. This test will fail gracfully if the board dosen't have any CAN interface. The other tests needs to be run on a board with two CAN interfaces (e.g. dra7 with external transceiver.) These tests requires two interfaces on the same board to send frames with the first interface and to receive them with the other one These tests will fail gracfully by skiping all test cases if the board doesn't have two interfaces. This link for the DRA7xx-EVM job : http://lava.baylibre.com:10080/scheduler/job/2860 This link for the AM335X-BONEBLACK (no CAN interface) : http://lava.baylibre.com:10080/scheduler/job/2862 Change-Id: I7d4c69f7817adbea8281d264cbbb7fa55571584e Signed-off-by: khouloud touil <ktouil@baylibre.com>
Diffstat (limited to 'common')
-rwxr-xr-xcommon/scripts/test_can_bitrate.sh185
-rwxr-xr-xcommon/scripts/test_can_loopback_mode.sh61
-rwxr-xr-xcommon/scripts/test_can_modules.sh139
-rwxr-xr-xcommon/scripts/test_can_send_receive.sh79
-rwxr-xr-xcommon/scripts/test_stats.sh37
5 files changed, 501 insertions, 0 deletions
diff --git a/common/scripts/test_can_bitrate.sh b/common/scripts/test_can_bitrate.sh
new file mode 100755
index 0000000..6802714
--- /dev/null
+++ b/common/scripts/test_can_bitrate.sh
@@ -0,0 +1,185 @@
+#!/bin/sh
+
+#This test is writen taking the DRA7xx-EVM board as an example
+#Theorical values of bitrate is from 1Kbit/s to 1Mbit/s
+#Real values to provide transmission are between 10797 bit/s and 1909090git bit/s
+#Real values that doesn't provide transmission but belong to the domain are between 781 bit/s and 5209999 bit/s
+
+if [ ! -e /sys/class/net/can1 ];then
+ lava-test-case canconfig_can0_bitrate --result skip
+ lava-test-case receive_frames_through_can1 --result skip
+ lava-test-case receive_frames_through_can1 --result skip
+ lava-test-case receive_frames_through_can1 --result skip
+ lava-test-case canconfig_can0_bitrate --result skip
+ lava-test-case receive_frames_through_can1 --result skip
+ exit 0
+fi
+
+#This is the first part of the test, that tests if the bitrate inserted belongs to the domain and if
+#this first bitrate afford frames transmission or not
+canconfig can0 stop
+if [ $? -eq 0 ];then
+ lava-test-case stop_can0 --result pass
+else
+ lava-test-case stop_can0 --result fail
+fi
+sleep 2
+canconfig can1 stop
+if [ $? -eq 0 ];then
+ lava-test-case stop_can1 --result pass
+else
+ lava-test-case stop_can1 --result fail
+fi
+sleep 2
+
+# b refers to bitrate
+
+found_bitrate=0
+for b in `seq 778 790`;do
+ canconfig can0 bitrate $b
+ x=$?
+ if [ $x -eq 0 ];then
+ lava-test-case can0_bitrate --result pass --measurement $b --units bit/s
+ echo "$b is the first bitrate in the domain"
+ found_bitrate=1
+ canconfig can1 bitrate $b
+ if [ $? -eq 0 ];then
+ lava-test-case can1_bitrate --result pass --measurement $b --units bit/s
+ else
+ lava-test-case can1_bitrate --result fail --measurement $b --units bit/s
+ fi
+ sleep 2
+ canconfig can0 start
+ if [ $? -eq 0 ];then
+ lava-test-case start_can0 --result pass
+ else
+ lava-test-case start_can0 --result fail
+ fi
+ sleep 2
+ canconfig can1 start
+ if [ $? -eq 0 ];then
+ lava-test-case start_can1 --result pass
+ else
+ lava-test-case start_can1 --result fail
+ fi
+ sleep 2
+ file_can=$(mktemp)
+ cansequence -p can0 &
+ candump can1 > $file_can &
+ sleep 3
+ if [ -s $file_can ];then
+ lava-test-case Receive_can1 --result pass --measurement $b --units bit/s
+ else
+ lava-test-case Receive_can1 --result fail --measurement $b --units bit/s
+ sleep 2
+ echo "This bitrate $b belongs to the domain but doesn't provide frames transmission"
+ break
+ fi
+ rm $file_can
+ fi
+done
+
+if [ $found_bitrate -eq 0 ];then
+ lava-test-case can0_bitrate --result fail --measurement $b --units bit/s
+ sleep 2
+ echo "There is no supportable bitrate in this interval"
+fi
+canconfig can0 stop
+canconfig can1 stop
+sleep 2
+#This is the second part of the test, it tests the first bitrate to provide frames transmission
+
+canconfig can0 stop
+canconfig can1 stop
+found_bitrate_for_transmisson=0
+for b in `seq 10790 10800`;do
+ canconfig can0 bitrate $b
+ canconfig can1 bitrate $b
+ canconfig can0 start
+ canconfig can1 start
+ sleep 3
+ file_can=$(mktemp)
+ cansequence -p can0 &
+ candump can1 > $file_can &
+ sleep 4
+ if [ -s $file_can ];then
+ found_bitrate_for_transmisson=1
+ lava-test-case Receive_can1 --result pass --measurement $b --units bit/s
+ sleep 2
+ echo "$b is the first supportable bitrate to provide transmission"
+ break
+ fi
+ canconfig can0 stop
+ canconfig can1 stop
+ rm $file_can
+done
+
+if [ $found_bitrate_for_transmisson -eq 0 ];then
+ lava-test-case Receive_can1 --result fail --measurement $b --units bit/s
+ sleep 2
+ echo "There is no bitrate in this interval to provide frames transmission"
+fi
+
+
+#This is the third part of the test, it tests the last bitrate to provide frames transmission
+
+canconfig can0 stop
+canconfig can1 stop
+bitrate_no_transmission=0
+for b in `seq 1909088 1909092`;do
+ canconfig can0 bitrate $b
+ canconfig can1 bitrate $b
+ canconfig can0 start
+ canconfig can1 start
+ sleep 2
+ file_can=$(mktemp)
+ cansequence -p can0 &
+ candump can1 > $file_can &
+ sleep 3
+ size=$(stat -c %s $file_can)
+ if [ $size -eq 0 ];then
+ bitrate_no_transmission=1
+ B=($b-1)
+ lava-test-case Receive_can1 --result pass --measurement $B --units bit/s
+ lava-test-case Receive_can1 --result fail --measurement $b --units bit/s
+ sleep 2
+ echo "This bitrate $b doesn't provide frames transmission"
+ echo "The last bitrate to provide frames transmission is $(($b-1))"
+ break
+ fi
+ canconfig can0 stop
+ canconfig can1 stop
+ rm $file_can
+done
+
+if [ $bitrate_no_transmission -eq 0 ];then
+ lava-test-case Receive_can1 --result pass --measurement $b --units bit/s
+ echo "All bitrates in this interval provide frames transmission"
+ canconfig can0 stop
+ canconfig can1 stop
+fi
+
+#This is the last part of the test, it tests the last bitrate that belongs to the domain
+sleep 3
+canconfig can0 stop
+canconfig can1 stop
+out_of_domain=0
+for b in `seq 5290999 5291000`;do
+ canconfig can0 bitrate $b
+ x=$?
+ sleep 2
+ if [ $x -ne 0 ];then
+ out_of_domain=1
+ lava-test-case can0_bitrate --result fail --measurement $b --units bit/s
+ echo "$b is the first bitrate to be out of the domain"
+ echo "The last bitrate to belong to the domain is $(($b-1))"
+ break
+ fi
+done
+
+if [ $out_of_domain -eq 0 ];then
+ lava-test-case can0_bitrate --result pass --measurement $b --units bit/s
+ echo "All bitrates in this interval belong to the domain"
+ canconfig can0 stop
+ canconfig can1 stop
+fi
diff --git a/common/scripts/test_can_loopback_mode.sh b/common/scripts/test_can_loopback_mode.sh
new file mode 100755
index 0000000..bd96c6b
--- /dev/null
+++ b/common/scripts/test_can_loopback_mode.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+if [ ! -e /sys/class/net/can0 ];then
+ lava-test-case canconfig_can0 --result skip
+ lava-test-case start_can0 --result skip
+ lava-test-case send_frames_through_can0 --result skip
+ lava-test-case receive_frames_through_can0 --result skip
+ lava-test-case stop_can0 --result skip
+ exit 0
+fi
+sleep 2
+#config the can interfaces
+canconfig can0 bitrate 50000 ctrlmode loopback on
+sleep 2
+if [ $? -eq 0 ];then
+ lava-test-case canconfig_can0 --result pass
+else
+ lava-test-case canconfig_can0 --result fail
+fi
+sleep 3
+
+#bring up the devices
+canconfig can0 start
+if [ $? -eq 0 ];then
+ lava-test-case start_can0 --result pass
+else
+ lava-test-case start_can0 --result fail
+fi
+sleep 4
+
+#send frames
+cansequence -p can0 &
+x=$?
+sleep 5
+if [ $x -eq 0 ];then
+ lava-test-case send_frames_through_can0 --result pass
+else
+ lava-test-case send_frames_through_can0 --result fail
+fi
+sleep 3
+file_can=$(mktemp)
+
+#receive frames
+candump can0 > $file_can &
+sleep 4
+if [ -s $file_can ];then
+ lava-test-case receive_frames_through_can0 --result pass
+else
+ lava-test-case receive_frames_through_can0 --result fail
+fi
+rm $file_can
+
+sleep 3
+canconfig can0 stop
+if [ $? -eq 0 ];then
+ lava-test-case stop_can0 --result pass
+else
+ lava-test-case stop_can0 --result fail
+fi
+
+sleep 5
diff --git a/common/scripts/test_can_modules.sh b/common/scripts/test_can_modules.sh
new file mode 100755
index 0000000..d7966b4
--- /dev/null
+++ b/common/scripts/test_can_modules.sh
@@ -0,0 +1,139 @@
+#!/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 canconfig_can1 --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
+ lava-test-case canconfig_can1 --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
+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
+
+canconfig can0 bitrate 50000
+if [ $? -eq 0 ];then
+ lava-test-case canconfig_can0 --result fail
+else
+ lava-test-case canconfig_can0 --result pass
+fi
+
+sleep 3
+
+canconfig can1 bitrate 50000
+if [ $? -eq 0 ];then
+ lava-test-case canconfig_can1 --result fail
+else
+ lava-test-case canconfig_can1 --result pass
+fi
+
+sleep 5
+
+modprobe can
+if [ $? -eq 0 ];then
+ lava-test-case load_can_module --result pass
+else
+ lava-test-case load_can_module --result fail
+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 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 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 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
+
+sleep 5
+
+canconfig can0 bitrate 50000
+if [ $? -eq 0 ];then
+ lava-test-case canconfig_can0 --result pass
+else
+ lava-test-case canconfig_can0 --result fail
+fi
+
+sleep 3
+canconfig can1 bitrate 50000
+if [ $? -eq 0 ];then
+ lava-test-case canconfig_can1 --result pass
+else
+ lava-test-case canconfig_can1 --result fail
+fi
+
+sleep 3
diff --git a/common/scripts/test_can_send_receive.sh b/common/scripts/test_can_send_receive.sh
new file mode 100755
index 0000000..d5d155c
--- /dev/null
+++ b/common/scripts/test_can_send_receive.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+
+if [ ! -e /sys/class/net/can1 ];then
+ lava-test-case canconfig_can0 --result skip
+ lava-test-case canconfig_can1 --result skip
+ lava-test-case start_can0 --result skip
+ lava-test-case start_can1 --result skip
+ lava-test-case send_frames_through_can0 --result skip
+ lava-test-case receive_frames_through_can1 --result skip
+ lava-test-case stop_can0 --result skip
+ lava-test-case stop_can1 --result skip
+ exit 0
+fi
+
+#config the can interfaces
+canconfig can0 bitrate 50000
+if [ $? -eq 0 ];then
+ lava-test-case canconfig_can0 --result pass
+else
+ lava-test-case canconfig_can0 --result fail
+fi
+sleep 3
+canconfig can1 bitrate 50000
+if [ $? -eq 0 ];then
+ lava-test-case canconfig_can1 --result pass
+else
+ lava-test-case canconfig_can1 --result fail
+fi
+sleep 3
+#bring up the devices
+canconfig can0 start
+if [ $? -eq 0 ];then
+ lava-test-case start_can0 --result pass
+else
+ lava-test-case start_can0 --result fail
+fi
+sleep 3
+canconfig can1 start
+if [ $? -eq 0 ];then
+ lava-test-case start_can1 --result pass
+else
+ lava-test-case start_can1 --result fail
+fi
+sleep 3
+#send frames
+cansequence -p can0 &
+if [ $? -eq 0 ];then
+ lava-test-case send_frames_through_can0 --result pass
+else
+ lava-test-case send_frames_through_can0 --result fail
+fi
+
+#receive frames
+file_can=$(mktemp)
+candump can1 > $file_can &
+sleep 3
+if [ -s $file_can ];then
+ lava-test-case receive_frames_through_can1 --result pass
+else
+ lava-test-case receive_frames_through_can1 --result fail
+fi
+rm $file_can
+
+sleep 10
+canconfig can0 stop
+if [ $? -eq 0 ];then
+ lava-test-case stop_can0 --result pass
+else
+ lava-test-case stop_can0 --result fail
+fi
+sleep 3
+canconfig can1 stop
+if [ $? -eq 0 ];then
+ lava-test-case stop_can1 --result pass
+else
+ lava-test-case stop_can1 --result fail
+fi
+sleep 5
diff --git a/common/scripts/test_stats.sh b/common/scripts/test_stats.sh
new file mode 100755
index 0000000..de73671
--- /dev/null
+++ b/common/scripts/test_stats.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+
+if [ ! -e /sys/class/net/can1 ];then
+ lava-test-case show_can_stats --result skip
+ lava-test-case show_can0_stats --result skip
+ lava-test-case show_can1_stats --result skip
+ exit 0
+fi
+
+# show can interfaces stats
+cat /proc/net/can/stats
+if [ $? -eq 0 ];then
+ lava-test-case show_can_stats --result pass
+else
+ lava-test-case show_can_stats --result fail
+fi
+
+sleep 5
+
+ip -d -s link show can0
+if [ $? -eq 0 ];then
+ lava-test-case show_can0_stats --result pass
+else
+ lava-test-case show_can0_stats --result fail
+fi
+
+sleep 5
+
+ip -d -s link show can1
+if [ $? -eq 0 ];then
+ lava-test-case show_can1_stats --result pass
+else
+ lava-test-case show_can1_stats --result fail
+fi
+
+sleep 7