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)
89 *) echo "unrecognised option: $1"
90 echo "usage: $0 [-B] [-d micor-sec-delay] [-N] [-n num-msgs]"
91 echo " -B forces a rebuild which will use .build"
102 export RMR_VCTL_FILE=".verbose"
107 build_path=../../.build
112 build_path=${BUILD_PATH:-"../../.build"} # we prefer .build at the root level, but allow user option
114 if [[ ! -d $build_path ]]
116 echo "cannot find build in: $build_path"
117 echo "either create, and then build RMr, or set BUILD_PATH as an evironment var before running this"
122 if [[ -d $build_path/lib64 ]]
124 export LD_LIBRARY_PATH=$build_path:$build_path/lib64
126 export LD_LIBRARY_PATH=$build_path:$build_path/lib
129 export LIBRARY_PATH=$LD_LIBRARY_PATH
130 export RMR_SEED_RT=${RMR_SEED_RT:-./local.rt} # allow easy testing with different rt
133 if [[ ! -f ./sender ]]
135 if ! make >/dev/null 2>&1
137 echo "[FAIL] cannot find sender binary, and cannot make it.... humm?"
143 sleep 2 # if sender starts faster than rcvr we can drop, so pause a bit
147 head -1 /tmp/PID$$.rrc | read rrc
148 head -1 /tmp/PID$$.src | read src
150 if (( !! (src + rrc) ))
152 echo "[FAIL] sender rc=$src receiver rc=$rrc"
154 echo "[PASS] sender rc=$src receiver rc=$rrc"
160 exit $(( !! (src + rrc) ))