examples/ipsec-secgw: clean up test scripts
[dpdk.git] / examples / ipsec-secgw / test / run_test.sh
index 3e39309..1222308 100755 (executable)
@@ -1,69 +1,67 @@
 #! /bin/bash
 # SPDX-License-Identifier: BSD-3-Clause
 
-# usage: /bin/bash run_test.sh [-46]
-# Run all defined linux_test[4,6].sh test-cases one by one
-# user has to setup properly the following environment variables:
-#  SGW_PATH - path to the ipsec-secgw binary to test
-#  REMOTE_HOST - ip/hostname of the DUT
-#  REMOTE_IFACE - iface name for the test-port on DUT
-#  ETH_DEV - ethernet device to be used on SUT by DPDK ('-w <pci-id>')
-# Also user can optonally setup:
-#  SGW_LCORE - lcore to run ipsec-secgw on (default value is 0)
-#  CRYPTO_DEV - crypto device to be used ('-w <pci-id>')
-#  if none specified appropriate vdevs will be created by the scrit
-#  MULTI_SEG_TEST - ipsec-secgw option to enable reassembly support and
-#  specify size of reassembly table (i.e. MULTI_SEG_TEST="--reassemble 128")
-# refer to linux_test[4,6].sh for more information
-
-
-# All supported modes to test.
-# naming convention:
-# 'old' means that ipsec-secgw will run in legacy (non-librte_ipsec mode)
+# Usage: /bin/bash run_test.sh [-46miflscph] <ipsec_mode>
+# Run all defined linux_test.sh test-cases one by one
+# If <ipsec_mode> is specified, run only that test case
+# User has to setup properly the following environment variables:
+#  SGW_PATH    - path to the ipsec-secgw binary to test
+#  REMOTE_HOST - ip/hostname of the DUT
+#  REMOTE_IFACE        - iface name for the test-port on DUT
+#  ETH_DEV     - ethernet device to be used on SUT by DPDK ('-w <pci-id>')
+# Also user can optionally setup:
+#  SGW_LCORE   - lcore to run ipsec-secgw on (default value is 0)
+#  CRYPTO_DEV  - crypto device to be used ('-w <pci-id>')
+#             if none specified appropriate vdevs will be created by the script
+#  SGW_MULTI_SEG - ipsec-secgw option to enable reassembly support and
+#              specify size of reassembly table (i.e. SGW_MULTI_SEG=128)
+# Refer to linux_test.sh for more information
+
+# All supported modes to test:
+#  trs_3descbc_sha1
+#  trs_aescbc_sha1
+#  trs_aesctr_sha1
+#  trs_aesgcm
+#  tun_3descbc_sha1
+#  tun_aescbc_sha1
+#  tun_aesctr_sha1
+#  tun_aesgcm
+# Naming convention:
 # 'tun/trs' refer to tunnel/transport mode respectively
 
 usage()
 {
        echo "Usage:"
-       echo -e "\t$0 -[46p]"
+       echo -e "\t$0 -[46miflscph] <ipsec_mode>"
        echo -e "\t\t-4 Perform Linux IPv4 network tests"
        echo -e "\t\t-6 Perform Linux IPv6 network tests"
+       echo -e "\t\t-m Add mixed IP protocol tests to IPv4/IPv6 \
+(only with option [-46])"
+       echo -e "\t\t-i Run inline tests (only with option [-46])"
+       echo -e "\t\t-f Run fallback tests (only with option [-46])"
+       echo -e "\t\t-l Run tests in legacy mode"
+       echo -e "\t\t-s Run all tests with reassembly support \
+(on default only fallback tests use reassembly support)"
+       echo -e "\t\t-c Run tests with use of cpu-crypto \
+(on default lookaside-none is used)"
        echo -e "\t\t-p Perform packet validation tests"
        echo -e "\t\t-h Display this help"
+       echo -e "\t\t<ipsec_mode> Run only specified test case i.e. tun_aesgcm"
 }
 
-LINUX_TEST="tun_aescbc_sha1 \
-tun_aescbc_sha1_esn \
-tun_aescbc_sha1_esn_atom \
-tun_aesgcm \
-tun_aesgcm_esn \
-tun_aesgcm_esn_atom \
+LINUX_TEST="trs_3descbc_sha1 \
 trs_aescbc_sha1 \
-trs_aescbc_sha1_esn \
-trs_aescbc_sha1_esn_atom \
-trs_aesgcm \
-trs_aesgcm_esn \
-trs_aesgcm_esn_atom \
-tun_aescbc_sha1_old \
-tun_aesgcm_old \
-trs_aescbc_sha1_old \
-trs_aesgcm_old \
-tun_aesctr_sha1 \
-tun_aesctr_sha1_old \
-tun_aesctr_sha1_esn \
-tun_aesctr_sha1_esn_atom \
 trs_aesctr_sha1 \
-trs_aesctr_sha1_old \
-trs_aesctr_sha1_esn \
-trs_aesctr_sha1_esn_atom \
+trs_aesgcm \
 tun_3descbc_sha1 \
-tun_3descbc_sha1_old \
-tun_3descbc_sha1_esn \
-tun_3descbc_sha1_esn_atom \
-trs_3descbc_sha1 \
-trs_3descbc_sha1_old \
-trs_3descbc_sha1_esn \
-trs_3descbc_sha1_esn_atom"
+tun_aescbc_sha1 \
+tun_aesctr_sha1 \
+tun_aesgcm"
+
+LINUX_TEST_INLINE_FALLBACK="trs_aesgcm \
+tun_aesgcm"
+
+LINUX_TEST_RUN=""
 
 PKT_TESTS="trs_ipv6opts \
 tun_null_header_reconstruct"
