2 # vim: ts=4 sw=4 noet :
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_rts_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 nng. This
25 # particular test starts several senders and one receiver. All messages
26 # go to the receiver and an ack is sent back to the sending process.
27 # Each sender puts a tag into the message allowing it to verify that
28 # all messages received were 'acks' to the ones it sent, and that no
29 # rts messages were routed to the wrong sender.
31 # Example command line:
34 # Author: E. Scott Daniels
35 # ---------------------------------------------------------------------------------
38 # The sender and receivers are run asynch. Their exit statuses are captured in a
39 # file in order for the 'main' to pick them up easily.
40 # $1 is the instance so we can keep logs separate.
43 export RMR_RTG_SVC=$(( 9991 + $1 ))
44 port=$(( 43080 + $1 ))
45 ./sender $nmsg $delay 5:6 $port
46 echo $? >/tmp/PID$$.$1.src # must communicate state back via file b/c asynch
49 # $1 is the instance so we can keep logs separate
54 export RMR_RTG_SVC=9990
55 ./receiver $(( nmsg * nsenders )) $port
56 echo $? >/tmp/PID$$.rrc
59 # Drop in a contrived route table. It should have only one entry which points
60 # message type 0 to the receiver. The sender must NOT be defined for a valid
61 # tests (rts should not require the sendter be in the route thable).
66 mse |5 | -1 | localhost:4460
72 # ---------------------------------------------------------
74 nmsg=10 # total number of messages to be exchanged (-n value changes)
75 delay=1000000 # microsec sleep between msg 1,000,000 == 1s
80 nsenders=3 # this is sane, but -s allows it to be set up
86 -b) rebuild=1; nopull="nopull";; # build without pulling
89 -s) nsenders=$2; shift;;
92 *) echo "unrecognised option: $1"
93 echo "usage: $0 [-B] [-d micor-sec-delay] [-n num-msgs] [-s nsenders]"
94 echo " -B forces a rebuild which will use .build"
105 export RMR_VCTL_FILE=".verbose"
111 ksh ./rebuild.ksh $nopull | read build_path
114 build_path=${BUILD_PATH:-"../../.build"} # we prefer .build at the root level, but allow user option
116 if [[ ! -d $build_path ]]
118 echo "cannot find build in: $build_path"
119 echo "either create, and then build RMr, or set BUILD_PATH as an evironment var before running this"
124 if [[ -d $build_path/lib64 ]]
126 export LD_LIBRARY_PATH=$build_path:$build_path/lib64
128 export LD_LIBRARY_PATH=$build_path:$build_path/lib
130 export LIBRARY_PATH=$LD_LIBRARY_PATH
131 export RMR_SEED_RT=./rts.rt
133 set_rt # create the route table
135 if [[ ! -f ./sender ]]
137 if ! make >/dev/null 2>&1
139 echo "[FAIL] cannot find sender binary, and cannot make it.... humm?"
146 sleep 2 # let receivers init so we don't shoot at an empty target
147 for (( i=0; i < nsenders; i++ )) # start the receivers with an instance number
155 for (( i=0; i < nsenders; i++ )) # collect return codes
157 head -1 /tmp/PID$$.$i.src | read x
161 head -1 /tmp/PID$$.rrc | read rrc
163 if (( !! (src + rrc) ))
165 echo "[FAIL] sender rc=$src receiver rc=$rrc"
167 echo "[PASS] sender rc=$src receiver rc=$rrc"
174 exit $(( !! (src + rrc) ))