blob: 96a445eb8155dd8a702bb769cf9f7b1fb336718d [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 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 Wallace19481612017-09-15 18:47:44 -0400327if [ -n "$mult_host"] && [ ! -f "$dpdk_devbind" ] ; then
328 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 Wallace543852a2017-08-03 02:11:34 -0400334if [ -n "$env_test_failed" ] ; then
335 exit 1
336fi
337
Dave Wallace8af20542017-10-26 03:29:30 -0400338if [ -f "$VCL_CONFIG" ] ; then
339 vcl_config="$(basename $VCL_CONFIG)"
340 vcl_config_dir="$(dirname $VCL_CONFIG)/"
341 api_prefix="$(egrep -s '^\s*api-prefix \w+' $VCL_CONFIG | tail -1 | awk -e '{print $2}')"
Dave Wallace543852a2017-08-03 02:11:34 -0400342 if [ -n "$api_prefix" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400343 api_segment=" api-segment { gid $user_gid prefix $api_prefix }"
Dave Wallace543852a2017-08-03 02:11:34 -0400344 fi
345fi
Dave Wallace8af20542017-10-26 03:29:30 -0400346if [ -n "$VCL_APP_NAMESPACE_ID" ] && [ -n "$VCL_APP_NAMESPACE_SECRET" ] ; then
347 namespace_id="$VCL_APP_NAMESPACE_ID"
348 namespace_secret="$VCL_APP_NAMESPACE_SECRET"
349fi
350
Dave Wallace3079a642017-09-06 01:59:43 -0400351if [ -z "$api_segment" ] ; then
352 api_segment=" api-segment { gid $user_gid }"
353fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500354vpp_args="unix { interactive full-coredump coredump-size unlimited exec $tmp_vpp_exec_file}${api_segment}"
Dave Wallace543852a2017-08-03 02:11:34 -0400355
Dave Wallace30fb4a22017-08-17 16:22:04 -0400356if [ $iperf3 -eq 1 ] ; then
Dave Wallace543852a2017-08-03 02:11:34 -0400357 app_dir="$(dirname $(which iperf3))/"
358 srvr_app=$iperf_srvr_app
359 clnt_app=$iperf_clnt_app
Dave Wallace30fb4a22017-08-17 16:22:04 -0400360 if [[ $run_test =~ "docker_".* ]] ; then
361 unset -v app_dir
362 sock_srvr_port=5201
363 docker_app_dir="networkstatic/"
364 unset -v docker_os
365 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400366else
367 app_dir="$vpp_dir"
368 srvr_app="$sock_srvr_app $sock_srvr_port"
369 clnt_app="$sock_clnt_app${sock_clnt_options} \$srvr_addr $sock_srvr_port"
370fi
371
Dave Wallace5c7cf1c2017-10-24 04:12:18 -0400372
Dave Wallace543852a2017-08-03 02:11:34 -0400373verify_no_vpp() {
Dave Wallace3d674492017-09-25 15:37:56 -0400374 local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\""
375
376 if [ -n "$api_prefix" ] ; then
377 grep_for_vpp="$grep_for_vpp|grep \"prefix $api_prefix\""
378 fi
379 local running_vpp="$(eval $grep_for_vpp)"
380 if [ -n "$running_vpp" ] ; then
381 echo "ERROR: Please kill the following vpp instance(s):"
Dave Wallace543852a2017-08-03 02:11:34 -0400382 echo
Dave Wallace3d674492017-09-25 15:37:56 -0400383 echo $running_vpp
Dave Wallace543852a2017-08-03 02:11:34 -0400384 echo
385 exit 1
386 fi
387 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 -0400388 sudo rm -f $clean_devshm
Dave Wallace543852a2017-08-03 02:11:34 -0400389 devshm_files="$(ls -l $clean_devshm 2>/dev/null | grep $(whoami))"
390 if [ "$devshm_files" != "" ] ; then
391 echo "ERROR: Please remove the following $vpp_shm_dir files:"
392 for file in "$devshm_files" ; do
393 echo " $file"
394 done
395 exit 1
396 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400397 if [ ! -d "$vpp_run_dir" ] ; then
398 sudo mkdir $vpp_run_dir
399 sudo chown root:$USER $vpp_run_dir
400 fi
401 if [ -n "$multi_host" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400402 vpp_eth_pci_id="$(ls -ld /sys/class/net/$vpp_eth_name/device | awk '{print $11}' | cut -d/ -f4)"
403 if [ -z "$vpp_eth_pci_id" ] ; then
404 echo "ERROR: Missing ethernet interface $vpp_eth_name!"
405 usage
406 fi
407 printf -v bus "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f2)"
408 printf -v slot "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f3 | cut -d. -f1)"
409 printf -v func "%x" "0x$(echo $vpp_eth_pci_id | cut -d. -f2)"
410
411 vpp_eth_kernel_driver="$(basename $(ls -l /sys/bus/pci/devices/$vpp_eth_pci_id/driver | awk '{print $11}'))"
412 if [ -z "$vpp_eth_kernel_driver" ] ; then
413 echo "ERROR: Missing kernel driver for $vpp_eth_name!"
414 usage
415 fi
416 case $vpp_eth_kernel_driver in
417 e1000)
418 vpp_eth_ifname="GigabitEthernet$bus/$slot/$func" ;;
419 ixgbe)
420 vpp_eth_ifname="TenGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400421 i40e)
422 vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3079a642017-09-06 01:59:43 -0400423 *)
424 echo "ERROR: Unknown ethernet kernel driver $vpp_eth_kernel_driver!"
425 usage ;;
426 esac
427
428 vpp_eth_ip4_addr="$(ip -4 -br addr show $vpp_eth_name | awk '{print $3}')"
429 if [ -z "$vpp_eth_ip4_addr" ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400430 if [ "$multi_host" = "server" ] ; then
431 vpp_eth_ip4_addr="10.10.10.10/24"
432 else
433 vpp_eth_ip4_addr="10.10.10.11/24"
434 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400435 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400436 if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400437 echo "ERROR: No inet6 address configured for $vpp_eth_name!"
438 usage
439 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400440 vpp_args="$vpp_args plugins { path ${lib64_dir}vpp_plugins } dpdk { dev $vpp_eth_pci_id }"
Dave Wallace3079a642017-09-06 01:59:43 -0400441
Dave Wallace3d674492017-09-25 15:37:56 -0400442 sudo ifconfig $vpp_eth_name down 2> /dev/null
Dave Wallace3079a642017-09-06 01:59:43 -0400443 echo "Configuring VPP to use $vpp_eth_name ($vpp_eth_pci_id), inet addr $vpp_eth_ip4_addr"
444
445 cat <<EOF >> $tmp_vpp_exec_file
446set int state $vpp_eth_ifname up
447set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr
448EOF
449
450 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400451
452 if [ -n "$namespace_id" ] ; then
453 cat <<EOF >> $tmp_vpp_exec_file
454session enable
455app ns add id $namespace_id secret $namespace_secret sw_if_index 0
456EOF
457 fi
458
459 cat <<EOF >> $tmp_vpp_exec_file
460show version
461show version verbose
462show cpu
463show int
464EOF
Dave Wallace543852a2017-08-03 02:11:34 -0400465}
466
467verify_no_docker_containers() {
468 if (( $(which docker | wc -l) < 1 )) ; then
469 echo "ERROR: docker is not installed!"
470 echo "See https://docs.docker.com/engine/installation/linux/ubuntu/"
471 echo " or https://docs.docker.com/engine/installation/linux/centos/"
472 exit 1
473 fi
474 if (( $(docker ps | wc -l) > 1 )) ; then
475 echo "ERROR: Run the following to kill all docker containers:"
476 echo "docker kill \$(docker ps -q)"
477 echo
478 docker ps
479 exit 1
480 fi
481}
482
483set_pre_cmd() {
484 # arguments
485 # $1 : emacs flag
486 # $2 : gdb flag
487 # $3 : optional LD_PRELOAD library pathname
488 local -i emacs=$1
489 local -i gdb=$2
490
491 if [ $emacs -eq 1 ] ; then
492 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
493 pre_cmd="$gdb_in_emacs "
494 elif [ $gdb -eq 1 ] ; then
495 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
Dave Wallace4878cbe2017-11-21 03:45:09 -0500496 pre_cmd="gdb -x $tmp_gdb_cmdfile --args "
Dave Wallace543852a2017-08-03 02:11:34 -0400497 elif [ -z $3 ] ; then
498 unset -v pre_cmd
499 else
500 docker_ld_preload="-e LD_PRELOAD=$3 "
501 pre_cmd="LD_PRELOAD=$3 "
502 fi
503}
504
505write_script_header() {
506 # arguments
507 # $1 : command script file
508 # $2 : gdb command file
509 # $3 : title
510 # $4 : optional command string (typically "sleep 2")
511 echo "$bash_header" > $1
512 echo -e "#\n# $1 generated on $(date)\n#" >> $1
513 if [ $leave_tmp_files -eq 0 ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400514 if [ -n "$multi_host" ] ; then
515 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 -0400516 else
517 echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1
518 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400519 fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500520 if [ -n "$VCL_CONFIG" ] ; then
521 echo "export VCL_CONFIG=${vcl_config_dir}${vcl_config}" >> $1
522 fi
Dave Wallaceb5a86ee2018-02-16 18:26:11 -0500523 if [ -n "$VCL_API_PREFIX" ] ; then
524 echo "export VCL_API_PREFIX=$VCL_API_PREFIX" >> $1
525 fi
Dave Wallace498b3a52017-11-09 13:00:34 -0500526 if [ -n "$VCL_DEBUG" ] ; then
527 echo "export VCL_DEBUG=$VCL_DEBUG" >> $1
528 fi
Dave Wallace048b1d62018-01-03 22:24:41 -0500529 if [ -n "$VCOM_DEBUG" ] ; then
530 echo "export VCOM_DEBUG=$VCOM_DEBUG" >> $1
531 fi
532 if [ -n "$VCOM_APP_NAME" ] ; then
533 echo "export VCOM_APP_NAME=$VCOM_APP_NAME" >> $1
534 fi
535 if [ -n "$VCOM_SID_BIT" ] ; then
536 echo "export VCOM_SID_BIT=$VCOM_SID_BIT" >> $1
537 fi
Dave Wallace8af20542017-10-26 03:29:30 -0400538 if [ -n "$namespace_id" ] ; then
539 echo "export VCL_APP_NAMESPACE_ID=\"$namespace_id\"" >> $1
540 echo "export VCL_APP_NAMESPACE_SECRET=\"$namespace_secret\"" >> $1
541 fi
Dave Wallacee695cb42017-11-02 22:04:42 -0400542 if [ -n "$VCL_APP_SCOPE_LOCAL" ] || [ -z "$multi_host" ] ; then
Dave Wallace774169b2017-11-01 20:07:40 -0400543 echo "export VCL_APP_SCOPE_LOCAL=true" >> $1
Dave Wallace8af20542017-10-26 03:29:30 -0400544 fi
Dave Wallacee695cb42017-11-02 22:04:42 -0400545 if [ -n "$VCL_APP_SCOPE_GLOBAL" ] || [ -n "$multi_host" ] ; then
Dave Wallace774169b2017-11-01 20:07:40 -0400546 echo "export VCL_APP_SCOPE_GLOBAL=true" >> $1
547 fi
548 if [ -n "$VCL_APP_PROXY_TRANSPORT_TCP" ] ; then
549 echo "export VCL_APP_PROXY_TRANSPORT_TCP=true" >> $1
550 fi
551 if [ -n "$VCL_APP_PROXY_TRANSPORT_UDP" ] ; then
552 echo "export VCL_APP_PROXY_TRANSPORT_UDP=true" >> $1
Dave Wallace8af20542017-10-26 03:29:30 -0400553 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400554 if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400555 if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400556 cat <<EOF >> $1
557$gdb_in_emacs() {
558 sudo emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
559}
560EOF
561 else
562 cat <<EOF >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400563$gdb_in_emacs() {
564 emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
565}
566EOF
Dave Wallace3079a642017-09-06 01:59:43 -0400567 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400568 fi
569 if [ -n "$4" ] ; then
570 echo "$4" >> $1
571 fi
572}
573
574write_script_footer() {
575 # arguments
576 # $1 : command script file
577 # $2 : perf flag indicating to run bash before exit
578 local -i perf=$2
579 if [ $bash_after_exit -eq 1 ] || [ $perf -eq 1 ] ; then
580 echo "bash" >> $1
581 fi
582}
583
584write_gdb_cmdfile() {
585 # arguments
586 # $1 : gdb command file
587 # $2 : User specified gdb cmdfile
588 # $3 : emacs flag
589 # $4 : optional LD_PRELOAD library pathname.
590 local -i emacs=$3
591
592 echo "# $1 generated on $(date)" > $1
593 echo "#" >> $1
594 echo "set confirm off" >> $1
595 if [ -n "$4" ] ; then
596 echo "set exec-wrapper env LD_PRELOAD=$4" >> $1
Dave Wallace59179392017-11-07 02:20:07 -0500597 # echo "start" >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400598 fi
599
600 if [ ! -f $2 ] ; then
601 echo -n "# " >> $1
602 fi
603 echo "source $2" >> $1
604 if [ $emacs -eq 0 ] ; then
605 echo "run" >> $1
606 fi
607}
608
609native_kernel() {
610 banner="Running NATIVE-KERNEL socket test"
Dave Wallace3079a642017-09-06 01:59:43 -0400611 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
612 title1="SERVER$title_dbg (Native-Kernel Socket Test)"
613 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
614 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
615 set_pre_cmd $emacs_server $gdb_server
616 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
617 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd1_file
618 write_script_footer $cmd1_file $perf_server
619 chmod +x $cmd1_file
620 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400621
Dave Wallace3079a642017-09-06 01:59:43 -0400622 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
623 title2="CLIENT$title_dbg (Native-Kernel Socket Test)"
624 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
625 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
626 set_pre_cmd $emacs_client $gdb_client
627 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
628 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd2_file
629 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd2_file
630 write_script_footer $cmd2_file $perf_client
631 chmod +x $cmd2_file
Dave Wallace543852a2017-08-03 02:11:34 -0400632
Dave Wallace3079a642017-09-06 01:59:43 -0400633 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400634}
635
636native_preload() {
637 verify_no_vpp
638 banner="Running NATIVE-PRELOAD socket test"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400639 ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400640
641 title1="VPP$title_dbg (Native-Preload Socket Test)"
642 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
643 gdb_cmdfile=$VPP_GDB_CMDFILE
644 set_pre_cmd $emacs_vpp $gdb_vpp
645 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400646 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
647 echo -n "sudo " >> $cmd1_file
648 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400649 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
650 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400651 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400652
Dave Wallace3079a642017-09-06 01:59:43 -0400653 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
654 title2="SERVER$title_dbg (Native-Preload Socket Test)"
655 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
656 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
657 set_pre_cmd $emacs_server $gdb_server $ld_preload
658 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
659 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd2_file
660 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
661 write_script_footer $cmd2_file $perf_server
662 chmod +x $cmd2_file
663 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400664
Dave Wallace3079a642017-09-06 01:59:43 -0400665 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
666 title3="CLIENT$title_dbg (Native-Preload Socket Test)"
667 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
668 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
669 set_pre_cmd $emacs_client $gdb_client $ld_preload
Dave Wallace8af20542017-10-26 03:29:30 -0400670 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
Dave Wallace3079a642017-09-06 01:59:43 -0400671 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd3_file
672 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
673 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
674 write_script_footer $cmd3_file $perf_client
675 chmod +x $cmd3_file
676 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400677}
678
679native_vcl() {
680 verify_no_vpp
681 banner="Running NATIVE-VCL socket test"
682
683 title1="VPP$title_dbg (Native-VCL Socket Test)"
684 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
685 gdb_cmdfile=$VPP_GDB_CMDFILE
686 set_pre_cmd $emacs_vpp $gdb_vpp
687 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400688 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
689 echo -n "sudo " >> $cmd1_file
690 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400691 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
692 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400693 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400694
Dave Wallace3079a642017-09-06 01:59:43 -0400695 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
696 title2="SERVER$title_dbg (Native-VCL Socket Test)"
697 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
698 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
699 set_pre_cmd $emacs_server $gdb_server
Dave Wallace3d674492017-09-25 15:37:56 -0400700 if [ "$multi_host" = "server" ] ; then
701 delay="sleep 10"
702 else
Dave Wallacef7f809c2017-10-03 01:48:42 -0400703 delay="sleep 2"
Dave Wallace3d674492017-09-25 15:37:56 -0400704 fi
705 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400706 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd2_file
707 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
708 write_script_footer $cmd2_file $perf_server
709 chmod +x $cmd2_file
710 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400711
Dave Wallace3079a642017-09-06 01:59:43 -0400712 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
713 title3="CLIENT$title_dbg (Native-VCL Socket Test)"
714 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
715 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
716 set_pre_cmd $emacs_client $gdb_client
Dave Wallace3d674492017-09-25 15:37:56 -0400717 if [ "$multi_host" = "client" ] ; then
718 delay="sleep 10"
719 else
Dave Wallace8af20542017-10-26 03:29:30 -0400720 delay="sleep 4"
Dave Wallace3d674492017-09-25 15:37:56 -0400721 fi
722 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400723 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd3_file
724 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
725 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
726 write_script_footer $cmd3_file $perf_client
727 chmod +x $cmd3_file
728 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400729}
730
731docker_kernel() {
732 verify_no_docker_containers
733 banner="Running DOCKER-KERNEL socket test"
734
Dave Wallace3079a642017-09-06 01:59:43 -0400735 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
736 title1="SERVER$title_dbg (Docker-Native Socket Test)"
737 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
738 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
739 set_pre_cmd $emacs_server $gdb_server
740 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
741 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
742 write_script_footer $cmd1_file $perf_server
743 chmod +x $cmd1_file
744 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400745
Dave Wallace3079a642017-09-06 01:59:43 -0400746 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
747 title2="CLIENT$title_dbg (Docker-Native Socket Test)"
748 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
749 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
750 set_pre_cmd $emacs_client $gdb_client
751 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
752 echo "$get_docker_server_ip4addr" >> $cmd2_file
753 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd2_file
754 write_script_footer $cmd2_file $perf_client
755 chmod +x $cmd2_file
756 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400757}
758
759docker_preload() {
760 verify_no_vpp
761 verify_no_docker_containers
762 banner="Running DOCKER-PRELOAD socket test"
Dave Wallace30fb4a22017-08-17 16:22:04 -0400763 docker_ld_preload_dir="/vcl-ldpreload/"
764 ld_preload_dir="$VCL_LDPRELOAD_LIB_DIR"
765 ld_preload="$docker_ld_preload_dir$vcl_ldpreload_lib "
766 docker_ld_preload_lib="$docker_ld_preload_dir$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400767
768 title1="VPP$title_dbg (Docker-Preload Socket Test)"
769 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
770 gdb_cmdfile=$VPP_GDB_CMDFILE
771 set_pre_cmd $emacs_vpp $gdb_vpp
772 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400773 if [ -n "$multi_host" ] ; then
774 echo -n "sudo " >> $cmd1_file
775 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400776 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
777 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400778 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400779
Dave Wallace3079a642017-09-06 01:59:43 -0400780 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
781 title2="SERVER$title_dbg (Docker-Preload Socket Test)"
782 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
783 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
784 set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib
785 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
Dave Wallaceee45d412017-11-24 21:44:06 -0500786 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 -0400787 write_script_footer $cmd2_file $perf_server
788 chmod +x $cmd2_file
789 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400790
Dave Wallace3079a642017-09-06 01:59:43 -0400791 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
792 title3="CLIENT$title_dbg (Docker-Preload Socket Test)"
793 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
794 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
795 set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib
Dave Wallace8af20542017-10-26 03:29:30 -0400796 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
Dave Wallace3079a642017-09-06 01:59:43 -0400797 echo "$get_docker_server_ip4addr" >> $cmd3_file
Dave Wallaceee45d412017-11-24 21:44:06 -0500798 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 -0400799 write_script_footer $cmd3_file $perf_client
800 chmod +x $cmd3_file
801 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400802}
803
804docker_vcl() {
805 verify_no_vpp
806 verify_no_docker_containers
807 banner="Running DOCKER-VCL socket test"
808
809 title1="VPP$title_dbg (Docker-VCL Socket Test)"
810 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
811 gdb_cmdfile=$VPP_GDB_CMDFILE
812 set_pre_cmd $emacs_vpp $gdb_vpp
813 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400814 if [ -n "$multi_host" ] ; then
815 echo -n "sudo " >> $cmd1_file
816 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400817 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
818 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400819 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400820
Dave Wallace3079a642017-09-06 01:59:43 -0400821 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
822 title2="SERVER$title_dbg (Docker-VCL Socket Test)"
823 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
824 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
825 set_pre_cmd $emacs_server $gdb_server
826 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
Dave Wallace8af20542017-10-26 03:29:30 -0400827 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 -0400828 write_script_footer $cmd2_file $perf_server
829 chmod +x $cmd2_file
830 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400831
Dave Wallace3079a642017-09-06 01:59:43 -0400832 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
833 title3="CLIENT$title_dbg (Docker-VCL Socket Test)"
834 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
835 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
836 set_pre_cmd $emacs_client $gdb_client
837 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3"
838 echo "$get_docker_server_ip4addr" >> $cmd3_file
Dave Wallace8af20542017-10-26 03:29:30 -0400839 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 -0400840 write_script_footer $cmd3_file $perf_client
841 chmod +x $cmd3_file
842 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400843}
844
845if [[ $run_test ]] ; then
846 eval $run_test
847else
848 echo "ERROR: Please specify a test to run!" >&2
849 usage;
850fi
851
852if (( $(which xfce4-terminal | wc -l) > 0 )) ; then
853 xterm_cmd="xfce4-terminal --geometry $xterm_geom"
854 if [[ $use_tabs ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400855 declare -a tab_cmd_files
856 declare -a tab_titles
857 declare -i i=0
858
859 if [ -x "$cmd1_file" ] ; then
860 tab_cmd_files[$i]="$cmd1_file"
861 tab_titles[$i]="$title1"
862 (( i++ ))
Dave Wallace543852a2017-08-03 02:11:34 -0400863 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400864 if [ -x "$cmd2_file" ] ; then
865 tab_cmd_files[$i]="$cmd2_file"
866 tab_titles[$i]="$title2"
867 (( i++ ))
868 fi
869 if [ -x "$cmd3_file" ] ; then
870 tab_cmd_files[$i]="$cmd3_file"
871 tab_titles[$i]="$title3"
872 fi
873
874 if [ -n "${tab_cmd_files[2]}" ] ; then
875 $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]}"
876 elif [ -n "${tab_cmd_files[1]}" ] ; then
877 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}"
878
879 else
880 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}"
881 fi
882
Dave Wallace543852a2017-08-03 02:11:34 -0400883 else
Dave Wallace3079a642017-09-06 01:59:43 -0400884 if [ -x "$cmd1_file" ] ; then
885 ($xterm_cmd --title "$title1" --command "$cmd1_file" &)
886 fi
887 if [ -x "$cmd2_file" ] ; then
888 ($xterm_cmd --title "$title2" --command "$cmd2_file" &)
889 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400890 if [ -x "$cmd3_file" ] ; then
891 ($xterm_cmd --title "$title3" --command "$cmd3_file" &)
892 fi
893 fi
894
895else
896 if [[ $use_tabs ]] ; then
897 echo "Sorry, plain ol' xterm doesn't support tabs."
898 fi
899 xterm_cmd="xterm -fs 10 -geometry $xterm_geom"
Dave Wallace3079a642017-09-06 01:59:43 -0400900 if [ -x "$cmd1_file" ] ; then
901 ($xterm_cmd -title "$title1" -e "$cmd1_file" &)
902 fi
903 if [ -x "$cmd2_file" ] ; then
904 ($xterm_cmd -title "$title2" -e "$cmd2_file" &)
905 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400906 if [ -x "$cmd3_file" ] ; then
907 ($xterm_cmd -title "$title3" -e "$cmd3_file" &)
908 fi
909fi
910
911sleep 1