@@ -74,7 +72,14 @@ DIR=$(dirname $0)
 run4=0
 run6=0
 runpkt=0
-while getopts ":46ph" opt
+mixed=0
+inline=0
+fallback=0
+legacy=0
+multi_seg=0
+cpu_crypto=0
+options=""
+while getopts ":46miflscph" opt
 do
        case $opt in
                4)
@@ -83,6 +88,27 @@ do
                6)
                        run6=1
                        ;;
+               m)
+                       mixed=1
+                       ;;
+               i)
+                       inline=1
+                       ;;
+               f)
+                       fallback=1
+                       ;;
+               l)
+                       legacy=1
+                       options="${options} -l"
+                       ;;
+               s)
+                       multi_seg=1
+                       options="${options} -s"
+                       ;;
+               c)
+                       cpu_crypto=1
+                       options="${options} -c"
+                       ;;
                p)
                        runpkt=1
                        ;;
@@ -98,12 +124,27 @@ do
        esac
 done
 
+shift $((OPTIND -1))
+LINUX_TEST_RUN=$*
+
 # no test suite has been selected
 if [[ ${run4} -eq 0 && ${run6} -eq 0 && ${runpkt} -eq 0 ]]; then
        usage
        exit 127
 fi
 
+# check parameters
+if [[ ${legacy} -eq 1 ]] && [[ ${multi_seg} -eq 1 || ${fallback} -eq 1 \
+   || ${cpu_crypto} -eq 1 ]]; then
+       echo "Fallback/reassembly/cpu-crypto cannot be used with legacy mode"
+       exit 127
+fi
+
+if [[ ${cpu_crypto} -eq 1 && ${inline} -eq 1 && ${fallback} -eq 0 ]]; then
+       echo "cpu-crypto cannot be used with inline mode"
+       exit 127
+fi
+
 # perform packet processing validation tests
 st=0
 if [ $runpkt -eq 1 ]; then
@@ -118,30 +159,84 @@ if [ $runpkt -eq 1 ]; then
        fi
 fi
 
-# perform network tests
-if [[ ${run4} -eq 1 || ${run6} -eq 1 ]]; then
-       for i in ${LINUX_TEST}; do
+desc=""
+
+# set inline/fallback tests if needed
+if [[ ${inline} -eq 1  || ${fallback} -eq 1 ]]; then
+
+       # add inline option if needed
+       if [[ ${inline} -eq 1 ]]; then
+               options="${options} -i"
+               desc="inline"
+       fi
+       # add fallback option if needed
+       if [[ ${fallback} -eq 1 ]]; then
+               options="${options} -f"
+               if [[ "${desc}" == "inline" ]]; then
+                       desc="${desc} and fallback"
+               else
+                       desc="fallback"
+               fi
+       fi
+
+       # select tests to run
+       if [[ -z "${LINUX_TEST_RUN}" ]]; then
+               LINUX_TEST_RUN="${LINUX_TEST_INLINE_FALLBACK}"
+       fi
+else
+       options="${options} -r"
+fi
+
+# select tests to run
+if [[ -z "${LINUX_TEST_RUN}" ]]; then
+       LINUX_TEST_RUN="${LINUX_TEST}"
+fi
+
+# perform selected tests
+if [[ ${run4} -eq 1 || ${run6} -eq 1 ]] ; then
 
-               echo "starting test ${i}"
+       for i in ${LINUX_TEST_RUN}; do
+
+               echo "starting ${desc} test ${i}"
 
                st4=0
+               st4m=0
                if [[ ${run4} -ne 0 ]]; then
-                       /bin/bash ${DIR}/linux_test4.sh ${i}
+                       /bin/bash ${DIR}/load_env.sh ${options} ipv4-ipv4 ${i}
                        st4=$?
-                       echo "test4 ${i} finished with status ${st4}"
+                       echo "${desc} test IPv4 ${i} finished with status \
+${st4}"
+                       if [[ ${mixed} -ne 0 ]] && [[ "${i}" == tun* ]]; then
+                               /bin/bash ${DIR}/load_env.sh ${options} \
+                               ipv4-ipv6 ${i}
+                               st4m=$?
+                               echo "${desc} test IPv4-IPv6 ${i} finished with\
+ status ${st4m}"
+                       fi
                fi
 
                st6=0
+               st6m=0
                if [[ ${run6} -ne 0 ]]; then
-                       /bin/bash ${DIR}/linux_test6.sh ${i}
+                       /bin/bash ${DIR}/load_env.sh ${options} ipv6-ipv6 ${i}
                        st6=$?
-                       echo "test6 ${i} finished with status ${st6}"
+                       echo "${desc} test IPv6 ${i} finished with status \
+${st6}"
+                       if [[ ${mixed} -ne 0 ]] && [[ "${i}" == tun* ]]; then
+                               /bin/bash ${DIR}/load_env.sh ${options} \
+                               ipv6-ipv4 ${i}
+                               st6m=$?
+                               echo "${desc} test IPv6-IPv4 ${i} finished with\
+ status ${st6m}"
+                       fi
                fi
 
-               let "st = st4 + st6"
+               let "st = st4 + st6 + st4m + st6m"
                if [[ $st -ne 0 ]]; then
-                       echo "ERROR test ${i} FAILED"
+                       echo "ERROR ${desc} test ${i} FAILED"
                        exit $st
                fi
        done
 fi
+
+echo "All tests have ended successfully"