Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | # |
| 3 | # socket_test.sh -- script to run socket tests. |
| 4 | # |
| 5 | script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
Yalei Wang | 904a850 | 2018-09-20 16:46:29 +0800 | [diff] [blame] | 6 | vpp_dir="$WS_ROOT/build-root/build-vpp-native/vpp/bin/" |
| 7 | vpp_debug_dir="$WS_ROOT/build-root/build-vpp_debug-native/vpp/bin/" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 8 | vpp_shm_dir="/dev/shm/" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 9 | vpp_run_dir="/run/vpp" |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 10 | lib_dir="$WS_ROOT/build-root/install-vpp-native/vpp/lib/" |
| 11 | lib_debug_dir="$WS_ROOT/build-root/install-vpp_debug-native/vpp/lib/" |
Dave Wallace | 6ccff02 | 2018-11-06 17:45:32 -0500 | [diff] [blame] | 12 | dpdk_devbind="$WS_ROOT/extras/vpp_config/scripts/dpdk-devbind.py" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 13 | docker_vpp_dir="/vpp/" |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 14 | docker_app_dir="/vpp/" |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 15 | docker_lib_dir="/vpp-lib/" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 16 | docker_os="ubuntu" |
Yalei Wang | 904a850 | 2018-09-20 16:46:29 +0800 | [diff] [blame] | 17 | vcl_ldpreload_lib="libvcl_ldpreload.so" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 18 | user_gid="$(id -g)" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 19 | vpp_app="vpp" |
Florin Coras | ab2f6db | 2018-08-31 14:31:41 -0700 | [diff] [blame] | 20 | sock_srvr_app="sock_test_server" |
| 21 | sock_clnt_app="sock_test_client" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 22 | sock_srvr_addr="127.0.0.1" |
| 23 | sock_srvr_port="22000" |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 24 | iperf_srvr_app="iperf3 -V4d -s" |
| 25 | iperf_clnt_app="iperf3 -V4d -c \$srvr_addr" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 26 | gdb_in_emacs="gdb_in_emacs" |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 27 | vcl_config="vcl.conf" |
| 28 | vcl_config_dir="$WS_ROOT/src/vcl/" |
| 29 | docker_vcl_config_dir="/etc/vpp/" |
Keith Burns (alagalah) | 9e482bb | 2017-08-30 14:06:52 -0700 | [diff] [blame] | 30 | xterm_geom="100x60" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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.$$" |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 36 | vpp_eth_name="enp0s8" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 37 | tmp_vpp_exec_file="/tmp/vpp_config.$$" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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" |
| 46 | |
| 47 | # Set default values for imported environment variables if they don't exist. |
| 48 | # |
| 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}" |
| 52 | |
| 53 | usage() { |
| 54 | cat <<EOF |
| 55 | Usage: socket_test.sh OPTIONS TEST |
| 56 | TESTS: |
| 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 | |
| 64 | OPTIONS: |
| 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 Wallace | 774169b | 2017-11-01 20:07:40 -0400 | [diff] [blame] | 69 | -c Set VCL_CONFIG to use the vcl_test.conf file. |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 70 | -i Run iperf3 for client/server app in native tests. |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 71 | -n Name of ethernet for VPP to use in multi-host cfg. |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 72 | -f Full thru host stack vpp configuration. |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 73 | -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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 75 | -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 | |
| 85 | OPTIONS passed to client/server: |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 86 | -6 Use IPv6. |
| 87 | -D Use UDP as the transport. |
Dave Wallace | 03dd90a | 2019-03-25 19:34:50 -0400 | [diff] [blame] | 88 | -L Use TLS as the transport. |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 89 | -S <ip address> Server IP address. |
| 90 | -P <server port> Server Port number. |
| 91 | -E <data> Run Echo test. |
| 92 | -N <num-writes> Test Cfg: number of writes. |
| 93 | -R <rxbuf-size> Test Cfg: rx buffer size. |
| 94 | -T <txbuf-size> Test Cfg: tx buffer size. |
| 95 | -U Run Uni-directional test. |
| 96 | -B Run Bi-directional test. |
| 97 | -I <num-tst-socks> Send data over multiple test sockets in parallel. |
| 98 | -V Test Cfg: Verbose mode. |
| 99 | -X Exit client/server after running test. |
| 100 | |
| 101 | Environment variables: |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 102 | VCL_CONFIG Pathname of vppcom configuration file. |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 103 | VPP_GDB_CMDFILE Pathname of gdb command file for vpp. |
| 104 | VPPCOM_CLIENT_GDB_CMDFILE Pathname of gdb command file for client. |
| 105 | VPPCOM_SERVER_GDB_CMDFILE Pathname of gdb command file for server. |
| 106 | EOF |
| 107 | exit 1 |
| 108 | } |
| 109 | |
| 110 | declare -i emacs_vpp=0 |
| 111 | declare -i emacs_client=0 |
| 112 | declare -i emacs_server=0 |
| 113 | declare -i gdb_vpp=0 |
| 114 | declare -i gdb_client=0 |
| 115 | declare -i gdb_server=0 |
| 116 | declare -i perf_vpp=0 |
| 117 | declare -i perf_client=0 |
| 118 | declare -i perf_server=0 |
| 119 | declare -i leave_tmp_files=0 |
| 120 | declare -i bash_after_exit=0 |
| 121 | declare -i iperf3=0 |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 122 | declare -i use_ipv6=0 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 123 | |
Dave Wallace | 03dd90a | 2019-03-25 19:34:50 -0400 | [diff] [blame] | 124 | while getopts ":hitlbcd6fn:m:e:g:p:E:I:N:P:R:S:T:UBVXDL" opt; do |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 125 | case $opt in |
| 126 | h) usage ;; |
| 127 | l) leave_tmp_files=1 |
| 128 | ;; |
| 129 | b) bash_after_exit=1 |
| 130 | ;; |
| 131 | i) iperf3=1 |
| 132 | ;; |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 133 | 6) use_ipv6=1 |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 134 | sock_srvr_addr="::1" |
| 135 | sock_clnt_options="$sock_clnt_options -$opt" |
| 136 | sock_srvr_options="$sock_srvr_options -$opt" |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 137 | ;; |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 138 | f) full_thru_host_stack_vpp_cfg=1 |
| 139 | ;; |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 140 | t) xterm_geom="180x40" |
| 141 | use_tabs="true" |
| 142 | ;; |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 143 | c) VCL_CONFIG="${vcl_config_dir}vcl_test.conf" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 144 | ;; |
| 145 | d) title_dbg="-DEBUG" |
| 146 | vpp_dir=$vpp_debug_dir |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 147 | lib_dir=$lib_debug_dir |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 148 | ;; |
| 149 | e) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then |
| 150 | emacs_client=1 |
| 151 | emacs_server=1 |
| 152 | emacs_vpp=1 |
| 153 | elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then |
| 154 | emacs_client=1 |
| 155 | elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then |
| 156 | emacs_server=1 |
| 157 | elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then |
| 158 | emacs_vpp=1 |
| 159 | else |
| 160 | echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2 |
| 161 | usage |
| 162 | fi |
| 163 | title_dbg="-DEBUG" |
| 164 | vpp_dir=$vpp_debug_dir |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 165 | lib_dir=$lib_debug_dir |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 166 | ;; |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 167 | n) vpp_eth_name="$OPTARG" |
| 168 | ;; |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 169 | m) if [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then |
| 170 | multi_host="client" |
| 171 | elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then |
| 172 | multi_host="server" |
| 173 | else |
| 174 | echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2 |
| 175 | usage |
| 176 | fi |
| 177 | ;; |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 178 | g) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then |
| 179 | gdb_client=1 |
| 180 | gdb_server=1 |
| 181 | gdb_vpp=1 |
| 182 | elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then |
| 183 | gdb_client=1 |
| 184 | elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then |
| 185 | gdb_server=1 |
| 186 | elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then |
| 187 | gdb_vpp=1 |
| 188 | else |
| 189 | echo "ERROR: Option -g unknown argument \'$OPTARG\'" >&2 |
| 190 | usage |
| 191 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 192 | ;; |
| 193 | p) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then |
| 194 | perf_client=1 |
| 195 | perf_server=1 |
| 196 | perf_vpp=1 |
| 197 | elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then |
| 198 | perf_client=1 |
| 199 | elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then |
| 200 | perf_server=1 |
| 201 | elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then |
| 202 | perf_vpp=1 |
| 203 | else |
| 204 | echo "ERROR: Option -p unknown argument \'$OPTARG\'" >&2 |
| 205 | usage |
| 206 | fi |
| 207 | echo "WARNING: -p options TBD" |
| 208 | ;; |
| 209 | S) sock_srvr_addr="$OPTARG" |
| 210 | ;; |
| 211 | P) sock_srvr_port="$OPTARG" |
| 212 | ;; |
Dave Wallace | 03dd90a | 2019-03-25 19:34:50 -0400 | [diff] [blame] | 213 | D|L) sock_clnt_options="$sock_clnt_options -$opt" |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 214 | sock_srvr_options="$sock_srvr_options -$opt" |
| 215 | ;; |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 216 | E|I|N|R|T) sock_clnt_options="$sock_clnt_options -$opt \"$OPTARG\"" |
| 217 | ;; |
| 218 | U|B|V|X) sock_clnt_options="$sock_clnt_options -$opt" |
| 219 | ;; |
| 220 | \?) |
| 221 | echo "ERROR: Invalid option: -$OPTARG" >&2 |
| 222 | usage |
| 223 | ;; |
| 224 | :) |
| 225 | echo "ERROR: Option -$OPTARG requires an argument." >&2 |
| 226 | usage |
| 227 | ;; |
| 228 | esac |
| 229 | done |
| 230 | |
| 231 | shift $(( $OPTIND-1 )) |
| 232 | while ! [[ $run_test ]] && (( $# > 0 )) ; do |
| 233 | case $1 in |
| 234 | "nk" | "native-kernel") |
| 235 | run_test="native_kernel" ;; |
| 236 | "np" | "native-preload") |
| 237 | run_test="native_preload" ;; |
| 238 | "nv" | "native-vcl") |
Yalei Wang | 904a850 | 2018-09-20 16:46:29 +0800 | [diff] [blame] | 239 | sock_srvr_app="vcl_test_server" |
| 240 | sock_clnt_app="vcl_test_client" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 241 | run_test="native_vcl" ;; |
| 242 | "dk" | "docker-kernel") |
| 243 | run_test="docker_kernel" ;; |
| 244 | "dp" | "docker-preload") |
| 245 | run_test="docker_preload" ;; |
| 246 | "dv" | "docker-vcl") |
Yalei Wang | 904a850 | 2018-09-20 16:46:29 +0800 | [diff] [blame] | 247 | sock_srvr_app="vcl_test_server" |
| 248 | sock_clnt_app="vcl_test_client" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 249 | run_test="docker_vcl" ;; |
| 250 | *) |
| 251 | echo "ERROR: Unknown option '$1'!" >&2 |
| 252 | usage ;; |
| 253 | esac |
| 254 | shift |
| 255 | done |
| 256 | |
Dave Wallace | ee45d41 | 2017-11-24 21:44:06 -0500 | [diff] [blame] | 257 | if [ -z "$VCL_DEBUG" ] ; then |
| 258 | if [ "$title_dbg" = "-DEBUG" ] ; then |
| 259 | VCL_DEBUG=1 |
| 260 | else |
| 261 | VCL_DEBUG=0 |
| 262 | fi |
| 263 | fi |
| 264 | |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 265 | VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-$lib_dir}" |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 266 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 267 | if [ -z "$WS_ROOT" ] ; then |
| 268 | echo "ERROR: WS_ROOT environment variable not set!" >&2 |
| 269 | echo " Please set WS_ROOT to VPP workspace root directory." >&2 |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 270 | exit 1 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 271 | fi |
| 272 | |
Dave Wallace | 6ccff02 | 2018-11-06 17:45:32 -0500 | [diff] [blame] | 273 | if [ ! -d $vpp_dir ] ; then |
| 274 | if [ -z "$title_dbg" ] ; then |
| 275 | (cd $WS_ROOT; make build-release) |
| 276 | else |
| 277 | (cd $WS_ROOT; make build) |
| 278 | fi |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 279 | fi |
| 280 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 281 | if [ ! -d $vpp_dir ] ; then |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 282 | echo "ERROR: Missing VPP$title_dbg bin directory!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 283 | echo " $vpp_dir" >&2 |
| 284 | env_test_failed="true" |
| 285 | fi |
| 286 | |
| 287 | if [[ $run_test =~ .*"_preload" ]] ; then |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 288 | if [ ! -d $lib_dir ] ; then |
| 289 | echo "ERROR: Missing VPP$title_dbg lib directory!" >&2 |
| 290 | echo " $lib_dir" >&2 |
Dave Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 291 | elif [ ! -d $VCL_LDPRELOAD_LIB_DIR ] ; then |
| 292 | echo "ERROR: Missing VCL LD_PRELOAD Library directory!" >&2 |
| 293 | echo " $VCL_LDPRELOAD_LIB_DIR" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 294 | env_test_failed="true" |
Dave Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 295 | elif [ ! -f $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib ] ; then |
| 296 | echo "ERROR: Missing VCL LD_PRELOAD library!" >&2 |
| 297 | echo " $VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 298 | env_test_failed="true" |
| 299 | fi |
| 300 | fi |
| 301 | |
| 302 | if [ ! -f $vpp_dir$vpp_app ] ; then |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 303 | echo "ERROR: Missing VPP$title_dbg Application!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 304 | echo " $vpp_dir$vpp_app" >&2 |
| 305 | env_test_failed="true" |
| 306 | fi |
| 307 | |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 308 | if [ ! -f $vpp_dir$sock_srvr_app ] && [ ! $iperf3 -eq 1 ] ; then |
Yalei Wang | 904a850 | 2018-09-20 16:46:29 +0800 | [diff] [blame] | 309 | echo "ERROR: Missing SERVER$title_dbg Socket Server Application!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 310 | echo " $vpp_dir$sock_srvr_app" >&2 |
| 311 | env_test_failed="true" |
| 312 | fi |
| 313 | |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 314 | if [ ! -f $vpp_dir$sock_clnt_app ] && [ ! $iperf3 -eq 1 ] ; then |
Yalei Wang | 904a850 | 2018-09-20 16:46:29 +0800 | [diff] [blame] | 315 | echo "ERROR: Missing CLIENT$title_dbg Socket Client Application!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 316 | echo " $vpp_dir$sock_clnt_app" >&2 |
| 317 | env_test_failed="true" |
| 318 | fi |
| 319 | |
| 320 | if [[ $run_test =~ "docker_".* ]] ; then |
| 321 | if [ $emacs_client -eq 1 ] || [ $emacs_server -eq 1 ] || [ $gdb_client -eq 1 ] || [ $gdb_server -eq 1 ] ; then |
| 322 | |
| 323 | echo "WARNING: gdb is not currently supported in docker." |
| 324 | echo " Ignoring client/server gdb options." |
| 325 | emacs_client=0 |
| 326 | emacs_server=0 |
| 327 | gdb_client=0 |
| 328 | gdb_server=0 |
| 329 | fi |
| 330 | fi |
| 331 | |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 332 | if [[ $run_test =~ .*"_vcl" ]] && [ $iperf3 -eq 1 ] ; then |
| 333 | echo "ERROR: Invalid option 'i' for test $run_test!" |
| 334 | echo " iperf3 is not compiled with the VCL library." |
| 335 | env_test_failed="true" |
| 336 | fi |
| 337 | |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 338 | if [ -n "$multi_host"] && [ ! -f "$dpdk_devbind" ] ; then |
Dave Wallace | 1948161 | 2017-09-15 18:47:44 -0400 | [diff] [blame] | 339 | echo "ERROR: Can't find dpdk-devbind.py!" |
Damjan Marion | 4a6cb83 | 2018-09-18 18:41:38 +0200 | [diff] [blame] | 340 | echo " Run \"cd \$WS_ROOT; make install-ext-deps\" to install it." |
Dave Wallace | 1948161 | 2017-09-15 18:47:44 -0400 | [diff] [blame] | 341 | echo |
| 342 | env_test_failed="true" |
| 343 | fi |
| 344 | |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 345 | if [ -n "$full_thru_host_stack_vpp_cfg" ] && [ -n "$multi_host" ] ; then |
| 346 | echo "ERROR: Invalid options, cannot specify both \"-f\" and \"-m $multi_host\"!" |
| 347 | echo |
| 348 | env_test_failed="true" |
| 349 | fi |
| 350 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 351 | if [ -n "$env_test_failed" ] ; then |
| 352 | exit 1 |
| 353 | fi |
| 354 | |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 355 | if [ -f "$VCL_CONFIG" ] ; then |
| 356 | vcl_config="$(basename $VCL_CONFIG)" |
| 357 | vcl_config_dir="$(dirname $VCL_CONFIG)/" |
| 358 | api_prefix="$(egrep -s '^\s*api-prefix \w+' $VCL_CONFIG | tail -1 | awk -e '{print $2}')" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 359 | if [ -n "$api_prefix" ] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 360 | api_segment=" api-segment { gid $user_gid prefix $api_prefix }" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 361 | fi |
| 362 | fi |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 363 | if [ -n "$VCL_APP_NAMESPACE_ID" ] && [ -n "$VCL_APP_NAMESPACE_SECRET" ] ; then |
| 364 | namespace_id="$VCL_APP_NAMESPACE_ID" |
| 365 | namespace_secret="$VCL_APP_NAMESPACE_SECRET" |
| 366 | fi |
| 367 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 368 | if [ -z "$api_segment" ] ; then |
| 369 | api_segment=" api-segment { gid $user_gid }" |
| 370 | fi |
Dave Wallace | 498b3a5 | 2017-11-09 13:00:34 -0500 | [diff] [blame] | 371 | vpp_args="unix { interactive full-coredump coredump-size unlimited exec $tmp_vpp_exec_file}${api_segment}" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 372 | |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 373 | if [ $iperf3 -eq 1 ] ; then |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 374 | app_dir="$(dirname $(which iperf3))/" |
| 375 | srvr_app=$iperf_srvr_app |
| 376 | clnt_app=$iperf_clnt_app |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 377 | if [[ $run_test =~ "docker_".* ]] ; then |
| 378 | unset -v app_dir |
| 379 | sock_srvr_port=5201 |
| 380 | docker_app_dir="networkstatic/" |
| 381 | unset -v docker_os |
| 382 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 383 | else |
| 384 | app_dir="$vpp_dir" |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 385 | srvr_app="$sock_srvr_app${sock_srvr_options} $sock_srvr_port" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 386 | clnt_app="$sock_clnt_app${sock_clnt_options} \$srvr_addr $sock_srvr_port" |
| 387 | fi |
| 388 | |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 389 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 390 | verify_no_vpp() { |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 391 | local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\"" |
| 392 | |
| 393 | if [ -n "$api_prefix" ] ; then |
| 394 | grep_for_vpp="$grep_for_vpp|grep \"prefix $api_prefix\"" |
| 395 | fi |
| 396 | local running_vpp="$(eval $grep_for_vpp)" |
| 397 | if [ -n "$running_vpp" ] ; then |
| 398 | echo "ERROR: Please kill the following vpp instance(s):" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 399 | echo |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 400 | echo $running_vpp |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 401 | echo |
| 402 | exit 1 |
| 403 | fi |
| 404 | 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 405 | sudo rm -f $clean_devshm |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 406 | devshm_files="$(ls -l $clean_devshm 2>/dev/null | grep $(whoami))" |
| 407 | if [ "$devshm_files" != "" ] ; then |
| 408 | echo "ERROR: Please remove the following $vpp_shm_dir files:" |
| 409 | for file in "$devshm_files" ; do |
| 410 | echo " $file" |
| 411 | done |
| 412 | exit 1 |
| 413 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 414 | if [ ! -d "$vpp_run_dir" ] ; then |
| 415 | sudo mkdir $vpp_run_dir |
| 416 | sudo chown root:$USER $vpp_run_dir |
| 417 | fi |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 418 | if [ $use_ipv6 -eq 0 ] && [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 419 | sock_srvr_table=0 |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 420 | sock_srvr_addr=172.16.1.1 |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 421 | sock_client_table=1 |
| 422 | sock_client_addr=172.16.2.1 |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 423 | client_namespace_id="1" |
| 424 | client_namespace_secret="5678" |
| 425 | server_namespace_id="0" |
| 426 | server_namespace_secret="1234" |
| 427 | cat <<EOF >> $tmp_vpp_exec_file |
| 428 | session enable |
| 429 | create loop inter |
| 430 | create loop inter |
| 431 | set inter state loop0 up |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 432 | set inter ip table loop0 $sock_srvr_table |
| 433 | set inter ip address loop0 $sock_srvr_addr/24 |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 434 | set inter state loop1 up |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 435 | set inter ip table loop1 $sock_client_table |
| 436 | set inter ip address loop1 $sock_client_addr/24 |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 437 | app ns add id 0 secret 1234 sw_if_index 1 |
| 438 | app ns add id 1 secret 5678 sw_if_index 2 |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 439 | ip route add $sock_srvr_addr/32 table $sock_client_table via lookup in table $sock_srvr_table |
| 440 | ip route add $sock_client_addr/32 table $sock_srvr_table via lookup in table $sock_client_table |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 441 | EOF |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 442 | elif [ $use_ipv6 -eq 1 ] && [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 443 | sock_srvr_table=1 |
| 444 | sock_srvr_addr=fd01:1::1 |
| 445 | sock_client_table=2 |
| 446 | sock_client_addr=fd01:2::1 |
| 447 | client_namespace_id="1" |
| 448 | client_namespace_secret="5678" |
| 449 | server_namespace_id="0" |
| 450 | server_namespace_secret="1234" |
| 451 | cat <<EOF >> $tmp_vpp_exec_file |
| 452 | session enable |
| 453 | create loop inter |
| 454 | create loop inter |
| 455 | set inter state loop0 up |
| 456 | set inter ip6 table loop0 $sock_srvr_table |
| 457 | set inter ip address loop0 $sock_srvr_addr/64 |
| 458 | set inter state loop1 up |
| 459 | set inter ip6 table loop1 $sock_client_table |
| 460 | set inter ip address loop1 $sock_client_addr/64 |
| 461 | app ns add id 0 secret 1234 sw_if_index 1 |
| 462 | app ns add id 1 secret 5678 sw_if_index 2 |
| 463 | ip route add $sock_srvr_addr/128 table $sock_client_table via lookup in table $sock_srvr_table |
| 464 | ip route add $sock_client_addr/128 table $sock_srvr_table via lookup in table $sock_client_table |
| 465 | EOF |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 466 | elif [ -n "$multi_host" ] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 467 | vpp_eth_pci_id="$(ls -ld /sys/class/net/$vpp_eth_name/device | awk '{print $11}' | cut -d/ -f4)" |
| 468 | if [ -z "$vpp_eth_pci_id" ] ; then |
| 469 | echo "ERROR: Missing ethernet interface $vpp_eth_name!" |
| 470 | usage |
| 471 | fi |
| 472 | printf -v bus "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f2)" |
| 473 | printf -v slot "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f3 | cut -d. -f1)" |
| 474 | printf -v func "%x" "0x$(echo $vpp_eth_pci_id | cut -d. -f2)" |
| 475 | |
| 476 | vpp_eth_kernel_driver="$(basename $(ls -l /sys/bus/pci/devices/$vpp_eth_pci_id/driver | awk '{print $11}'))" |
| 477 | if [ -z "$vpp_eth_kernel_driver" ] ; then |
| 478 | echo "ERROR: Missing kernel driver for $vpp_eth_name!" |
| 479 | usage |
| 480 | fi |
| 481 | case $vpp_eth_kernel_driver in |
| 482 | e1000) |
| 483 | vpp_eth_ifname="GigabitEthernet$bus/$slot/$func" ;; |
| 484 | ixgbe) |
| 485 | vpp_eth_ifname="TenGigabitEthernet$bus/$slot/$func" ;; |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 486 | i40e) |
| 487 | vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;; |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 488 | *) |
| 489 | echo "ERROR: Unknown ethernet kernel driver $vpp_eth_kernel_driver!" |
| 490 | usage ;; |
| 491 | esac |
| 492 | |
| 493 | vpp_eth_ip4_addr="$(ip -4 -br addr show $vpp_eth_name | awk '{print $3}')" |
| 494 | if [ -z "$vpp_eth_ip4_addr" ] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 495 | if [ "$multi_host" = "server" ] ; then |
| 496 | vpp_eth_ip4_addr="10.10.10.10/24" |
| 497 | else |
| 498 | vpp_eth_ip4_addr="10.10.10.11/24" |
| 499 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 500 | fi |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 501 | if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 502 | echo "ERROR: No inet6 address configured for $vpp_eth_name!" |
| 503 | usage |
| 504 | fi |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 505 | vpp_args="$vpp_args plugins { path ${lib_dir}vpp_plugins } dpdk { dev $vpp_eth_pci_id }" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 506 | |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 507 | sudo ifconfig $vpp_eth_name down 2> /dev/null |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 508 | echo "Configuring VPP to use $vpp_eth_name ($vpp_eth_pci_id), inet addr $vpp_eth_ip4_addr" |
| 509 | |
| 510 | cat <<EOF >> $tmp_vpp_exec_file |
| 511 | set int state $vpp_eth_ifname up |
| 512 | set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr |
| 513 | EOF |
| 514 | |
| 515 | fi |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 516 | |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 517 | if [ -z "$full_thru_host_stack_vpp_cfg" ] && [ -n "$namespace_id" ] ; then |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 518 | cat <<EOF >> $tmp_vpp_exec_file |
| 519 | session enable |
| 520 | app ns add id $namespace_id secret $namespace_secret sw_if_index 0 |
| 521 | EOF |
| 522 | fi |
| 523 | |
| 524 | cat <<EOF >> $tmp_vpp_exec_file |
Yalei Wang | 904a850 | 2018-09-20 16:46:29 +0800 | [diff] [blame] | 525 | create tap id 0 |
| 526 | set int ip addr tap0 172.17.0.2/24 |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 527 | show version |
| 528 | show version verbose |
| 529 | show cpu |
| 530 | show int |
| 531 | EOF |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | verify_no_docker_containers() { |
| 535 | if (( $(which docker | wc -l) < 1 )) ; then |
| 536 | echo "ERROR: docker is not installed!" |
| 537 | echo "See https://docs.docker.com/engine/installation/linux/ubuntu/" |
| 538 | echo " or https://docs.docker.com/engine/installation/linux/centos/" |
| 539 | exit 1 |
| 540 | fi |
| 541 | if (( $(docker ps | wc -l) > 1 )) ; then |
| 542 | echo "ERROR: Run the following to kill all docker containers:" |
| 543 | echo "docker kill \$(docker ps -q)" |
| 544 | echo |
| 545 | docker ps |
| 546 | exit 1 |
| 547 | fi |
| 548 | } |
| 549 | |
| 550 | set_pre_cmd() { |
| 551 | # arguments |
| 552 | # $1 : emacs flag |
| 553 | # $2 : gdb flag |
| 554 | # $3 : optional LD_PRELOAD library pathname |
| 555 | local -i emacs=$1 |
| 556 | local -i gdb=$2 |
| 557 | |
| 558 | if [ $emacs -eq 1 ] ; then |
| 559 | write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3 |
| 560 | pre_cmd="$gdb_in_emacs " |
| 561 | elif [ $gdb -eq 1 ] ; then |
| 562 | write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3 |
Dave Wallace | 4878cbe | 2017-11-21 03:45:09 -0500 | [diff] [blame] | 563 | pre_cmd="gdb -x $tmp_gdb_cmdfile --args " |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 564 | elif [ -z $3 ] ; then |
| 565 | unset -v pre_cmd |
| 566 | else |
| 567 | docker_ld_preload="-e LD_PRELOAD=$3 " |
| 568 | pre_cmd="LD_PRELOAD=$3 " |
| 569 | fi |
| 570 | } |
| 571 | |
| 572 | write_script_header() { |
| 573 | # arguments |
| 574 | # $1 : command script file |
| 575 | # $2 : gdb command file |
| 576 | # $3 : title |
| 577 | # $4 : optional command string (typically "sleep 2") |
| 578 | echo "$bash_header" > $1 |
| 579 | echo -e "#\n# $1 generated on $(date)\n#" >> $1 |
| 580 | if [ $leave_tmp_files -eq 0 ] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 581 | if [ -n "$multi_host" ] ; then |
| 582 | 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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 583 | else |
| 584 | echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1 |
| 585 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 586 | fi |
Dave Wallace | 498b3a5 | 2017-11-09 13:00:34 -0500 | [diff] [blame] | 587 | if [ -n "$VCL_CONFIG" ] ; then |
| 588 | echo "export VCL_CONFIG=${vcl_config_dir}${vcl_config}" >> $1 |
| 589 | fi |
Dave Wallace | b5a86ee | 2018-02-16 18:26:11 -0500 | [diff] [blame] | 590 | if [ -n "$VCL_API_PREFIX" ] ; then |
| 591 | echo "export VCL_API_PREFIX=$VCL_API_PREFIX" >> $1 |
| 592 | fi |
Dave Wallace | 498b3a5 | 2017-11-09 13:00:34 -0500 | [diff] [blame] | 593 | if [ -n "$VCL_DEBUG" ] ; then |
| 594 | echo "export VCL_DEBUG=$VCL_DEBUG" >> $1 |
| 595 | fi |
Dave Wallace | 3ee1fe1 | 2018-02-23 01:09:11 -0500 | [diff] [blame] | 596 | if [ -n "$LDP_DEBUG" ] ; then |
| 597 | echo "export LDP_DEBUG=$LDP_DEBUG" >> $1 |
Dave Wallace | 048b1d6 | 2018-01-03 22:24:41 -0500 | [diff] [blame] | 598 | fi |
| 599 | if [ -n "$VCOM_APP_NAME" ] ; then |
| 600 | echo "export VCOM_APP_NAME=$VCOM_APP_NAME" >> $1 |
| 601 | fi |
| 602 | if [ -n "$VCOM_SID_BIT" ] ; then |
| 603 | echo "export VCOM_SID_BIT=$VCOM_SID_BIT" >> $1 |
| 604 | fi |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 605 | if [ -n "$namespace_id" ] ; then |
| 606 | echo "export VCL_APP_NAMESPACE_ID=\"$namespace_id\"" >> $1 |
| 607 | echo "export VCL_APP_NAMESPACE_SECRET=\"$namespace_secret\"" >> $1 |
| 608 | fi |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 609 | if [ -n "$VCL_APP_SCOPE_LOCAL" ] || [ -z "$multi_host" ] && |
| 610 | [ -z "$full_thru_host_stack_vpp_cfg" ] ; then |
Dave Wallace | 774169b | 2017-11-01 20:07:40 -0400 | [diff] [blame] | 611 | echo "export VCL_APP_SCOPE_LOCAL=true" >> $1 |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 612 | fi |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 613 | if [ -n "$VCL_APP_SCOPE_GLOBAL" ] || [ -n "$multi_host" ] || |
| 614 | [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
Dave Wallace | 774169b | 2017-11-01 20:07:40 -0400 | [diff] [blame] | 615 | echo "export VCL_APP_SCOPE_GLOBAL=true" >> $1 |
| 616 | fi |
| 617 | if [ -n "$VCL_APP_PROXY_TRANSPORT_TCP" ] ; then |
| 618 | echo "export VCL_APP_PROXY_TRANSPORT_TCP=true" >> $1 |
| 619 | fi |
| 620 | if [ -n "$VCL_APP_PROXY_TRANSPORT_UDP" ] ; then |
| 621 | echo "export VCL_APP_PROXY_TRANSPORT_UDP=true" >> $1 |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 622 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 623 | if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 624 | if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 625 | cat <<EOF >> $1 |
| 626 | $gdb_in_emacs() { |
| 627 | sudo emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")" |
| 628 | } |
| 629 | EOF |
| 630 | else |
| 631 | cat <<EOF >> $1 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 632 | $gdb_in_emacs() { |
| 633 | emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")" |
| 634 | } |
| 635 | EOF |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 636 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 637 | fi |
| 638 | if [ -n "$4" ] ; then |
| 639 | echo "$4" >> $1 |
| 640 | fi |
| 641 | } |
| 642 | |
| 643 | write_script_footer() { |
| 644 | # arguments |
| 645 | # $1 : command script file |
| 646 | # $2 : perf flag indicating to run bash before exit |
| 647 | local -i perf=$2 |
| 648 | if [ $bash_after_exit -eq 1 ] || [ $perf -eq 1 ] ; then |
| 649 | echo "bash" >> $1 |
| 650 | fi |
| 651 | } |
| 652 | |
| 653 | write_gdb_cmdfile() { |
| 654 | # arguments |
| 655 | # $1 : gdb command file |
| 656 | # $2 : User specified gdb cmdfile |
| 657 | # $3 : emacs flag |
| 658 | # $4 : optional LD_PRELOAD library pathname. |
| 659 | local -i emacs=$3 |
| 660 | |
| 661 | echo "# $1 generated on $(date)" > $1 |
| 662 | echo "#" >> $1 |
| 663 | echo "set confirm off" >> $1 |
| 664 | if [ -n "$4" ] ; then |
| 665 | echo "set exec-wrapper env LD_PRELOAD=$4" >> $1 |
Dave Wallace | 5917939 | 2017-11-07 02:20:07 -0500 | [diff] [blame] | 666 | # echo "start" >> $1 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 667 | fi |
| 668 | |
| 669 | if [ ! -f $2 ] ; then |
| 670 | echo -n "# " >> $1 |
| 671 | fi |
| 672 | echo "source $2" >> $1 |
| 673 | if [ $emacs -eq 0 ] ; then |
| 674 | echo "run" >> $1 |
| 675 | fi |
| 676 | } |
| 677 | |
| 678 | native_kernel() { |
| 679 | banner="Running NATIVE-KERNEL socket test" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 680 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 681 | title1="SERVER$title_dbg (Native-Kernel Socket Test)" |
| 682 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 683 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 684 | set_pre_cmd $emacs_server $gdb_server |
| 685 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
| 686 | echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd1_file |
| 687 | write_script_footer $cmd1_file $perf_server |
| 688 | chmod +x $cmd1_file |
| 689 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 690 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 691 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 692 | title2="CLIENT$title_dbg (Native-Kernel Socket Test)" |
| 693 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 694 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 695 | set_pre_cmd $emacs_client $gdb_client |
| 696 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
| 697 | echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd2_file |
| 698 | echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd2_file |
| 699 | write_script_footer $cmd2_file $perf_client |
| 700 | chmod +x $cmd2_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 701 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 702 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | native_preload() { |
| 706 | verify_no_vpp |
| 707 | banner="Running NATIVE-PRELOAD socket test" |
Dave Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 708 | ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib " |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 709 | |
| 710 | title1="VPP$title_dbg (Native-Preload Socket Test)" |
| 711 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp |
| 712 | gdb_cmdfile=$VPP_GDB_CMDFILE |
| 713 | set_pre_cmd $emacs_vpp $gdb_vpp |
| 714 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 715 | if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then |
| 716 | echo -n "sudo " >> $cmd1_file |
| 717 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 718 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file |
| 719 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 720 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 721 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 722 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 723 | title2="SERVER$title_dbg (Native-Preload Socket Test)" |
| 724 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 725 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 726 | set_pre_cmd $emacs_server $gdb_server $ld_preload |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 727 | if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 728 | namespace_id="$server_namespace_id" |
| 729 | namespace_secret="$server_namespace_secret" |
| 730 | fi |
Dave Wallace | de91006 | 2018-03-20 09:22:13 -0400 | [diff] [blame] | 731 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 3" |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 732 | echo "export LD_LIBRARY_PATH=\"$lib_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd2_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 733 | echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file |
| 734 | write_script_footer $cmd2_file $perf_server |
| 735 | chmod +x $cmd2_file |
| 736 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 737 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 738 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 739 | title3="CLIENT$title_dbg (Native-Preload Socket Test)" |
| 740 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 741 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 742 | set_pre_cmd $emacs_client $gdb_client $ld_preload |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 743 | if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 744 | namespace_id="$client_namespace_id" |
| 745 | namespace_secret="$client_namespace_secret" |
| 746 | fi |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 747 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4" |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 748 | echo "export LD_LIBRARY_PATH=\"$lib_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd3_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 749 | echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file |
| 750 | echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file |
| 751 | write_script_footer $cmd3_file $perf_client |
| 752 | chmod +x $cmd3_file |
| 753 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | native_vcl() { |
| 757 | verify_no_vpp |
| 758 | banner="Running NATIVE-VCL socket test" |
| 759 | |
| 760 | title1="VPP$title_dbg (Native-VCL Socket Test)" |
| 761 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp |
| 762 | gdb_cmdfile=$VPP_GDB_CMDFILE |
| 763 | set_pre_cmd $emacs_vpp $gdb_vpp |
| 764 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 765 | if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then |
| 766 | echo -n "sudo " >> $cmd1_file |
| 767 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 768 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file |
| 769 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 770 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 771 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 772 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 773 | title2="SERVER$title_dbg (Native-VCL Socket Test)" |
| 774 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 775 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 776 | set_pre_cmd $emacs_server $gdb_server |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 777 | if [ "$multi_host" = "server" ] ; then |
| 778 | delay="sleep 10" |
| 779 | else |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 780 | delay="sleep 3" |
| 781 | fi |
| 782 | if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 783 | namespace_id="$server_namespace_id" |
| 784 | namespace_secret="$server_namespace_secret" |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 785 | fi |
| 786 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay" |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 787 | echo "export LD_LIBRARY_PATH=\"$lib_dir:$LD_LIBRARY_PATH\"" >> $cmd2_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 788 | echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file |
| 789 | write_script_footer $cmd2_file $perf_server |
| 790 | chmod +x $cmd2_file |
| 791 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 792 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 793 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 794 | title3="CLIENT$title_dbg (Native-VCL Socket Test)" |
| 795 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 796 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 797 | set_pre_cmd $emacs_client $gdb_client |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 798 | if [ "$multi_host" = "client" ] ; then |
| 799 | delay="sleep 10" |
| 800 | else |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 801 | delay="sleep 4" |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 802 | fi |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 803 | if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 804 | namespace_id="$client_namespace_id" |
| 805 | namespace_secret="$client_namespace_secret" |
| 806 | fi |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 807 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay" |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 808 | echo "export LD_LIBRARY_PATH=\"$lib_dir:$LD_LIBRARY_PATH\"" >> $cmd3_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 809 | echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file |
| 810 | echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file |
| 811 | write_script_footer $cmd3_file $perf_client |
| 812 | chmod +x $cmd3_file |
| 813 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | docker_kernel() { |
| 817 | verify_no_docker_containers |
| 818 | banner="Running DOCKER-KERNEL socket test" |
| 819 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 820 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 821 | title1="SERVER$title_dbg (Docker-Native Socket Test)" |
| 822 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 823 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 824 | set_pre_cmd $emacs_server $gdb_server |
| 825 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
| 826 | 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 |
| 827 | write_script_footer $cmd1_file $perf_server |
| 828 | chmod +x $cmd1_file |
| 829 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 830 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 831 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 832 | title2="CLIENT$title_dbg (Docker-Native Socket Test)" |
| 833 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 834 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 835 | set_pre_cmd $emacs_client $gdb_client |
| 836 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
| 837 | echo "$get_docker_server_ip4addr" >> $cmd2_file |
| 838 | echo "docker run -it --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd2_file |
| 839 | write_script_footer $cmd2_file $perf_client |
| 840 | chmod +x $cmd2_file |
| 841 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | docker_preload() { |
| 845 | verify_no_vpp |
| 846 | verify_no_docker_containers |
| 847 | banner="Running DOCKER-PRELOAD socket test" |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 848 | docker_ld_preload_dir="/vcl-ldpreload/" |
| 849 | ld_preload_dir="$VCL_LDPRELOAD_LIB_DIR" |
| 850 | ld_preload="$docker_ld_preload_dir$vcl_ldpreload_lib " |
| 851 | docker_ld_preload_lib="$docker_ld_preload_dir$vcl_ldpreload_lib " |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 852 | |
| 853 | title1="VPP$title_dbg (Docker-Preload Socket Test)" |
| 854 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp |
| 855 | gdb_cmdfile=$VPP_GDB_CMDFILE |
| 856 | set_pre_cmd $emacs_vpp $gdb_vpp |
| 857 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 858 | if [ -n "$multi_host" ] ; then |
| 859 | echo -n "sudo " >> $cmd1_file |
| 860 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 861 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file |
| 862 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 863 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 864 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 865 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 866 | title2="SERVER$title_dbg (Docker-Preload Socket Test)" |
| 867 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 868 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 869 | set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 870 | if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 871 | namespace_id="$server_namespace_id" |
| 872 | namespace_secret="$server_namespace_secret" |
| 873 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 874 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 875 | echo "docker run -it -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib_dir:$docker_lib_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_lib_dir:$docker_ld_preload_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 876 | write_script_footer $cmd2_file $perf_server |
| 877 | chmod +x $cmd2_file |
| 878 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 879 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 880 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 881 | title3="CLIENT$title_dbg (Docker-Preload Socket Test)" |
| 882 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 883 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 884 | set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 885 | if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 886 | namespace_id="$client_namespace_id" |
| 887 | namespace_secret="$client_namespace_secret" |
| 888 | fi |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 889 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 890 | echo "$get_docker_server_ip4addr" >> $cmd3_file |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 891 | echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib_dir:$docker_lib_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_lib_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 892 | write_script_footer $cmd3_file $perf_client |
| 893 | chmod +x $cmd3_file |
| 894 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 895 | } |
| 896 | |
| 897 | docker_vcl() { |
| 898 | verify_no_vpp |
| 899 | verify_no_docker_containers |
| 900 | banner="Running DOCKER-VCL socket test" |
| 901 | |
| 902 | title1="VPP$title_dbg (Docker-VCL Socket Test)" |
| 903 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp |
| 904 | gdb_cmdfile=$VPP_GDB_CMDFILE |
| 905 | set_pre_cmd $emacs_vpp $gdb_vpp |
| 906 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 907 | if [ -n "$multi_host" ] ; then |
| 908 | echo -n "sudo " >> $cmd1_file |
| 909 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 910 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file |
| 911 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 912 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 913 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 914 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 915 | title2="SERVER$title_dbg (Docker-VCL Socket Test)" |
| 916 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 917 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 918 | set_pre_cmd $emacs_server $gdb_server |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 919 | if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 920 | namespace_id="$server_namespace_id" |
| 921 | namespace_secret="$server_namespace_secret" |
| 922 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 923 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 924 | echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib_dir:$docker_lib_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_lib_dir $docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 925 | write_script_footer $cmd2_file $perf_server |
| 926 | chmod +x $cmd2_file |
| 927 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 928 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 929 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 930 | title3="CLIENT$title_dbg (Docker-VCL Socket Test)" |
| 931 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 932 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 933 | set_pre_cmd $emacs_client $gdb_client |
Dave Wallace | fbbb07c | 2018-03-08 11:35:03 -0500 | [diff] [blame] | 934 | if [ -n "$full_thru_host_stack_vpp_cfg" ] ; then |
| 935 | namespace_id="$client_namespace_id" |
| 936 | namespace_secret="$client_namespace_secret" |
| 937 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 938 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3" |
| 939 | echo "$get_docker_server_ip4addr" >> $cmd3_file |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 940 | echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib_dir:$docker_lib_dir -v $vcl_config_dir:$docker_vcl_config_dir -e VCL_CONFIG=${docker_vcl_config_dir}/$vcl_config -e LD_LIBRARY_PATH=$docker_lib_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 941 | write_script_footer $cmd3_file $perf_client |
| 942 | chmod +x $cmd3_file |
| 943 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 944 | } |
| 945 | |
| 946 | if [[ $run_test ]] ; then |
| 947 | eval $run_test |
| 948 | else |
| 949 | echo "ERROR: Please specify a test to run!" >&2 |
| 950 | usage; |
| 951 | fi |
| 952 | |
| 953 | if (( $(which xfce4-terminal | wc -l) > 0 )) ; then |
| 954 | xterm_cmd="xfce4-terminal --geometry $xterm_geom" |
| 955 | if [[ $use_tabs ]] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 956 | declare -a tab_cmd_files |
| 957 | declare -a tab_titles |
| 958 | declare -i i=0 |
| 959 | |
| 960 | if [ -x "$cmd1_file" ] ; then |
| 961 | tab_cmd_files[$i]="$cmd1_file" |
| 962 | tab_titles[$i]="$title1" |
| 963 | (( i++ )) |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 964 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 965 | if [ -x "$cmd2_file" ] ; then |
| 966 | tab_cmd_files[$i]="$cmd2_file" |
| 967 | tab_titles[$i]="$title2" |
| 968 | (( i++ )) |
| 969 | fi |
| 970 | if [ -x "$cmd3_file" ] ; then |
| 971 | tab_cmd_files[$i]="$cmd3_file" |
| 972 | tab_titles[$i]="$title3" |
| 973 | fi |
| 974 | |
| 975 | if [ -n "${tab_cmd_files[2]}" ] ; then |
| 976 | $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]}" |
| 977 | elif [ -n "${tab_cmd_files[1]}" ] ; then |
| 978 | $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}" |
| 979 | |
| 980 | else |
| 981 | $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" |
| 982 | fi |
| 983 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 984 | else |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 985 | if [ -x "$cmd1_file" ] ; then |
| 986 | ($xterm_cmd --title "$title1" --command "$cmd1_file" &) |
| 987 | fi |
| 988 | if [ -x "$cmd2_file" ] ; then |
| 989 | ($xterm_cmd --title "$title2" --command "$cmd2_file" &) |
| 990 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 991 | if [ -x "$cmd3_file" ] ; then |
| 992 | ($xterm_cmd --title "$title3" --command "$cmd3_file" &) |
| 993 | fi |
| 994 | fi |
| 995 | |
| 996 | else |
| 997 | if [[ $use_tabs ]] ; then |
| 998 | echo "Sorry, plain ol' xterm doesn't support tabs." |
| 999 | fi |
| 1000 | xterm_cmd="xterm -fs 10 -geometry $xterm_geom" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 1001 | if [ -x "$cmd1_file" ] ; then |
| 1002 | ($xterm_cmd -title "$title1" -e "$cmd1_file" &) |
| 1003 | fi |
| 1004 | if [ -x "$cmd2_file" ] ; then |
| 1005 | ($xterm_cmd -title "$title2" -e "$cmd2_file" &) |
| 1006 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 1007 | if [ -x "$cmd3_file" ] ; then |
| 1008 | ($xterm_cmd -title "$title3" -e "$cmd3_file" &) |
| 1009 | fi |
| 1010 | fi |
| 1011 | |
| 1012 | sleep 1 |