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