1#!/bin/bash 2 3DIR=$(dirname $0) 4 5if [ $(id -u) -ne 0 ]; then 6 echo "Run as root" 7 exit 1 8fi 9 10# check python requirements 11python3 ${DIR}/pkttest.py check_reqs 12if [ $? -ne 0 ]; then 13 echo "Requirements for Python not met, exiting" 14 exit 1 15fi 16 17# secgw application parameters setup 18CRYPTO_DEV="--vdev=crypto_null0" 19SGW_PORT_CFG="--vdev=net_tap0,mac=fixed --vdev=net_tap1,mac=fixed" 20SGW_EAL_XPRM="--no-pci" 21SGW_CMD_XPRM=-l 22SGW_WAIT_DEV="dtap0" 23. ${DIR}/common_defs_secgw.sh 24 25echo "Running tests: $*" 26for testcase in $* 27do 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 65done 66