blob: 0b1f928ed106ad7f40513e4b25318fe3ce2ac9fe [file] [log] [blame]
Dave Wallace543852a2017-08-03 02:11:34 -04001#! /bin/bash
2#
3# socket_test.sh -- script to run socket tests.
4#
5script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6vpp_dir="$WS_ROOT/build-root/install-vpp-native/vpp/bin/"
7vpp_debug_dir="$WS_ROOT/build-root/install-vpp_debug-native/vpp/bin/"
8vpp_shm_dir="/dev/shm/"
Dave Wallace3079a642017-09-06 01:59:43 -04009vpp_run_dir="/run/vpp"
Dave Wallace543852a2017-08-03 02:11:34 -040010lib64_dir="$WS_ROOT/build-root/install-vpp-native/vpp/lib64/"
11lib64_debug_dir="$WS_ROOT/build-root/install-vpp_debug-native/vpp/lib64/"
Dave Wallace19481612017-09-15 18:47:44 -040012dpdk_devbind="/usr/share/dpdk/usertools/dpdk-devbind.py"
Dave Wallace543852a2017-08-03 02:11:34 -040013docker_vpp_dir="/vpp/"
Dave Wallace30fb4a22017-08-17 16:22:04 -040014docker_app_dir="/vpp/"
Dave Wallace543852a2017-08-03 02:11:34 -040015docker_lib64_dir="/vpp-lib64/"
16docker_os="ubuntu"
Dave Wallaced69f4f42017-08-14 18:26:46 -040017vcl_ldpreload_lib="libvcl_ldpreload.so.0.0.0"
Dave Wallace3079a642017-09-06 01:59:43 -040018user_gid="$(id -g)"
Dave Wallace543852a2017-08-03 02:11:34 -040019vpp_app="vpp"
20sock_srvr_app="sock_test_server"
21sock_clnt_app="sock_test_client"
22sock_srvr_addr="127.0.0.1"
23sock_srvr_port="22000"
Dave Wallace30fb4a22017-08-17 16:22:04 -040024iperf_srvr_app="iperf3 -V4d -s"
25iperf_clnt_app="iperf3 -V4d -c \$srvr_addr"
Dave Wallace543852a2017-08-03 02:11:34 -040026gdb_in_emacs="gdb_in_emacs"
Dave Wallace8af20542017-10-26 03:29:30 -040027vcl_config="vcl.conf"
28vcl_config_dir="$WS_ROOT/src/vcl/"
29docker_vcl_config_dir="/etc/vpp/"
Keith Burns (alagalah)9e482bb2017-08-30 14:06:52 -070030xterm_geom="100x60"
Dave Wallace543852a2017-08-03 02:11:34 -040031bash_header="#! /bin/bash"
32tmp_cmdfile_prefix="/tmp/socket_test_cmd"
33cmd1_file="${tmp_cmdfile_prefix}1.$$"
34cmd2_file="${tmp_cmdfile_prefix}2.$$"
35cmd3_file="${tmp_cmdfile_prefix}3.$$"
Dave Wallace3d674492017-09-25 15:37:56 -040036vpp_eth_name="enp0s8"
Dave Wallace3079a642017-09-06 01:59:43 -040037tmp_vpp_exec_file="/tmp/vpp_config.$$"
Dave Wallace543852a2017-08-03 02:11:34 -040038tmp_gdb_cmdfile_prefix="/tmp/gdb_cmdfile"
39def_gdb_cmdfile_prefix="$WS_ROOT/extras/gdb/gdb_cmdfile"
40tmp_gdb_cmdfile_vpp="${tmp_gdb_cmdfile_prefix}_vpp.$$"
41tmp_gdb_cmdfile_client="${tmp_gdb_cmdfile_prefix}_vcl_client.$$"
42tmp_gdb_cmdfile_server="${tmp_gdb_cmdfile_prefix}_vcl_server.$$"
43get_docker_server_ip4addr='srvr_addr=$(docker network inspect bridge | grep IPv4Address | awk -e '\''{print $2}'\'' | sed -e '\''s,/16,,'\'' -e '\''s,",,g'\'' -e '\''s/,//'\'')'
44#' single quote to fix the confused emacs colorizer.
45trap_signals="SIGINT SIGTERM EXIT"
46
47# Set default values for imported environment variables if they don't exist.
48#
49VPP_GDB_CMDFILE="${VPP_GDB_CMDFILE:-${def_gdb_cmdfile_prefix}.vpp}"
50VPPCOM_CLIENT_GDB_CMDFILE="${VPPCOM_CLIENT_GDB_CMDFILE:-${def_gdb_cmdfile_prefix}.vppcom_client}"
51VPPCOM_SERVER_GDB_CMDFILE="${VPPCOM_SERVER_GDB_CMDFILE:-${def_gdb_cmdfile_prefix}.vppcom_server}"
52
53usage() {
54 cat <<EOF
55Usage: socket_test.sh OPTIONS TEST
56TESTS:
57 nk, native-kernel Run server & client on host using kernel.
58 nv, native-vcl Run vpp, server & client on host using VppComLib.
59 np, native-preload Run vpp, server & client on host using LD_PRELOAD.
60 dk, docker-kernel Run server & client in docker using kernel stack.
61 dv, docker-vcl Run vpp on host, server & client in docker using VppComLib.
62 dp, docker-preload Run vpp on host, server & client in docker using LD_PRELOAD.
63
64OPTIONS:
65 -h Print this usage text.
66 -l Leave ${tmp_cmdfile_prefix}* files after test run.
67 -b Run bash after application exit.
68 -d Run the vpp_debug version of all apps.
Dave Wallace774169b2017-11-01 20:07:40 -040069 -c Set VCL_CONFIG to use the vcl_test.conf file.
Dave Wallace543852a2017-08-03 02:11:34 -040070 -i Run iperf3 for client/server app in native tests.
Dave Wallace3d674492017-09-25 15:37:56 -040071 -n Name of ethernet for VPP to use in multi-host cfg.
72 -6 Use ipv6 addressing.
Dave Wallace3079a642017-09-06 01:59:43 -040073 -m c[lient] Run client in multi-host cfg (server on remote host)
74 s[erver] Run server in multi-host cfg (client on remote host)
Dave Wallace543852a2017-08-03 02:11:34 -040075 -e a[ll] Run all in emacs+gdb.
76 c[lient] Run client in emacs+gdb.
77 s[erver] Run server in emacs+gdb.
78 v[pp] Run vpp in emacs+gdb.
79 -g a[ll] Run all in gdb.
80 c[lient] Run client in gdb.
81 s[erver] Run server in gdb.
82 v[pp] Run vpp in gdb.
83 -t Use tabs in one xterm if available (e.g. xfce4-terminal).
84
85OPTIONS passed to client/server:
86 -S <ip address> Server IP address.
87 -P <server port> Server Port number.
88 -E <data> Run Echo test.
89 -N <num-writes> Test Cfg: number of writes.
90 -R <rxbuf-size> Test Cfg: rx buffer size.
91 -T <txbuf-size> Test Cfg: tx buffer size.
92 -U Run Uni-directional test.
93 -B Run Bi-directional test.
94 -I <num-tst-socks> Send data over multiple test sockets in parallel.
95 -V Test Cfg: Verbose mode.
96 -X Exit client/server after running test.
97
98Environment variables:
Dave Wallace8af20542017-10-26 03:29:30 -040099 VCL_CONFIG Pathname of vppcom configuration file.
Dave Wallace543852a2017-08-03 02:11:34 -0400100 VPP_GDB_CMDFILE Pathname of gdb command file for vpp.
101 VPPCOM_CLIENT_GDB_CMDFILE Pathname of gdb command file for client.
102 VPPCOM_SERVER_GDB_CMDFILE Pathname of gdb command file for server.
103EOF
104 exit 1
105}
106
107declare -i emacs_vpp=0
108declare -i emacs_client=0
109declare -i emacs_server=0
110declare -i gdb_vpp=0
111declare -i gdb_client=0
112declare -i gdb_server=0
113declare -i perf_vpp=0
114declare -i perf_client=0
115declare -i perf_server=0
116declare -i leave_tmp_files=0
117declare -i bash_after_exit=0
118declare -i iperf3=0
Dave Wallace3d674492017-09-25 15:37:56 -0400119declare -i use_ipv6=0
Dave Wallace543852a2017-08-03 02:11:34 -0400120
Dave Wallace3d674492017-09-25 15:37:56 -0400121while getopts ":hitlbcd6n:m:e:g:p:E:I:N:P:R:S:T:UBVX" opt; do
Dave Wallace543852a2017-08-03 02:11:34 -0400122 case $opt in
123 h) usage ;;
124 l) leave_tmp_files=1
125 ;;
126 b) bash_after_exit=1
127 ;;
128 i) iperf3=1
129 ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400130 6) use_ipv6=1
131 ;;
Dave Wallace543852a2017-08-03 02:11:34 -0400132 t) xterm_geom="180x40"
133 use_tabs="true"
134 ;;
Dave Wallace8af20542017-10-26 03:29:30 -0400135 c) VCL_CONFIG="${vcl_config_dir}vcl_test.conf"
Dave Wallace543852a2017-08-03 02:11:34 -0400136 ;;
137 d) title_dbg="-DEBUG"
138 vpp_dir=$vpp_debug_dir
139 lib64_dir=$lib64_debug_dir
140 ;;
141 e) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
142 emacs_client=1
143 emacs_server=1
144 emacs_vpp=1
145 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
146 emacs_client=1
147 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
148 emacs_server=1
149 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
150 emacs_vpp=1
151 else
152 echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2
153 usage
154 fi
155 title_dbg="-DEBUG"
156 vpp_dir=$vpp_debug_dir
157 lib64_dir=$lib64_debug_dir
158 ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400159 n) vpp_eth_name="$OPTARG"
160 ;;
Dave Wallace3079a642017-09-06 01:59:43 -0400161 m) if [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
162 multi_host="client"
163 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
164 multi_host="server"
165 else
166 echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2
167 usage
168 fi
169 ;;
Dave Wallace543852a2017-08-03 02:11:34 -0400170 g) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
171 gdb_client=1
172 gdb_server=1
173 gdb_vpp=1
174 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
175 gdb_client=1
176 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
177 gdb_server=1
178 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
179 gdb_vpp=1
180 else
181 echo "ERROR: Option -g unknown argument \'$OPTARG\'" >&2
182 usage
183 fi
184 title_dbg="-DEBUG"
185 vpp_dir=$vpp_debug_dir
186 lib64_dir=$lib64_debug_dir
187 ;;
188 p) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
189 perf_client=1
190 perf_server=1
191 perf_vpp=1
192 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
193 perf_client=1
194 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
195 perf_server=1
196 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
197 perf_vpp=1
198 else
199 echo "ERROR: Option -p unknown argument \'$OPTARG\'" >&2
200 usage
201 fi
202 echo "WARNING: -p options TBD"
203 ;;
204 S) sock_srvr_addr="$OPTARG"
205 ;;
206 P) sock_srvr_port="$OPTARG"
207 ;;
208E|I|N|R|T) sock_clnt_options="$sock_clnt_options -$opt \"$OPTARG\""
209 ;;
210 U|B|V|X) sock_clnt_options="$sock_clnt_options -$opt"
211 ;;
212 \?)
213 echo "ERROR: Invalid option: -$OPTARG" >&2
214 usage
215 ;;
216 :)
217 echo "ERROR: Option -$OPTARG requires an argument." >&2
218 usage
219 ;;
220 esac
221done
222
223shift $(( $OPTIND-1 ))
224while ! [[ $run_test ]] && (( $# > 0 )) ; do
225 case $1 in
226 "nk" | "native-kernel")
227 run_test="native_kernel" ;;
228 "np" | "native-preload")
229 run_test="native_preload" ;;
230 "nv" | "native-vcl")
231 sock_srvr_app="vcl_test_server"
232 sock_clnt_app="vcl_test_client"
233 run_test="native_vcl" ;;
234 "dk" | "docker-kernel")
235 run_test="docker_kernel" ;;
236 "dp" | "docker-preload")
237 run_test="docker_preload" ;;
238 "dv" | "docker-vcl")
239 sock_srvr_app="vcl_test_server"
240 sock_clnt_app="vcl_test_client"
241 run_test="docker_vcl" ;;
242 *)
243 echo "ERROR: Unknown option '$1'!" >&2
244 usage ;;
245 esac
246 shift
247done
248
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400249VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-$lib64_dir}"
250
Dave Wallace543852a2017-08-03 02:11:34 -0400251if [ -z "$WS_ROOT" ] ; then
252 echo "ERROR: WS_ROOT environment variable not set!" >&2
253 echo " Please set WS_ROOT to VPP workspace root directory." >&2
Dave Wallace3079a642017-09-06 01:59:43 -0400254 exit 1
Dave Wallace543852a2017-08-03 02:11:34 -0400255fi
256
Dave Wallace4f6c3a92017-10-24 15:39:44 -0400257if [[ "$(grep bin_PROGRAMS $WS_ROOT/src/vcl.am)" = "" ]] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400258 $WS_ROOT/extras/vagrant/vcl_test.sh $WS_ROOT $USER
259 (cd $WS_ROOT; make build)
260fi
261
Dave Wallace543852a2017-08-03 02:11:34 -0400262if [ ! -d $vpp_dir ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400263 echo "ERROR: Missing VPP$title_dbg bin directory!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400264 echo " $vpp_dir" >&2
265 env_test_failed="true"
266fi
267
268if [[ $run_test =~ .*"_preload" ]] ; then
269 if [ ! -d $lib64_dir ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400270 echo "ERROR: Missing VPP$title_dbg lib64 directory!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400271 echo " $lib64_dir" >&2
Dave Wallaced69f4f42017-08-14 18:26:46 -0400272 elif [ ! -d $VCL_LDPRELOAD_LIB_DIR ] ; then
273 echo "ERROR: Missing VCL LD_PRELOAD Library directory!" >&2
274 echo " $VCL_LDPRELOAD_LIB_DIR" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400275 env_test_failed="true"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400276 elif [ ! -f $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib ] ; then
277 echo "ERROR: Missing VCL LD_PRELOAD library!" >&2
278 echo " $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400279 env_test_failed="true"
280 fi
281fi
282
283if [ ! -f $vpp_dir$vpp_app ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400284 echo "ERROR: Missing VPP$title_dbg Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400285 echo " $vpp_dir$vpp_app" >&2
286 env_test_failed="true"
287fi
288
Dave Wallace30fb4a22017-08-17 16:22:04 -0400289if [ ! -f $vpp_dir$sock_srvr_app ] && [ ! $iperf3 -eq 1 ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400290 echo "ERROR: Missing$title_dbg Socket Server Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400291 echo " $vpp_dir$sock_srvr_app" >&2
292 env_test_failed="true"
293fi
294
Dave Wallace30fb4a22017-08-17 16:22:04 -0400295if [ ! -f $vpp_dir$sock_clnt_app ] && [ ! $iperf3 -eq 1 ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400296 echo "ERROR: Missing$title_dbg Socket Client Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400297 echo " $vpp_dir$sock_clnt_app" >&2
298 env_test_failed="true"
299fi
300
301if [[ $run_test =~ "docker_".* ]] ; then
302 if [ $emacs_client -eq 1 ] || [ $emacs_server -eq 1 ] || [ $gdb_client -eq 1 ] || [ $gdb_server -eq 1 ] ; then
303
304 echo "WARNING: gdb is not currently supported in docker."
305 echo " Ignoring client/server gdb options."
306 emacs_client=0
307 emacs_server=0
308 gdb_client=0
309 gdb_server=0
310 fi
311fi
312
Dave Wallace30fb4a22017-08-17 16:22:04 -0400313if [[ $run_test =~ .*"_vcl" ]] && [ $iperf3 -eq 1 ] ; then
314 echo "ERROR: Invalid option 'i' for test $run_test!"
315 echo " iperf3 is not compiled with the VCL library."
316 env_test_failed="true"
317fi
318
Dave Wallace19481612017-09-15 18:47:44 -0400319if [ -n "$mult_host"] && [ ! -f "$dpdk_devbind" ] ; then
320 echo "ERROR: Can't find dpdk-devbind.py!"
321 echo " Run \"cd \$WS_ROOT; make dpdk-install-dev\" to install it."
322 echo
323 env_test_failed="true"
324fi
325
Dave Wallace543852a2017-08-03 02:11:34 -0400326if [ -n "$env_test_failed" ] ; then
327 exit 1
328fi
329
Dave Wallace8af20542017-10-26 03:29:30 -0400330if [ -f "$VCL_CONFIG" ] ; then
331 vcl_config="$(basename $VCL_CONFIG)"
332 vcl_config_dir="$(dirname $VCL_CONFIG)/"
333 api_prefix="$(egrep -s '^\s*api-prefix \w+' $VCL_CONFIG | tail -1 | awk -e '{print $2}')"
Dave Wallace543852a2017-08-03 02:11:34 -0400334 if [ -n "$api_prefix" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400335 api_segment=" api-segment { gid $user_gid prefix $api_prefix }"
Dave Wallace543852a2017-08-03 02:11:34 -0400336 fi
337fi
Dave Wallace8af20542017-10-26 03:29:30 -0400338if [ -n "$VCL_APP_NAMESPACE_ID" ] && [ -n "$VCL_APP_NAMESPACE_SECRET" ] ; then
339 namespace_id="$VCL_APP_NAMESPACE_ID"
340 namespace_secret="$VCL_APP_NAMESPACE_SECRET"
341fi
342
Dave Wallace3079a642017-09-06 01:59:43 -0400343if [ -z "$api_segment" ] ; then
344 api_segment=" api-segment { gid $user_gid }"
345fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500346vpp_args="unix { interactive full-coredump coredump-size unlimited exec $tmp_vpp_exec_file}${api_segment}"
Dave Wallace543852a2017-08-03 02:11:34 -0400347
Dave Wallace30fb4a22017-08-17 16:22:04 -0400348if [ $iperf3 -eq 1 ] ; then
Dave Wallace543852a2017-08-03 02:11:34 -0400349 app_dir="$(dirname $(which iperf3))/"
350 srvr_app=$iperf_srvr_app
351 clnt_app=$iperf_clnt_app
Dave Wallace30fb4a22017-08-17 16:22:04 -0400352 if [[ $run_test =~ "docker_".* ]] ; then
353 unset -v app_dir
354 sock_srvr_port=5201
355 docker_app_dir="networkstatic/"
356 unset -v docker_os
357 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400358else
359 app_dir="$vpp_dir"
360 srvr_app="$sock_srvr_app $sock_srvr_port"
361 clnt_app="$sock_clnt_app${sock_clnt_options} \$srvr_addr $sock_srvr_port"
362fi
363
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400364
Dave Wallace543852a2017-08-03 02:11:34 -0400365verify_no_vpp() {
Dave Wallace3d674492017-09-25 15:37:56 -0400366 local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\""
367
368 if [ -n "$api_prefix" ] ; then
369 grep_for_vpp="$grep_for_vpp|grep \"prefix $api_prefix\""
370 fi
371 local running_vpp="$(eval $grep_for_vpp)"
372 if [ -n "$running_vpp" ] ; then
373 echo "ERROR: Please kill the following vpp instance(s):"
Dave Wallace543852a2017-08-03 02:11:34 -0400374 echo
Dave Wallace3d674492017-09-25 15:37:56 -0400375 echo $running_vpp
Dave Wallace543852a2017-08-03 02:11:34 -0400376 echo
377 exit 1
378 fi
379 clean_devshm="$vpp_shm_dir*db $vpp_shm_dir*global_vm $vpp_shm_dir*vpe-api $vpp_shm_dir[0-9]*-[0-9]* $vpp_shm_dir*:segment[0-9]*"
Dave Wallace3d674492017-09-25 15:37:56 -0400380 sudo rm -f $clean_devshm
Dave Wallace543852a2017-08-03 02:11:34 -0400381 devshm_files="$(ls -l $clean_devshm 2>/dev/null | grep $(whoami))"
382 if [ "$devshm_files" != "" ] ; then
383 echo "ERROR: Please remove the following $vpp_shm_dir files:"
384 for file in "$devshm_files" ; do
385 echo " $file"
386 done
387 exit 1
388 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400389 if [ ! -d "$vpp_run_dir" ] ; then
390 sudo mkdir $vpp_run_dir
391 sudo chown root:$USER $vpp_run_dir
392 fi
393 if [ -n "$multi_host" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400394 vpp_eth_pci_id="$(ls -ld /sys/class/net/$vpp_eth_name/device | awk '{print $11}' | cut -d/ -f4)"
395 if [ -z "$vpp_eth_pci_id" ] ; then
396 echo "ERROR: Missing ethernet interface $vpp_eth_name!"
397 usage
398 fi
399 printf -v bus "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f2)"
400 printf -v slot "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f3 | cut -d. -f1)"
401 printf -v func "%x" "0x$(echo $vpp_eth_pci_id | cut -d. -f2)"
402
403 vpp_eth_kernel_driver="$(basename $(ls -l /sys/bus/pci/devices/$vpp_eth_pci_id/driver | awk '{print $11}'))"
404 if [ -z "$vpp_eth_kernel_driver" ] ; then
405 echo "ERROR: Missing kernel driver for $vpp_eth_name!"
406 usage
407 fi
408 case $vpp_eth_kernel_driver in
409 e1000)
410 vpp_eth_ifname="GigabitEthernet$bus/$slot/$func" ;;
411 ixgbe)
412 vpp_eth_ifname="TenGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400413 i40e)
414 vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3079a642017-09-06 01:59:43 -0400415 *)
416 echo "ERROR: Unknown ethernet kernel driver $vpp_eth_kernel_driver!"
417 usage ;;
418 esac
419
420 vpp_eth_ip4_addr="$(ip -4 -br addr show $vpp_eth_name | awk '{print $3}')"
421 if [ -z "$vpp_eth_ip4_addr" ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400422 if [ "$multi_host" = "server" ] ; then
423 vpp_eth_ip4_addr="10.10.10.10/24"
424 else
425 vpp_eth_ip4_addr="10.10.10.11/24"
426 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400427 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400428 if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400429 echo "ERROR: No inet6 address configured for $vpp_eth_name!"
430 usage
431 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400432 vpp_args="$vpp_args plugins { path ${lib64_dir}vpp_plugins } dpdk { dev $vpp_eth_pci_id }"
Dave Wallace3079a642017-09-06 01:59:43 -0400433
Dave Wallace3d674492017-09-25 15:37:56 -0400434 sudo ifconfig $vpp_eth_name down 2> /dev/null
Dave Wallace3079a642017-09-06 01:59:43 -0400435 echo "Configuring VPP to use $vpp_eth_name ($vpp_eth_pci_id), inet addr $vpp_eth_ip4_addr"
436
437 cat <<EOF >> $tmp_vpp_exec_file
438set int state $vpp_eth_ifname up
439set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr
440EOF
441
442 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400443
444 if [ -n "$namespace_id" ] ; then
445 cat <<EOF >> $tmp_vpp_exec_file
446session enable
447app ns add id $namespace_id secret $namespace_secret sw_if_index 0
448EOF
449 fi
450
451 cat <<EOF >> $tmp_vpp_exec_file
452show version
453show version verbose
454show cpu
455show int
456EOF
Dave Wallace543852a2017-08-03 02:11:34 -0400457}
458
459verify_no_docker_containers() {
460 if (( $(which docker | wc -l) < 1 )) ; then
461 echo "ERROR: docker is not installed!"
462 echo "See https://docs.docker.com/engine/installation/linux/ubuntu/"
463 echo " or https://docs.docker.com/engine/installation/linux/centos/"
464 exit 1
465 fi
466 if (( $(docker ps | wc -l) > 1 )) ; then
467 echo "ERROR: Run the following to kill all docker containers:"
468 echo "docker kill \$(docker ps -q)"
469 echo
470 docker ps
471 exit 1
472 fi
473}
474
475set_pre_cmd() {
476 # arguments
477 # $1 : emacs flag
478 # $2 : gdb flag
479 # $3 : optional LD_PRELOAD library pathname
480 local -i emacs=$1
481 local -i gdb=$2
482
483 if [ $emacs -eq 1 ] ; then
484 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
485 pre_cmd="$gdb_in_emacs "
486 elif [ $gdb -eq 1 ] ; then
487 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
Dave Wallace4878cbe2017-11-21 03:45:09 -0500488 pre_cmd="gdb -x $tmp_gdb_cmdfile --args "
Dave Wallace543852a2017-08-03 02:11:34 -0400489 elif [ -z $3 ] ; then
490 unset -v pre_cmd
491 else
492 docker_ld_preload="-e LD_PRELOAD=$3 "
493 pre_cmd="LD_PRELOAD=$3 "
494 fi
495}
496
497write_script_header() {
498 # arguments
499 # $1 : command script file
500 # $2 : gdb command file
501 # $3 : title
502 # $4 : optional command string (typically "sleep 2")
503 echo "$bash_header" > $1
504 echo -e "#\n# $1 generated on $(date)\n#" >> $1
505 if [ $leave_tmp_files -eq 0 ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400506 if [ -n "$multi_host" ] ; then
507 echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file; sudo $dpdk_devbind -b $vpp_eth_kernel_driver $vpp_eth_pci_id; sudo ifconfig $vpp_eth_name up\" $trap_signals" >> $1
Dave Wallace3079a642017-09-06 01:59:43 -0400508 else
509 echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1
510 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400511 fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500512 if [ -n "$VCL_CONFIG" ] ; then
513 echo "export VCL_CONFIG=${vcl_config_dir}${vcl_config}" >> $1
514 fi
515 if [ -n "$VCL_DEBUG" ] ; then
516 echo "export VCL_DEBUG=$VCL_DEBUG" >> $1
517 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400518 if [ -n "$namespace_id" ] ; then
519 echo "export VCL_APP_NAMESPACE_ID=\"$namespace_id\"" >> $1
520 echo "export VCL_APP_NAMESPACE_SECRET=\"$namespace_secret\"" >> $1
521 fi
Dave Wallacee695cb42017-11-02 22:04:42 -0400522 if [ -n "$VCL_APP_SCOPE_LOCAL" ] || [ -z "$multi_host" ] ; then
Dave Wallace774169b2017-11-01 20:07:40 -0400523 echo "export VCL_APP_SCOPE_LOCAL=true" >> $1
Dave Wallace8af20542017-10-26 03:29:30 -0400524 fi
Dave Wallacee695cb42017-11-02 22:04:42 -0400525 if [ -n "$VCL_APP_SCOPE_GLOBAL" ] || [ -n "$multi_host" ] ; then
Dave Wallace774169b2017-11-01 20:07:40 -0400526 echo "export VCL_APP_SCOPE_GLOBAL=true" >> $1
527 fi
528 if [ -n "$VCL_APP_PROXY_TRANSPORT_TCP" ] ; then
529 echo "export VCL_APP_PROXY_TRANSPORT_TCP=true" >> $1
530 fi
531 if [ -n "$VCL_APP_PROXY_TRANSPORT_UDP" ] ; then
532 echo "export VCL_APP_PROXY_TRANSPORT_UDP=true" >> $1
Dave Wallace8af20542017-10-26 03:29:30 -0400533 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400534 if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400535 if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400536 cat <<EOF >> $1
537$gdb_in_emacs() {
538 sudo emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
539}
540EOF
541 else
542 cat <<EOF >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400543$gdb_in_emacs() {
544 emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
545}
546EOF
Dave Wallace3079a642017-09-06 01:59:43 -0400547 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400548 fi
549 if [ -n "$4" ] ; then
550 echo "$4" >> $1
551 fi
552}
553
554write_script_footer() {
555 # arguments
556 # $1 : command script file
557 # $2 : perf flag indicating to run bash before exit
558 local -i perf=$2
559 if [ $bash_after_exit -eq 1 ] || [ $perf -eq 1 ] ; then
560 echo "bash" >> $1
561 fi
562}
563
564write_gdb_cmdfile() {
565 # arguments
566 # $1 : gdb command file
567 # $2 : User specified gdb cmdfile
568 # $3 : emacs flag
569 # $4 : optional LD_PRELOAD library pathname.
570 local -i emacs=$3
571
572 echo "# $1 generated on $(date)" > $1
573 echo "#" >> $1
574 echo "set confirm off" >> $1
575 if [ -n "$4" ] ; then
576 echo "set exec-wrapper env LD_PRELOAD=$4" >> $1
Dave Wallace59179392017-11-07 02:20:07 -0500577 # echo "start" >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400578 fi
579
580 if [ ! -f $2 ] ; then
581 echo -n "# " >> $1
582 fi
583 echo "source $2" >> $1
584 if [ $emacs -eq 0 ] ; then
585 echo "run" >> $1
586 fi
587}
588
589native_kernel() {
590 banner="Running NATIVE-KERNEL socket test"
Dave Wallace3079a642017-09-06 01:59:43 -0400591 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
592 title1="SERVER$title_dbg (Native-Kernel Socket Test)"
593 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
594 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
595 set_pre_cmd $emacs_server $gdb_server
596 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
597 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd1_file
598 write_script_footer $cmd1_file $perf_server
599 chmod +x $cmd1_file
600 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400601
Dave Wallace3079a642017-09-06 01:59:43 -0400602 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
603 title2="CLIENT$title_dbg (Native-Kernel Socket Test)"
604 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
605 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
606 set_pre_cmd $emacs_client $gdb_client
607 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
608 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd2_file
609 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd2_file
610 write_script_footer $cmd2_file $perf_client
611 chmod +x $cmd2_file
Dave Wallace543852a2017-08-03 02:11:34 -0400612
Dave Wallace3079a642017-09-06 01:59:43 -0400613 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400614}
615
616native_preload() {
617 verify_no_vpp
618 banner="Running NATIVE-PRELOAD socket test"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400619 ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400620
621 title1="VPP$title_dbg (Native-Preload Socket Test)"
622 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
623 gdb_cmdfile=$VPP_GDB_CMDFILE
624 set_pre_cmd $emacs_vpp $gdb_vpp
625 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400626 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
627 echo -n "sudo " >> $cmd1_file
628 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400629 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
630 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400631 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400632
Dave Wallace3079a642017-09-06 01:59:43 -0400633 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
634 title2="SERVER$title_dbg (Native-Preload Socket Test)"
635 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
636 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
637 set_pre_cmd $emacs_server $gdb_server $ld_preload
638 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
639 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd2_file
640 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
641 write_script_footer $cmd2_file $perf_server
642 chmod +x $cmd2_file
643 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400644
Dave Wallace3079a642017-09-06 01:59:43 -0400645 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
646 title3="CLIENT$title_dbg (Native-Preload Socket Test)"
647 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
648 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
649 set_pre_cmd $emacs_client $gdb_client $ld_preload
Dave Wallace8af20542017-10-26 03:29:30 -0400650 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
Dave Wallace3079a642017-09-06 01:59:43 -0400651 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd3_file
652 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
653 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
654 write_script_footer $cmd3_file $perf_client
655 chmod +x $cmd3_file
656 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400657}
658
659native_vcl() {
660 verify_no_vpp
661 banner="Running NATIVE-VCL socket test"
662
663 title1="VPP$title_dbg (Native-VCL Socket Test)"
664 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
665 gdb_cmdfile=$VPP_GDB_CMDFILE
666 set_pre_cmd $emacs_vpp $gdb_vpp
667 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400668 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
669 echo -n "sudo " >> $cmd1_file
670 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400671 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
672 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400673 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400674
Dave Wallace3079a642017-09-06 01:59:43 -0400675 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
676 title2="SERVER$title_dbg (Native-VCL Socket Test)"
677 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
678 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
679 set_pre_cmd $emacs_server $gdb_server
Dave Wallace3d674492017-09-25 15:37:56 -0400680 if [ "$multi_host" = "server" ] ; then
681 delay="sleep 10"
682 else
Dave Wallacef7f809c2017-10-03 01:48:42 -0400683 delay="sleep 2"
Dave Wallace3d674492017-09-25 15:37:56 -0400684 fi
685 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400686 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd2_file
687 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
688 write_script_footer $cmd2_file $perf_server
689 chmod +x $cmd2_file
690 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400691
Dave Wallace3079a642017-09-06 01:59:43 -0400692 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
693 title3="CLIENT$title_dbg (Native-VCL Socket Test)"
694 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
695 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
696 set_pre_cmd $emacs_client $gdb_client
Dave Wallace3d674492017-09-25 15:37:56 -0400697 if [ "$multi_host" = "client" ] ; then
698 delay="sleep 10"
699 else
Dave Wallace8af20542017-10-26 03:29:30 -0400700 delay="sleep 4"
Dave Wallace3d674492017-09-25 15:37:56 -0400701 fi
702 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400703 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd3_file
704 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
705 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
706 write_script_footer $cmd3_file $perf_client
707 chmod +x $cmd3_file
708 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400709}
710
711docker_kernel() {
712 verify_no_docker_containers
713 banner="Running DOCKER-KERNEL socket test"
714
Dave Wallace3079a642017-09-06 01:59:43 -0400715 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
716 title1="SERVER$title_dbg (Docker-Native Socket Test)"
717 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
718 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
719 set_pre_cmd $emacs_server $gdb_server
720 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
721 echo "docker run -it --cpuset-cpus='4-7' --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir -p $sock_srvr_port:$sock_srvr_port $docker_os ${docker_app_dir}${srvr_app}" >> $cmd1_file
722 write_script_footer $cmd1_file $perf_server
723 chmod +x $cmd1_file
724 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400725
Dave Wallace3079a642017-09-06 01:59:43 -0400726 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
727 title2="CLIENT$title_dbg (Docker-Native Socket Test)"
728 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
729 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
730 set_pre_cmd $emacs_client $gdb_client
731 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
732 echo "$get_docker_server_ip4addr" >> $cmd2_file
733 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd2_file
734 write_script_footer $cmd2_file $perf_client
735 chmod +x $cmd2_file
736 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400737}
738
739docker_preload() {
740 verify_no_vpp
741 verify_no_docker_containers
742 banner="Running DOCKER-PRELOAD socket test"
Dave Wallace30fb4a22017-08-17 16:22:04 -0400743 docker_ld_preload_dir="/vcl-ldpreload/"
744 ld_preload_dir="$VCL_LDPRELOAD_LIB_DIR"
745 ld_preload="$docker_ld_preload_dir$vcl_ldpreload_lib "
746 docker_ld_preload_lib="$docker_ld_preload_dir$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400747
748 title1="VPP$title_dbg (Docker-Preload Socket Test)"
749 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
750 gdb_cmdfile=$VPP_GDB_CMDFILE
751 set_pre_cmd $emacs_vpp $gdb_vpp
752 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400753 if [ -n "$multi_host" ] ; then
754 echo -n "sudo " >> $cmd1_file
755 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400756 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
757 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400758 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400759
Dave Wallace3079a642017-09-06 01:59:43 -0400760 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
761 title2="SERVER$title_dbg (Docker-Preload Socket Test)"
762 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
763 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
764 set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib
765 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
Dave Wallace8af20542017-10-26 03:29:30 -0400766 echo "docker run -it -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $ld_preload_dir:$docker_ld_preload_dir -v $vcl_config_dir:$docker_vcl_config_dir -p $sock_srvr_port:$sock_srvr_port -e VCL_CONFIG=${docker_vcl_config_dir}$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir:$docker_ld_preload_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file
Dave Wallace3079a642017-09-06 01:59:43 -0400767 write_script_footer $cmd2_file $perf_server
768 chmod +x $cmd2_file
769 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400770
Dave Wallace3079a642017-09-06 01:59:43 -0400771 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
772 title3="CLIENT$title_dbg (Docker-Preload Socket Test)"
773 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
774 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
775 set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib
Dave Wallace8af20542017-10-26 03:29:30 -0400776 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
Dave Wallace3079a642017-09-06 01:59:43 -0400777 echo "$get_docker_server_ip4addr" >> $cmd3_file
Dave Wallace8af20542017-10-26 03:29:30 -0400778 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $ld_preload_dir:$docker_ld_preload_dir -v $vcl_config_dir:$docker_vcl_config_dir -e VCL_CONFIG=${docker_vcl_config_dir}$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file
Dave Wallace3079a642017-09-06 01:59:43 -0400779 write_script_footer $cmd3_file $perf_client
780 chmod +x $cmd3_file
781 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400782}
783
784docker_vcl() {
785 verify_no_vpp
786 verify_no_docker_containers
787 banner="Running DOCKER-VCL socket test"
788
789 title1="VPP$title_dbg (Docker-VCL Socket Test)"
790 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
791 gdb_cmdfile=$VPP_GDB_CMDFILE
792 set_pre_cmd $emacs_vpp $gdb_vpp
793 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400794 if [ -n "$multi_host" ] ; then
795 echo -n "sudo " >> $cmd1_file
796 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400797 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
798 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400799 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400800
Dave Wallace3079a642017-09-06 01:59:43 -0400801 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
802 title2="SERVER$title_dbg (Docker-VCL Socket Test)"
803 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
804 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
805 set_pre_cmd $emacs_server $gdb_server
806 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
Dave Wallace8af20542017-10-26 03:29:30 -0400807 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $vcl_config_dir:$docker_vcl_config_dir -p $sock_srvr_port:$sock_srvr_port -e VCL_CONFIG=${docker_vcl_config_dir}/$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir $docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file
Dave Wallace3079a642017-09-06 01:59:43 -0400808 write_script_footer $cmd2_file $perf_server
809 chmod +x $cmd2_file
810 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400811
Dave Wallace3079a642017-09-06 01:59:43 -0400812 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
813 title3="CLIENT$title_dbg (Docker-VCL Socket Test)"
814 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
815 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
816 set_pre_cmd $emacs_client $gdb_client
817 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3"
818 echo "$get_docker_server_ip4addr" >> $cmd3_file
Dave Wallace8af20542017-10-26 03:29:30 -0400819 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $vcl_config_dir:$docker_vcl_config_dir -e VCL_CONFIG=${docker_vcl_config_dir}/$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file
Dave Wallace3079a642017-09-06 01:59:43 -0400820 write_script_footer $cmd3_file $perf_client
821 chmod +x $cmd3_file
822 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400823}
824
825if [[ $run_test ]] ; then
826 eval $run_test
827else
828 echo "ERROR: Please specify a test to run!" >&2
829 usage;
830fi
831
832if (( $(which xfce4-terminal | wc -l) > 0 )) ; then
833 xterm_cmd="xfce4-terminal --geometry $xterm_geom"
834 if [[ $use_tabs ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400835 declare -a tab_cmd_files
836 declare -a tab_titles
837 declare -i i=0
838
839 if [ -x "$cmd1_file" ] ; then
840 tab_cmd_files[$i]="$cmd1_file"
841 tab_titles[$i]="$title1"
842 (( i++ ))
Dave Wallace543852a2017-08-03 02:11:34 -0400843 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400844 if [ -x "$cmd2_file" ] ; then
845 tab_cmd_files[$i]="$cmd2_file"
846 tab_titles[$i]="$title2"
847 (( i++ ))
848 fi
849 if [ -x "$cmd3_file" ] ; then
850 tab_cmd_files[$i]="$cmd3_file"
851 tab_titles[$i]="$title3"
852 fi
853
854 if [ -n "${tab_cmd_files[2]}" ] ; then
855 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}" --tab --title "${tab_titles[2]}" --command "${tab_cmd_files[2]}"
856 elif [ -n "${tab_cmd_files[1]}" ] ; then
857 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}"
858
859 else
860 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}"
861 fi
862
Dave Wallace543852a2017-08-03 02:11:34 -0400863 else
Dave Wallace3079a642017-09-06 01:59:43 -0400864 if [ -x "$cmd1_file" ] ; then
865 ($xterm_cmd --title "$title1" --command "$cmd1_file" &)
866 fi
867 if [ -x "$cmd2_file" ] ; then
868 ($xterm_cmd --title "$title2" --command "$cmd2_file" &)
869 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400870 if [ -x "$cmd3_file" ] ; then
871 ($xterm_cmd --title "$title3" --command "$cmd3_file" &)
872 fi
873 fi
874
875else
876 if [[ $use_tabs ]] ; then
877 echo "Sorry, plain ol' xterm doesn't support tabs."
878 fi
879 xterm_cmd="xterm -fs 10 -geometry $xterm_geom"
Dave Wallace3079a642017-09-06 01:59:43 -0400880 if [ -x "$cmd1_file" ] ; then
881 ($xterm_cmd -title "$title1" -e "$cmd1_file" &)
882 fi
883 if [ -x "$cmd2_file" ] ; then
884 ($xterm_cmd -title "$title2" -e "$cmd2_file" &)
885 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400886 if [ -x "$cmd3_file" ] ; then
887 ($xterm_cmd -title "$title3" -e "$cmd3_file" &)
888 fi
889fi
890
891sleep 1