3 # socket_test.sh -- script to run socket tests.
5 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6 vpp_dir="$WS_ROOT/build-root/install-vpp-native/vpp/bin/"
7 vpp_debug_dir="$WS_ROOT/build-root/install-vpp_debug-native/vpp/bin/"
8 vpp_shm_dir="/dev/shm/"
10 lib64_dir="$WS_ROOT/build-root/install-vpp-native/vpp/lib64/"
11 lib64_debug_dir="$WS_ROOT/build-root/install-vpp_debug-native/vpp/lib64/"
12 dpdk_devbind="/usr/share/dpdk/usertools/dpdk-devbind.py"
13 docker_vpp_dir="/vpp/"
14 docker_app_dir="/vpp/"
15 docker_lib64_dir="/vpp-lib64/"
17 vcl_ldpreload_lib="libvcl_ldpreload.so.0.0.0"
20 sock_srvr_app="sock_test_server"
21 sock_clnt_app="sock_test_client"
22 sock_srvr_addr="127.0.0.1"
23 sock_srvr_port="22000"
24 iperf_srvr_app="iperf3 -V4d -s"
25 iperf_clnt_app="iperf3 -V4d -c \$srvr_addr"
26 gdb_in_emacs="gdb_in_emacs"
28 vcl_config_dir="$WS_ROOT/src/vcl/"
29 docker_vcl_config_dir="/etc/vpp/"
31 bash_header="#! /bin/bash"
32 tmp_cmdfile_prefix="/tmp/socket_test_cmd"
33 cmd1_file="${tmp_cmdfile_prefix}1.$$"
34 cmd2_file="${tmp_cmdfile_prefix}2.$$"
35 cmd3_file="${tmp_cmdfile_prefix}3.$$"
37 tmp_vpp_exec_file="/tmp/vpp_config.$$"
38 tmp_gdb_cmdfile_prefix="/tmp/gdb_cmdfile"
39 def_gdb_cmdfile_prefix="$WS_ROOT/extras/gdb/gdb_cmdfile"
40 tmp_gdb_cmdfile_vpp="${tmp_gdb_cmdfile_prefix}_vpp.$$"
41 tmp_gdb_cmdfile_client="${tmp_gdb_cmdfile_prefix}_vcl_client.$$"
42 tmp_gdb_cmdfile_server="${tmp_gdb_cmdfile_prefix}_vcl_server.$$"
43 get_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.
45 trap_signals="SIGINT SIGTERM EXIT"
47 # Set default values for imported environment variables if they don't exist.
49 VPP_GDB_CMDFILE="${VPP_GDB_CMDFILE:-${def_gdb_cmdfile_prefix}.vpp}"
50 VPPCOM_CLIENT_GDB_CMDFILE="${VPPCOM_CLIENT_GDB_CMDFILE:-${def_gdb_cmdfile_prefix}.vppcom_client}"
51 VPPCOM_SERVER_GDB_CMDFILE="${VPPCOM_SERVER_GDB_CMDFILE:-${def_gdb_cmdfile_prefix}.vppcom_server}"
55 Usage: socket_test.sh OPTIONS TEST
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.
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.
69 -c Set VCL_CONFIG to use the vcl_test.conf file.
70 -i Run iperf3 for client/server app in native tests.
71 -n Name of ethernet for VPP to use in multi-host cfg.
72 -6 Use ipv6 addressing.
73 -f Full thru host stack vpp configuration.
74 -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)
76 -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.
84 -t Use tabs in one xterm if available (e.g. xfce4-terminal).
86 OPTIONS 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.
99 Environment variables:
100 VCL_CONFIG 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.
108 declare -i emacs_vpp=0
109 declare -i emacs_client=0
110 declare -i emacs_server=0
112 declare -i gdb_client=0
113 declare -i gdb_server=0
114 declare -i perf_vpp=0
115 declare -i perf_client=0
116 declare -i perf_server=0
117 declare -i leave_tmp_files=0
118 declare -i bash_after_exit=0
120 declare -i use_ipv6=0
122 while getopts ":hitlbcd6fn:m:e:g:p:E:I:N:P:R:S:T:UBVX" opt; do
133 f) full_thru_host_stack_vpp_cfg=1
135 t) xterm_geom="180x40"
138 c) VCL_CONFIG="${vcl_config_dir}vcl_test.conf"
140 d) title_dbg="-DEBUG"
141 vpp_dir=$vpp_debug_dir
142 lib64_dir=$lib64_debug_dir
144 e) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
148 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
150 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
152 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
155 echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2
159 vpp_dir=$vpp_debug_dir
160 lib64_dir=$lib64_debug_dir
162 n) vpp_eth_name="$OPTARG"
164 m) if [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
166 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
169 echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2
173 g) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
177 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
179 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
181 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
184 echo "ERROR: Option -g unknown argument \'$OPTARG\'" >&2
188 vpp_dir=$vpp_debug_dir
189 lib64_dir=$lib64_debug_dir
191 p) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then
195 elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then
197 elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then
199 elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then
202 echo "ERROR: Option -p unknown argument \'$OPTARG\'" >&2
205 echo "WARNING: -p options TBD"
207 S) sock_srvr_addr="$OPTARG"
209 P) sock_srvr_port="$OPTARG"
211 E|I|N|R|T) sock_clnt_options="$sock_clnt_options -$opt \"$OPTARG\""
213 U|B|V|X) sock_clnt_options="$sock_clnt_options -$opt"
216 echo "ERROR: Invalid option: -$OPTARG" >&2
220 echo "ERROR: Option -$OPTARG requires an argument." >&2
226 shift $(( $OPTIND-1 ))
227 while ! [[ $run_test ]] && (( $# > 0 )) ; do
229 "nk" | "native-kernel")
230 run_test="native_kernel" ;;
231 "np" | "native-preload")
232 run_test="native_preload" ;;
234 sock_srvr_app="vcl_test_server"
235 sock_clnt_app="vcl_test_client"
236 run_test="native_vcl" ;;
237 "dk" | "docker-kernel")
238 run_test="docker_kernel" ;;
239 "dp" | "docker-preload")
240 run_test="docker_preload" ;;
242 sock_srvr_app="vcl_test_server"
243 sock_clnt_app="vcl_test_client"
244 run_test="docker_vcl" ;;
246 echo "ERROR: Unknown option '$1'!" >&2
252 if [ -z "$VCL_DEBUG" ] ; then
253 if [ "$title_dbg" = "-DEBUG" ] ; then
260 VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-$lib64_dir}"
262 if [ -z "$WS_ROOT" ] ; then
263 echo "ERROR: WS_ROOT environment variable not set!" >&2
264 echo " Please set WS_ROOT to VPP workspace root directory." >&2
268 if [[ "$(grep bin_PROGRAMS $WS_ROOT/src/vcl.am)" = "" ]] ; then
269 $WS_ROOT/extras/vagrant/vcl_test.sh $WS_ROOT $USER
270 (cd $WS_ROOT; make build)
273 if [ ! -d $vpp_dir ] ; then
274 echo "ERROR: Missing VPP$title_dbg bin directory!" >&2
276 env_test_failed="true"
279 if [[ $run_test =~ .*"_preload" ]] ; then
280 if [ ! -d $lib64_dir ] ; then
281 echo "ERROR: Missing VPP$title_dbg lib64 directory!" >&2
282 echo " $lib64_dir" >&2
283 elif [ ! -d $VCL_LDPRELOAD_LIB_DIR ] ; then
284 echo "ERROR: Missing VCL LD_PRELOAD Library directory!" >&2
285 echo " $VCL_LDPRELOAD_LIB_DIR" >&2
286 env_test_failed="true"
287 elif [ ! -f $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib ] ; then
288 echo "ERROR: Missing VCL LD_PRELOAD library!" >&2
289 echo " $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib" >&2
290 env_test_failed="true"
294 if [ ! -f $vpp_dir$vpp_app ] ; then
295 echo "ERROR: Missing VPP$title_dbg Application!" >&2
296 echo " $vpp_dir$vpp_app" >&2
297 env_test_failed="true"
300 if [ ! -f $vpp_dir$sock_srvr_app ] && [ ! $iperf3 -eq 1 ] ; then
301 echo "ERROR: Missing$title_dbg Socket Server Application!" >&2
302 echo " $vpp_dir$sock_srvr_app" >&2
303 env_test_failed="true"
306 if [ ! -f $vpp_dir$sock_clnt_app ] && [ ! $iperf3 -eq 1 ] ; then
307 echo "ERROR: Missing$title_dbg Socket Client Application!" >&2
308 echo " $vpp_dir$sock_clnt_app" >&2
309 env_test_failed="true"
312 if [[ $run_test =~ "docker_".* ]] ; then
313 if [ $emacs_client -eq 1 ] || [ $emacs_server -eq 1 ] || [ $gdb_client -eq 1 ] || [ $gdb_server -eq 1 ] ; then
315 echo "WARNING: gdb is not currently supported in docker."
316 echo " Ignoring client/server gdb options."
324 if [[ $run_test =~ .*"_vcl" ]] && [ $iperf3 -eq 1 ] ; then
325 echo "ERROR: Invalid option 'i' for test $run_test!"
326 echo " iperf3 is not compiled with the VCL library."
327 env_test_failed="true"
330 if [ -n "$multi_host"] && [ ! -f "$dpdk_devbind" ] ; then
331 echo "ERROR: Can't find dpdk-devbind.py!"
332 echo " Run \"cd \$WS_ROOT; make dpdk-install-dev\" to install it."
334 env_test_failed="true"
337 if [ -n "$full_thru_host_stack_vpp_cfg" ] && [ -n "$multi_host" ] ; then
338 echo "ERROR: Invalid options, cannot specify both \"-f\" and \"-m $multi_host\"!"
340 env_test_failed="true"
343 if [ -n "$env_test_failed" ] ; then
347 if [ -f "$VCL_CONFIG" ] ; then
348 vcl_config="$(basename $VCL_CONFIG)"
349 vcl_config_dir="$(dirname $VCL_CONFIG)/"
350 api_prefix="$(egrep -s '^\s*api-prefix \w+' $VCL_CONFIG | tail -1 | awk -e '{print $2}')"
351 if [ -n "$api_prefix" ] ; then
352 api_segment=" api-segment { gid $user_gid prefix $api_prefix }"
355 if [ -n "$VCL_APP_NAMESPACE_ID" ] && [ -n "$VCL_APP_NAMESPACE_SECRET" ] ; then
356 namespace_id="$VCL_APP_NAMESPACE_ID"
357 namespace_secret="$VCL_APP_NAMESPACE_SECRET"
360 if [ -z "$api_segment" ] ; then
361 api_segment=" api-segment { gid $user_gid }"
363 vpp_args="unix { interactive full-coredump coredump-size unlimited exec $tmp_vpp_exec_file}${api_segment}"
365 if [ $iperf3 -eq 1 ] ; then
366 app_dir="$(dirname $(which iperf3))/"
367 srvr_app=$iperf_srvr_app
368 clnt_app=$iperf_clnt_app
369 if [[ $run_test =~ "docker_".* ]] ; then
372 docker_app_dir="networkstatic/"
377 srvr_app="$sock_srvr_app $sock_srvr_port"
378 clnt_app="$sock_clnt_app${sock_clnt_options} \$srvr_addr $sock_srvr_port"
383 local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\""
385 if [ -n "$api_prefix" ] ; then
386 grep_for_vpp="$grep_for_vpp|grep \"prefix $api_prefix\""
388 local running_vpp="$(eval $grep_for_vpp)"
389 if [ -n "$running_vpp" ] ; then
390 echo "ERROR: Please kill the following vpp instance(s):"
396 clean_devshm="$vpp_shm_dir*db $vpp_shm_dir*global_vm $vpp_shm_dir*vpe-api $vpp_shm_dir[0-9]*-[0-9]* $vpp_shm_dir*:segment[0-9]*"
397 sudo rm -f $clean_devshm
398 devshm_files="$(ls -l $clean_devshm 2>/dev/null | grep $(whoami))"
399 if [ "$devshm_files" != "" ] ; then
400 echo "ERROR: Please remove the following $vpp_shm_dir files:"
401 for file in "$devshm_files" ; do
406 if [ ! -d "$vpp_run_dir" ] ; then
407 sudo mkdir $vpp_run_dir
408 sudo chown root:$USER $vpp_run_dir
410 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
411 sock_srvr_addr=172.16.1.1
412 client_namespace_id="1"
413 client_namespace_secret="5678"
414 server_namespace_id="0"
415 server_namespace_secret="1234"
416 cat <<EOF >> $tmp_vpp_exec_file
420 set inter state loop0 up
421 set inter ip table loop0 0
422 set inter ip address loop0 172.16.1.1/24
423 set inter state loop1 up
424 set inter ip table loop1 1
425 set inter ip address loop1 172.16.2.1/24
426 app ns add id 0 secret 1234 sw_if_index 1
427 app ns add id 1 secret 5678 sw_if_index 2
428 ip route add 172.16.1.1/32 table 1 via lookup in table 0
429 ip route add 172.16.2.1/32 table 0 via lookup in table 1
432 elif [ -n "$multi_host" ] ; then
433 vpp_eth_pci_id="$(ls -ld /sys/class/net/$vpp_eth_name/device | awk '{print $11}' | cut -d/ -f4)"
434 if [ -z "$vpp_eth_pci_id" ] ; then
435 echo "ERROR: Missing ethernet interface $vpp_eth_name!"
438 printf -v bus "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f2)"
439 printf -v slot "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f3 | cut -d. -f1)"
440 printf -v func "%x" "0x$(echo $vpp_eth_pci_id | cut -d. -f2)"
442 vpp_eth_kernel_driver="$(basename $(ls -l /sys/bus/pci/devices/$vpp_eth_pci_id/driver | awk '{print $11}'))"
443 if [ -z "$vpp_eth_kernel_driver" ] ; then
444 echo "ERROR: Missing kernel driver for $vpp_eth_name!"
447 case $vpp_eth_kernel_driver in
449 vpp_eth_ifname="GigabitEthernet$bus/$slot/$func" ;;
451 vpp_eth_ifname="TenGigabitEthernet$bus/$slot/$func" ;;
453 vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;;
455 echo "ERROR: Unknown ethernet kernel driver $vpp_eth_kernel_driver!"
459 vpp_eth_ip4_addr="$(ip -4 -br addr show $vpp_eth_name | awk '{print $3}')"
460 if [ -z "$vpp_eth_ip4_addr" ] ; then
461 if [ "$multi_host" = "server" ] ; then
462 vpp_eth_ip4_addr="10.10.10.10/24"
464 vpp_eth_ip4_addr="10.10.10.11/24"
467 if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then
468 echo "ERROR: No inet6 address configured for $vpp_eth_name!"
471 vpp_args="$vpp_args plugins { path ${lib64_dir}vpp_plugins } dpdk { dev $vpp_eth_pci_id }"
473 sudo ifconfig $vpp_eth_name down 2> /dev/null
474 echo "Configuring VPP to use $vpp_eth_name ($vpp_eth_pci_id), inet addr $vpp_eth_ip4_addr"
476 cat <<EOF >> $tmp_vpp_exec_file
477 set int state $vpp_eth_ifname up
478 set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr
483 if [ -z "$full_thru_host_stack_vpp_cfg" ] && [ -n "$namespace_id" ] ; then
484 cat <<EOF >> $tmp_vpp_exec_file
486 app ns add id $namespace_id secret $namespace_secret sw_if_index 0
490 cat <<EOF >> $tmp_vpp_exec_file
498 verify_no_docker_containers() {
499 if (( $(which docker | wc -l) < 1 )) ; then
500 echo "ERROR: docker is not installed!"
501 echo "See https://docs.docker.com/engine/installation/linux/ubuntu/"
502 echo " or https://docs.docker.com/engine/installation/linux/centos/"
505 if (( $(docker ps | wc -l) > 1 )) ; then
506 echo "ERROR: Run the following to kill all docker containers:"
507 echo "docker kill \$(docker ps -q)"
518 # $3 : optional LD_PRELOAD library pathname
522 if [ $emacs -eq 1 ] ; then
523 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
524 pre_cmd="$gdb_in_emacs "
525 elif [ $gdb -eq 1 ] ; then
526 write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3
527 pre_cmd="gdb -x $tmp_gdb_cmdfile --args "
528 elif [ -z $3 ] ; then
531 docker_ld_preload="-e LD_PRELOAD=$3 "
532 pre_cmd="LD_PRELOAD=$3 "
536 write_script_header() {
538 # $1 : command script file
539 # $2 : gdb command file
541 # $4 : optional command string (typically "sleep 2")
542 echo "$bash_header" > $1
543 echo -e "#\n# $1 generated on $(date)\n#" >> $1
544 if [ $leave_tmp_files -eq 0 ] ; then
545 if [ -n "$multi_host" ] ; then
546 echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file; sudo $dpdk_devbind -b $vpp_eth_kernel_driver $vpp_eth_pci_id; sudo ifconfig $vpp_eth_name up\" $trap_signals" >> $1
548 echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1
551 if [ -n "$VCL_CONFIG" ] ; then
552 echo "export VCL_CONFIG=${vcl_config_dir}${vcl_config}" >> $1
554 if [ -n "$VCL_API_PREFIX" ] ; then
555 echo "export VCL_API_PREFIX=$VCL_API_PREFIX" >> $1
557 if [ -n "$VCL_DEBUG" ] ; then
558 echo "export VCL_DEBUG=$VCL_DEBUG" >> $1
560 if [ -n "$LDP_DEBUG" ] ; then
561 echo "export LDP_DEBUG=$LDP_DEBUG" >> $1
563 if [ -n "$VCOM_APP_NAME" ] ; then
564 echo "export VCOM_APP_NAME=$VCOM_APP_NAME" >> $1
566 if [ -n "$VCOM_SID_BIT" ] ; then
567 echo "export VCOM_SID_BIT=$VCOM_SID_BIT" >> $1
569 if [ -n "$namespace_id" ] ; then
570 echo "export VCL_APP_NAMESPACE_ID=\"$namespace_id\"" >> $1
571 echo "export VCL_APP_NAMESPACE_SECRET=\"$namespace_secret\"" >> $1
573 if [ -n "$VCL_APP_SCOPE_LOCAL" ] || [ -z "$multi_host" ] &&
574 [ -z "$full_thru_host_stack_vpp_cfg" ] ; then
575 echo "export VCL_APP_SCOPE_LOCAL=true" >> $1
577 if [ -n "$VCL_APP_SCOPE_GLOBAL" ] || [ -n "$multi_host" ] ||
578 [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
579 echo "export VCL_APP_SCOPE_GLOBAL=true" >> $1
581 if [ -n "$VCL_APP_PROXY_TRANSPORT_TCP" ] ; then
582 echo "export VCL_APP_PROXY_TRANSPORT_TCP=true" >> $1
584 if [ -n "$VCL_APP_PROXY_TRANSPORT_UDP" ] ; then
585 echo "export VCL_APP_PROXY_TRANSPORT_UDP=true" >> $1
587 if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then
588 if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then
591 sudo emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
597 emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")"
602 if [ -n "$4" ] ; then
607 write_script_footer() {
609 # $1 : command script file
610 # $2 : perf flag indicating to run bash before exit
612 if [ $bash_after_exit -eq 1 ] || [ $perf -eq 1 ] ; then
617 write_gdb_cmdfile() {
619 # $1 : gdb command file
620 # $2 : User specified gdb cmdfile
622 # $4 : optional LD_PRELOAD library pathname.
625 echo "# $1 generated on $(date)" > $1
627 echo "set confirm off" >> $1
628 if [ -n "$4" ] ; then
629 echo "set exec-wrapper env LD_PRELOAD=$4" >> $1
633 if [ ! -f $2 ] ; then
636 echo "source $2" >> $1
637 if [ $emacs -eq 0 ] ; then
643 banner="Running NATIVE-KERNEL socket test"
644 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
645 title1="SERVER$title_dbg (Native-Kernel Socket Test)"
646 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
647 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
648 set_pre_cmd $emacs_server $gdb_server
649 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
650 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd1_file
651 write_script_footer $cmd1_file $perf_server
655 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
656 title2="CLIENT$title_dbg (Native-Kernel Socket Test)"
657 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
658 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
659 set_pre_cmd $emacs_client $gdb_client
660 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
661 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd2_file
662 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd2_file
663 write_script_footer $cmd2_file $perf_client
671 banner="Running NATIVE-PRELOAD socket test"
672 ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib "
674 title1="VPP$title_dbg (Native-Preload Socket Test)"
675 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
676 gdb_cmdfile=$VPP_GDB_CMDFILE
677 set_pre_cmd $emacs_vpp $gdb_vpp
678 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
679 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
680 echo -n "sudo " >> $cmd1_file
682 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
683 write_script_footer $cmd1_file $perf_vpp
686 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
687 title2="SERVER$title_dbg (Native-Preload Socket Test)"
688 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
689 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
690 set_pre_cmd $emacs_server $gdb_server $ld_preload
691 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
692 namespace_id="$server_namespace_id"
693 namespace_secret="$server_namespace_secret"
695 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
696 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd2_file
697 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
698 write_script_footer $cmd2_file $perf_server
702 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
703 title3="CLIENT$title_dbg (Native-Preload Socket Test)"
704 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
705 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
706 set_pre_cmd $emacs_client $gdb_client $ld_preload
707 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
708 namespace_id="$client_namespace_id"
709 namespace_secret="$client_namespace_secret"
711 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
712 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd3_file
713 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
714 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
715 write_script_footer $cmd3_file $perf_client
722 banner="Running NATIVE-VCL socket test"
724 title1="VPP$title_dbg (Native-VCL Socket Test)"
725 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
726 gdb_cmdfile=$VPP_GDB_CMDFILE
727 set_pre_cmd $emacs_vpp $gdb_vpp
728 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
729 if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then
730 echo -n "sudo " >> $cmd1_file
732 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file
733 write_script_footer $cmd1_file $perf_vpp
736 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
737 title2="SERVER$title_dbg (Native-VCL Socket Test)"
738 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
739 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
740 set_pre_cmd $emacs_server $gdb_server
741 if [ "$multi_host" = "server" ] ; then
746 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
747 namespace_id="$server_namespace_id"
748 namespace_secret="$server_namespace_secret"
750 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay"
751 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd2_file
752 echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file
753 write_script_footer $cmd2_file $perf_server
757 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
758 title3="CLIENT$title_dbg (Native-VCL Socket Test)"
759 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
760 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
761 set_pre_cmd $emacs_client $gdb_client
762 if [ "$multi_host" = "client" ] ; then
767 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
768 namespace_id="$client_namespace_id"
769 namespace_secret="$client_namespace_secret"
771 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay"
772 echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd3_file
773 echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file
774 echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file
775 write_script_footer $cmd3_file $perf_client
781 verify_no_docker_containers
782 banner="Running DOCKER-KERNEL socket test"
784 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
785 title1="SERVER$title_dbg (Docker-Native Socket Test)"
786 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
787 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
788 set_pre_cmd $emacs_server $gdb_server
789 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
790 echo "docker run -it --cpuset-cpus='4-7' --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir -p $sock_srvr_port:$sock_srvr_port $docker_os ${docker_app_dir}${srvr_app}" >> $cmd1_file
791 write_script_footer $cmd1_file $perf_server
795 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
796 title2="CLIENT$title_dbg (Docker-Native Socket Test)"
797 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
798 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
799 set_pre_cmd $emacs_client $gdb_client
800 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
801 echo "$get_docker_server_ip4addr" >> $cmd2_file
802 echo "docker run -it --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd2_file
803 write_script_footer $cmd2_file $perf_client
810 verify_no_docker_containers
811 banner="Running DOCKER-PRELOAD socket test"
812 docker_ld_preload_dir="/vcl-ldpreload/"
813 ld_preload_dir="$VCL_LDPRELOAD_LIB_DIR"
814 ld_preload="$docker_ld_preload_dir$vcl_ldpreload_lib "
815 docker_ld_preload_lib="$docker_ld_preload_dir$vcl_ldpreload_lib "
817 title1="VPP$title_dbg (Docker-Preload Socket Test)"
818 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
819 gdb_cmdfile=$VPP_GDB_CMDFILE
820 set_pre_cmd $emacs_vpp $gdb_vpp
821 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
822 if [ -n "$multi_host" ] ; then
823 echo -n "sudo " >> $cmd1_file
825 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
826 write_script_footer $cmd1_file $perf_vpp
829 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
830 title2="SERVER$title_dbg (Docker-Preload Socket Test)"
831 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
832 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
833 set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib
834 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
835 namespace_id="$server_namespace_id"
836 namespace_secret="$server_namespace_secret"
838 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
839 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
840 write_script_footer $cmd2_file $perf_server
844 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
845 title3="CLIENT$title_dbg (Docker-Preload Socket Test)"
846 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
847 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
848 set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib
849 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
850 namespace_id="$client_namespace_id"
851 namespace_secret="$client_namespace_secret"
853 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4"
854 echo "$get_docker_server_ip4addr" >> $cmd3_file
855 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
856 write_script_footer $cmd3_file $perf_client
863 verify_no_docker_containers
864 banner="Running DOCKER-VCL socket test"
866 title1="VPP$title_dbg (Docker-VCL Socket Test)"
867 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp
868 gdb_cmdfile=$VPP_GDB_CMDFILE
869 set_pre_cmd $emacs_vpp $gdb_vpp
870 write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1"
871 if [ -n "$multi_host" ] ; then
872 echo -n "sudo " >> $cmd1_file
874 echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file
875 write_script_footer $cmd1_file $perf_vpp
878 if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then
879 title2="SERVER$title_dbg (Docker-VCL Socket Test)"
880 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server
881 gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE
882 set_pre_cmd $emacs_server $gdb_server
883 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
884 namespace_id="$server_namespace_id"
885 namespace_secret="$server_namespace_secret"
887 write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2"
888 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
889 write_script_footer $cmd2_file $perf_server
893 if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then
894 title3="CLIENT$title_dbg (Docker-VCL Socket Test)"
895 tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client
896 gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE
897 set_pre_cmd $emacs_client $gdb_client
898 if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then
899 namespace_id="$client_namespace_id"
900 namespace_secret="$client_namespace_secret"
902 write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3"
903 echo "$get_docker_server_ip4addr" >> $cmd3_file
904 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
905 write_script_footer $cmd3_file $perf_client
910 if [[ $run_test ]] ; then
913 echo "ERROR: Please specify a test to run!" >&2
917 if (( $(which xfce4-terminal | wc -l) > 0 )) ; then
918 xterm_cmd="xfce4-terminal --geometry $xterm_geom"
919 if [[ $use_tabs ]] ; then
920 declare -a tab_cmd_files
921 declare -a tab_titles
924 if [ -x "$cmd1_file" ] ; then
925 tab_cmd_files[$i]="$cmd1_file"
926 tab_titles[$i]="$title1"
929 if [ -x "$cmd2_file" ] ; then
930 tab_cmd_files[$i]="$cmd2_file"
931 tab_titles[$i]="$title2"
934 if [ -x "$cmd3_file" ] ; then
935 tab_cmd_files[$i]="$cmd3_file"
936 tab_titles[$i]="$title3"
939 if [ -n "${tab_cmd_files[2]}" ] ; then
940 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}" --tab --title "${tab_titles[2]}" --command "${tab_cmd_files[2]}"
941 elif [ -n "${tab_cmd_files[1]}" ] ; then
942 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}"
945 $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}"
949 if [ -x "$cmd1_file" ] ; then
950 ($xterm_cmd --title "$title1" --command "$cmd1_file" &)
952 if [ -x "$cmd2_file" ] ; then
953 ($xterm_cmd --title "$title2" --command "$cmd2_file" &)
955 if [ -x "$cmd3_file" ] ; then
956 ($xterm_cmd --title "$title3" --command "$cmd3_file" &)
961 if [[ $use_tabs ]] ; then
962 echo "Sorry, plain ol' xterm doesn't support tabs."
964 xterm_cmd="xterm -fs 10 -geometry $xterm_geom"
965 if [ -x "$cmd1_file" ] ; then
966 ($xterm_cmd -title "$title1" -e "$cmd1_file" &)
968 if [ -x "$cmd2_file" ] ; then
969 ($xterm_cmd -title "$title2" -e "$cmd2_file" &)
971 if [ -x "$cmd3_file" ] ; then
972 ($xterm_cmd -title "$title3" -e "$cmd3_file" &)