2 # vim: ts=4 sw=4 noet :
3 #==================================================================================
4 # Copyright (c) 2019-2021 Nokia
5 # Copyright (c) 2018-2021 AT&T Intellectual Property
6 # Copyright (c) 2023 Alexandre Huff
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #==================================================================================
22 # ---------------------------------------------------------------------------------
23 # Mnemonic: run_ipv6_test.sh
24 # Abstract: This is a simple script to set up and run the basic send/receive
25 # processes using IPv6 for some library validation on top of si95.
26 # This particular test starts a sender and a receiver application.
27 # All messages go to the receiver and an ack is sent back to the
30 # The number of message, and the delay between each message may be given
31 # on the command line.
33 # Example command line:
34 # bash ./run_ipv6_test.sh # default 10 messages at 1 msg/sec
35 # bash ./run_ipv6_test.sh -n 10 -d 100000 # 10 messages, delay 100 ms
38 # Author: Alexandre Huff
39 # ---------------------------------------------------------------------------------
42 # The sender and receiver are run asynch. Their exit statuses are captured in a
43 # file in order for the 'main' to pick them up easily.
46 ./sender${si} $nmsg $delay
47 echo $? >/tmp/PID$$.src # must communicate state back via file b/c asynch
50 # start receiver listening for nmsgs from each thread
53 echo $? >/tmp/PID$$.rrc
56 # Generate a route table that is tailored to our needs.
61 # This is a route table to test IPv6 support with sender and receiver
64 mse | 0 | 0 | $localhost:4560
65 mse | 1 | 10 | $localhost:4560
66 mse | 2 | 20 | $localhost:4560
67 rte | 3 | $localhost:4560
68 rte | 4 | $localhost:4560
69 rte | 5 | $localhost:4560
70 rte | 6 | $localhost:4560
71 rte | 7 | $localhost:4560
72 rte | 8 | $localhost:4560
73 rte | 9 | $localhost:4560
78 function ensure_ipv6 {
79 v6=$(ip -6 address show lo)
82 v4=$(ip -4 address show lo)
85 export RMR_BIND_IF=$localhost # force RMR to bind to an IPv6 address (defaults to IPv4 on dual stack)
86 echo "[INFO] forcing RMR binding to $localhost"
88 echo "[INFO] using IPv6-only stack" # RMR binds to any interface address, no need to specify RMR_BIND_IF
91 echo "[WARN] skipping IPv6 test, unable to detect IPv6 stack"
92 exit 0 # exit success in favor to allow overall tests to pass if all other tests have passed
96 # ---------------------------------------------------------
98 nmsg=10 # total number of messages to be exchanged (-n value changes)
99 delay=1000000 # microsec sleep between msg 1,000,000 == 1s
103 dev_base=1 # -D turns off to allow this to run on installed libs
114 -d) delay=$2; shift;;
120 *) echo "unrecognised option: $1"
121 echo "usage: $0 [-B] [-M] [-d micro-sec-delay] [-n num-msgs]"
122 echo " -B forces an RMR rebuild"
123 echo " -M force test applications to rebuild"
136 export RMR_VCTL_FILE=".verbose"
140 if [[ -z $BUILD_PATH ]] # if not explicitly set, assume one of our standard spots
142 if [[ -d $src_root/.build ]] # look for build directory in expected places
143 then # run scripts will honour this
144 export BUILD_PATH=$src_root/.build
146 if [[ -d $src_root/build ]]
148 export BUILD_PATH=$src_root/build
150 echo "[ERR] BUILD_PATH not set and no logical build directory exists to use"
151 echo "[INFO] tried: $src_root/build and $src_root/.build"
155 echo "[INFO] using discovered build directory: $BUILD_PATH"
157 echo "[INFO] using externally supplied build directory: $BUILD_PATH"
167 if [[ -z $LD_LIBRARY_PATH ]] # cmake test will set and it must be honoured
169 if (( dev_base )) # assume we are testing against what we've built, not what is installed
171 if [[ -d $BUILD_PATH/lib64 ]]
173 export LD_LIBRARY_PATH=$BUILD_PATH:$BUILD_PATH/lib64:$LD_LIBRARY_PATH
175 export LD_LIBRARY_PATH=$BUILD_PATH:$BUILD_PATH/lib:$LD_LIBRARY_PATH
177 export LIBRARY_PATH=$LD_LIBRARY_PATH
178 else # -D option gets us here to test an installed library
179 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
180 export LIBRARY_PATH=$LD_LIBRARY_PATH
184 export RMR_SEED_RT=${RMR_SEED_RT:-./ipv6.rt} # allow easy testing with different rt
186 if [[ ! -f $RMR_SEED_RT ]] # create special rt
191 if (( rebuild || force_make )) || [[ ! -f ./sender${si} || ! -f ./receiver${si} ]]
193 if ! make -B sender${si} receiver${si} >/tmp/PID$$.log 2>&1
195 echo "[FAIL] cannot find sender{$si} and/or receiver${si} binary, and cannot make them.... humm?"
203 sleep 2 # if caller starts faster than rcvr we can drop, so pause a bit
207 rrc=$(head -1 /tmp/PID$$.rrc) # get pass/fail state from each
208 src=$(head -1 /tmp/PID$$.src)
210 if (( !! (src + rrc) ))
212 echo "[FAIL] sender rc=$src receiver rc=$rrc"
214 echo "[PASS] sender rc=$src receiver rc=$rrc"
220 exit $(( !! (src + rrc) ))