]> rtime.felk.cvut.cz Git - socketcan-devel.git/blob - test/test_netlayer.sh
Added test script analogue to the LTP test to check the CAN networklayer.
[socketcan-devel.git] / test / test_netlayer.sh
1 #!/bin/sh
2 #
3 # testscript to check CAN filters and CAN frame flow in Linux network layer
4 #
5 # $Id$
6 #
7
8 if [ $(id -ru) -ne 0 ]; then
9      echo You need to be root to execute these tests
10      exit 1
11 fi
12
13 # load needed CAN networklayer modules
14 modprobe -f can
15 modprobe -f can_raw
16
17 # ensure the vcan driver to perform the ECHO on driver level
18 modprobe -r vcan
19 modprobe -f vcan echo=1
20
21 VCAN=vcan0
22
23 # create virtual CAN device
24 ip link add dev $VCAN type vcan || exit 1
25 ifconfig $VCAN up
26
27 # check precondition for CAN frame flow test
28 HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
29
30 if [ $HAS_ECHO -ne 1 ]
31 then
32     return 1
33 fi
34
35 # test of CAN filters on af_can.c 
36 ./tst-filter $VCAN || return 1
37
38 # test of CAN frame flow down to the netdevice and up again
39 ./tst-rcv-own-msgs $VCAN || return 1
40
41 echo ---
42 echo "CAN networklayer tests succeeded."
43 echo ---
44
45 return 0
46
47