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" |
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. |
| 72 | -6 Use ipv6 addressing. |
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: |
| 86 | -S <ip address> Server IP address. |
| 87 | -P <server port> Server Port number. |
| 88 | -E <data> Run Echo test. |
| 89 | -N <num-writes> Test Cfg: number of writes. |
| 90 | -R <rxbuf-size> Test Cfg: rx buffer size. |
| 91 | -T <txbuf-size> Test Cfg: tx buffer size. |
| 92 | -U Run Uni-directional test. |
| 93 | -B Run Bi-directional test. |
| 94 | -I <num-tst-socks> Send data over multiple test sockets in parallel. |
| 95 | -V Test Cfg: Verbose mode. |
| 96 | -X Exit client/server after running test. |
| 97 | |
| 98 | Environment variables: |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 99 | VCL_CONFIG Pathname of vppcom configuration file. |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 100 | VPP_GDB_CMDFILE Pathname of gdb command file for vpp. |
| 101 | VPPCOM_CLIENT_GDB_CMDFILE Pathname of gdb command file for client. |
| 102 | VPPCOM_SERVER_GDB_CMDFILE Pathname of gdb command file for server. |
| 103 | EOF |
| 104 | exit 1 |
| 105 | } |
| 106 | |
| 107 | declare -i emacs_vpp=0 |
| 108 | declare -i emacs_client=0 |
| 109 | declare -i emacs_server=0 |
| 110 | declare -i gdb_vpp=0 |
| 111 | declare -i gdb_client=0 |
| 112 | declare -i gdb_server=0 |
| 113 | declare -i perf_vpp=0 |
| 114 | declare -i perf_client=0 |
| 115 | declare -i perf_server=0 |
| 116 | declare -i leave_tmp_files=0 |
| 117 | declare -i bash_after_exit=0 |
| 118 | declare -i iperf3=0 |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 119 | declare -i use_ipv6=0 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 120 | |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 121 | 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] | 122 | case $opt in |
| 123 | h) usage ;; |
| 124 | l) leave_tmp_files=1 |
| 125 | ;; |
| 126 | b) bash_after_exit=1 |
| 127 | ;; |
| 128 | i) iperf3=1 |
| 129 | ;; |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 130 | 6) use_ipv6=1 |
| 131 | ;; |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 132 | t) xterm_geom="180x40" |
| 133 | use_tabs="true" |
| 134 | ;; |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 135 | c) VCL_CONFIG="${vcl_config_dir}vcl_test.conf" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 136 | ;; |
| 137 | d) title_dbg="-DEBUG" |
| 138 | vpp_dir=$vpp_debug_dir |
| 139 | lib64_dir=$lib64_debug_dir |
| 140 | ;; |
| 141 | e) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then |
| 142 | emacs_client=1 |
| 143 | emacs_server=1 |
| 144 | emacs_vpp=1 |
| 145 | elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then |
| 146 | emacs_client=1 |
| 147 | elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then |
| 148 | emacs_server=1 |
| 149 | elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then |
| 150 | emacs_vpp=1 |
| 151 | else |
| 152 | echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2 |
| 153 | usage |
| 154 | fi |
| 155 | title_dbg="-DEBUG" |
| 156 | vpp_dir=$vpp_debug_dir |
| 157 | lib64_dir=$lib64_debug_dir |
| 158 | ;; |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 159 | n) vpp_eth_name="$OPTARG" |
| 160 | ;; |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 161 | m) if [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then |
| 162 | multi_host="client" |
| 163 | elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then |
| 164 | multi_host="server" |
| 165 | else |
| 166 | echo "ERROR: Option -e unknown argument \'$OPTARG\'" >&2 |
| 167 | usage |
| 168 | fi |
| 169 | ;; |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 170 | g) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then |
| 171 | gdb_client=1 |
| 172 | gdb_server=1 |
| 173 | gdb_vpp=1 |
| 174 | elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then |
| 175 | gdb_client=1 |
| 176 | elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then |
| 177 | gdb_server=1 |
| 178 | elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then |
| 179 | gdb_vpp=1 |
| 180 | else |
| 181 | echo "ERROR: Option -g unknown argument \'$OPTARG\'" >&2 |
| 182 | usage |
| 183 | fi |
| 184 | title_dbg="-DEBUG" |
| 185 | vpp_dir=$vpp_debug_dir |
| 186 | lib64_dir=$lib64_debug_dir |
| 187 | ;; |
| 188 | p) if [ $OPTARG = "a" ] || [ $OPTARG = "all" ] ; then |
| 189 | perf_client=1 |
| 190 | perf_server=1 |
| 191 | perf_vpp=1 |
| 192 | elif [ $OPTARG = "c" ] || [ $OPTARG = "client" ] ; then |
| 193 | perf_client=1 |
| 194 | elif [ $OPTARG = "s" ] || [ $OPTARG = "server" ] ; then |
| 195 | perf_server=1 |
| 196 | elif [ $OPTARG = "v" ] || [ $OPTARG = "vpp" ] ; then |
| 197 | perf_vpp=1 |
| 198 | else |
| 199 | echo "ERROR: Option -p unknown argument \'$OPTARG\'" >&2 |
| 200 | usage |
| 201 | fi |
| 202 | echo "WARNING: -p options TBD" |
| 203 | ;; |
| 204 | S) sock_srvr_addr="$OPTARG" |
| 205 | ;; |
| 206 | P) sock_srvr_port="$OPTARG" |
| 207 | ;; |
| 208 | E|I|N|R|T) sock_clnt_options="$sock_clnt_options -$opt \"$OPTARG\"" |
| 209 | ;; |
| 210 | U|B|V|X) sock_clnt_options="$sock_clnt_options -$opt" |
| 211 | ;; |
| 212 | \?) |
| 213 | echo "ERROR: Invalid option: -$OPTARG" >&2 |
| 214 | usage |
| 215 | ;; |
| 216 | :) |
| 217 | echo "ERROR: Option -$OPTARG requires an argument." >&2 |
| 218 | usage |
| 219 | ;; |
| 220 | esac |
| 221 | done |
| 222 | |
| 223 | shift $(( $OPTIND-1 )) |
| 224 | while ! [[ $run_test ]] && (( $# > 0 )) ; do |
| 225 | case $1 in |
| 226 | "nk" | "native-kernel") |
| 227 | run_test="native_kernel" ;; |
| 228 | "np" | "native-preload") |
| 229 | run_test="native_preload" ;; |
| 230 | "nv" | "native-vcl") |
| 231 | sock_srvr_app="vcl_test_server" |
| 232 | sock_clnt_app="vcl_test_client" |
| 233 | run_test="native_vcl" ;; |
| 234 | "dk" | "docker-kernel") |
| 235 | run_test="docker_kernel" ;; |
| 236 | "dp" | "docker-preload") |
| 237 | run_test="docker_preload" ;; |
| 238 | "dv" | "docker-vcl") |
| 239 | sock_srvr_app="vcl_test_server" |
| 240 | sock_clnt_app="vcl_test_client" |
| 241 | run_test="docker_vcl" ;; |
| 242 | *) |
| 243 | echo "ERROR: Unknown option '$1'!" >&2 |
| 244 | usage ;; |
| 245 | esac |
| 246 | shift |
| 247 | done |
| 248 | |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 249 | VCL_LDPRELOAD_LIB_DIR="${VCL_LDPRELOAD_LIB_DIR:-$lib64_dir}" |
| 250 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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 | 4f6c3a9 | 2017-10-24 15:39:44 -0400 | [diff] [blame] | 257 | if [[ "$(grep bin_PROGRAMS $WS_ROOT/src/vcl.am)" = "" ]] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 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 |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 263 | echo "ERROR: Missing VPP$title_dbg bin directory!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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 |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 270 | echo "ERROR: Missing VPP$title_dbg lib64 directory!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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 |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 284 | echo "ERROR: Missing VPP$title_dbg Application!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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 | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 290 | echo "ERROR: Missing$title_dbg Socket Server Application!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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 | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 296 | echo "ERROR: Missing$title_dbg Socket Client Application!" >&2 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 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 | |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 330 | if [ -f "$VCL_CONFIG" ] ; then |
| 331 | vcl_config="$(basename $VCL_CONFIG)" |
| 332 | vcl_config_dir="$(dirname $VCL_CONFIG)/" |
| 333 | 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] | 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 | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 338 | if [ -n "$VCL_APP_NAMESPACE_ID" ] && [ -n "$VCL_APP_NAMESPACE_SECRET" ] ; then |
| 339 | namespace_id="$VCL_APP_NAMESPACE_ID" |
| 340 | namespace_secret="$VCL_APP_NAMESPACE_SECRET" |
| 341 | fi |
| 342 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 343 | if [ -z "$api_segment" ] ; then |
| 344 | api_segment=" api-segment { gid $user_gid }" |
| 345 | fi |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 346 | vpp_args="unix { interactive exec $tmp_vpp_exec_file}${api_segment}" |
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 | |
Dave Wallace | 5c7cf1c | 2017-10-24 04:12:18 -0400 | [diff] [blame] | 364 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 365 | verify_no_vpp() { |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 366 | local grep_for_vpp="ps -eaf|grep -v grep|grep \"bin/vpp\"" |
| 367 | |
| 368 | if [ -n "$api_prefix" ] ; then |
| 369 | grep_for_vpp="$grep_for_vpp|grep \"prefix $api_prefix\"" |
| 370 | fi |
| 371 | local running_vpp="$(eval $grep_for_vpp)" |
| 372 | if [ -n "$running_vpp" ] ; then |
| 373 | echo "ERROR: Please kill the following vpp instance(s):" |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 374 | echo |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 375 | echo $running_vpp |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 376 | echo |
| 377 | exit 1 |
| 378 | fi |
| 379 | 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] | 380 | sudo rm -f $clean_devshm |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 381 | devshm_files="$(ls -l $clean_devshm 2>/dev/null | grep $(whoami))" |
| 382 | if [ "$devshm_files" != "" ] ; then |
| 383 | echo "ERROR: Please remove the following $vpp_shm_dir files:" |
| 384 | for file in "$devshm_files" ; do |
| 385 | echo " $file" |
| 386 | done |
| 387 | exit 1 |
| 388 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 389 | if [ ! -d "$vpp_run_dir" ] ; then |
| 390 | sudo mkdir $vpp_run_dir |
| 391 | sudo chown root:$USER $vpp_run_dir |
| 392 | fi |
| 393 | if [ -n "$multi_host" ] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 394 | vpp_eth_pci_id="$(ls -ld /sys/class/net/$vpp_eth_name/device | awk '{print $11}' | cut -d/ -f4)" |
| 395 | if [ -z "$vpp_eth_pci_id" ] ; then |
| 396 | echo "ERROR: Missing ethernet interface $vpp_eth_name!" |
| 397 | usage |
| 398 | fi |
| 399 | printf -v bus "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f2)" |
| 400 | printf -v slot "%x" "0x$(echo $vpp_eth_pci_id | cut -d: -f3 | cut -d. -f1)" |
| 401 | printf -v func "%x" "0x$(echo $vpp_eth_pci_id | cut -d. -f2)" |
| 402 | |
| 403 | vpp_eth_kernel_driver="$(basename $(ls -l /sys/bus/pci/devices/$vpp_eth_pci_id/driver | awk '{print $11}'))" |
| 404 | if [ -z "$vpp_eth_kernel_driver" ] ; then |
| 405 | echo "ERROR: Missing kernel driver for $vpp_eth_name!" |
| 406 | usage |
| 407 | fi |
| 408 | case $vpp_eth_kernel_driver in |
| 409 | e1000) |
| 410 | vpp_eth_ifname="GigabitEthernet$bus/$slot/$func" ;; |
| 411 | ixgbe) |
| 412 | vpp_eth_ifname="TenGigabitEthernet$bus/$slot/$func" ;; |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 413 | i40e) |
| 414 | vpp_eth_ifname="FortyGigabitEthernet$bus/$slot/$func" ;; |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 415 | *) |
| 416 | echo "ERROR: Unknown ethernet kernel driver $vpp_eth_kernel_driver!" |
| 417 | usage ;; |
| 418 | esac |
| 419 | |
| 420 | vpp_eth_ip4_addr="$(ip -4 -br addr show $vpp_eth_name | awk '{print $3}')" |
| 421 | if [ -z "$vpp_eth_ip4_addr" ] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 422 | if [ "$multi_host" = "server" ] ; then |
| 423 | vpp_eth_ip4_addr="10.10.10.10/24" |
| 424 | else |
| 425 | vpp_eth_ip4_addr="10.10.10.11/24" |
| 426 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 427 | fi |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 428 | if [ $use_ipv6 -eq 1 ] && [ -z "$vpp_eth_ip6_addr" ] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 429 | echo "ERROR: No inet6 address configured for $vpp_eth_name!" |
| 430 | usage |
| 431 | fi |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 432 | 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] | 433 | |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 434 | sudo ifconfig $vpp_eth_name down 2> /dev/null |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 435 | echo "Configuring VPP to use $vpp_eth_name ($vpp_eth_pci_id), inet addr $vpp_eth_ip4_addr" |
| 436 | |
| 437 | cat <<EOF >> $tmp_vpp_exec_file |
| 438 | set int state $vpp_eth_ifname up |
| 439 | set int ip addr $vpp_eth_ifname $vpp_eth_ip4_addr |
| 440 | EOF |
| 441 | |
| 442 | fi |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 443 | |
| 444 | if [ -n "$namespace_id" ] ; then |
| 445 | cat <<EOF >> $tmp_vpp_exec_file |
| 446 | session enable |
| 447 | app ns add id $namespace_id secret $namespace_secret sw_if_index 0 |
| 448 | EOF |
| 449 | fi |
| 450 | |
| 451 | cat <<EOF >> $tmp_vpp_exec_file |
| 452 | show version |
| 453 | show version verbose |
| 454 | show cpu |
| 455 | show int |
| 456 | EOF |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | verify_no_docker_containers() { |
| 460 | if (( $(which docker | wc -l) < 1 )) ; then |
| 461 | echo "ERROR: docker is not installed!" |
| 462 | echo "See https://docs.docker.com/engine/installation/linux/ubuntu/" |
| 463 | echo " or https://docs.docker.com/engine/installation/linux/centos/" |
| 464 | exit 1 |
| 465 | fi |
| 466 | if (( $(docker ps | wc -l) > 1 )) ; then |
| 467 | echo "ERROR: Run the following to kill all docker containers:" |
| 468 | echo "docker kill \$(docker ps -q)" |
| 469 | echo |
| 470 | docker ps |
| 471 | exit 1 |
| 472 | fi |
| 473 | } |
| 474 | |
| 475 | set_pre_cmd() { |
| 476 | # arguments |
| 477 | # $1 : emacs flag |
| 478 | # $2 : gdb flag |
| 479 | # $3 : optional LD_PRELOAD library pathname |
| 480 | local -i emacs=$1 |
| 481 | local -i gdb=$2 |
| 482 | |
| 483 | if [ $emacs -eq 1 ] ; then |
| 484 | write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3 |
| 485 | pre_cmd="$gdb_in_emacs " |
| 486 | elif [ $gdb -eq 1 ] ; then |
| 487 | write_gdb_cmdfile $tmp_gdb_cmdfile $gdb_cmdfile $emacs $3 |
| 488 | pre_cmd="gdb -x $tmp_gdb_cmdfile -i=mi --args " |
| 489 | elif [ -z $3 ] ; then |
| 490 | unset -v pre_cmd |
| 491 | else |
| 492 | docker_ld_preload="-e LD_PRELOAD=$3 " |
| 493 | pre_cmd="LD_PRELOAD=$3 " |
| 494 | fi |
| 495 | } |
| 496 | |
| 497 | write_script_header() { |
| 498 | # arguments |
| 499 | # $1 : command script file |
| 500 | # $2 : gdb command file |
| 501 | # $3 : title |
| 502 | # $4 : optional command string (typically "sleep 2") |
| 503 | echo "$bash_header" > $1 |
| 504 | echo -e "#\n# $1 generated on $(date)\n#" >> $1 |
| 505 | if [ $leave_tmp_files -eq 0 ] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 506 | if [ -n "$multi_host" ] ; then |
| 507 | 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] | 508 | else |
| 509 | echo "trap \"rm -f $1 $2 $tmp_vpp_exec_file\" $trap_signals" >> $1 |
| 510 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 511 | fi |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 512 | echo "export VCL_CONFIG=${vcl_config_dir}${vcl_config}" >> $1 |
| 513 | if [ -n "$namespace_id" ] ; then |
| 514 | echo "export VCL_APP_NAMESPACE_ID=\"$namespace_id\"" >> $1 |
| 515 | echo "export VCL_APP_NAMESPACE_SECRET=\"$namespace_secret\"" >> $1 |
| 516 | fi |
Dave Wallace | e695cb4 | 2017-11-02 22:04:42 -0400 | [diff] [blame] | 517 | if [ -n "$VCL_APP_SCOPE_LOCAL" ] || [ -z "$multi_host" ] ; then |
Dave Wallace | 774169b | 2017-11-01 20:07:40 -0400 | [diff] [blame] | 518 | echo "export VCL_APP_SCOPE_LOCAL=true" >> $1 |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 519 | fi |
Dave Wallace | e695cb4 | 2017-11-02 22:04:42 -0400 | [diff] [blame] | 520 | if [ -n "$VCL_APP_SCOPE_GLOBAL" ] || [ -n "$multi_host" ] ; then |
Dave Wallace | 774169b | 2017-11-01 20:07:40 -0400 | [diff] [blame] | 521 | echo "export VCL_APP_SCOPE_GLOBAL=true" >> $1 |
| 522 | fi |
| 523 | if [ -n "$VCL_APP_PROXY_TRANSPORT_TCP" ] ; then |
| 524 | echo "export VCL_APP_PROXY_TRANSPORT_TCP=true" >> $1 |
| 525 | fi |
| 526 | if [ -n "$VCL_APP_PROXY_TRANSPORT_UDP" ] ; then |
| 527 | echo "export VCL_APP_PROXY_TRANSPORT_UDP=true" >> $1 |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 528 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 529 | if [ "$pre_cmd" = "$gdb_in_emacs " ] ; then |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 530 | if [ -n "$multi_host" ] && [[ $3 =~ "VPP".* ]] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 531 | cat <<EOF >> $1 |
| 532 | $gdb_in_emacs() { |
| 533 | sudo emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")" |
| 534 | } |
| 535 | EOF |
| 536 | else |
| 537 | cat <<EOF >> $1 |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 538 | $gdb_in_emacs() { |
| 539 | emacs --eval "(gdb \"gdb -x $2 -i=mi --args \$*\")" --eval "(setq frame-title-format \"$3\")" |
| 540 | } |
| 541 | EOF |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 542 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 543 | fi |
| 544 | if [ -n "$4" ] ; then |
| 545 | echo "$4" >> $1 |
| 546 | fi |
| 547 | } |
| 548 | |
| 549 | write_script_footer() { |
| 550 | # arguments |
| 551 | # $1 : command script file |
| 552 | # $2 : perf flag indicating to run bash before exit |
| 553 | local -i perf=$2 |
| 554 | if [ $bash_after_exit -eq 1 ] || [ $perf -eq 1 ] ; then |
| 555 | echo "bash" >> $1 |
| 556 | fi |
| 557 | } |
| 558 | |
| 559 | write_gdb_cmdfile() { |
| 560 | # arguments |
| 561 | # $1 : gdb command file |
| 562 | # $2 : User specified gdb cmdfile |
| 563 | # $3 : emacs flag |
| 564 | # $4 : optional LD_PRELOAD library pathname. |
| 565 | local -i emacs=$3 |
| 566 | |
| 567 | echo "# $1 generated on $(date)" > $1 |
| 568 | echo "#" >> $1 |
| 569 | echo "set confirm off" >> $1 |
| 570 | if [ -n "$4" ] ; then |
| 571 | echo "set exec-wrapper env LD_PRELOAD=$4" >> $1 |
| 572 | echo "start" >> $1 |
| 573 | fi |
| 574 | |
| 575 | if [ ! -f $2 ] ; then |
| 576 | echo -n "# " >> $1 |
| 577 | fi |
| 578 | echo "source $2" >> $1 |
| 579 | if [ $emacs -eq 0 ] ; then |
| 580 | echo "run" >> $1 |
| 581 | fi |
| 582 | } |
| 583 | |
| 584 | native_kernel() { |
| 585 | banner="Running NATIVE-KERNEL socket test" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 586 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 587 | title1="SERVER$title_dbg (Native-Kernel Socket Test)" |
| 588 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 589 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 590 | set_pre_cmd $emacs_server $gdb_server |
| 591 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
| 592 | echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd1_file |
| 593 | write_script_footer $cmd1_file $perf_server |
| 594 | chmod +x $cmd1_file |
| 595 | fi |
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" = "client" ] ; then |
| 598 | title2="CLIENT$title_dbg (Native-Kernel Socket Test)" |
| 599 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 600 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 601 | set_pre_cmd $emacs_client $gdb_client |
| 602 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
| 603 | echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd2_file |
| 604 | echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd2_file |
| 605 | write_script_footer $cmd2_file $perf_client |
| 606 | chmod +x $cmd2_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 607 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 608 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | native_preload() { |
| 612 | verify_no_vpp |
| 613 | banner="Running NATIVE-PRELOAD socket test" |
Dave Wallace | d69f4f4 | 2017-08-14 18:26:46 -0400 | [diff] [blame] | 614 | ld_preload="$VCL_LDPRELOAD_LIB_DIR/$vcl_ldpreload_lib " |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 615 | |
| 616 | title1="VPP$title_dbg (Native-Preload Socket Test)" |
| 617 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp |
| 618 | gdb_cmdfile=$VPP_GDB_CMDFILE |
| 619 | set_pre_cmd $emacs_vpp $gdb_vpp |
| 620 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 621 | if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then |
| 622 | echo -n "sudo " >> $cmd1_file |
| 623 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 624 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file |
| 625 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 626 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 627 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 628 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 629 | title2="SERVER$title_dbg (Native-Preload Socket Test)" |
| 630 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 631 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 632 | set_pre_cmd $emacs_server $gdb_server $ld_preload |
| 633 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
| 634 | echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd2_file |
| 635 | echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file |
| 636 | write_script_footer $cmd2_file $perf_server |
| 637 | chmod +x $cmd2_file |
| 638 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 639 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 640 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 641 | title3="CLIENT$title_dbg (Native-Preload Socket Test)" |
| 642 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 643 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 644 | set_pre_cmd $emacs_client $gdb_client $ld_preload |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 645 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 646 | echo "export LD_LIBRARY_PATH=\"$lib64_dir:$VCL_LDPRELOAD_LIB_DIR:$LD_LIBRARY_PATH\"" >> $cmd3_file |
| 647 | echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file |
| 648 | echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file |
| 649 | write_script_footer $cmd3_file $perf_client |
| 650 | chmod +x $cmd3_file |
| 651 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | native_vcl() { |
| 655 | verify_no_vpp |
| 656 | banner="Running NATIVE-VCL socket test" |
| 657 | |
| 658 | title1="VPP$title_dbg (Native-VCL Socket Test)" |
| 659 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp |
| 660 | gdb_cmdfile=$VPP_GDB_CMDFILE |
| 661 | set_pre_cmd $emacs_vpp $gdb_vpp |
| 662 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 663 | if [ -n "$multi_host" ] && [ $emacs_vpp -eq 0 ] ; then |
| 664 | echo -n "sudo " >> $cmd1_file |
| 665 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 666 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args " >> $cmd1_file |
| 667 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 668 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 669 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 670 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 671 | title2="SERVER$title_dbg (Native-VCL Socket Test)" |
| 672 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 673 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 674 | set_pre_cmd $emacs_server $gdb_server |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 675 | if [ "$multi_host" = "server" ] ; then |
| 676 | delay="sleep 10" |
| 677 | else |
Dave Wallace | f7f809c | 2017-10-03 01:48:42 -0400 | [diff] [blame] | 678 | delay="sleep 2" |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 679 | fi |
| 680 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "$delay" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 681 | echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd2_file |
| 682 | echo "${pre_cmd}${app_dir}${srvr_app}" >> $cmd2_file |
| 683 | write_script_footer $cmd2_file $perf_server |
| 684 | chmod +x $cmd2_file |
| 685 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 686 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 687 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 688 | title3="CLIENT$title_dbg (Native-VCL Socket Test)" |
| 689 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 690 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 691 | set_pre_cmd $emacs_client $gdb_client |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 692 | if [ "$multi_host" = "client" ] ; then |
| 693 | delay="sleep 10" |
| 694 | else |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 695 | delay="sleep 4" |
Dave Wallace | 3d67449 | 2017-09-25 15:37:56 -0400 | [diff] [blame] | 696 | fi |
| 697 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "$delay" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 698 | echo "export LD_LIBRARY_PATH=\"$lib64_dir:$LD_LIBRARY_PATH\"" >> $cmd3_file |
| 699 | echo "srvr_addr=\"$sock_srvr_addr\"" >> $cmd3_file |
| 700 | echo "${pre_cmd}${app_dir}${clnt_app}" >> $cmd3_file |
| 701 | write_script_footer $cmd3_file $perf_client |
| 702 | chmod +x $cmd3_file |
| 703 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | docker_kernel() { |
| 707 | verify_no_docker_containers |
| 708 | banner="Running DOCKER-KERNEL socket test" |
| 709 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 710 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 711 | title1="SERVER$title_dbg (Docker-Native Socket Test)" |
| 712 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 713 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 714 | set_pre_cmd $emacs_server $gdb_server |
| 715 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
| 716 | 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 |
| 717 | write_script_footer $cmd1_file $perf_server |
| 718 | chmod +x $cmd1_file |
| 719 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 720 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 721 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 722 | title2="CLIENT$title_dbg (Docker-Native Socket Test)" |
| 723 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 724 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 725 | set_pre_cmd $emacs_client $gdb_client |
| 726 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
| 727 | echo "$get_docker_server_ip4addr" >> $cmd2_file |
| 728 | echo "docker run -it --cpuset-cpus='4-7' -v $vpp_dir:$docker_vpp_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd2_file |
| 729 | write_script_footer $cmd2_file $perf_client |
| 730 | chmod +x $cmd2_file |
| 731 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | docker_preload() { |
| 735 | verify_no_vpp |
| 736 | verify_no_docker_containers |
| 737 | banner="Running DOCKER-PRELOAD socket test" |
Dave Wallace | 30fb4a2 | 2017-08-17 16:22:04 -0400 | [diff] [blame] | 738 | docker_ld_preload_dir="/vcl-ldpreload/" |
| 739 | ld_preload_dir="$VCL_LDPRELOAD_LIB_DIR" |
| 740 | ld_preload="$docker_ld_preload_dir$vcl_ldpreload_lib " |
| 741 | docker_ld_preload_lib="$docker_ld_preload_dir$vcl_ldpreload_lib " |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 742 | |
| 743 | title1="VPP$title_dbg (Docker-Preload Socket Test)" |
| 744 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp |
| 745 | gdb_cmdfile=$VPP_GDB_CMDFILE |
| 746 | set_pre_cmd $emacs_vpp $gdb_vpp |
| 747 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 748 | if [ -n "$multi_host" ] ; then |
| 749 | echo -n "sudo " >> $cmd1_file |
| 750 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 751 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file |
| 752 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 753 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 754 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 755 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 756 | title2="SERVER$title_dbg (Docker-Preload Socket Test)" |
| 757 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 758 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 759 | set_pre_cmd $emacs_server $gdb_server $docker_ld_preload_lib |
| 760 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 761 | echo "docker run -it -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $ld_preload_dir:$docker_ld_preload_dir -v $vcl_config_dir:$docker_vcl_config_dir -p $sock_srvr_port:$sock_srvr_port -e VCL_CONFIG=${docker_vcl_config_dir}$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir:$docker_ld_preload_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 762 | write_script_footer $cmd2_file $perf_server |
| 763 | chmod +x $cmd2_file |
| 764 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 765 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 766 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 767 | title3="CLIENT$title_dbg (Docker-Preload Socket Test)" |
| 768 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 769 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 770 | set_pre_cmd $emacs_client $gdb_client $docker_ld_preload_lib |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 771 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 4" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 772 | echo "$get_docker_server_ip4addr" >> $cmd3_file |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 773 | echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $ld_preload_dir:$docker_ld_preload_dir -v $vcl_config_dir:$docker_vcl_config_dir -e VCL_CONFIG=${docker_vcl_config_dir}$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir ${docker_ld_preload}$docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 774 | write_script_footer $cmd3_file $perf_client |
| 775 | chmod +x $cmd3_file |
| 776 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | docker_vcl() { |
| 780 | verify_no_vpp |
| 781 | verify_no_docker_containers |
| 782 | banner="Running DOCKER-VCL socket test" |
| 783 | |
| 784 | title1="VPP$title_dbg (Docker-VCL Socket Test)" |
| 785 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_vpp |
| 786 | gdb_cmdfile=$VPP_GDB_CMDFILE |
| 787 | set_pre_cmd $emacs_vpp $gdb_vpp |
| 788 | write_script_header $cmd1_file $tmp_gdb_cmdfile "$title1" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 789 | if [ -n "$multi_host" ] ; then |
| 790 | echo -n "sudo " >> $cmd1_file |
| 791 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 792 | echo "${pre_cmd}$vpp_dir$vpp_app $vpp_args" >> $cmd1_file |
| 793 | write_script_footer $cmd1_file $perf_vpp |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 794 | chmod +x $cmd1_file |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 795 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 796 | if [ -z "$multi_host" ] || [ "$multi_host" = "server" ] ; then |
| 797 | title2="SERVER$title_dbg (Docker-VCL Socket Test)" |
| 798 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_server |
| 799 | gdb_cmdfile=$VPPCOM_SERVER_GDB_CMDFILE |
| 800 | set_pre_cmd $emacs_server $gdb_server |
| 801 | write_script_header $cmd2_file $tmp_gdb_cmdfile "$title2" "sleep 2" |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 802 | echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $vcl_config_dir:$docker_vcl_config_dir -p $sock_srvr_port:$sock_srvr_port -e VCL_CONFIG=${docker_vcl_config_dir}/$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir $docker_os ${docker_app_dir}${srvr_app}" >> $cmd2_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 803 | write_script_footer $cmd2_file $perf_server |
| 804 | chmod +x $cmd2_file |
| 805 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 806 | |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 807 | if [ -z "$multi_host" ] || [ "$multi_host" = "client" ] ; then |
| 808 | title3="CLIENT$title_dbg (Docker-VCL Socket Test)" |
| 809 | tmp_gdb_cmdfile=$tmp_gdb_cmdfile_client |
| 810 | gdb_cmdfile=$VPPCOM_CLIENT_GDB_CMDFILE |
| 811 | set_pre_cmd $emacs_client $gdb_client |
| 812 | write_script_header $cmd3_file $tmp_gdb_cmdfile "$title3" "sleep 3" |
| 813 | echo "$get_docker_server_ip4addr" >> $cmd3_file |
Dave Wallace | 8af2054 | 2017-10-26 03:29:30 -0400 | [diff] [blame] | 814 | echo "docker run -it --cpuset-cpus='4-7' -v $vpp_shm_dir:$vpp_shm_dir -v $vpp_dir:$docker_vpp_dir -v $lib64_dir:$docker_lib64_dir -v $vcl_config_dir:$docker_vcl_config_dir -e VCL_CONFIG=${docker_vcl_config_dir}/$vcl_config -e LD_LIBRARY_PATH=$docker_lib64_dir $docker_os ${docker_app_dir}${clnt_app}" >> $cmd3_file |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 815 | write_script_footer $cmd3_file $perf_client |
| 816 | chmod +x $cmd3_file |
| 817 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 818 | } |
| 819 | |
| 820 | if [[ $run_test ]] ; then |
| 821 | eval $run_test |
| 822 | else |
| 823 | echo "ERROR: Please specify a test to run!" >&2 |
| 824 | usage; |
| 825 | fi |
| 826 | |
| 827 | if (( $(which xfce4-terminal | wc -l) > 0 )) ; then |
| 828 | xterm_cmd="xfce4-terminal --geometry $xterm_geom" |
| 829 | if [[ $use_tabs ]] ; then |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 830 | declare -a tab_cmd_files |
| 831 | declare -a tab_titles |
| 832 | declare -i i=0 |
| 833 | |
| 834 | if [ -x "$cmd1_file" ] ; then |
| 835 | tab_cmd_files[$i]="$cmd1_file" |
| 836 | tab_titles[$i]="$title1" |
| 837 | (( i++ )) |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 838 | fi |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 839 | if [ -x "$cmd2_file" ] ; then |
| 840 | tab_cmd_files[$i]="$cmd2_file" |
| 841 | tab_titles[$i]="$title2" |
| 842 | (( i++ )) |
| 843 | fi |
| 844 | if [ -x "$cmd3_file" ] ; then |
| 845 | tab_cmd_files[$i]="$cmd3_file" |
| 846 | tab_titles[$i]="$title3" |
| 847 | fi |
| 848 | |
| 849 | if [ -n "${tab_cmd_files[2]}" ] ; then |
| 850 | $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]}" |
| 851 | elif [ -n "${tab_cmd_files[1]}" ] ; then |
| 852 | $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" --tab --title "${tab_titles[1]}" --command "${tab_cmd_files[1]}" |
| 853 | |
| 854 | else |
| 855 | $xterm_cmd --title "${tab_titles[0]}" --command "${tab_cmd_files[0]}" |
| 856 | fi |
| 857 | |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 858 | else |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 859 | if [ -x "$cmd1_file" ] ; then |
| 860 | ($xterm_cmd --title "$title1" --command "$cmd1_file" &) |
| 861 | fi |
| 862 | if [ -x "$cmd2_file" ] ; then |
| 863 | ($xterm_cmd --title "$title2" --command "$cmd2_file" &) |
| 864 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 865 | if [ -x "$cmd3_file" ] ; then |
| 866 | ($xterm_cmd --title "$title3" --command "$cmd3_file" &) |
| 867 | fi |
| 868 | fi |
| 869 | |
| 870 | else |
| 871 | if [[ $use_tabs ]] ; then |
| 872 | echo "Sorry, plain ol' xterm doesn't support tabs." |
| 873 | fi |
| 874 | xterm_cmd="xterm -fs 10 -geometry $xterm_geom" |
Dave Wallace | 3079a64 | 2017-09-06 01:59:43 -0400 | [diff] [blame] | 875 | if [ -x "$cmd1_file" ] ; then |
| 876 | ($xterm_cmd -title "$title1" -e "$cmd1_file" &) |
| 877 | fi |
| 878 | if [ -x "$cmd2_file" ] ; then |
| 879 | ($xterm_cmd -title "$title2" -e "$cmd2_file" &) |
| 880 | fi |
Dave Wallace | 543852a | 2017-08-03 02:11:34 -0400 | [diff] [blame] | 881 | if [ -x "$cmd3_file" ] ; then |
| 882 | ($xterm_cmd -title "$title3" -e "$cmd3_file" &) |
| 883 | fi |
| 884 | fi |
| 885 | |
| 886 | sleep 1 |