aboutsummaryrefslogtreecommitdiff
path: root/test/linux-generic/validation/api/pktio/pktio_run_netmap.sh
blob: 7dde7ae1cc228b40d6a57e779e11823bd08c3874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
#
# Copyright (c) 2016, Linaro Limited
# All rights reserved.
#
# SPDX-License-Identifier:	BSD-3-Clause
#

# any parameter passed as arguments to this script is passed unchanged to
# the test itself (pktio_main)

# directories where pktio_main binary can be found:
# -in the validation dir when running make check (intree or out of tree)
# -in the script directory, when running after 'make install', or
# -in the validation when running standalone (./pktio_run) intree.
# -in the current directory.
# running stand alone out of tree requires setting PATH
PATH=${TEST_DIR}/api/pktio:$PATH
PATH=$(dirname $0):$PATH
PATH=$(dirname $0)/../../../../common_plat/validation/api/pktio:$PATH
PATH=.:$PATH

pktio_main_path=$(which pktio_main${EXEEXT})
if [ -x "$pktio_main_path" ] ; then
	echo "running with pktio_main: $pktio_main_path"
else
	echo "cannot find pktio_main: please set you PATH for it."
fi

# directory where platform test sources are, including scripts
TEST_SRC_DIR=$(dirname $0)

# exit codes expected by automake for skipped tests
TEST_SKIPPED=77

# Use installed pktio env or for make check take it from the test directory
if [ -f "./pktio_env" ]; then
	. ./pktio_env
elif [ -f ${TEST_SRC_DIR}/pktio_env ]; then
	. ${TEST_SRC_DIR}/pktio_env
else
	echo "ERROR: unable to find pktio_env!"
	echo "pktio_env has to be in current directory or in ${TEST_SRC_DIR}"
	exit 1
fi

run_test()
{
	local ret=0

	pktio_main${EXEEXT} $*
	ret=$?

	if [ $ret -ne 0 ]; then
		echo "!!! FAILED !!!"
	fi

	return $ret
}

run_test_vale()
{
	# use two vale ports on the same switch
	export ODP_PKTIO_IF0=valetest:0
	export ODP_PKTIO_IF1=valetest:1
	run_test
	return $?
}

run_test_pipe()
{
	# use a netmap pipe
	export ODP_PKTIO_IF0=valetest:0{0
	export ODP_PKTIO_IF1=valetest:0}0
	run_test
	return $?
}

run_test_veth()
{
	if [ "$(lsmod | grep veth)" = "" ]; then
		echo "netmap enabled veth module not loaded, skipping test."
		return 0
	fi

	setup_pktio_env clean
	export ODP_PKTIO_IF0=$IF0
	export ODP_PKTIO_IF1=$IF1
	run_test
	return $?
}

run()
{
	local ret=0

	# need to be root to run these tests
	if [ "$(id -u)" != "0" ]; then
		echo "netmap tests must be run as root, skipping test."
		exit $TEST_SKIPPED
	fi

	if [ "$(lsmod | grep netmap)" = "" ]; then
		echo "netmap kernel module not loaded, skipping test."
		exit $TEST_SKIPPED
	fi

	if [ "$ODP_PKTIO_IF0" != "" ]; then
		run_test
		ret=$?
	else
		run_test_vale
		r=$?; [ $ret = 0 ] && ret=$r
		run_test_pipe
		r=$?; [ $ret = 0 ] && ret=$r
		run_test_veth
		r=$?; [ $ret = 0 ] && ret=$r
	fi

	exit $ret
}

run