2 # vim: ts=4 sw=4 noet :
3 #==================================================================================
4 # Copyright (c) 2019-2020 Nokia
5 # Copyright (c) 2018-2020 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${si} $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${si} $(( 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
87 -b) rebuild=1; nopull="nopull";; # build without pulling
90 -N) si="";; # enable NNG tests (disable si)
91 -s) nsenders=$2; shift;;
92 -S) si="_si";; # enable SI95 tests
95 *) echo "unrecognised option: $1"
96 echo "usage: $0 [-B] [-d micor-sec-delay] [-M] [-n num-msgs] [-s nsenders] [-S]"
97 echo " -B forces a rebuild which will use .build"
98 echo " -M force test applications to be remade"
99 echo " -S build/test SI95 based binaries"
110 export RMR_VCTL_FILE=".verbose"
116 $SHELL ./rebuild.ksh $nopull | read build_path
119 build_path=${BUILD_PATH:-"../../.build"} # we prefer .build at the root level, but allow user option
121 if [[ ! -d $build_path ]]
123 echo "cannot find build in: $build_path"
124 echo "either create, and then build RMr, or set BUILD_PATH as an evironment var before running this"
129 if [[ -d $build_path/lib64 ]]
131 export LD_LIBRARY_PATH=$build_path:$build_path/lib64:$LD_LIBRARY_PATH
133 export LD_LIBRARY_PATH=$build_path:$build_path/lib:$LD_LIBRARY_PATH
135 export LIBRARY_PATH=$LD_LIBRARY_PATH
136 export RMR_SEED_RT=./rts.rt
138 set_rt # create the route table
140 if [[ ! -f ./sender${si} || ! -f ./receiver${si} ]]
142 if ! make ./sender${si} ./receiver${si} >/dev/null 2>&1
144 echo "[FAIL] cannot find sender${si} and/or receiver${si} binary, and cannot make them.... humm?"
151 sleep 2 # let receivers init so we don't shoot at an empty target
152 for (( i=0; i < nsenders; i++ )) # start the receivers with an instance number
160 for (( i=0; i < nsenders; i++ )) # collect return codes
162 head -1 /tmp/PID$$.$i.src | read x
166 head -1 /tmp/PID$$.rrc | read rrc
168 if (( !! (src + rrc) ))
170 echo "[FAIL] sender rc=$src receiver rc=$rrc"
172 echo "[PASS] sender rc=$src receiver rc=$rrc"
179 exit $(( !! (src + rrc) ))