3 #----------------------------------------------------------------------------------
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.
19 #---------------------------------------------------------------------------------
22 # ----------------------------------------------------------------------
24 # Abstract: Simple script to attempt to verify that the mc_listener is
25 # capable of running. This will start a listener and a sender
26 # and then will cat a few lines from one of the FIFOs.
27 # This script is designed to run using the geneated runtime
28 # image; in other words, it expects to find the binaries
29 # in /playpen/bin if that directory exists. If it does not it
30 # assumes the current working directory is where the binaries
33 # Date: 26 August 2019
34 # Author: E. Scott Daniels
35 # ----------------------------------------------------------------------
37 # set the various sleep values based on long test or short test
38 function set_wait_values {
41 export MCL_RDC_FREQ=13 # file cycle after 13s
54 # run sender at a 2 msg/sec rate (500000 musec delay)
55 # sender sends msg types 0-6 and the route table in /tmp
56 # will direct them to the listener. We also need to switch
57 # the RT listen port so there is no collision with the listen
61 echo "starting sender"
62 RMR_SEED_RT=/tmp/local.rt RMR_RTG_SVC=9989 $bin_dir/sender 43086 10000 >/tmp/sender.log 2>&1 &
66 echo "stopping sender $spid"
70 function run_listener {
71 echo "starting listener"
72 $bin_dir/mc_listener $ext_hdr -r 1 -d $fifo_dir >/tmp/listen.log 2>&1 &
76 echo "stopping listener $lpid"
80 # run a pipe reader for one message type
82 echo "starting pipe reader $1"
83 $bin_dir/pipe_reader $ext_hdr -m $1 -d $fifo_dir >/tmp/pr.$1.log 2>&1 &
84 #$bin_dir/pipe_reader -m $1 -d $fifo_dir & # >/tmp/pr.$1.log 2>&1
88 echo "stopping pipe reader $ppid"
92 # generate a dummy route table that the sender needs
94 cat <<endKat >/tmp/local.rt
96 mse | 0 | -1 | localhost:4560
97 mse | 1 | -1 | localhost:4560
98 mse | 2 | -1 | localhost:4560
99 mse | 3 | -1 | localhost:4560
100 mse | 4 | -1 | localhost:4560
101 mse | 5 | -1 | localhost:4560
102 mse | 6 | -1 | localhost:4560
107 # ---- run everything ---------------------------------------------------
109 si="" # if -s given then we add this to sender/listener to run SI95 versions
110 ext_hdr="" # run with extended header enabled (-e turns extended off)
119 *) echo "$1 is not a recognised option"
128 if [[ -d /playpen/bin ]] # designed to run in the container, but this allows unit test by jenkins to drive too
130 bin_dir=/playpen/${si}bin
137 if (( ! raw_capture )) # -n set, turn off capture
139 export MCL_RDC_ENABLE=0
142 if [[ -d /data/final ]] # assume if we find data that final directory goes here
144 echo "### found /data/final using that as final directory"
145 export MCL_RDC_FINAL=/data/final
148 if [[ -d /data/stage ]]
150 echo "### found /data/staging using that as stage directory"
151 export MCL_RDC_STAGE=/data/stage
153 final_dir=${MCL_RDC_FINAL:-/tmp/rdc/final}
154 stage_dir=${MCL_RDC_STAGE:-/tmp/rdc/stage}
157 mkdir -p $fifo_dir # redirect fifos so we don't depend on mount
159 gen_rt # generate a dummy route table
163 for p in 0 1 2 3 4 5 6
170 sleep $main_wait # long enough for all functions to finish w/o having to risk a wait hanging
171 echo "all functions stopped; looking at logs"
173 # ---------- validation -------------------------------------------------
177 # logs should be > 0 in size
178 echo "----- logs ---------"
181 # pipe reader log files 1-6 should have 'stand up and cheer' messages
182 # pipe reader log for MT 0 will likley be empty as sender sends only
183 # one of those and buffer not likely flushed. So, we only check 1-6
187 if [[ ! -s /tmp/pr.$l.log ]]
189 echo "[FAIL] log $l was empty"
192 if ! grep -q -i "stand up and cheer" /tmp/pr.$l.log
194 echo "[FAIL] pipe reader log did not have any valid messages: /tmp/pr.$l.log"
202 echo "[OK] All logs seem good"
205 nfifos=$( ls /tmp/fifos/MT_* | wc -l )
208 echo "didn't find enough fifos"
212 echo "[OK] Found expected fifos"
215 if (( raw_capture )) # not an error if not capturing
217 if [[ -d $stage_dir ]]
219 echo "[OK] Found staging direcory ($stage_dir)"
223 echo "[FAIL] No staging directory found ($stage_dir)"
227 if [[ -d $final_dir ]]
229 echo "[OK] Found final direcory ($final_dir)"
232 if (( long_test )) # look for files in final dir to ensure roll
234 found=$( ls $final_dir/MC* | wc -l )
237 echo "[OK] Found $found files in final directory ($final_dir)"
239 echo "[FAIL] Did not find any files in the final directory ($final_dir)"
245 echo "[FAIL] No final directory found"
251 echo "[FAIL] $errors errors noticed"