]> rtime.felk.cvut.cz Git - socketcan-devel.git/commitdiff
Added test script analogue to the LTP test to check the CAN networklayer.
authorhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Mon, 18 Jul 2011 17:30:47 +0000 (17:30 +0000)
committerhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Mon, 18 Jul 2011 17:30:47 +0000 (17:30 +0000)
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1265 030b6a49-0b11-0410-94ab-b0dab22257f2

test/test_netlayer.sh [new file with mode: 0755]

diff --git a/test/test_netlayer.sh b/test/test_netlayer.sh
new file mode 100755 (executable)
index 0000000..e8a45f9
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# testscript to check CAN filters and CAN frame flow in Linux network layer
+#
+# $Id$
+#
+
+if [ $(id -ru) -ne 0 ]; then
+     echo You need to be root to execute these tests
+     exit 1
+fi
+
+# load needed CAN networklayer modules
+modprobe -f can
+modprobe -f can_raw
+
+# ensure the vcan driver to perform the ECHO on driver level
+modprobe -r vcan
+modprobe -f vcan echo=1
+
+VCAN=vcan0
+
+# create virtual CAN device
+ip link add dev $VCAN type vcan || exit 1
+ifconfig $VCAN up
+
+# check precondition for CAN frame flow test
+HAS_ECHO=`ip link show $VCAN | grep -c ECHO`
+
+if [ $HAS_ECHO -ne 1 ]
+then
+    return 1
+fi
+
+# test of CAN filters on af_can.c 
+./tst-filter $VCAN || return 1
+
+# test of CAN frame flow down to the netdevice and up again
+./tst-rcv-own-msgs $VCAN || return 1
+
+echo ---
+echo "CAN networklayer tests succeeded."
+echo ---
+
+return 0
+
+