blob: 5c3ea1cdb5acf2cb3bacfef1e7f82ba20d805ff7 [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"
27vppcom_conf="vppcom.conf"
28vppcom_conf_dir="$WS_ROOT/src/uri/"
29docker_vppcom_conf_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}"
Dave Wallaced69f4f42017-08-14 18:26:46 -040052VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-/usr/local/lib}"
Dave Wallace543852a2017-08-03 02:11:34 -040053
54usage() {
55 cat <<EOF
56Usage: socket_test.sh OPTIONS TEST
57TESTS:
58 nk, native-kernel Run server & client on host using kernel.
59 nv, native-vcl Run vpp, server & client on host using VppComLib.
60 np, native-preload Run vpp, server & client on host using LD_PRELOAD.
61 dk, docker-kernel Run server & client in docker using kernel stack.
62 dv, docker-vcl Run vpp on host, server & client in docker using VppComLib.
63 dp, docker-preload Run vpp on host, server & client in docker using LD_PRELOAD.
64
65OPTIONS:
66 -h Print this usage text.
67 -l Leave ${tmp_cmdfile_prefix}* files after test run.
68 -b Run bash after application exit.
69 -d Run the vpp_debug version of all apps.
70 -c Set VPPCOM_CONF to use the vppcom_test.conf file.
71 -i Run iperf3 for client/server app in native tests.
Dave Wallace3d674492017-09-25 15:37:56 -040072 -n Name of ethernet for VPP to use in multi-host cfg.
73 -6 Use ipv6 addressing.
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:
100 VPPCOM_CONF Pathname of vppcom configuration file.
101 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 Wallace3d674492017-09-25 15:37:56 -0400122while getopts ":hitlbcd6n: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 Wallace543852a2017-08-03 02:11:34 -0400133 t) xterm_geom="180x40"
134 use_tabs="true"
135 ;;
136 c) VPPCOM_CONF="${vppcom_conf_dir}vppcom_test.conf"
137 ;;
138 d) title_dbg="-DEBUG"
Dave Wallace3d674492017-09-25 15:37:56 -0400139 _debug="_debug"
Dave Wallace543852a2017-08-03 02:11:34 -0400140 vpp_dir=$vpp_debug_dir
141 lib64_dir=$lib64_debug_dir
142 ;;
143 e) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
144 emacs_client=1
145 emacs_server=1
146 emacs_vpp=1
147 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
148 emacs_client=1
149 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
150 emacs_server=1
151 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
152 emacs_vpp=1
153 else
154 echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2
155 usage
156 fi
157 title_dbg="-DEBUG"
158 vpp_dir=$vpp_debug_dir
159 lib64_dir=$lib64_debug_dir
160 ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400161 n) vpp_eth_name="$OPTARG"
162 ;;
Dave Wallace3079a642017-09-06 01:59:43 -0400163 m) if [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
164 multi_host="client"
165 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
166 multi_host="server"
167 else
168 echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2
169 usage
170 fi
171 ;;
Dave Wallace543852a2017-08-03 02:11:34 -0400172 g) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
173 gdb_client=1
174 gdb_server=1
175 gdb_vpp=1
176 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
177 gdb_client=1
178 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
179 gdb_server=1
180 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
181 gdb_vpp=1
182 else
183 echo "ERROR: Option -g unknown argument \'$OPTARG\'" >&2
184 usage
185 fi
186 title_dbg="-DEBUG"
187 vpp_dir=$vpp_debug_dir
188 lib64_dir=$lib64_debug_dir
189 ;;
190 p) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
191 perf_client=1
192 perf_server=1
193 perf_vpp=1
194 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
195 perf_client=1
196 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
197 perf_server=1
198 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
199 perf_vpp=1
200 else
201 echo "ERROR: Option -p unknown argument \'$OPTARG\'" >&2
202 usage
203 fi
204 echo "WARNING: -p options TBD"
205 ;;
206 S) sock_srvr_addr="$OPTARG"
207 ;;
208 P) sock_srvr_port="$OPTARG"
209 ;;
210E|I|N|R|T) sock_clnt_options="$sock_clnt_options -$opt \"$OPTARG\""
211 ;;
212 U|B|V|X) sock_clnt_options="$sock_clnt_options -$opt"
213 ;;
214 \?)
215 echo "ERROR: Invalid option: -$OPTARG" >&2
216 usage
217 ;;
218 :)
219 echo "ERROR: Option -$OPTARG requires an argument." >&2
220 usage
221 ;;
222 esac
223done
224
225shift $(( $OPTIND-1 ))
226while ! [[ $run_test ]] && (( $# > 0 )) ; do
227 case $1 in
228 "nk" | "native-kernel")
229 run_test="native_kernel" ;;
230 "np" | "native-preload")
231 run_test="native_preload" ;;
232 "nv" | "native-vcl")
233 sock_srvr_app="vcl_test_server"
234 sock_clnt_app="vcl_test_client"
235 run_test="native_vcl" ;;
236 "dk" | "docker-kernel")
237 run_test="docker_kernel" ;;
238 "dp" | "docker-preload")
239 run_test="docker_preload" ;;
240 "dv" | "docker-vcl")
241 sock_srvr_app="vcl_test_server"
242 sock_clnt_app="vcl_test_client"
243 run_test="docker_vcl" ;;
244 *)
245 echo "ERROR: Unknown option '$1'!" >&2
246 usage ;;
247 esac
248 shift
249done
250
251if [ -z "$WS_ROOT" ] ; then
252 echo "ERROR: WS_ROOT environment variable not set!" >&2
253 echo " Please set WS_ROOT to VPP workspace root directory." >&2
Dave Wallace3079a642017-09-06 01:59:43 -0400254 exit 1
Dave Wallace543852a2017-08-03 02:11:34 -0400255fi
256
Dave Wallace3d674492017-09-25 15:37:56 -0400257if [[ "$(grep bin_PROGRAMS $WS_ROOT/src/uri.am)" = "" ]] ; then
258 $WS_ROOT/extras/vagrant/vcl_test.sh $WS_ROOT $USER
259 (cd $WS_ROOT; make build)
260fi
261
Dave Wallace543852a2017-08-03 02:11:34 -0400262if [ ! -d $vpp_dir ] ; then
263 echo "ERROR: Missing VPP$DEBUG bin directory!" >&2
264 echo " $vpp_dir" >&2
265 env_test_failed="true"
266fi
267
268if [[ $run_test =~ .*"_preload" ]] ; then
269 if [ ! -d $lib64_dir ] ; then
270 echo "ERROR: Missing VPP$DEBUG lib64 directory!" >&2
271 echo " $lib64_dir" >&2
Dave Wallaced69f4f42017-08-14 18:26:46 -0400272 elif [ ! -d $VCL_LDPRELOAD_LIB_DIR ] ; then
273 echo "ERROR: Missing VCL LD_PRELOAD Library directory!" >&2
274 echo " $VCL_LDPRELOAD_LIB_DIR" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400275 env_test_failed="true"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400276 elif [ ! -f $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib ] ; then
277 echo "ERROR: Missing VCL LD_PRELOAD library!" >&2
278 echo " $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib" >&2
Dave Wallace543852a2017-08-03 02:11:34 -0400279 env_test_failed="true"
280 fi
281fi
282
283if [ ! -f $vpp_dir$vpp_app ] ; then
284 echo "ERROR: Missing VPP$DEBUG Application!" >&2
285 echo " $vpp_dir$vpp_app" >&2
286 env_test_failed="true"
287fi
288
Dave Wallace30fb4a22017-08-17 16:22:04 -0400289if [ ! -f $vpp_dir$sock_srvr_app ] && [ ! $iperf3 -eq 1 ] ; then
Dave Wallace543852a2017-08-03 02:11:34 -0400290 echo "ERROR: Missing$DEBUG Socket Server Application!" >&2
291 echo " $vpp_dir$sock_srvr_app" >&2
292 env_test_failed="true"
293fi
294
Dave Wallace30fb4a22017-08-17 16:22:04 -0400295if [ ! -f $vpp_dir$sock_clnt_app ] && [ ! $iperf3 -eq 1 ] ; then
Dave Wallace543852a2017-08-03 02:11:34 -0400296 echo "ERROR: Missing$DEBUG Socket Client Application!" >&2
297 echo " $vpp_dir$sock_clnt_app" >&2
298 env_test_failed="true"
299fi
300
301if [[ $run_test =~ "docker_".* ]] ; then
302 if [ $emacs_client -eq 1 ] || [ $emacs_server -eq 1 ] || [ $gdb_client -eq 1 ] || [ $gdb_server -eq 1 ] ; then
303
304 echo "WARNING: gdb is not currently supported in docker."
305 echo " Ignoring client/server gdb options."
306 emacs_client=0
307 emacs_server=0
308 gdb_client=0
309 gdb_server=0
310 fi
311fi
312
Dave Wallace30fb4a22017-08-17 16:22:04 -0400313if [[ $run_test =~ .*"_vcl" ]] && [ $iperf3 -eq 1 ] ; then
314 echo "ERROR: Invalid option 'i' for test $run_test!"
315 echo " iperf3 is not compiled with the VCL library."
316 env_test_failed="true"
317fi
318
Dave Wallace19481612017-09-15 18:47:44 -0400319if [ -n "$mult_host"] && [ ! -f "$dpdk_devbind" ] ; then
320 echo "ERROR: Can't find dpdk-devbind.py!"
321 echo " Run \"cd \$WS_ROOT; make dpdk-install-dev\" to install it."
322 echo
323 env_test_failed="true"
324fi
325
Dave Wallace543852a2017-08-03 02:11:34 -0400326if [ -n "$env_test_failed" ] ; then
327 exit 1
328fi
329
330if [ -f "$VPPCOM_CONF" ] ; then
331 vppcom_conf="$(basename $VPPCOM_CONF)"
332 vppcom_conf_dir="$(dirname $VPPCOM_CONF)/"
333 api_prefix="$(egrep -s '^\s*api-prefix \w+' $VPPCOM_CONF | awk -e '{print $2}')"
334 if [ -n "$api_prefix" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400335 api_segment=" api-segment { gid $user_gid prefix $api_prefix }"
Dave Wallace543852a2017-08-03 02:11:34 -0400336 fi
337fi
Dave Wallace3079a642017-09-06 01:59:43 -0400338if [ -z "$api_segment" ] ; then
339 api_segment=" api-segment { gid $user_gid }"
340fi
341if [ -n "$multi_host" ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400342 sudo modprobe uio_pci_generic
Dave Wallace3079a642017-09-06 01:59:43 -0400343 vpp_args="unix { interactive exec $tmp_vpp_exec_file}${api_segment}"
344else
345 vpp_args="unix { interactive }${api_segment}"
346fi
Dave Wallace543852a2017-08-03 02:11:34 -0400347
Dave Wallace30fb4a22017-08-17 16:22:04 -0400348if [ $iperf3 -eq 1 ] ; then
Dave Wallace543852a2017-08-03 02:11:34 -0400349 app_dir="$(dirname $(which iperf3))/"
350 srvr_app=$iperf_srvr_app
351 clnt_app=$iperf_clnt_app
Dave Wallace30fb4a22017-08-17 16:22:04 -0400352 if [[ $run_test =~ "docker_".* ]] ; then
353 unset -v app_dir
354 sock_srvr_port=5201
355 docker_app_dir="networkstatic/"
356 unset -v docker_os
357 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400358else
359 app_dir="$vpp_dir"
360 srvr_app="$sock_srvr_app $sock_srvr_port"
361 clnt_app="$sock_clnt_app${sock_clnt_options} \$srvr_addr $sock_srvr_port"
362fi
363
364verify_no_vpp() {
Dave Wallace3d674492017-09-25 15:37:56 -0400365 local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\""
366
367 if [ -n "$api_prefix" ] ; then
368 grep_for_vpp="$grep_for_vpp|grep \"prefix $api_prefix\""
369 fi
370 local running_vpp="$(eval $grep_for_vpp)"
371 if [ -n "$running_vpp" ] ; then
372 echo "ERROR: Please kill the following vpp instance(s):"
Dave Wallace543852a2017-08-03 02:11:34 -0400373 echo
Dave Wallace3d674492017-09-25 15:37:56 -0400374 echo $running_vpp
Dave Wallace543852a2017-08-03 02:11:34 -0400375 echo
376 exit 1
377 fi
378 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 -0400379 sudo rm -f $clean_devshm
Dave Wallace543852a2017-08-03 02:11:34 -0400380 devshm_files="$(ls -l $clean_devshm 2>/dev/null | grep $(whoami))"
381 if [ "$devshm_files" != "" ] ; then
382 echo "ERROR: Please remove the following $vpp_shm_dir files:"
383 for file in "$devshm_files" ; do
384 echo " $file"
385 done
386 exit 1
387 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400388 if [ ! -d "$vpp_run_dir" ] ; then
389 sudo mkdir $vpp_run_dir
390 sudo chown root:$USER $vpp_run_dir
391 fi
392 if [ -n "$multi_host" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400393 vpp_eth_pci_id="$(ls -ld /sys/class/net/$vpp_eth_name/device | awk '{print $11}' | cut -d/ -f4)"
394 if [ -z "$vpp_eth_pci_id" ] ; then
395 echo "ERROR: Missing ethernet interface $vpp_eth_name!"
396 usage
397 fi
398 printf -v bus "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f2)"
399 printf -v slot "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f3 | cut -d. -f1)"
400 printf -v func "%x" "0x$(echo $vpp_eth_pci_id | cut -d. -f2)"
401
402 vpp_eth_kernel_driver="$(basename $(ls -l /sys/bus/pci/devices/$vpp_eth_pci_id/driver | awk '{print $11}'))"
403 if [ -z "$vpp_eth_kernel_driver" ] ; then
404 echo "ERROR: Missing kernel driver for $vpp_eth_name!"
405 usage
406 fi
407 case $vpp_eth_kernel_driver in
408 e1000)
409 vpp_eth_ifname="GigabitEthernet$bus/$slot/$func" ;;
410 ixgbe)
411 vpp_eth_ifname="TenGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3d674492017-09-25 15:37:56 -0400412 i40e)
413 vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;;
Dave Wallace3079a642017-09-06 01:59:43 -0400414 *)
415 echo "ERROR: Unknown ethernet kernel driver $vpp_eth_kernel_driver!"
416 usage ;;
417 esac
418
419 vpp_eth_ip4_addr="$(ip -4 -br addr show $vpp_eth_name | awk '{print $3}')"
420 if [ -z "$vpp_eth_ip4_addr" ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400421 if [ "$multi_host" = "server" ] ; then
422 vpp_eth_ip4_addr="10.10.10.10/24"
423 else
424 vpp_eth_ip4_addr="10.10.10.11/24"
425 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400426 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400427 if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400428 echo "ERROR: No inet6 address configured for $vpp_eth_name!"
429 usage
430 fi
Dave Wallace3d674492017-09-25 15:37:56 -0400431 vpp_args="$vpp_args plugins { path ${lib64_dir}vpp_plugins } dpdk { dev $vpp_eth_pci_id }"
Dave Wallace3079a642017-09-06 01:59:43 -0400432
Dave Wallace3d674492017-09-25 15:37:56 -0400433 sudo ifconfig $vpp_eth_name down 2> /dev/null
Dave Wallace3079a642017-09-06 01:59:43 -0400434 echo "Configuring VPP to use $vpp_eth_name ($vpp_eth_pci_id), inet addr $vpp_eth_ip4_addr"
435
436 cat <<EOF >> $tmp_vpp_exec_file
437set int state $vpp_eth_ifname up
438set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr
439EOF
440
441 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400442}
443
444verify_no_docker_containers() {
445 if (( $(which docker | wc -l) < 1 )) ; then
446 echo "ERROR: docker is not installed!"
447 echo "See https://docs.docker.com/engine/installation/linux/ubuntu/"
448 echo " or https://docs.docker.com/engine/installation/linux/centos/"
449 exit 1
450 fi
451 if (( $(docker ps | wc -l) > 1 )) ; then
452 echo "ERROR: Run the following to kill all docker containers:"
453 echo "docker kill \$(docker ps -q)"
454 echo
455 docker ps
456 exit 1
457 fi
458}
459
460set_pre_cmd() {
461 # arguments
462 # $1 : emacs flag
463 # $2 : gdb flag
464 # $3 : optional LD_PRELOAD library pathname
465 local -i emacs=$1
466 local -i gdb=$2
467
468 if [ $emacs -eq 1 ] ; then
469 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
470 pre_cmd="$gdb_in_emacs "
471 elif [ $gdb -eq 1 ] ; then
472 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
473 pre_cmd="gdb -x $tmp_gdb_cmdfile -i=mi --args "
474 elif [ -z $3 ] ; then
475 unset -v pre_cmd
476 else
477 docker_ld_preload="-e LD_PRELOAD=$3 "
478 pre_cmd="LD_PRELOAD=$3 "
479 fi
480}
481
482write_script_header() {
483 # arguments
484 # $1 : command script file
485 # $2 : gdb command file
486 # $3 : title
487 # $4 : optional command string (typically "sleep 2")
488 echo "$bash_header" > $1
489 echo -e "#\n# $1 generated on $(date)\n#" >> $1
490 if [ $leave_tmp_files -eq 0 ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400491 if [ -n "$multi_host" ] ; then
492 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 -0400493 else
494 echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1
495 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400496 fi
497 echo "export VPPCOM_CONF=${vppcom_conf_dir}${vppcom_conf}" >> $1
498 if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then
Dave Wallace3d674492017-09-25 15:37:56 -0400499 if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400500 cat <<EOF >> $1
501$gdb_in_emacs() {
502 sudo emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
503}
504EOF
505 else
506 cat <<EOF >> $1
Dave Wallace543852a2017-08-03 02:11:34 -0400507$gdb_in_emacs() {
508 emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
509}
510EOF
Dave Wallace3079a642017-09-06 01:59:43 -0400511 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400512 fi
513 if [ -n "$4" ] ; then
514 echo "$4" >> $1
515 fi
516}
517
518write_script_footer() {
519 # arguments
520 # $1 : command script file
521 # $2 : perf flag indicating to run bash before exit
522 local -i perf=$2
523 if [ $bash_after_exit -eq 1 ] || [ $perf -eq 1 ] ; then
524 echo "bash" >> $1
525 fi
526}
527
528write_gdb_cmdfile() {
529 # arguments
530 # $1 : gdb command file
531 # $2 : User specified gdb cmdfile
532 # $3 : emacs flag
533 # $4 : optional LD_PRELOAD library pathname.
534 local -i emacs=$3
535
536 echo "# $1 generated on $(date)" > $1
537 echo "#" >> $1
538 echo "set confirm off" >> $1
539 if [ -n "$4" ] ; then
540 echo "set exec-wrapper env LD_PRELOAD=$4" >> $1
541 echo "start" >> $1
542 fi
543
544 if [ ! -f $2 ] ; then
545 echo -n "# " >> $1
546 fi
547 echo "source $2" >> $1
548 if [ $emacs -eq 0 ] ; then
549 echo "run" >> $1
550 fi
551}
552
553native_kernel() {
554 banner="Running NATIVE-KERNEL socket test"
Dave Wallace3079a642017-09-06 01:59:43 -0400555 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
556 title1="SERVER$title_dbg (Native-Kernel Socket Test)"
557 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
558 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
559 set_pre_cmd $emacs_server $gdb_server
560 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
561 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd1_file
562 write_script_footer $cmd1_file $perf_server
563 chmod +x $cmd1_file
564 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400565
Dave Wallace3079a642017-09-06 01:59:43 -0400566 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
567 title2="CLIENT$title_dbg (Native-Kernel Socket Test)"
568 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
569 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
570 set_pre_cmd $emacs_client $gdb_client
571 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
572 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd2_file
573 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd2_file
574 write_script_footer $cmd2_file $perf_client
575 chmod +x $cmd2_file
Dave Wallace543852a2017-08-03 02:11:34 -0400576
Dave Wallace3079a642017-09-06 01:59:43 -0400577 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400578}
579
580native_preload() {
581 verify_no_vpp
582 banner="Running NATIVE-PRELOAD socket test"
Dave Wallaced69f4f42017-08-14 18:26:46 -0400583 ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400584
585 title1="VPP$title_dbg (Native-Preload Socket Test)"
586 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
587 gdb_cmdfile=$VPP_GDB_CMDFILE
588 set_pre_cmd $emacs_vpp $gdb_vpp
589 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400590 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
591 echo -n "sudo " >> $cmd1_file
592 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400593 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
594 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400595 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400596
Dave Wallace3079a642017-09-06 01:59:43 -0400597 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
598 title2="SERVER$title_dbg (Native-Preload Socket Test)"
599 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
600 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
601 set_pre_cmd $emacs_server $gdb_server $ld_preload
602 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
603 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd2_file
604 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
605 write_script_footer $cmd2_file $perf_server
606 chmod +x $cmd2_file
607 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400608
Dave Wallace3079a642017-09-06 01:59:43 -0400609 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
610 title3="CLIENT$title_dbg (Native-Preload Socket Test)"
611 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
612 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
613 set_pre_cmd $emacs_client $gdb_client $ld_preload
614 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3"
615 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd3_file
616 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
617 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
618 write_script_footer $cmd3_file $perf_client
619 chmod +x $cmd3_file
620 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400621}
622
623native_vcl() {
624 verify_no_vpp
625 banner="Running NATIVE-VCL socket test"
626
627 title1="VPP$title_dbg (Native-VCL Socket Test)"
628 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
629 gdb_cmdfile=$VPP_GDB_CMDFILE
630 set_pre_cmd $emacs_vpp $gdb_vpp
631 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400632 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
633 echo -n "sudo " >> $cmd1_file
634 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400635 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
636 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400637 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400638
Dave Wallace3079a642017-09-06 01:59:43 -0400639 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
640 title2="SERVER$title_dbg (Native-VCL Socket Test)"
641 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
642 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
643 set_pre_cmd $emacs_server $gdb_server
Dave Wallace3d674492017-09-25 15:37:56 -0400644 if [ "$multi_host" = "server" ] ; then
645 delay="sleep 10"
646 else
Dave Wallacef7f809c2017-10-03 01:48:42 -0400647 delay="sleep 2"
Dave Wallace3d674492017-09-25 15:37:56 -0400648 fi
649 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400650 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd2_file
651 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
652 write_script_footer $cmd2_file $perf_server
653 chmod +x $cmd2_file
654 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400655
Dave Wallace3079a642017-09-06 01:59:43 -0400656 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
657 title3="CLIENT$title_dbg (Native-VCL Socket Test)"
658 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
659 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
660 set_pre_cmd $emacs_client $gdb_client
Dave Wallace3d674492017-09-25 15:37:56 -0400661 if [ "$multi_host" = "client" ] ; then
662 delay="sleep 10"
663 else
Dave Wallacef7f809c2017-10-03 01:48:42 -0400664 delay="sleep 2"
Dave Wallace3d674492017-09-25 15:37:56 -0400665 fi
666 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay"
Dave Wallace3079a642017-09-06 01:59:43 -0400667 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd3_file
668 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
669 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
670 write_script_footer $cmd3_file $perf_client
671 chmod +x $cmd3_file
672 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400673}
674
675docker_kernel() {
676 verify_no_docker_containers
677 banner="Running DOCKER-KERNEL socket test"
678
Dave Wallace3079a642017-09-06 01:59:43 -0400679 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
680 title1="SERVER$title_dbg (Docker-Native Socket Test)"
681 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
682 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
683 set_pre_cmd $emacs_server $gdb_server
684 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
685 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
686 write_script_footer $cmd1_file $perf_server
687 chmod +x $cmd1_file
688 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400689
Dave Wallace3079a642017-09-06 01:59:43 -0400690 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
691 title2="CLIENT$title_dbg (Docker-Native Socket Test)"
692 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
693 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
694 set_pre_cmd $emacs_client $gdb_client
695 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
696 echo "$get_docker_server_ip4addr" >> $cmd2_file
697 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd2_file
698 write_script_footer $cmd2_file $perf_client
699 chmod +x $cmd2_file
700 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400701}
702
703docker_preload() {
704 verify_no_vpp
705 verify_no_docker_containers
706 banner="Running DOCKER-PRELOAD socket test"
Dave Wallace30fb4a22017-08-17 16:22:04 -0400707 docker_ld_preload_dir="/vcl-ldpreload/"
708 ld_preload_dir="$VCL_LDPRELOAD_LIB_DIR"
709 ld_preload="$docker_ld_preload_dir$vcl_ldpreload_lib "
710 docker_ld_preload_lib="$docker_ld_preload_dir$vcl_ldpreload_lib "
Dave Wallace543852a2017-08-03 02:11:34 -0400711
712 title1="VPP$title_dbg (Docker-Preload Socket Test)"
713 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
714 gdb_cmdfile=$VPP_GDB_CMDFILE
715 set_pre_cmd $emacs_vpp $gdb_vpp
716 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400717 if [ -n "$multi_host" ] ; then
718 echo -n "sudo " >> $cmd1_file
719 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400720 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
721 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400722 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400723
Dave Wallace3079a642017-09-06 01:59:43 -0400724 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
725 title2="SERVER$title_dbg (Docker-Preload Socket Test)"
726 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
727 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
728 set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib
729 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
730 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 $vppcom_conf_dir:$docker_vppcom_conf_dir -p $sock_srvr_port:$sock_srvr_port -e VPPCOM_CONF=${docker_vppcom_conf_dir}$vppcom_conf -e LD_LIBRARY_PATH=$docker_lib64_dir:$docker_ld_preload_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file
731 write_script_footer $cmd2_file $perf_server
732 chmod +x $cmd2_file
733 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400734
Dave Wallace3079a642017-09-06 01:59:43 -0400735 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
736 title3="CLIENT$title_dbg (Docker-Preload Socket Test)"
737 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
738 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
739 set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib
740 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3"
741 echo "$get_docker_server_ip4addr" >> $cmd3_file
742 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 $vppcom_conf_dir:$docker_vppcom_conf_dir -e VPPCOM_CONF=${docker_vppcom_conf_dir}$vppcom_conf -e LD_LIBRARY_PATH=$docker_lib64_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file
743 write_script_footer $cmd3_file $perf_client
744 chmod +x $cmd3_file
745 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400746}
747
748docker_vcl() {
749 verify_no_vpp
750 verify_no_docker_containers
751 banner="Running DOCKER-VCL socket test"
752
753 title1="VPP$title_dbg (Docker-VCL Socket Test)"
754 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
755 gdb_cmdfile=$VPP_GDB_CMDFILE
756 set_pre_cmd $emacs_vpp $gdb_vpp
757 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
Dave Wallace3079a642017-09-06 01:59:43 -0400758 if [ -n "$multi_host" ] ; then
759 echo -n "sudo " >> $cmd1_file
760 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400761 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
762 write_script_footer $cmd1_file $perf_vpp
Dave Wallace3079a642017-09-06 01:59:43 -0400763 chmod +x $cmd1_file
Dave Wallace543852a2017-08-03 02:11:34 -0400764
Dave Wallace3079a642017-09-06 01:59:43 -0400765 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
766 title2="SERVER$title_dbg (Docker-VCL Socket Test)"
767 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
768 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
769 set_pre_cmd $emacs_server $gdb_server
770 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
771 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 $vppcom_conf_dir:$docker_vppcom_conf_dir -p $sock_srvr_port:$sock_srvr_port -e VPPCOM_CONF=${docker_vppcom_conf_dir}/$vppcom_conf -e LD_LIBRARY_PATH=$docker_lib64_dir $docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file
772 write_script_footer $cmd2_file $perf_server
773 chmod +x $cmd2_file
774 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400775
Dave Wallace3079a642017-09-06 01:59:43 -0400776 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
777 title3="CLIENT$title_dbg (Docker-VCL Socket Test)"
778 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
779 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
780 set_pre_cmd $emacs_client $gdb_client
781 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3"
782 echo "$get_docker_server_ip4addr" >> $cmd3_file
783 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 $vppcom_conf_dir:$docker_vppcom_conf_dir -e VPPCOM_CONF=${docker_vppcom_conf_dir}/$vppcom_conf -e LD_LIBRARY_PATH=$docker_lib64_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file
784 write_script_footer $cmd3_file $perf_client
785 chmod +x $cmd3_file
786 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400787}
788
789if [[ $run_test ]] ; then
790 eval $run_test
791else
792 echo "ERROR: Please specify a test to run!" >&2
793 usage;
794fi
795
796if (( $(which xfce4-terminal | wc -l) > 0 )) ; then
797 xterm_cmd="xfce4-terminal --geometry $xterm_geom"
798 if [[ $use_tabs ]] ; then
Dave Wallace3079a642017-09-06 01:59:43 -0400799 declare -a tab_cmd_files
800 declare -a tab_titles
801 declare -i i=0
802
803 if [ -x "$cmd1_file" ] ; then
804 tab_cmd_files[$i]="$cmd1_file"
805 tab_titles[$i]="$title1"
806 (( i++ ))
Dave Wallace543852a2017-08-03 02:11:34 -0400807 fi
Dave Wallace3079a642017-09-06 01:59:43 -0400808 if [ -x "$cmd2_file" ] ; then
809 tab_cmd_files[$i]="$cmd2_file"
810 tab_titles[$i]="$title2"
811 (( i++ ))
812 fi
813 if [ -x "$cmd3_file" ] ; then
814 tab_cmd_files[$i]="$cmd3_file"
815 tab_titles[$i]="$title3"
816 fi
817
818 if [ -n "${tab_cmd_files[2]}" ] ; then
819 $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]}"
820 elif [ -n "${tab_cmd_files[1]}" ] ; then
821 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}"
822
823 else
824 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}"
825 fi
826
Dave Wallace543852a2017-08-03 02:11:34 -0400827 else
Dave Wallace3079a642017-09-06 01:59:43 -0400828 if [ -x "$cmd1_file" ] ; then
829 ($xterm_cmd --title "$title1" --command "$cmd1_file" &)
830 fi
831 if [ -x "$cmd2_file" ] ; then
832 ($xterm_cmd --title "$title2" --command "$cmd2_file" &)
833 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400834 if [ -x "$cmd3_file" ] ; then
835 ($xterm_cmd --title "$title3" --command "$cmd3_file" &)
836 fi
837 fi
838
839else
840 if [[ $use_tabs ]] ; then
841 echo "Sorry, plain ol' xterm doesn't support tabs."
842 fi
843 xterm_cmd="xterm -fs 10 -geometry $xterm_geom"
Dave Wallace3079a642017-09-06 01:59:43 -0400844 if [ -x "$cmd1_file" ] ; then
845 ($xterm_cmd -title "$title1" -e "$cmd1_file" &)
846 fi
847 if [ -x "$cmd2_file" ] ; then
848 ($xterm_cmd -title "$title2" -e "$cmd2_file" &)
849 fi
Dave Wallace543852a2017-08-03 02:11:34 -0400850 if [ -x "$cmd3_file" ] ; then
851 ($xterm_cmd -title "$title3" -e "$cmd3_file" &)
852 fi
853fi
854
855sleep 1