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 # ----------------------------------------------------------------------
23 # Mnemonic: verify_replay.sh
24 # Abstract: Simple script to attempt to verify that the replay utility
25 # works as expected. This assumes that verify.sh has been run
26 # and that at least one RDC file is in /tmp/rdc. This script
27 # will start the replay utility and a few pipe listeners to
30 # Date: 19 November 2019
31 # Author: E. Scott Daniels
32 # ----------------------------------------------------------------------
34 # set the various sleep values based on long test or short test
35 function set_wait_values {
41 echo "starting replayer"
42 file=$( ls ${stage_dir}/MCLT_*|head -1 )
46 $bin_dir/rdc_replay -f $file -d $fifo_dir >$log_dir/replay.log 2>&1
49 echo "replay finished"
52 # run a pipe reader for one message type
54 echo "starting pipe reader $1"
55 $bin_dir/pipe_reader $ext_hdr -m $1 -d $fifo_dir >$log_dir/pr.$1.log 2>&1 &
59 echo "stopping pipe reader $1"
63 # ---- run everything ---------------------------------------------------
65 log_dir=/tmp/mcl_verify
68 ext_hdr="" # run with extended header enabled (-e turns extended off)
69 run_listener=0 # -a turns on to run all
74 *) echo "$1 is not a recognised option"
76 echo "-a will cause the listener verification to run which generates files for this script"
84 if [[ -d /playpen/bin ]] # designed to run in the container, but this allows unit test by jenkins to drive too
86 bin_dir=/playpen/${si}bin
93 echo "running listener to generate test files to replay..."
95 verify.sh # assumed to be in the path
101 if (( ! raw_capture )) # -n set, turn off capture
103 export MCL_RDC_ENABLE=0
106 if [[ -d /data/final ]] # assume if we find data that final directory goes here
108 echo "### found /data/final using that as final directory"
109 export MCL_RDC_FINAL=/data/final
112 stage_dir=${MCL_RDC_STAGE:-/tmp/rdc/stage}
113 if [[ ! -d $stage_dir ]]
115 echo "abort: cannot find stage directory to replay from: $stage_dir"
120 if [[ ! -d $fifo_dir ]]
122 mkdir -p $fifo_dir # redirect fifos so we don't depend on mount
126 for p in 0 1 2 3 4 5 6
132 run_replay & # start after readers are going
134 sleep $main_wait # long enough for all functions to finish w/o having to risk a wait hanging
135 echo "all functions stopped; looking at logs"
137 # ---------- validation -------------------------------------------------
141 # logs should be > 0 in size
142 echo "----- logs ---------"
143 ls -al $log_dir/*.log
145 # pipe reader log files 1-6 should have 'stand up and cheer' messages
146 # pipe reader log for MT 0 will likley be empty as sender sends only
147 # one of those and buffer not likely flushed. So, we only check 1-6
151 if [[ ! -s $log_dir/pr.$l.log ]]
153 echo "[FAIL] log $l was empty"
156 if ! grep -q -i "stand up and cheer" $log_dir/pr.$l.log
158 echo "[FAIL] pipe reader log did not have any valid messages: $log_dir/pr.$l.log"
166 echo "[OK] All logs seem good"
169 nfifos=$( ls /tmp/fifos/MT_* | wc -l )
172 echo "didn't find enough fifos"
176 echo "[OK] Found expected fifos"
181 echo "[FAIL] $errors errors noticed"