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