3e3930991a999cbf30fc1896985db5137b7db741
[dpdk.git] / examples / ipsec-secgw / test / run_test.sh
1 #! /bin/bash
2 # SPDX-License-Identifier: BSD-3-Clause
3
4 # usage: /bin/bash run_test.sh [-46]
5 # Run all defined linux_test[4,6].sh test-cases one by one
6 # user has to setup properly the following environment variables:
7 #  SGW_PATH - path to the ipsec-secgw binary to test
8 #  REMOTE_HOST - ip/hostname of the DUT
9 #  REMOTE_IFACE - iface name for the test-port on DUT
10 #  ETH_DEV - ethernet device to be used on SUT by DPDK ('-w <pci-id>')
11 # Also user can optonally setup:
12 #  SGW_LCORE - lcore to run ipsec-secgw on (default value is 0)
13 #  CRYPTO_DEV - crypto device to be used ('-w <pci-id>')
14 #  if none specified appropriate vdevs will be created by the scrit
15 #  MULTI_SEG_TEST - ipsec-secgw option to enable reassembly support and
16 #  specify size of reassembly table (i.e. MULTI_SEG_TEST="--reassemble 128")
17 # refer to linux_test[4,6].sh for more information
18
19
20 # All supported modes to test.
21 # naming convention:
22 # 'old' means that ipsec-secgw will run in legacy (non-librte_ipsec mode)
23 # 'tun/trs' refer to tunnel/transport mode respectively
24
25 usage()
26 {
27         echo "Usage:"
28         echo -e "\t$0 -[46p]"
29         echo -e "\t\t-4 Perform Linux IPv4 network tests"
30         echo -e "\t\t-6 Perform Linux IPv6 network tests"
31         echo -e "\t\t-p Perform packet validation tests"
32         echo -e "\t\t-h Display this help"
33 }
34
35 LINUX_TEST="tun_aescbc_sha1 \
36 tun_aescbc_sha1_esn \
37 tun_aescbc_sha1_esn_atom \
38 tun_aesgcm \
39 tun_aesgcm_esn \
40 tun_aesgcm_esn_atom \
41 trs_aescbc_sha1 \
42 trs_aescbc_sha1_esn \
43 trs_aescbc_sha1_esn_atom \
44 trs_aesgcm \
45 trs_aesgcm_esn \
46 trs_aesgcm_esn_atom \
47 tun_aescbc_sha1_old \
48 tun_aesgcm_old \
49 trs_aescbc_sha1_old \
50 trs_aesgcm_old \
51 tun_aesctr_sha1 \
52 tun_aesctr_sha1_old \
53 tun_aesctr_sha1_esn \
54 tun_aesctr_sha1_esn_atom \
55 trs_aesctr_sha1 \
56 trs_aesctr_sha1_old \
57 trs_aesctr_sha1_esn \
58 trs_aesctr_sha1_esn_atom \
59 tun_3descbc_sha1 \
60 tun_3descbc_sha1_old \
61 tun_3descbc_sha1_esn \
62 tun_3descbc_sha1_esn_atom \
63 trs_3descbc_sha1 \
64 trs_3descbc_sha1_old \
65 trs_3descbc_sha1_esn \
66 trs_3descbc_sha1_esn_atom"
67
68 PKT_TESTS="trs_ipv6opts \
69 tun_null_header_reconstruct"
70
71 DIR=$(dirname $0)
72
73 # get input options
74 run4=0
75 run6=0
76 runpkt=0
77 while getopts ":46ph" opt
78 do
79         case $opt in
80                 4)
81                         run4=1
82                         ;;
83                 6)
84                         run6=1
85                         ;;
86                 p)
87                         runpkt=1
88                         ;;
89                 h)
90                         usage
91                         exit 0
92                         ;;
93                 ?)
94                         echo "Invalid option"
95                         usage
96                         exit 127
97                         ;;
98         esac
99 done
100
101 # no test suite has been selected
102 if [[ ${run4} -eq 0 && ${run6} -eq 0 && ${runpkt} -eq 0 ]]; then
103         usage
104         exit 127
105 fi
106
107 # perform packet processing validation tests
108 st=0
109 if [ $runpkt -eq 1 ]; then
110         echo "Performing packet validation tests"
111         /bin/bash ${DIR}/pkttest.sh ${PKT_TESTS}
112         st=$?
113
114         echo "pkttests finished with status ${st}"
115         if [[ ${st} -ne 0 ]]; then
116                 echo "ERROR pkttests FAILED"
117                 exit ${st}
118         fi
119 fi
120
121 # perform network tests
122 if [[ ${run4} -eq 1 || ${run6} -eq 1 ]]; then
123         for i in ${LINUX_TEST}; do
124
125                 echo "starting test ${i}"
126
127                 st4=0
128                 if [[ ${run4} -ne 0 ]]; then
129                         /bin/bash ${DIR}/linux_test4.sh ${i}
130                         st4=$?
131                         echo "test4 ${i} finished with status ${st4}"
132                 fi
133
134                 st6=0
135                 if [[ ${run6} -ne 0 ]]; then
136                         /bin/bash ${DIR}/linux_test6.sh ${i}
137                         st6=$?
138                         echo "test6 ${i} finished with status ${st6}"
139                 fi
140
141                 let "st = st4 + st6"
142                 if [[ $st -ne 0 ]]; then
143                         echo "ERROR test ${i} FAILED"
144                         exit $st
145                 fi
146         done
147 fi