blob: ca33eeefe038d8e8fba2c68b17e08deb0e24217c [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
Dave Wallace543852a2017-08-03 02:11:34 -0400187 ;;
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 Wallaceee45d412017-11-24 21:44:06 -0500249if [ -z "$VCL_DEBUG" ] ; then
250 if [ "$title_dbg" = "-DEBUG" ] ; then
251 VCL_DEBUG=1
252 else
253 VCL_DEBUG=0
254 fi
255fi
256
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400257VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-$lib64_dir}"
258
Dave Wallace543852a2017-08-03 02:11:34 -0400259if [ -z "$WS_ROOT" ] ; then
260 echo "ERROR: WS_ROOT environment variable not set!" >&2
261 echo " Please set WS_ROOT to VPP workspace root directory." >&2
Dave Wallace3079a642017-09-06 01:59:43 -0400262 exit 1
Dave Wallace543852a2017-08-03 02:11:34 -0400263fi
264
Dave Wallace4f6c3a92017-10-24 15:39:44 -0400265if [[ "$(grep bin_PROGRAMS $WS_ROOT/src/vcl.am)" = "" ]] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400266 $WS_ROOT/extras/vagrant/vcl_test.sh $WS_ROOT $USER
267 (cd $WS_ROOT; make build)
268fi
269
Dave Wallace543852a2017-08-03 02:11:34 -0400270if [ ! -d $vpp_dir ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400271 echo "ERROR: Missing VPP$title_dbg bin directory!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400272 echo " $vpp_dir" >&2
273 env_test_failed="true"
274fi
275
276if [[ $run_test =~ .*"_preload" ]] ; then
277 if [ ! -d $lib64_dir ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400278 echo "ERROR: Missing VPP$title_dbg lib64 directory!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400279 echo " $lib64_dir" >&2
Dave Wallaced69f4f42017-08-14 18:26:46 -0400280 elif [ ! -d $VCL_LDPRELOAD_LIB_DIR ] ; then
281 echo "ERROR: Missing VCL LD_PRELOAD Library directory!" >&2
282 echo " $VCL_LDPRELOAD_LIB_DIR" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400283 env_test_failed="true"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400284 elif [ ! -f $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib ] ; then
285 echo "ERROR: Missing VCL LD_PRELOAD library!" >&2
286 echo " $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400287 env_test_failed="true"
288 fi
289fi
290
291if [ ! -f $vpp_dir$vpp_app ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400292 echo "ERROR: Missing VPP$title_dbg Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400293 echo " $vpp_dir$vpp_app" >&2
294 env_test_failed="true"
295fi
296
Dave Wallace30fb4a22017-08-17 16:22:04 -0400297if [ ! -f $vpp_dir$sock_srvr_app ] && [ ! $iperf3 -eq 1 ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400298 echo "ERROR: Missing$title_dbg Socket Server Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400299 echo " $vpp_dir$sock_srvr_app" >&2
300 env_test_failed="true"
301fi
302
Dave Wallace30fb4a22017-08-17 16:22:04 -0400303if [ ! -f $vpp_dir$sock_clnt_app ] && [ ! $iperf3 -eq 1 ] ; then
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400304 echo "ERROR: Missing$title_dbg Socket Client Application!" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400305 echo " $vpp_dir$sock_clnt_app" >&2
306 env_test_failed="true"
307fi
308
309if [[ $run_test =~ "docker_".* ]] ; then
310 if [ $emacs_client -eq 1 ] || [ $emacs_server -eq 1 ] || [ $gdb_client -eq 1 ] || [ $gdb_server -eq 1 ] ; then
311
312 echo "WARNING: gdb is not currently supported in docker."
313 echo " Ignoring client/server gdb options."
314 emacs_client=0
315 emacs_server=0
316 gdb_client=0
317 gdb_server=0
318 fi
319fi
320
Dave Wallace30fb4a22017-08-17 16:22:04 -0400321if [[ $run_test =~ .*"_vcl" ]] && [ $iperf3 -eq 1 ] ; then
322 echo "ERROR: Invalid option 'i' for test $run_test!"
323 echo " iperf3 is not compiled with the VCL library."
324 env_test_failed="true"
325fi
326
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500327if [ -n "$multi_host"] && [ ! -f "$dpdk_devbind" ] ; then
Dave Wallace19481612017-09-15 18:47:44 -0400328 echo "ERROR: Can't find dpdk-devbind.py!"
329 echo " Run \"cd \$WS_ROOT; make dpdk-install-dev\" to install it."
330 echo
331 env_test_failed="true"
332fi
333
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500334if [ -n "$full_thru_host_stack_vpp_cfg" ] && [ -n "$multi_host" ] ; then
335 echo "ERROR: Invalid options, cannot specify both \"-f\" and \"-m $multi_host\"!"
336 echo
337 env_test_failed="true"
338fi
339
Dave Wallace543852a2017-08-03 02:11:34 -0400340if [ -n "$env_test_failed" ] ; then
341 exit 1
342fi
343
Dave Wallace8af20542017-10-26 03:29:30 -0400344if [ -f "$VCL_CONFIG" ] ; then
345 vcl_config="$(basename $VCL_CONFIG)"
346 vcl_config_dir="$(dirname $VCL_CONFIG)/"
347 api_prefix="$(egrep -s '^\s*api-prefix \w+' $VCL_CONFIG | tail -1 | awk -e '{print $2}')"
Dave Wallace543852a2017-08-03 02:11:34 -0400348 if [ -n "$api_prefix" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400349 api_segment=" api-segment { gid $user_gid prefix $api_prefix }"
Dave Wallace543852a2017-08-03 02:11:34 -0400350 fi
351fi
Dave Wallace8af20542017-10-26 03:29:30 -0400352if [ -n "$VCL_APP_NAMESPACE_ID" ] && [ -n "$VCL_APP_NAMESPACE_SECRET" ] ; then
353 namespace_id="$VCL_APP_NAMESPACE_ID"
354 namespace_secret="$VCL_APP_NAMESPACE_SECRET"
355fi
356
Dave Wallace3079a642017-09-06 01:59:43 -0400357if [ -z "$api_segment" ] ; then
358 api_segment=" api-segment { gid $user_gid }"
359fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500360vpp_args="unix { interactive full-coredump coredump-size unlimited exec $tmp_vpp_exec_file}${api_segment}"
Dave Wallace543852a2017-08-03 02:11:34 -0400361
Dave Wallace30fb4a22017-08-17 16:22:04 -0400362if [ $iperf3 -eq 1 ] ; then
Dave Wallace543852a2017-08-03 02:11:34 -0400363 app_dir="$(dirname $(which iperf3))/"
364 srvr_app=$iperf_srvr_app
365 clnt_app=$iperf_clnt_app
Dave Wallace30fb4a22017-08-17 16:22:04 -0400366 if [[ $run_test =~ "docker_".* ]] ; then
367 unset -v app_dir
368 sock_srvr_port=5201
369 docker_app_dir="networkstatic/"
370 unset -v docker_os
371 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400372else
373 app_dir="$vpp_dir"
374 srvr_app="$sock_srvr_app $sock_srvr_port"
375 clnt_app="$sock_clnt_app${sock_clnt_options} \$srvr_addr $sock_srvr_port"
376fi
377
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400378
Dave Wallace543852a2017-08-03 02:11:34 -0400379verify_no_vpp() {
Dave Wallace3d674492017-09-25 15:37:56 -0400380 local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\""
381
382 if [ -n "$api_prefix" ] ; then
383 grep_for_vpp="$grep_for_vpp|grep \"prefix $api_prefix\""
384 fi
385 local running_vpp="$(eval $grep_for_vpp)"
386 if [ -n "$running_vpp" ] ; then
387 echo "ERROR: Please kill the following vpp instance(s):"
Dave Wallace543852a2017-08-03 02:11:34 -0400388 echo
Dave Wallace3d674492017-09-25 15:37:56 -0400389 echo $running_vpp
Dave Wallace543852a2017-08-03 02:11:34 -0400390 echo
391 exit 1
392 fi
393 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 -0400394 sudo rm -f $clean_devshm
Dave Wallace543852a2017-08-03 02:11:34 -0400395 devshm_files="$(ls -l $clean_devshm 2>/dev/null | grep $(whoami))"
396 if [ "$devshm_files" != "" ] ; then
397 echo "ERROR: Please remove the following $vpp_shm_dir files:"
398 for file in "$devshm_files" ; do
399 echo " $file"
400 done
401 exit 1
402 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400403 if [ ! -d "$vpp_run_dir" ] ; then
404 sudo mkdir $vpp_run_dir
405 sudo chown root:$USER $vpp_run_dir
406 fi
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500407 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
408 sock_srvr_addr=172.16.1.1
409 client_namespace_id="1"
410 client_namespace_secret="5678"
411 server_namespace_id="0"
412 server_namespace_secret="1234"
413 cat <<EOF >> $tmp_vpp_exec_file
414session enable
415create loop inter
416create loop inter
417set inter state loop0 up
418set inter ip table loop0 0
419set inter ip address loop0 172.16.1.1/24
420set inter state loop1 up
421set inter ip table loop1 1
422set inter ip address loop1 172.16.2.1/24
423app ns add id 0 secret 1234 sw_if_index 1
424app ns add id 1 secret 5678 sw_if_index 2
425ip route add 172.16.1.1/32 table 1 via lookup in table 0
426ip route add 172.16.2.1/32 table 0 via lookup in table 1
427EOF
428
429 elif [ -n "$multi_host" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400430 vpp_eth_pci_id="$(ls -ld /sys/class/net/$vpp_eth_name/device | awk '{print $11}' | cut -d/ -f4)"
431 if [ -z "$vpp_eth_pci_id" ] ; then
432 echo "ERROR: Missing ethernet interface $vpp_eth_name!"
433 usage
434 fi
435 printf -v bus "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f2)"
436 printf -v slot "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f3 | cut -d. -f1)"
437 printf -v func "%x" "0x$(echo $vpp_eth_pci_id | cut -d. -f2)"
438
439 vpp_eth_kernel_driver="$(basename $(ls -l /sys/bus/pci/devices/$vpp_eth_pci_id/driver | awk '{print $11}'))"
440 if [ -z "$vpp_eth_kernel_driver" ] ; then
441 echo "ERROR: Missing kernel driver for $vpp_eth_name!"
442 usage
443 fi
444 case $vpp_eth_kernel_driver in
445 e1000)
446 vpp_eth_ifname="GigabitEthernet$bus/$slot/$func" ;;
447 ixgbe)
448 vpp_eth_ifname="TenGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400449 i40e)
450 vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3079a642017-09-06 01:59:43 -0400451 *)
452 echo "ERROR: Unknown ethernet kernel driver $vpp_eth_kernel_driver!"
453 usage ;;
454 esac
455
456 vpp_eth_ip4_addr="$(ip -4 -br addr show $vpp_eth_name | awk '{print $3}')"
457 if [ -z "$vpp_eth_ip4_addr" ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400458 if [ "$multi_host" = "server" ] ; then
459 vpp_eth_ip4_addr="10.10.10.10/24"
460 else
461 vpp_eth_ip4_addr="10.10.10.11/24"
462 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400463 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400464 if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400465 echo "ERROR: No inet6 address configured for $vpp_eth_name!"
466 usage
467 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400468 vpp_args="$vpp_args plugins { path ${lib64_dir}vpp_plugins } dpdk { dev $vpp_eth_pci_id }"
Dave Wallace3079a642017-09-06 01:59:43 -0400469
Dave Wallace3d674492017-09-25 15:37:56 -0400470 sudo ifconfig $vpp_eth_name down 2> /dev/null
Dave Wallace3079a642017-09-06 01:59:43 -0400471 echo "Configuring VPP to use $vpp_eth_name ($vpp_eth_pci_id), inet addr $vpp_eth_ip4_addr"
472
473 cat <<EOF >> $tmp_vpp_exec_file
474set int state $vpp_eth_ifname up
475set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr
476EOF
477
478 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400479
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500480 if [ -z "$full_thru_host_stack_vpp_cfg" ] && [ -n "$namespace_id" ] ; then
Dave Wallace8af20542017-10-26 03:29:30 -0400481 cat <<EOF >> $tmp_vpp_exec_file
482session enable
483app ns add id $namespace_id secret $namespace_secret sw_if_index 0
484EOF
485 fi
486
487 cat <<EOF >> $tmp_vpp_exec_file
488show version
489show version verbose
490show cpu
491show int
492EOF
Dave Wallace543852a2017-08-03 02:11:34 -0400493}
494
495verify_no_docker_containers() {
496 if (( $(which docker | wc -l) < 1 )) ; then
497 echo "ERROR: docker is not installed!"
498 echo "See https://docs.docker.com/engine/installation/linux/ubuntu/"
499 echo " or https://docs.docker.com/engine/installation/linux/centos/"
500 exit 1
501 fi
502 if (( $(docker ps | wc -l) > 1 )) ; then
503 echo "ERROR: Run the following to kill all docker containers:"
504 echo "docker kill \$(docker ps -q)"
505 echo
506 docker ps
507 exit 1
508 fi
509}
510
511set_pre_cmd() {
512 # arguments
513 # $1 : emacs flag
514 # $2 : gdb flag
515 # $3 : optional LD_PRELOAD library pathname
516 local -i emacs=$1
517 local -i gdb=$2
518
519 if [ $emacs -eq 1 ] ; then
520 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
521 pre_cmd="$gdb_in_emacs "
522 elif [ $gdb -eq 1 ] ; then
523 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
Dave Wallace4878cbe2017-11-21 03:45:09 -0500524 pre_cmd="gdb -x $tmp_gdb_cmdfile --args "
Dave Wallace543852a2017-08-03 02:11:34 -0400525 elif [ -z $3 ] ; then
526 unset -v pre_cmd
527 else
528 docker_ld_preload="-e LD_PRELOAD=$3 "
529 pre_cmd="LD_PRELOAD=$3 "
530 fi
531}
532
533write_script_header() {
534 # arguments
535 # $1 : command script file
536 # $2 : gdb command file
537 # $3 : title
538 # $4 : optional command string (typically "sleep 2")
539 echo "$bash_header" > $1
540 echo -e "#\n# $1 generated on $(date)\n#" >> $1
541 if [ $leave_tmp_files -eq 0 ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400542 if [ -n "$multi_host" ] ; then
543 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 -0400544 else
545 echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1
546 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400547 fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500548 if [ -n "$VCL_CONFIG" ] ; then
549 echo "export VCL_CONFIG=${vcl_config_dir}${vcl_config}" >> $1
550 fi
Dave Wallaceb5a86ee2018-02-16 18:26:11 -0500551 if [ -n "$VCL_API_PREFIX" ] ; then
552 echo "export VCL_API_PREFIX=$VCL_API_PREFIX" >> $1
553 fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500554 if [ -n "$VCL_DEBUG" ] ; then
555 echo "export VCL_DEBUG=$VCL_DEBUG" >> $1
556 fi
Dave Wallace3ee1fe12018-02-23 01:09:11 -0500557 if [ -n "$LDP_DEBUG" ] ; then
558 echo "export LDP_DEBUG=$LDP_DEBUG" >> $1
Dave Wallace048b1d62018-01-03 22:24:41 -0500559 fi
560 if [ -n "$VCOM_APP_NAME" ] ; then
561 echo "export VCOM_APP_NAME=$VCOM_APP_NAME" >> $1
562 fi
563 if [ -n "$VCOM_SID_BIT" ] ; then
564 echo "export VCOM_SID_BIT=$VCOM_SID_BIT" >> $1
565 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400566 if [ -n "$namespace_id" ] ; then
567 echo "export VCL_APP_NAMESPACE_ID=\"$namespace_id\"" >> $1
568 echo "export VCL_APP_NAMESPACE_SECRET=\"$namespace_secret\"" >> $1
569 fi
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500570 if [ -n "$VCL_APP_SCOPE_LOCAL" ] || [ -z "$multi_host" ] &&
571 [ -z "$full_thru_host_stack_vpp_cfg" ] ; then
Dave Wallace774169b2017-11-01 20:07:40 -0400572 echo "export VCL_APP_SCOPE_LOCAL=true" >> $1
Dave Wallace8af20542017-10-26 03:29:30 -0400573 fi
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500574 if [ -n "$VCL_APP_SCOPE_GLOBAL" ] || [ -n "$multi_host" ] ||
575 [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
Dave Wallace774169b2017-11-01 20:07:40 -0400576 echo "export VCL_APP_SCOPE_GLOBAL=true" >> $1
577 fi
578 if [ -n "$VCL_APP_PROXY_TRANSPORT_TCP" ] ; then
579 echo "export VCL_APP_PROXY_TRANSPORT_TCP=true" >> $1
580 fi
581 if [ -n "$VCL_APP_PROXY_TRANSPORT_UDP" ] ; then
582 echo "export VCL_APP_PROXY_TRANSPORT_UDP=true" >> $1
Dave Wallace8af20542017-10-26 03:29:30 -0400583 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400584 if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400585 if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400586 cat <<EOF >> $1
587$gdb_in_emacs() {
588 sudo emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
589}
590EOF
591 else
592 cat <<EOF >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400593$gdb_in_emacs() {
594 emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
595}
596EOF
Dave Wallace3079a642017-09-06 01:59:43 -0400597 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400598 fi
599 if [ -n "$4" ] ; then
600 echo "$4" >> $1
601 fi
602}
603
604write_script_footer() {
605 # arguments
606 # $1 : command script file
607 # $2 : perf flag indicating to run bash before exit
608 local -i perf=$2
609 if [ $bash_after_exit -eq 1 ] || [ $perf -eq 1 ] ; then
610 echo "bash" >> $1
611 fi
612}
613
614write_gdb_cmdfile() {
615 # arguments
616 # $1 : gdb command file
617 # $2 : User specified gdb cmdfile
618 # $3 : emacs flag
619 # $4 : optional LD_PRELOAD library pathname.
620 local -i emacs=$3
621
622 echo "# $1 generated on $(date)" > $1
623 echo "#" >> $1
624 echo "set confirm off" >> $1
625 if [ -n "$4" ] ; then
626 echo "set exec-wrapper env LD_PRELOAD=$4" >> $1
Dave Wallace59179392017-11-07 02:20:07 -0500627 # echo "start" >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400628 fi
629
630 if [ ! -f $2 ] ; then
631 echo -n "# " >> $1
632 fi
633 echo "source $2" >> $1
634 if [ $emacs -eq 0 ] ; then
635 echo "run" >> $1
636 fi
637}
638
639native_kernel() {
640 banner="Running NATIVE-KERNEL socket test"
Dave Wallace3079a642017-09-06 01:59:43 -0400641 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
642 title1="SERVER$title_dbg (Native-Kernel Socket Test)"
643 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
644 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
645 set_pre_cmd $emacs_server $gdb_server
646 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
647 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd1_file
648 write_script_footer $cmd1_file $perf_server
649 chmod +x $cmd1_file
650 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400651
Dave Wallace3079a642017-09-06 01:59:43 -0400652 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
653 title2="CLIENT$title_dbg (Native-Kernel Socket Test)"
654 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
655 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
656 set_pre_cmd $emacs_client $gdb_client
657 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
658 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd2_file
659 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd2_file
660 write_script_footer $cmd2_file $perf_client
661 chmod +x $cmd2_file
Dave Wallace543852a2017-08-03 02:11:34 -0400662
Dave Wallace3079a642017-09-06 01:59:43 -0400663 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400664}
665
666native_preload() {
667 verify_no_vpp
668 banner="Running NATIVE-PRELOAD socket test"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400669 ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400670
671 title1="VPP$title_dbg (Native-Preload Socket Test)"
672 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
673 gdb_cmdfile=$VPP_GDB_CMDFILE
674 set_pre_cmd $emacs_vpp $gdb_vpp
675 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400676 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
677 echo -n "sudo " >> $cmd1_file
678 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400679 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
680 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400681 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400682
Dave Wallace3079a642017-09-06 01:59:43 -0400683 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
684 title2="SERVER$title_dbg (Native-Preload Socket Test)"
685 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
686 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
687 set_pre_cmd $emacs_server $gdb_server $ld_preload
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500688 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
689 namespace_id="$server_namespace_id"
690 namespace_secret="$server_namespace_secret"
691 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400692 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
693 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd2_file
694 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
695 write_script_footer $cmd2_file $perf_server
696 chmod +x $cmd2_file
697 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400698
Dave Wallace3079a642017-09-06 01:59:43 -0400699 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
700 title3="CLIENT$title_dbg (Native-Preload Socket Test)"
701 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
702 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
703 set_pre_cmd $emacs_client $gdb_client $ld_preload
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500704 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
705 namespace_id="$client_namespace_id"
706 namespace_secret="$client_namespace_secret"
707 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400708 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
Dave Wallace3079a642017-09-06 01:59:43 -0400709 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd3_file
710 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
711 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
712 write_script_footer $cmd3_file $perf_client
713 chmod +x $cmd3_file
714 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400715}
716
717native_vcl() {
718 verify_no_vpp
719 banner="Running NATIVE-VCL socket test"
720
721 title1="VPP$title_dbg (Native-VCL Socket Test)"
722 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
723 gdb_cmdfile=$VPP_GDB_CMDFILE
724 set_pre_cmd $emacs_vpp $gdb_vpp
725 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400726 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
727 echo -n "sudo " >> $cmd1_file
728 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400729 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
730 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400731 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400732
Dave Wallace3079a642017-09-06 01:59:43 -0400733 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
734 title2="SERVER$title_dbg (Native-VCL Socket Test)"
735 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
736 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
737 set_pre_cmd $emacs_server $gdb_server
Dave Wallace3d674492017-09-25 15:37:56 -0400738 if [ "$multi_host" = "server" ] ; then
739 delay="sleep 10"
740 else
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500741 delay="sleep 3"
742 fi
743 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
744 namespace_id="$server_namespace_id"
745 namespace_secret="$server_namespace_secret"
Dave Wallace3d674492017-09-25 15:37:56 -0400746 fi
747 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400748 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd2_file
749 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
750 write_script_footer $cmd2_file $perf_server
751 chmod +x $cmd2_file
752 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400753
Dave Wallace3079a642017-09-06 01:59:43 -0400754 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
755 title3="CLIENT$title_dbg (Native-VCL Socket Test)"
756 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
757 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
758 set_pre_cmd $emacs_client $gdb_client
Dave Wallace3d674492017-09-25 15:37:56 -0400759 if [ "$multi_host" = "client" ] ; then
760 delay="sleep 10"
761 else
Dave Wallace8af20542017-10-26 03:29:30 -0400762 delay="sleep 4"
Dave Wallace3d674492017-09-25 15:37:56 -0400763 fi
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500764 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
765 namespace_id="$client_namespace_id"
766 namespace_secret="$client_namespace_secret"
767 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400768 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400769 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd3_file
770 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
771 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
772 write_script_footer $cmd3_file $perf_client
773 chmod +x $cmd3_file
774 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400775}
776
777docker_kernel() {
778 verify_no_docker_containers
779 banner="Running DOCKER-KERNEL socket test"
780
Dave Wallace3079a642017-09-06 01:59:43 -0400781 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
782 title1="SERVER$title_dbg (Docker-Native Socket Test)"
783 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
784 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
785 set_pre_cmd $emacs_server $gdb_server
786 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
787 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
788 write_script_footer $cmd1_file $perf_server
789 chmod +x $cmd1_file
790 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400791
Dave Wallace3079a642017-09-06 01:59:43 -0400792 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
793 title2="CLIENT$title_dbg (Docker-Native Socket Test)"
794 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
795 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
796 set_pre_cmd $emacs_client $gdb_client
797 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
798 echo "$get_docker_server_ip4addr" >> $cmd2_file
799 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd2_file
800 write_script_footer $cmd2_file $perf_client
801 chmod +x $cmd2_file
802 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400803}
804
805docker_preload() {
806 verify_no_vpp
807 verify_no_docker_containers
808 banner="Running DOCKER-PRELOAD socket test"
Dave Wallace30fb4a22017-08-17 16:22:04 -0400809 docker_ld_preload_dir="/vcl-ldpreload/"
810 ld_preload_dir="$VCL_LDPRELOAD_LIB_DIR"
811 ld_preload="$docker_ld_preload_dir$vcl_ldpreload_lib "
812 docker_ld_preload_lib="$docker_ld_preload_dir$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400813
814 title1="VPP$title_dbg (Docker-Preload Socket Test)"
815 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
816 gdb_cmdfile=$VPP_GDB_CMDFILE
817 set_pre_cmd $emacs_vpp $gdb_vpp
818 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400819 if [ -n "$multi_host" ] ; then
820 echo -n "sudo " >> $cmd1_file
821 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400822 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
823 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400824 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400825
Dave Wallace3079a642017-09-06 01:59:43 -0400826 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
827 title2="SERVER$title_dbg (Docker-Preload Socket Test)"
828 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
829 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
830 set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500831 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
832 namespace_id="$server_namespace_id"
833 namespace_secret="$server_namespace_secret"
834 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400835 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
Dave Wallaceee45d412017-11-24 21:44:06 -0500836 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 -0400837 write_script_footer $cmd2_file $perf_server
838 chmod +x $cmd2_file
839 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400840
Dave Wallace3079a642017-09-06 01:59:43 -0400841 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
842 title3="CLIENT$title_dbg (Docker-Preload Socket Test)"
843 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
844 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
845 set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500846 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
847 namespace_id="$client_namespace_id"
848 namespace_secret="$client_namespace_secret"
849 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400850 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
Dave Wallace3079a642017-09-06 01:59:43 -0400851 echo "$get_docker_server_ip4addr" >> $cmd3_file
Dave Wallaceee45d412017-11-24 21:44:06 -0500852 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 -0400853 write_script_footer $cmd3_file $perf_client
854 chmod +x $cmd3_file
855 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400856}
857
858docker_vcl() {
859 verify_no_vpp
860 verify_no_docker_containers
861 banner="Running DOCKER-VCL socket test"
862
863 title1="VPP$title_dbg (Docker-VCL Socket Test)"
864 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
865 gdb_cmdfile=$VPP_GDB_CMDFILE
866 set_pre_cmd $emacs_vpp $gdb_vpp
867 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400868 if [ -n "$multi_host" ] ; then
869 echo -n "sudo " >> $cmd1_file
870 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400871 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
872 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400873 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400874
Dave Wallace3079a642017-09-06 01:59:43 -0400875 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
876 title2="SERVER$title_dbg (Docker-VCL Socket Test)"
877 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
878 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
879 set_pre_cmd $emacs_server $gdb_server
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500880 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
881 namespace_id="$server_namespace_id"
882 namespace_secret="$server_namespace_secret"
883 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400884 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
Dave Wallace8af20542017-10-26 03:29:30 -0400885 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 -0400886 write_script_footer $cmd2_file $perf_server
887 chmod +x $cmd2_file
888 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400889
Dave Wallace3079a642017-09-06 01:59:43 -0400890 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
891 title3="CLIENT$title_dbg (Docker-VCL Socket Test)"
892 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
893 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
894 set_pre_cmd $emacs_client $gdb_client
Dave Wallacefbbb07c2018-03-08 11:35:03 -0500895 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
896 namespace_id="$client_namespace_id"
897 namespace_secret="$client_namespace_secret"
898 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400899 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3"
900 echo "$get_docker_server_ip4addr" >> $cmd3_file
Dave Wallace8af20542017-10-26 03:29:30 -0400901 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 -0400902 write_script_footer $cmd3_file $perf_client
903 chmod +x $cmd3_file
904 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400905}
906
907if [[ $run_test ]] ; then
908 eval $run_test
909else
910 echo "ERROR: Please specify a test to run!" >&2
911 usage;
912fi
913
914if (( $(which xfce4-terminal | wc -l) > 0 )) ; then
915 xterm_cmd="xfce4-terminal --geometry $xterm_geom"
916 if [[ $use_tabs ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400917 declare -a tab_cmd_files
918 declare -a tab_titles
919 declare -i i=0
920
921 if [ -x "$cmd1_file" ] ; then
922 tab_cmd_files[$i]="$cmd1_file"
923 tab_titles[$i]="$title1"
924 (( i++ ))
Dave Wallace543852a2017-08-03 02:11:34 -0400925 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400926 if [ -x "$cmd2_file" ] ; then
927 tab_cmd_files[$i]="$cmd2_file"
928 tab_titles[$i]="$title2"
929 (( i++ ))
930 fi
931 if [ -x "$cmd3_file" ] ; then
932 tab_cmd_files[$i]="$cmd3_file"
933 tab_titles[$i]="$title3"
934 fi
935
936 if [ -n "${tab_cmd_files[2]}" ] ; then
937 $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]}"
938 elif [ -n "${tab_cmd_files[1]}" ] ; then
939 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}"
940
941 else
942 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}"
943 fi
944
Dave Wallace543852a2017-08-03 02:11:34 -0400945 else
Dave Wallace3079a642017-09-06 01:59:43 -0400946 if [ -x "$cmd1_file" ] ; then
947 ($xterm_cmd --title "$title1" --command "$cmd1_file" &)
948 fi
949 if [ -x "$cmd2_file" ] ; then
950 ($xterm_cmd --title "$title2" --command "$cmd2_file" &)
951 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400952 if [ -x "$cmd3_file" ] ; then
953 ($xterm_cmd --title "$title3" --command "$cmd3_file" &)
954 fi
955 fi
956
957else
958 if [[ $use_tabs ]] ; then
959 echo "Sorry, plain ol' xterm doesn't support tabs."
960 fi
961 xterm_cmd="xterm -fs 10 -geometry $xterm_geom"
Dave Wallace3079a642017-09-06 01:59:43 -0400962 if [ -x "$cmd1_file" ] ; then
963 ($xterm_cmd -title "$title1" -e "$cmd1_file" &)
964 fi
965 if [ -x "$cmd2_file" ] ; then
966 ($xterm_cmd -title "$title2" -e "$cmd2_file" &)
967 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400968 if [ -x "$cmd3_file" ] ; then
969 ($xterm_cmd -title "$title3" -e "$cmd3_file" &)
970 fi
971fi
972
973sleep 1