blob: aab1d6c1b4f2603d98546f4c91ccfef3adb0f328 [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 Wallacefbbb07c2018-03-08 11:35:03 -050073 -f Full thru host stack vpp configuration.
Dave Wallace3079a642017-09-06 01:59:43 -040074 -m c[lient] Run client in multi-host cfg (server on remote host)
75 s[erver] Run server in multi-host cfg (client on remote host)
Dave Wallace543852a2017-08-03 02:11:34 -040076 -e a[ll] Run all in emacs+gdb.
77 c[lient] Run client in emacs+gdb.
78 s[erver] Run server in emacs+gdb.
79 v[pp] Run vpp in emacs+gdb.
80 -g a[ll] Run all in gdb.
81 c[lient] Run client in gdb.
82 s[erver] Run server in gdb.
83 v[pp] Run vpp in gdb.
84 -t Use tabs in one xterm if available (e.g. xfce4-terminal).
85
86OPTIONS passed to client/server:
87 -S <ip address> Server IP address.
88 -P <server port> Server Port number.
89 -E <data> Run Echo test.
90 -N <num-writes> Test Cfg: number of writes.
91 -R <rxbuf-size> Test Cfg: rx buffer size.
92 -T <txbuf-size> Test Cfg: tx buffer size.
93 -U Run Uni-directional test.
94 -B Run Bi-directional test.
95 -I <num-tst-socks> Send data over multiple test sockets in parallel.
96 -V Test Cfg: Verbose mode.
97 -X Exit client/server after running test.
98
99Environment variables:
Dave Wallace8af20542017-10-26 03:29:30 -0400100 VCL_CONFIG Pathname of vppcom configuration file.
Dave Wallace543852a2017-08-03 02:11:34 -0400101 VPP_GDB_CMDFILE Pathname of gdb command file for vpp.
102 VPPCOM_CLIENT_GDB_CMDFILE Pathname of gdb command file for client.
103 VPPCOM_SERVER_GDB_CMDFILE Pathname of gdb command file for server.
104EOF
105 exit 1
106}
107
108declare -i emacs_vpp=0
109declare -i emacs_client=0
110declare -i emacs_server=0
111declare -i gdb_vpp=0
112declare -i gdb_client=0
113declare -i gdb_server=0
114declare -i perf_vpp=0
115declare -i perf_client=0
116declare -i perf_server=0
117declare -i leave_tmp_files=0
118declare -i bash_after_exit=0
119declare -i iperf3=0
Dave Wallace3d674492017-09-25 15:37:56 -0400120declare -i use_ipv6=0
Dave Wallace543852a2017-08-03 02:11:34 -0400121
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500122while getopts ":hitlbcd6fn:m:e:g:p:E:I:N:P:R:S:T:UBVX" opt; do
Dave Wallace543852a2017-08-03 02:11:34 -0400123 case $opt in
124 h) usage ;;
125 l) leave_tmp_files=1
126 ;;
127 b) bash_after_exit=1
128 ;;
129 i) iperf3=1
130 ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400131 6) use_ipv6=1
132 ;;
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500133 f) full_thru_host_stack_vpp_cfg=1
134 ;;
Dave Wallace543852a2017-08-03 02:11:34 -0400135 t) xterm_geom="180x40"
136 use_tabs="true"
137 ;;
Dave Wallace8af20542017-10-26 03:29:30 -0400138 c) VCL_CONFIG="${vcl_config_dir}vcl_test.conf"
Dave Wallace543852a2017-08-03 02:11:34 -0400139 ;;
140 d) title_dbg="-DEBUG"
141 vpp_dir=$vpp_debug_dir
142 lib64_dir=$lib64_debug_dir
143 ;;
144 e) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
145 emacs_client=1
146 emacs_server=1
147 emacs_vpp=1
148 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
149 emacs_client=1
150 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
151 emacs_server=1
152 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
153 emacs_vpp=1
154 else
155 echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2
156 usage
157 fi
158 title_dbg="-DEBUG"
159 vpp_dir=$vpp_debug_dir
160 lib64_dir=$lib64_debug_dir
161 ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400162 n) vpp_eth_name="$OPTARG"
163 ;;
Dave Wallace3079a642017-09-06 01:59:43 -0400164 m) if [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
165 multi_host="client"
166 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
167 multi_host="server"
168 else
169 echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2
170 usage
171 fi
172 ;;
Dave Wallace543852a2017-08-03 02:11:34 -0400173 g) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
174 gdb_client=1
175 gdb_server=1
176 gdb_vpp=1
177 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
178 gdb_client=1
179 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
180 gdb_server=1
181 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
182 gdb_vpp=1
183 else
184 echo "ERROR: Option -g unknown argument \'$OPTARG\'" >&2
185 usage
186 fi
187 title_dbg="-DEBUG"
188 vpp_dir=$vpp_debug_dir
189 lib64_dir=$lib64_debug_dir
190 ;;
191 p) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
192 perf_client=1
193 perf_server=1
194 perf_vpp=1
195 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
196 perf_client=1
197 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
198 perf_server=1
199 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
200 perf_vpp=1
201 else
202 echo "ERROR: Option -p unknown argument \'$OPTARG\'" >&2
203 usage
204 fi
205 echo "WARNING: -p options TBD"
206 ;;
207 S) sock_srvr_addr="$OPTARG"
208 ;;
209 P) sock_srvr_port="$OPTARG"
210 ;;
211E|I|N|R|T) sock_clnt_options="$sock_clnt_options -$opt \"$OPTARG\""
212 ;;
213 U|B|V|X) sock_clnt_options="$sock_clnt_options -$opt"
214 ;;
215 \?)
216 echo "ERROR: Invalid option: -$OPTARG" >&2
217 usage
218 ;;
219 :)
220 echo "ERROR: Option -$OPTARG requires an argument." >&2
221 usage
222 ;;
223 esac
224done
225
226shift $(( $OPTIND-1 ))
227while ! [[ $run_test ]] && (( $# > 0 )) ; do
228 case $1 in
229 "nk" | "native-kernel")
230 run_test="native_kernel" ;;
231 "np" | "native-preload")
232 run_test="native_preload" ;;
233 "nv" | "native-vcl")
234 sock_srvr_app="vcl_test_server"
235 sock_clnt_app="vcl_test_client"
236 run_test="native_vcl" ;;
237 "dk" | "docker-kernel")
238 run_test="docker_kernel" ;;
239 "dp" | "docker-preload")
240 run_test="docker_preload" ;;
241 "dv" | "docker-vcl")
242 sock_srvr_app="vcl_test_server"
243 sock_clnt_app="vcl_test_client"
244 run_test="docker_vcl" ;;
245 *)
246 echo "ERROR: Unknown option '$1'!" >&2
247 usage ;;
248 esac
249 shift
250done
251
Dave Wallaceee45d412017-11-24 21:44:06 -0500252if [ -z "$VCL_DEBUG" ] ; then
253 if [ "$title_dbg" = "-DEBUG" ] ; then
254 VCL_DEBUG=1
255 else
256 VCL_DEBUG=0
257 fi
258fi
259
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400260VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-$lib64_dir}"
261
Dave Wallace543852a2017-08-03 02:11:34 -0400262if [ -z "$WS_ROOT" ] ; then
263 echo "ERROR: WS_ROOT environment variable not set!" >&2
264 echo " Please set WS_ROOT to VPP workspace root directory." >&2
Dave Wallace3079a642017-09-06 01:59:43 -0400265 exit 1
Dave Wallace543852a2017-08-03 02:11:34 -0400266fi
267
Dave Wallace4f6c3a92017-10-24 15:39:44 -0400268if [[ "$(grep bin_PROGRAMS $WS_ROOT/src/vcl.am)" = "" ]] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400269 $WS_ROOT/extras/vagrant/vcl_test.sh $WS_ROOT $USER
270 (cd $WS_ROOT; make build)
271fi
272
Dave Wallace543852a2017-08-03 02:11:34 -0400273if [ ! -d $vpp_dir ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400274 echo "ERROR: Missing VPP$title_dbg bin directory!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400275 echo " $vpp_dir" >&2
276 env_test_failed="true"
277fi
278
279if [[ $run_test =~ .*"_preload" ]] ; then
280 if [ ! -d $lib64_dir ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400281 echo "ERROR: Missing VPP$title_dbg lib64 directory!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400282 echo " $lib64_dir" >&2
Dave Wallaced69f4f42017-08-14 18:26:46 -0400283 elif [ ! -d $VCL_LDPRELOAD_LIB_DIR ] ; then
284 echo "ERROR: Missing VCL LD_PRELOAD Library directory!" >&2
285 echo " $VCL_LDPRELOAD_LIB_DIR" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400286 env_test_failed="true"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400287 elif [ ! -f $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib ] ; then
288 echo "ERROR: Missing VCL LD_PRELOAD library!" >&2
289 echo " $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400290 env_test_failed="true"
291 fi
292fi
293
294if [ ! -f $vpp_dir$vpp_app ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400295 echo "ERROR: Missing VPP$title_dbg Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400296 echo " $vpp_dir$vpp_app" >&2
297 env_test_failed="true"
298fi
299
Dave Wallace30fb4a22017-08-17 16:22:04 -0400300if [ ! -f $vpp_dir$sock_srvr_app ] && [ ! $iperf3 -eq 1 ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400301 echo "ERROR: Missing$title_dbg Socket Server Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400302 echo " $vpp_dir$sock_srvr_app" >&2
303 env_test_failed="true"
304fi
305
Dave Wallace30fb4a22017-08-17 16:22:04 -0400306if [ ! -f $vpp_dir$sock_clnt_app ] && [ ! $iperf3 -eq 1 ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400307 echo "ERROR: Missing$title_dbg Socket Client Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400308 echo " $vpp_dir$sock_clnt_app" >&2
309 env_test_failed="true"
310fi
311
312if [[ $run_test =~ "docker_".* ]] ; then
313 if [ $emacs_client -eq 1 ] || [ $emacs_server -eq 1 ] || [ $gdb_client -eq 1 ] || [ $gdb_server -eq 1 ] ; then
314
315 echo "WARNING: gdb is not currently supported in docker."
316 echo " Ignoring client/server gdb options."
317 emacs_client=0
318 emacs_server=0
319 gdb_client=0
320 gdb_server=0
321 fi
322fi
323
Dave Wallace30fb4a22017-08-17 16:22:04 -0400324if [[ $run_test =~ .*"_vcl" ]] && [ $iperf3 -eq 1 ] ; then
325 echo "ERROR: Invalid option 'i' for test $run_test!"
326 echo " iperf3 is not compiled with the VCL library."
327 env_test_failed="true"
328fi
329
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500330if [ -n "$multi_host"] && [ ! -f "$dpdk_devbind" ] ; then
Dave Wallace19481612017-09-15 18:47:44 -0400331 echo "ERROR: Can't find dpdk-devbind.py!"
332 echo " Run \"cd \$WS_ROOT; make dpdk-install-dev\" to install it."
333 echo
334 env_test_failed="true"
335fi
336
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500337if [ -n "$full_thru_host_stack_vpp_cfg" ] && [ -n "$multi_host" ] ; then
338 echo "ERROR: Invalid options, cannot specify both \"-f\" and \"-m $multi_host\"!"
339 echo
340 env_test_failed="true"
341fi
342
Dave Wallace543852a2017-08-03 02:11:34 -0400343if [ -n "$env_test_failed" ] ; then
344 exit 1
345fi
346
Dave Wallace8af20542017-10-26 03:29:30 -0400347if [ -f "$VCL_CONFIG" ] ; then
348 vcl_config="$(basename $VCL_CONFIG)"
349 vcl_config_dir="$(dirname $VCL_CONFIG)/"
350 api_prefix="$(egrep -s '^\s*api-prefix \w+' $VCL_CONFIG | tail -1 | awk -e '{print $2}')"
Dave Wallace543852a2017-08-03 02:11:34 -0400351 if [ -n "$api_prefix" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400352 api_segment=" api-segment { gid $user_gid prefix $api_prefix }"
Dave Wallace543852a2017-08-03 02:11:34 -0400353 fi
354fi
Dave Wallace8af20542017-10-26 03:29:30 -0400355if [ -n "$VCL_APP_NAMESPACE_ID" ] && [ -n "$VCL_APP_NAMESPACE_SECRET" ] ; then
356 namespace_id="$VCL_APP_NAMESPACE_ID"
357 namespace_secret="$VCL_APP_NAMESPACE_SECRET"
358fi
359
Dave Wallace3079a642017-09-06 01:59:43 -0400360if [ -z "$api_segment" ] ; then
361 api_segment=" api-segment { gid $user_gid }"
362fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500363vpp_args="unix { interactive full-coredump coredump-size unlimited exec $tmp_vpp_exec_file}${api_segment}"
Dave Wallace543852a2017-08-03 02:11:34 -0400364
Dave Wallace30fb4a22017-08-17 16:22:04 -0400365if [ $iperf3 -eq 1 ] ; then
Dave Wallace543852a2017-08-03 02:11:34 -0400366 app_dir="$(dirname $(which iperf3))/"
367 srvr_app=$iperf_srvr_app
368 clnt_app=$iperf_clnt_app
Dave Wallace30fb4a22017-08-17 16:22:04 -0400369 if [[ $run_test =~ "docker_".* ]] ; then
370 unset -v app_dir
371 sock_srvr_port=5201
372 docker_app_dir="networkstatic/"
373 unset -v docker_os
374 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400375else
376 app_dir="$vpp_dir"
377 srvr_app="$sock_srvr_app $sock_srvr_port"
378 clnt_app="$sock_clnt_app${sock_clnt_options} \$srvr_addr $sock_srvr_port"
379fi
380
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400381
Dave Wallace543852a2017-08-03 02:11:34 -0400382verify_no_vpp() {
Dave Wallace3d674492017-09-25 15:37:56 -0400383 local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\""
384
385 if [ -n "$api_prefix" ] ; then
386 grep_for_vpp="$grep_for_vpp|grep \"prefix $api_prefix\""
387 fi
388 local running_vpp="$(eval $grep_for_vpp)"
389 if [ -n "$running_vpp" ] ; then
390 echo "ERROR: Please kill the following vpp instance(s):"
Dave Wallace543852a2017-08-03 02:11:34 -0400391 echo
Dave Wallace3d674492017-09-25 15:37:56 -0400392 echo $running_vpp
Dave Wallace543852a2017-08-03 02:11:34 -0400393 echo
394 exit 1
395 fi
396 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 -0400397 sudo rm -f $clean_devshm
Dave Wallace543852a2017-08-03 02:11:34 -0400398 devshm_files="$(ls -l $clean_devshm 2>/dev/null | grep $(whoami))"
399 if [ "$devshm_files" != "" ] ; then
400 echo "ERROR: Please remove the following $vpp_shm_dir files:"
401 for file in "$devshm_files" ; do
402 echo " $file"
403 done
404 exit 1
405 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400406 if [ ! -d "$vpp_run_dir" ] ; then
407 sudo mkdir $vpp_run_dir
408 sudo chown root:$USER $vpp_run_dir
409 fi
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500410 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
411 sock_srvr_addr=172.16.1.1
412 client_namespace_id="1"
413 client_namespace_secret="5678"
414 server_namespace_id="0"
415 server_namespace_secret="1234"
416 cat <<EOF >> $tmp_vpp_exec_file
417session enable
418create loop inter
419create loop inter
420set inter state loop0 up
421set inter ip table loop0 0
422set inter ip address loop0 172.16.1.1/24
423set inter state loop1 up
424set inter ip table loop1 1
425set inter ip address loop1 172.16.2.1/24
426app ns add id 0 secret 1234 sw_if_index 1
427app ns add id 1 secret 5678 sw_if_index 2
428ip route add 172.16.1.1/32 table 1 via lookup in table 0
429ip route add 172.16.2.1/32 table 0 via lookup in table 1
430EOF
431
432 elif [ -n "$multi_host" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400433 vpp_eth_pci_id="$(ls -ld /sys/class/net/$vpp_eth_name/device | awk '{print $11}' | cut -d/ -f4)"
434 if [ -z "$vpp_eth_pci_id" ] ; then
435 echo "ERROR: Missing ethernet interface $vpp_eth_name!"
436 usage
437 fi
438 printf -v bus "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f2)"
439 printf -v slot "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f3 | cut -d. -f1)"
440 printf -v func "%x" "0x$(echo $vpp_eth_pci_id | cut -d. -f2)"
441
442 vpp_eth_kernel_driver="$(basename $(ls -l /sys/bus/pci/devices/$vpp_eth_pci_id/driver | awk '{print $11}'))"
443 if [ -z "$vpp_eth_kernel_driver" ] ; then
444 echo "ERROR: Missing kernel driver for $vpp_eth_name!"
445 usage
446 fi
447 case $vpp_eth_kernel_driver in
448 e1000)
449 vpp_eth_ifname="GigabitEthernet$bus/$slot/$func" ;;
450 ixgbe)
451 vpp_eth_ifname="TenGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400452 i40e)
453 vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3079a642017-09-06 01:59:43 -0400454 *)
455 echo "ERROR: Unknown ethernet kernel driver $vpp_eth_kernel_driver!"
456 usage ;;
457 esac
458
459 vpp_eth_ip4_addr="$(ip -4 -br addr show $vpp_eth_name | awk '{print $3}')"
460 if [ -z "$vpp_eth_ip4_addr" ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400461 if [ "$multi_host" = "server" ] ; then
462 vpp_eth_ip4_addr="10.10.10.10/24"
463 else
464 vpp_eth_ip4_addr="10.10.10.11/24"
465 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400466 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400467 if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400468 echo "ERROR: No inet6 address configured for $vpp_eth_name!"
469 usage
470 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400471 vpp_args="$vpp_args plugins { path ${lib64_dir}vpp_plugins } dpdk { dev $vpp_eth_pci_id }"
Dave Wallace3079a642017-09-06 01:59:43 -0400472
Dave Wallace3d674492017-09-25 15:37:56 -0400473 sudo ifconfig $vpp_eth_name down 2> /dev/null
Dave Wallace3079a642017-09-06 01:59:43 -0400474 echo "Configuring VPP to use $vpp_eth_name ($vpp_eth_pci_id), inet addr $vpp_eth_ip4_addr"
475
476 cat <<EOF >> $tmp_vpp_exec_file
477set int state $vpp_eth_ifname up
478set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr
479EOF
480
481 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400482
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500483 if [ -z "$full_thru_host_stack_vpp_cfg" ] && [ -n "$namespace_id" ] ; then
Dave Wallace8af20542017-10-26 03:29:30 -0400484 cat <<EOF >> $tmp_vpp_exec_file
485session enable
486app ns add id $namespace_id secret $namespace_secret sw_if_index 0
487EOF
488 fi
489
490 cat <<EOF >> $tmp_vpp_exec_file
491show version
492show version verbose
493show cpu
494show int
495EOF
Dave Wallace543852a2017-08-03 02:11:34 -0400496}
497
498verify_no_docker_containers() {
499 if (( $(which docker | wc -l) < 1 )) ; then
500 echo "ERROR: docker is not installed!"
501 echo "See https://docs.docker.com/engine/installation/linux/ubuntu/"
502 echo " or https://docs.docker.com/engine/installation/linux/centos/"
503 exit 1
504 fi
505 if (( $(docker ps | wc -l) > 1 )) ; then
506 echo "ERROR: Run the following to kill all docker containers:"
507 echo "docker kill \$(docker ps -q)"
508 echo
509 docker ps
510 exit 1
511 fi
512}
513
514set_pre_cmd() {
515 # arguments
516 # $1 : emacs flag
517 # $2 : gdb flag
518 # $3 : optional LD_PRELOAD library pathname
519 local -i emacs=$1
520 local -i gdb=$2
521
522 if [ $emacs -eq 1 ] ; then
523 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
524 pre_cmd="$gdb_in_emacs "
525 elif [ $gdb -eq 1 ] ; then
526 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
Dave Wallace4878cbe2017-11-21 03:45:09 -0500527 pre_cmd="gdb -x $tmp_gdb_cmdfile --args "
Dave Wallace543852a2017-08-03 02:11:34 -0400528 elif [ -z $3 ] ; then
529 unset -v pre_cmd
530 else
531 docker_ld_preload="-e LD_PRELOAD=$3 "
532 pre_cmd="LD_PRELOAD=$3 "
533 fi
534}
535
536write_script_header() {
537 # arguments
538 # $1 : command script file
539 # $2 : gdb command file
540 # $3 : title
541 # $4 : optional command string (typically "sleep 2")
542 echo "$bash_header" > $1
543 echo -e "#\n# $1 generated on $(date)\n#" >> $1
544 if [ $leave_tmp_files -eq 0 ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400545 if [ -n "$multi_host" ] ; then
546 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 -0400547 else
548 echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1
549 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400550 fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500551 if [ -n "$VCL_CONFIG" ] ; then
552 echo "export VCL_CONFIG=${vcl_config_dir}${vcl_config}" >> $1
553 fi
Dave Wallaceb5a86ee2018-02-16 18:26:11 -0500554 if [ -n "$VCL_API_PREFIX" ] ; then
555 echo "export VCL_API_PREFIX=$VCL_API_PREFIX" >> $1
556 fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500557 if [ -n "$VCL_DEBUG" ] ; then
558 echo "export VCL_DEBUG=$VCL_DEBUG" >> $1
559 fi
Dave Wallace3ee1fe12018-02-23 01:09:11 -0500560 if [ -n "$LDP_DEBUG" ] ; then
561 echo "export LDP_DEBUG=$LDP_DEBUG" >> $1
Dave Wallace048b1d62018-01-03 22:24:41 -0500562 fi
563 if [ -n "$VCOM_APP_NAME" ] ; then
564 echo "export VCOM_APP_NAME=$VCOM_APP_NAME" >> $1
565 fi
566 if [ -n "$VCOM_SID_BIT" ] ; then
567 echo "export VCOM_SID_BIT=$VCOM_SID_BIT" >> $1
568 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400569 if [ -n "$namespace_id" ] ; then
570 echo "export VCL_APP_NAMESPACE_ID=\"$namespace_id\"" >> $1
571 echo "export VCL_APP_NAMESPACE_SECRET=\"$namespace_secret\"" >> $1
572 fi
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500573 if [ -n "$VCL_APP_SCOPE_LOCAL" ] || [ -z "$multi_host" ] &&
574 [ -z "$full_thru_host_stack_vpp_cfg" ] ; then
Dave Wallace774169b2017-11-01 20:07:40 -0400575 echo "export VCL_APP_SCOPE_LOCAL=true" >> $1
Dave Wallace8af20542017-10-26 03:29:30 -0400576 fi
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500577 if [ -n "$VCL_APP_SCOPE_GLOBAL" ] || [ -n "$multi_host" ] ||
578 [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
Dave Wallace774169b2017-11-01 20:07:40 -0400579 echo "export VCL_APP_SCOPE_GLOBAL=true" >> $1
580 fi
581 if [ -n "$VCL_APP_PROXY_TRANSPORT_TCP" ] ; then
582 echo "export VCL_APP_PROXY_TRANSPORT_TCP=true" >> $1
583 fi
584 if [ -n "$VCL_APP_PROXY_TRANSPORT_UDP" ] ; then
585 echo "export VCL_APP_PROXY_TRANSPORT_UDP=true" >> $1
Dave Wallace8af20542017-10-26 03:29:30 -0400586 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400587 if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400588 if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400589 cat <<EOF >> $1
590$gdb_in_emacs() {
591 sudo emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
592}
593EOF
594 else
595 cat <<EOF >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400596$gdb_in_emacs() {
597 emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
598}
599EOF
Dave Wallace3079a642017-09-06 01:59:43 -0400600 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400601 fi
602 if [ -n "$4" ] ; then
603 echo "$4" >> $1
604 fi
605}
606
607write_script_footer() {
608 # arguments
609 # $1 : command script file
610 # $2 : perf flag indicating to run bash before exit
611 local -i perf=$2
612 if [ $bash_after_exit -eq 1 ] || [ $perf -eq 1 ] ; then
613 echo "bash" >> $1
614 fi
615}
616
617write_gdb_cmdfile() {
618 # arguments
619 # $1 : gdb command file
620 # $2 : User specified gdb cmdfile
621 # $3 : emacs flag
622 # $4 : optional LD_PRELOAD library pathname.
623 local -i emacs=$3
624
625 echo "# $1 generated on $(date)" > $1
626 echo "#" >> $1
627 echo "set confirm off" >> $1
628 if [ -n "$4" ] ; then
629 echo "set exec-wrapper env LD_PRELOAD=$4" >> $1
Dave Wallace59179392017-11-07 02:20:07 -0500630 # echo "start" >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400631 fi
632
633 if [ ! -f $2 ] ; then
634 echo -n "# " >> $1
635 fi
636 echo "source $2" >> $1
637 if [ $emacs -eq 0 ] ; then
638 echo "run" >> $1
639 fi
640}
641
642native_kernel() {
643 banner="Running NATIVE-KERNEL socket test"
Dave Wallace3079a642017-09-06 01:59:43 -0400644 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
645 title1="SERVER$title_dbg (Native-Kernel Socket Test)"
646 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
647 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
648 set_pre_cmd $emacs_server $gdb_server
649 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
650 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd1_file
651 write_script_footer $cmd1_file $perf_server
652 chmod +x $cmd1_file
653 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400654
Dave Wallace3079a642017-09-06 01:59:43 -0400655 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
656 title2="CLIENT$title_dbg (Native-Kernel Socket Test)"
657 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
658 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
659 set_pre_cmd $emacs_client $gdb_client
660 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
661 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd2_file
662 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd2_file
663 write_script_footer $cmd2_file $perf_client
664 chmod +x $cmd2_file
Dave Wallace543852a2017-08-03 02:11:34 -0400665
Dave Wallace3079a642017-09-06 01:59:43 -0400666 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400667}
668
669native_preload() {
670 verify_no_vpp
671 banner="Running NATIVE-PRELOAD socket test"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400672 ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400673
674 title1="VPP$title_dbg (Native-Preload Socket Test)"
675 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
676 gdb_cmdfile=$VPP_GDB_CMDFILE
677 set_pre_cmd $emacs_vpp $gdb_vpp
678 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400679 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
680 echo -n "sudo " >> $cmd1_file
681 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400682 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
683 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400684 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400685
Dave Wallace3079a642017-09-06 01:59:43 -0400686 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
687 title2="SERVER$title_dbg (Native-Preload Socket Test)"
688 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
689 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
690 set_pre_cmd $emacs_server $gdb_server $ld_preload
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500691 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
692 namespace_id="$server_namespace_id"
693 namespace_secret="$server_namespace_secret"
694 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400695 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
696 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd2_file
697 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
698 write_script_footer $cmd2_file $perf_server
699 chmod +x $cmd2_file
700 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400701
Dave Wallace3079a642017-09-06 01:59:43 -0400702 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
703 title3="CLIENT$title_dbg (Native-Preload Socket Test)"
704 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
705 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
706 set_pre_cmd $emacs_client $gdb_client $ld_preload
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500707 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
708 namespace_id="$client_namespace_id"
709 namespace_secret="$client_namespace_secret"
710 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400711 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
Dave Wallace3079a642017-09-06 01:59:43 -0400712 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd3_file
713 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
714 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
715 write_script_footer $cmd3_file $perf_client
716 chmod +x $cmd3_file
717 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400718}
719
720native_vcl() {
721 verify_no_vpp
722 banner="Running NATIVE-VCL socket test"
723
724 title1="VPP$title_dbg (Native-VCL Socket Test)"
725 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
726 gdb_cmdfile=$VPP_GDB_CMDFILE
727 set_pre_cmd $emacs_vpp $gdb_vpp
728 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400729 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
730 echo -n "sudo " >> $cmd1_file
731 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400732 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
733 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400734 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400735
Dave Wallace3079a642017-09-06 01:59:43 -0400736 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
737 title2="SERVER$title_dbg (Native-VCL Socket Test)"
738 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
739 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
740 set_pre_cmd $emacs_server $gdb_server
Dave Wallace3d674492017-09-25 15:37:56 -0400741 if [ "$multi_host" = "server" ] ; then
742 delay="sleep 10"
743 else
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500744 delay="sleep 3"
745 fi
746 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
747 namespace_id="$server_namespace_id"
748 namespace_secret="$server_namespace_secret"
Dave Wallace3d674492017-09-25 15:37:56 -0400749 fi
750 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400751 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd2_file
752 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
753 write_script_footer $cmd2_file $perf_server
754 chmod +x $cmd2_file
755 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400756
Dave Wallace3079a642017-09-06 01:59:43 -0400757 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
758 title3="CLIENT$title_dbg (Native-VCL Socket Test)"
759 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
760 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
761 set_pre_cmd $emacs_client $gdb_client
Dave Wallace3d674492017-09-25 15:37:56 -0400762 if [ "$multi_host" = "client" ] ; then
763 delay="sleep 10"
764 else
Dave Wallace8af20542017-10-26 03:29:30 -0400765 delay="sleep 4"
Dave Wallace3d674492017-09-25 15:37:56 -0400766 fi
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500767 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
768 namespace_id="$client_namespace_id"
769 namespace_secret="$client_namespace_secret"
770 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400771 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400772 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd3_file
773 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
774 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
775 write_script_footer $cmd3_file $perf_client
776 chmod +x $cmd3_file
777 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400778}
779
780docker_kernel() {
781 verify_no_docker_containers
782 banner="Running DOCKER-KERNEL socket test"
783
Dave Wallace3079a642017-09-06 01:59:43 -0400784 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
785 title1="SERVER$title_dbg (Docker-Native Socket Test)"
786 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
787 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
788 set_pre_cmd $emacs_server $gdb_server
789 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
790 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
791 write_script_footer $cmd1_file $perf_server
792 chmod +x $cmd1_file
793 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400794
Dave Wallace3079a642017-09-06 01:59:43 -0400795 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
796 title2="CLIENT$title_dbg (Docker-Native Socket Test)"
797 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
798 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
799 set_pre_cmd $emacs_client $gdb_client
800 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
801 echo "$get_docker_server_ip4addr" >> $cmd2_file
802 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd2_file
803 write_script_footer $cmd2_file $perf_client
804 chmod +x $cmd2_file
805 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400806}
807
808docker_preload() {
809 verify_no_vpp
810 verify_no_docker_containers
811 banner="Running DOCKER-PRELOAD socket test"
Dave Wallace30fb4a22017-08-17 16:22:04 -0400812 docker_ld_preload_dir="/vcl-ldpreload/"
813 ld_preload_dir="$VCL_LDPRELOAD_LIB_DIR"
814 ld_preload="$docker_ld_preload_dir$vcl_ldpreload_lib "
815 docker_ld_preload_lib="$docker_ld_preload_dir$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400816
817 title1="VPP$title_dbg (Docker-Preload Socket Test)"
818 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
819 gdb_cmdfile=$VPP_GDB_CMDFILE
820 set_pre_cmd $emacs_vpp $gdb_vpp
821 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400822 if [ -n "$multi_host" ] ; then
823 echo -n "sudo " >> $cmd1_file
824 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400825 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
826 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400827 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400828
Dave Wallace3079a642017-09-06 01:59:43 -0400829 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
830 title2="SERVER$title_dbg (Docker-Preload Socket Test)"
831 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
832 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
833 set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500834 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
835 namespace_id="$server_namespace_id"
836 namespace_secret="$server_namespace_secret"
837 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400838 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
Dave Wallaceee45d412017-11-24 21:44:06 -0500839 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_DEBUG=$VCL_DEBUG -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 -0400840 write_script_footer $cmd2_file $perf_server
841 chmod +x $cmd2_file
842 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400843
Dave Wallace3079a642017-09-06 01:59:43 -0400844 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
845 title3="CLIENT$title_dbg (Docker-Preload Socket Test)"
846 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
847 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
848 set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500849 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
850 namespace_id="$client_namespace_id"
851 namespace_secret="$client_namespace_secret"
852 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400853 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
Dave Wallace3079a642017-09-06 01:59:43 -0400854 echo "$get_docker_server_ip4addr" >> $cmd3_file
Dave Wallaceee45d412017-11-24 21:44:06 -0500855 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_DEBUG=$VCL_DEBUG -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 -0400856 write_script_footer $cmd3_file $perf_client
857 chmod +x $cmd3_file
858 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400859}
860
861docker_vcl() {
862 verify_no_vpp
863 verify_no_docker_containers
864 banner="Running DOCKER-VCL socket test"
865
866 title1="VPP$title_dbg (Docker-VCL Socket Test)"
867 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
868 gdb_cmdfile=$VPP_GDB_CMDFILE
869 set_pre_cmd $emacs_vpp $gdb_vpp
870 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400871 if [ -n "$multi_host" ] ; then
872 echo -n "sudo " >> $cmd1_file
873 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400874 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
875 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400876 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400877
Dave Wallace3079a642017-09-06 01:59:43 -0400878 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
879 title2="SERVER$title_dbg (Docker-VCL Socket Test)"
880 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
881 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
882 set_pre_cmd $emacs_server $gdb_server
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500883 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
884 namespace_id="$server_namespace_id"
885 namespace_secret="$server_namespace_secret"
886 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400887 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
Dave Wallace8af20542017-10-26 03:29:30 -0400888 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 -0400889 write_script_footer $cmd2_file $perf_server
890 chmod +x $cmd2_file
891 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400892
Dave Wallace3079a642017-09-06 01:59:43 -0400893 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
894 title3="CLIENT$title_dbg (Docker-VCL Socket Test)"
895 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
896 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
897 set_pre_cmd $emacs_client $gdb_client
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500898 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
899 namespace_id="$client_namespace_id"
900 namespace_secret="$client_namespace_secret"
901 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400902 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3"
903 echo "$get_docker_server_ip4addr" >> $cmd3_file
Dave Wallace8af20542017-10-26 03:29:30 -0400904 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 -0400905 write_script_footer $cmd3_file $perf_client
906 chmod +x $cmd3_file
907 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400908}
909
910if [[ $run_test ]] ; then
911 eval $run_test
912else
913 echo "ERROR: Please specify a test to run!" >&2
914 usage;
915fi
916
917if (( $(which xfce4-terminal | wc -l) > 0 )) ; then
918 xterm_cmd="xfce4-terminal --geometry $xterm_geom"
919 if [[ $use_tabs ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400920 declare -a tab_cmd_files
921 declare -a tab_titles
922 declare -i i=0
923
924 if [ -x "$cmd1_file" ] ; then
925 tab_cmd_files[$i]="$cmd1_file"
926 tab_titles[$i]="$title1"
927 (( i++ ))
Dave Wallace543852a2017-08-03 02:11:34 -0400928 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400929 if [ -x "$cmd2_file" ] ; then
930 tab_cmd_files[$i]="$cmd2_file"
931 tab_titles[$i]="$title2"
932 (( i++ ))
933 fi
934 if [ -x "$cmd3_file" ] ; then
935 tab_cmd_files[$i]="$cmd3_file"
936 tab_titles[$i]="$title3"
937 fi
938
939 if [ -n "${tab_cmd_files[2]}" ] ; then
940 $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]}"
941 elif [ -n "${tab_cmd_files[1]}" ] ; then
942 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}"
943
944 else
945 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}"
946 fi
947
Dave Wallace543852a2017-08-03 02:11:34 -0400948 else
Dave Wallace3079a642017-09-06 01:59:43 -0400949 if [ -x "$cmd1_file" ] ; then
950 ($xterm_cmd --title "$title1" --command "$cmd1_file" &)
951 fi
952 if [ -x "$cmd2_file" ] ; then
953 ($xterm_cmd --title "$title2" --command "$cmd2_file" &)
954 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400955 if [ -x "$cmd3_file" ] ; then
956 ($xterm_cmd --title "$title3" --command "$cmd3_file" &)
957 fi
958 fi
959
960else
961 if [[ $use_tabs ]] ; then
962 echo "Sorry, plain ol' xterm doesn't support tabs."
963 fi
964 xterm_cmd="xterm -fs 10 -geometry $xterm_geom"
Dave Wallace3079a642017-09-06 01:59:43 -0400965 if [ -x "$cmd1_file" ] ; then
966 ($xterm_cmd -title "$title1" -e "$cmd1_file" &)
967 fi
968 if [ -x "$cmd2_file" ] ; then
969 ($xterm_cmd -title "$title2" -e "$cmd2_file" &)
970 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400971 if [ -x "$cmd3_file" ] ; then
972 ($xterm_cmd -title "$title3" -e "$cmd3_file" &)
973 fi
974fi
975
976sleep 1