Commit 3e20585a authored by Vincent Mailhol's avatar Vincent Mailhol Committed by Marc Kleine-Budde
Browse files

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: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 77442ffa
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -9,17 +9,25 @@ net_dir=$(dirname $0)/..
source $net_dir/lib.sh

export CANIF=${CANIF:-"vcan0"}
BITRATE=${BITRATE:-500000}

setup()
{
	if [[ $CANIF == vcan* ]]; then
		ip link add name $CANIF type vcan || exit $ksft_skip
	else
		ip link set dev $CANIF type can bitrate $BITRATE || exit $ksft_skip
	fi
	ip link set dev $CANIF up
	pwd
}

cleanup()
{
	ip link set dev $CANIF down
	if [[ $CANIF == vcan* ]]; then
		ip link delete $CANIF
	fi
}

test_raw_filter()