Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: can: test_raw_filter.sh: add support of physical interfaces

Allow the user to specify a physical interface through the $CANIF
environment variable. Add a $BITRATE environment variable set with a
default value of 500000.

If $CANIF is omitted or if it starts with vcan (e.g. vcan1), the test
will use the virtual can interface type. Otherwise, it will assume
that the provided interface is a physical can interface.

For example:

CANIF=can1 BITRATE=1000000 ./test_raw_filter.sh

will run set the can1 interface with a bitrate of one million and run
the tests on it.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Vincent Mailhol and committed by
Marc Kleine-Budde
3e20585a 77442ffa

+10 -2
+10 -2
tools/testing/selftests/net/can/test_raw_filter.sh
··· 9 9 source $net_dir/lib.sh 10 10 11 11 export CANIF=${CANIF:-"vcan0"} 12 + BITRATE=${BITRATE:-500000} 12 13 13 14 setup() 14 15 { 15 - ip link add name $CANIF type vcan || exit $ksft_skip 16 + if [[ $CANIF == vcan* ]]; then 17 + ip link add name $CANIF type vcan || exit $ksft_skip 18 + else 19 + ip link set dev $CANIF type can bitrate $BITRATE || exit $ksft_skip 20 + fi 16 21 ip link set dev $CANIF up 17 22 pwd 18 23 } 19 24 20 25 cleanup() 21 26 { 22 - ip link delete $CANIF 27 + ip link set dev $CANIF down 28 + if [[ $CANIF == vcan* ]]; then 29 + ip link delete $CANIF 30 + fi 23 31 } 24 32 25 33 test_raw_filter()