From: hartkopp Date: Mon, 18 Jul 2011 17:30:47 +0000 (+0000) Subject: Added test script analogue to the LTP test to check the CAN networklayer. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/socketcan-devel.git/commitdiff_plain/49c5b6902c6262a0aaf4f76df731f76742c09030 Added test script analogue to the LTP test to check the CAN networklayer. git-svn-id: svn://svn.berlios.de//socketcan/trunk@1265 030b6a49-0b11-0410-94ab-b0dab22257f2 --- diff --git a/test/test_netlayer.sh b/test/test_netlayer.sh new file mode 100755 index 0000000..e8a45f9 --- /dev/null +++ b/test/test_netlayer.sh @@ -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 + +