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 )" |
| 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/" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 9 | vpp_run_dir="/run/vpp" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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/" |
Dave Wallace | 1948161 | 2017-09-15 18:47:44 -0400 | [diff] [blame] | 12 | dpdk_devbind="/usr/share/dpdk/usertools/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/" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 15 | docker_lib64_dir="/vpp-lib64/" |
| 16 | docker_os="ubuntu" |
Dave Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 17 | vcl_ldpreload_lib="libvcl_ldpreload.so.0.0.0" |
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" |
| 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" |
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" |
| 27 | vppcom_conf="vppcom.conf" |
| 28 | vppcom_conf_dir="$WS_ROOT/src/uri/" |
| 29 | docker_vppcom_conf_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}" |
Dave Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 52 | VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-/usr/local/lib}" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 53 | |
| 54 | usage() { |
| 55 | cat <<EOF |
| 56 | Usage: socket_test.sh OPTIONS TEST |
| 57 | TESTS: |
| 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 | |
| 65 | OPTIONS: |
| 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 72 | -n Name of ethernet for VPP to use in multi-host cfg. |
| 73 | -6 Use ipv6 addressing. |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 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) |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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. |
| 83 | v[pp] Run vpp in gdb. |
| 84 | -t Use tabs in one xterm if available (e.g. xfce4-terminal). |
| 85 | |
| 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. |
| 98 | |
| 99 | Environment 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. |
| 104 | EOF |
| 105 | exit 1 |
| 106 | } |
| 107 | |
| 108 | declare -i emacs_vpp=0 |
| 109 | declare -i emacs_client=0 |
| 110 | declare -i emacs_server=0 |
| 111 | declare -i gdb_vpp=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 |
| 119 | declare -i iperf3=0 |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 120 | declare -i use_ipv6=0 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 121 | |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 122 | while getopts ":hitlbcd6n:m:e:g:p:E:I:N:P:R:S:T:UBVX" opt; do |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 123 | 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 131 | 6) use_ipv6=1 |
| 132 | ;; |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 133 | 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 139 | _debug="_debug" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 140 | 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 161 | n) vpp_eth_name="$OPTARG" |
| 162 | ;; |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 163 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 172 | 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 | ;; |
| 210 | E|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 |
| 223 | done |
| 224 | |
| 225 | shift $(( $OPTIND-1 )) |
| 226 | while ! [[ $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 |
| 249 | done |
| 250 | |
| 251 | if [ -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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 254 | exit 1 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 255 | fi |
| 256 | |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 257 | if [[ "$(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) |
| 260 | fi |
| 261 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 262 | if [ ! -d $vpp_dir ] ; then |
| 263 | echo "ERROR: Missing VPP$DEBUG bin directory!" >&2 |
| 264 | echo " $vpp_dir" >&2 |
| 265 | env_test_failed="true" |
| 266 | fi |
| 267 | |
| 268 | if [[ $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 Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 272 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 275 | env_test_failed="true" |
Dave Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 276 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 279 | env_test_failed="true" |
| 280 | fi |
| 281 | fi |
| 282 | |
| 283 | if [ ! -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" |
| 287 | fi |
| 288 | |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 289 | if [ ! -f $vpp_dir$sock_srvr_app ] && [ ! $iperf3 -eq 1 ] ; then |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 290 | echo "ERROR: Missing$DEBUG Socket Server Application!" >&2 |
| 291 | echo " $vpp_dir$sock_srvr_app" >&2 |
| 292 | env_test_failed="true" |
| 293 | fi |
| 294 | |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 295 | if [ ! -f $vpp_dir$sock_clnt_app ] && [ ! $iperf3 -eq 1 ] ; then |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 296 | echo "ERROR: Missing$DEBUG Socket Client Application!" >&2 |
| 297 | echo " $vpp_dir$sock_clnt_app" >&2 |
| 298 | env_test_failed="true" |
| 299 | fi |
| 300 | |
| 301 | if [[ $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 |
| 311 | fi |
| 312 | |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 313 | if [[ $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" |
| 317 | fi |
| 318 | |
Dave Wallace | 1948161 | 2017-09-15 18:47:44 -0400 | [diff] [blame] | 319 | if [ -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" |
| 324 | fi |
| 325 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 326 | if [ -n "$env_test_failed" ] ; then |
| 327 | exit 1 |
| 328 | fi |
| 329 | |
| 330 | if [ -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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 335 | api_segment=" api-segment { gid $user_gid prefix $api_prefix }" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 336 | fi |
| 337 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 338 | if [ -z "$api_segment" ] ; then |
| 339 | api_segment=" api-segment { gid $user_gid }" |
| 340 | fi |
| 341 | if [ -n "$multi_host" ] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 342 | sudo modprobe uio_pci_generic |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 343 | vpp_args="unix { interactive exec $tmp_vpp_exec_file}${api_segment}" |
| 344 | else |
| 345 | vpp_args="unix { interactive }${api_segment}" |
| 346 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 347 | |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 348 | if [ $iperf3 -eq 1 ] ; then |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 349 | app_dir="$(dirname $(which iperf3))/" |
| 350 | srvr_app=$iperf_srvr_app |
| 351 | clnt_app=$iperf_clnt_app |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 352 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 358 | else |
| 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" |
| 362 | fi |
| 363 | |
| 364 | verify_no_vpp() { |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 365 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 373 | echo |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 374 | echo $running_vpp |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 375 | 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 379 | sudo rm -f $clean_devshm |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 380 | 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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 388 | 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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 393 | 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 412 | i40e) |
| 413 | vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;; |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 414 | *) |
| 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 421 | 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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 426 | fi |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 427 | if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 428 | echo "ERROR: No inet6 address configured for $vpp_eth_name!" |
| 429 | usage |
| 430 | fi |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 431 | vpp_args="$vpp_args plugins { path ${lib64_dir}vpp_plugins } dpdk { dev $vpp_eth_pci_id }" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 432 | |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 433 | sudo ifconfig $vpp_eth_name down 2> /dev/null |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 434 | 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 |
| 437 | set int state $vpp_eth_ifname up |
| 438 | set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr |
| 439 | EOF |
| 440 | |
| 441 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | verify_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 | |
| 460 | set_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 | |
| 482 | write_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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 491 | 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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 493 | else |
| 494 | echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1 |
| 495 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 496 | fi |
| 497 | echo "export VPPCOM_CONF=${vppcom_conf_dir}${vppcom_conf}" >> $1 |
| 498 | if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 499 | if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 500 | 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 | } |
| 504 | EOF |
| 505 | else |
| 506 | cat <<EOF >> $1 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 507 | $gdb_in_emacs() { |
| 508 | emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")" |
| 509 | } |
| 510 | EOF |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 511 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 512 | fi |
| 513 | if [ -n "$4" ] ; then |
| 514 | echo "$4" >> $1 |
| 515 | fi |
| 516 | } |
| 517 | |
| 518 | write_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 | |
| 528 | write_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 | |
| 553 | native_kernel() { |
| 554 | banner="Running NATIVE-KERNEL socket test" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 555 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 565 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 566 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 576 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 577 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | native_preload() { |
| 581 | verify_no_vpp |
| 582 | banner="Running NATIVE-PRELOAD socket test" |
Dave Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 583 | ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib " |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 584 | |
| 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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 590 | if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then |
| 591 | echo -n "sudo " >> $cmd1_file |
| 592 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 593 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file |
| 594 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 595 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 596 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 597 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 608 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 609 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | native_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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 632 | if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then |
| 633 | echo -n "sudo " >> $cmd1_file |
| 634 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 635 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file |
| 636 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 637 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 638 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 639 | 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 644 | if [ "$multi_host" = "server" ] ; then |
| 645 | delay="sleep 10" |
| 646 | else |
Dave Wallace | f7f809c | 2017-10-03 01:48:42 -0400 | [diff] [blame] | 647 | delay="sleep 2" |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 648 | fi |
| 649 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 650 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 655 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 656 | 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 Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 661 | if [ "$multi_host" = "client" ] ; then |
| 662 | delay="sleep 10" |
| 663 | else |
Dave Wallace | f7f809c | 2017-10-03 01:48:42 -0400 | [diff] [blame] | 664 | delay="sleep 2" |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 665 | fi |
| 666 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 667 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | docker_kernel() { |
| 676 | verify_no_docker_containers |
| 677 | banner="Running DOCKER-KERNEL socket test" |
| 678 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 679 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 689 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 690 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | docker_preload() { |
| 704 | verify_no_vpp |
| 705 | verify_no_docker_containers |
| 706 | banner="Running DOCKER-PRELOAD socket test" |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 707 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 711 | |
| 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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 717 | if [ -n "$multi_host" ] ; then |
| 718 | echo -n "sudo " >> $cmd1_file |
| 719 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 720 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file |
| 721 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 722 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 723 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 724 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 734 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 735 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | docker_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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 758 | if [ -n "$multi_host" ] ; then |
| 759 | echo -n "sudo " >> $cmd1_file |
| 760 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 761 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file |
| 762 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 763 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 764 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 765 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 775 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 776 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | if [[ $run_test ]] ; then |
| 790 | eval $run_test |
| 791 | else |
| 792 | echo "ERROR: Please specify a test to run!" >&2 |
| 793 | usage; |
| 794 | fi |
| 795 | |
| 796 | if (( $(which xfce4-terminal | wc -l) > 0 )) ; then |
| 797 | xterm_cmd="xfce4-terminal --geometry $xterm_geom" |
| 798 | if [[ $use_tabs ]] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 799 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 807 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 808 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 827 | else |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 828 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 834 | if [ -x "$cmd3_file" ] ; then |
| 835 | ($xterm_cmd --title "$title3" --command "$cmd3_file" &) |
| 836 | fi |
| 837 | fi |
| 838 | |
| 839 | else |
| 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 Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 844 | 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 Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 850 | if [ -x "$cmd3_file" ] ; then |
| 851 | ($xterm_cmd -title "$title3" -e "$cmd3_file" &) |
| 852 | fi |
| 853 | fi |
| 854 | |
| 855 | sleep 1 |