xref: /dpdk/examples/ipsec-secgw/test/pkttest.sh (revision 1dc48bce518de1d8cb73f961404a47311c4a248d)
1#!/bin/bash
2# SPDX-License-Identifier: BSD-3-Clause
3
4DIR=$(dirname $0)
5
6if [ $(id -u) -ne 0 ]; then
7	echo "Run as root"
8	exit 1
9fi
10
11# check python requirements
12python3 ${DIR}/pkttest.py check_reqs
13if [ $? -ne 0 ]; then
14	echo "Requirements for Python not met, exiting"
15	exit 1
16fi
17
18# secgw application parameters setup
19CRYPTO_DEV="--vdev=crypto_null0"
20SGW_PORT_CFG="--vdev=net_tap0,mac=fixed --vdev=net_tap1,mac=fixed"
21SGW_EAL_XPRM="--no-pci"
22SGW_CMD_XPRM=-l
23SGW_WAIT_DEV="dtap0"
24. ${DIR}/common_defs_secgw.sh
25
26echo "Running tests: $*"
27for testcase in $*
28do
29	# check test file presence
30	testfile="${DIR}/${testcase}.py"
31	if [ ! -f ${testfile} ]; then
32		echo "Invalid test ${testcase}"
33		continue
34	fi
35
36	# prepare test config
37	python3 ${testfile} config > ${SGW_CFG_FILE}
38	if [ $? -ne 0 ]; then
39		rm -f ${SGW_CFG_FILE}
40		echo "Cannot get secgw configuration for test ${testcase}"
41		exit 1
42	fi
43
44	# start the application
45	secgw_start
46
47	# setup interfaces
48	ifconfig dtap0 up
49	ifconfig dtap1 up
50
51	# run the test
52	echo "Running test case: ${testcase}"
53	python3 ${testfile}
54	st=$?
55
56	# stop the application
57	secgw_stop
58
59	# report test result and exit on failure
60	if [ $st -eq 0 ]; then
61		echo "Test case ${testcase} succeeded"
62	else
63		echo "Test case ${testcase} failed!"
64		exit $st
65	fi
66done
67