From f48f8fed096c534b65a428c5c0618261ed1a04af Mon Sep 17 00:00:00 2001 From: khouloud touil Date: Thu, 12 Jul 2018 10:36:46 +0200 Subject: Fix the CAN bus tests At first to be able to configure the can interfaces, we had to use the libsocketcan, but this lib should be used with canutils utilities, but a conflict happened between the canutils and the can-utils, so I had to fix the tests to be able to use only the can-utils utilities. This link for a LAVA test job for these tests: http://lava.baylibre.com:10080/scheduler/job/10883 Change-Id: I7b988496d6977d6d9d82f8f82b58520444dbc7d6 Signed-off-by: khouloud touil --- common/scripts/test_can_bitrate.sh | 67 ++++++++++++++++---------------- common/scripts/test_can_loopback_mode.sh | 8 ++-- common/scripts/test_can_modules.sh | 8 ++-- common/scripts/test_can_send_receive.sh | 14 +++---- 4 files changed, 48 insertions(+), 49 deletions(-) (limited to 'common') diff --git a/common/scripts/test_can_bitrate.sh b/common/scripts/test_can_bitrate.sh index 6802714..0a34fc0 100755 --- a/common/scripts/test_can_bitrate.sh +++ b/common/scripts/test_can_bitrate.sh @@ -17,14 +17,14 @@ 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 +ip link set can0 down 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 +ip link set can1 down if [ $? -eq 0 ];then lava-test-case stop_can1 --result pass else @@ -36,27 +36,27 @@ sleep 2 found_bitrate=0 for b in `seq 778 790`;do - canconfig can0 bitrate $b + ip link set can0 type can 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 + ip link set can1 type can 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 + ip link set can0 up 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 + ip link set can1 up if [ $? -eq 0 ];then lava-test-case start_can1 --result pass else @@ -64,7 +64,7 @@ for b in `seq 778 790`;do fi sleep 2 file_can=$(mktemp) - cansequence -p can0 & + cangen can0 & candump can1 > $file_can & sleep 3 if [ -s $file_can ];then @@ -84,22 +84,22 @@ if [ $found_bitrate -eq 0 ];then sleep 2 echo "There is no supportable bitrate in this interval" fi -canconfig can0 stop -canconfig can1 stop +ip link set can0 down +ip link set can1 down 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 +ip link set can0 down +ip link set can1 down 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 + ip link set can0 type can bitrate $b + ip link set can1 type can bitrate $b + ip link set can0 up + ip link set can1 up sleep 3 file_can=$(mktemp) - cansequence -p can0 & + cangen can0 & candump can1 > $file_can & sleep 4 if [ -s $file_can ];then @@ -109,8 +109,8 @@ for b in `seq 10790 10800`;do echo "$b is the first supportable bitrate to provide transmission" break fi - canconfig can0 stop - canconfig can1 stop + ip link set can0 down + ip link set can1 down rm $file_can done @@ -123,49 +123,48 @@ fi #This is the third part of the test, it tests the last bitrate to provide frames transmission -canconfig can0 stop -canconfig can1 stop +ip link set can0 down +ip link set can1 down 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 + ip link set can0 type can bitrate $b + ip link set can1 type can bitrate $b + ip link set can0 up + ip link set can1 up sleep 2 file_can=$(mktemp) - cansequence -p can0 & + cangen 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 pass --measurement $(($b-1)) --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 + ip link set can0 down + ip link set can1 down 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 + ip link set can0 down + ip link set can1 down 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 +ip link set can0 down +ip link set can1 down out_of_domain=0 for b in `seq 5290999 5291000`;do - canconfig can0 bitrate $b + ip link set can0 type can bitrate $b x=$? sleep 2 if [ $x -ne 0 ];then diff --git a/common/scripts/test_can_loopback_mode.sh b/common/scripts/test_can_loopback_mode.sh index bd96c6b..7f86ef9 100755 --- a/common/scripts/test_can_loopback_mode.sh +++ b/common/scripts/test_can_loopback_mode.sh @@ -10,7 +10,7 @@ if [ ! -e /sys/class/net/can0 ];then fi sleep 2 #config the can interfaces -canconfig can0 bitrate 50000 ctrlmode loopback on +ip link set can0 type can bitrate 50000 loopback on sleep 2 if [ $? -eq 0 ];then lava-test-case canconfig_can0 --result pass @@ -20,7 +20,7 @@ fi sleep 3 #bring up the devices -canconfig can0 start +ip link set can0 up if [ $? -eq 0 ];then lava-test-case start_can0 --result pass else @@ -29,7 +29,7 @@ fi sleep 4 #send frames -cansequence -p can0 & +cangen can0 & x=$? sleep 5 if [ $x -eq 0 ];then @@ -51,7 +51,7 @@ fi rm $file_can sleep 3 -canconfig can0 stop +ip link set can0 down if [ $? -eq 0 ];then lava-test-case stop_can0 --result pass else diff --git a/common/scripts/test_can_modules.sh b/common/scripts/test_can_modules.sh index d7966b4..d6caf54 100755 --- a/common/scripts/test_can_modules.sh +++ b/common/scripts/test_can_modules.sh @@ -63,7 +63,7 @@ fi sleep 5 -canconfig can0 bitrate 50000 +ip link set can0 type can bitrate 50000 if [ $? -eq 0 ];then lava-test-case canconfig_can0 --result fail else @@ -72,7 +72,7 @@ fi sleep 3 -canconfig can1 bitrate 50000 +ip link set can1 type can bitrate 50000 if [ $? -eq 0 ];then lava-test-case canconfig_can1 --result fail else @@ -121,7 +121,7 @@ fi sleep 5 -canconfig can0 bitrate 50000 +ip link set can0 type can bitrate 50000 if [ $? -eq 0 ];then lava-test-case canconfig_can0 --result pass else @@ -129,7 +129,7 @@ else fi sleep 3 -canconfig can1 bitrate 50000 +ip link set can1 type can bitrate 50000 if [ $? -eq 0 ];then lava-test-case canconfig_can1 --result pass else diff --git a/common/scripts/test_can_send_receive.sh b/common/scripts/test_can_send_receive.sh index d5d155c..06bde6f 100755 --- a/common/scripts/test_can_send_receive.sh +++ b/common/scripts/test_can_send_receive.sh @@ -14,14 +14,14 @@ if [ ! -e /sys/class/net/can1 ];then fi #config the can interfaces -canconfig can0 bitrate 50000 +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 sleep 3 -canconfig can1 bitrate 50000 +ip link set can1 type can bitrate 50000 if [ $? -eq 0 ];then lava-test-case canconfig_can1 --result pass else @@ -29,14 +29,14 @@ else fi sleep 3 #bring up the devices -canconfig can0 start +ip link set can0 up 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 +ip link set can1 up if [ $? -eq 0 ];then lava-test-case start_can1 --result pass else @@ -44,7 +44,7 @@ else fi sleep 3 #send frames -cansequence -p can0 & +cangen can0 & if [ $? -eq 0 ];then lava-test-case send_frames_through_can0 --result pass else @@ -63,14 +63,14 @@ fi rm $file_can sleep 10 -canconfig can0 stop +ip link set can0 down 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 +ip link set can1 down if [ $? -eq 0 ];then lava-test-case stop_can1 --result pass else -- cgit 1.2.3-korg