3 #==================================================================================
4 # Copyright (c) 2019 Nokia
5 # Copyright (c) 2018-2019 AT&T Intellectual Property.
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #==================================================================================
21 # ---------------------------------------------------------------------------------
22 # Mnemonic: run_app_test.ksh
23 # Abstract: This is a simple script to set up and run the basic send/receive
24 # processes for some library validation on top of nano/nng.
25 # It should be possible to clone the repo, switch to this directory
26 # and execute 'ksh run -B' which will build RMr, make the sender and
27 # recevier then run the basic test.
29 # Example command line:
30 # ksh ./run # default 10 messages at 1 msg/sec
31 # ksh ./run -N # default but with nanomsg lib
32 # ksh ./run -d 100 -n 10000 # send 10k messages with 100ms delay between
35 # Author: E. Scott Daniels
36 # ---------------------------------------------------------------------------------
39 # The sender and receiver are run asynch. Their exit statuses are captured in a
40 # file in order for the 'main' to pick them up easily.
45 ./sender_nano $nmsg $delay
49 echo $? >/tmp/PID$$.src # must communicate state back via file b/c asynch
53 if (( $nano_receiver ))
59 echo $? >/tmp/PID$$.rrc
62 # ---------------------------------------------------------
64 if [[ ! -f local.rt ]] # we need the real host name in the local.rt; build one from mask if not there
67 sed "s!%%hostname%%!$hn!" rt.mask >local.rt
70 nmsg=10 # total number of messages to be exchanged (-n value changes)
71 delay=1000000 # microsec sleep between msg 1,000,000 == 1s
72 nano_sender=0 # start nano version if set (-N)
76 nopull="" # -b sets so that build does not pull
82 -B) rebuild=1;; # build with pull first
83 -b) rebuild=1; nopull="nopull";; # buld without pull
91 *) echo "unrecognised option: $1"
92 echo "usage: $0 [-B] [-d micor-sec-delay] [-N] [-n num-msgs]"
93 echo " -B forces a rebuild which will use .build"
104 export RMR_VCTL_FILE=".verbose"
110 ksh ./rebuild.ksh $nopull | read build_path
113 build_path=${BUILD_PATH:-"../../.build"} # we prefer .build at the root level, but allow user option
115 if [[ ! -d $build_path ]]
117 echo "cannot find build in: $build_path"
118 echo "either create, and then build RMr, or set BUILD_PATH as an evironment var before running this"
123 if [[ -d $build_path/lib64 ]]
125 export LD_LIBRARY_PATH=$build_path:$build_path/lib64
127 export LD_LIBRARY_PATH=$build_path:$build_path/lib
130 export LIBRARY_PATH=$LD_LIBRARY_PATH
131 export RMR_SEED_RT=${RMR_SEED_RT:-./local.rt} # allow easy testing with different rt
134 if [[ ! -f ./sender ]]
136 if ! make >/dev/null 2>&1
138 echo "[FAIL] cannot find sender binary, and cannot make it.... humm?"
144 sleep 2 # if sender starts faster than rcvr we can drop, so pause a bit
148 head -1 /tmp/PID$$.rrc | read rrc
149 head -1 /tmp/PID$$.src | read src
151 if (( !! (src + rrc) ))
153 echo "[FAIL] sender rc=$src receiver rc=$rrc"
155 echo "[PASS] sender rc=$src receiver rc=$rrc"
161 exit $(( !! (src + rrc) ))