Correct bug in listener not detecting eagain/eintr correctly
[ric-app/mc.git] / sidecars / listener / src / verify_replay.sh
index 3cc0fc9..5acefc6 100755 (executable)
@@ -24,7 +24,7 @@
 # Abstract: Simple script to attempt to verify that the replay utility
 #                      works as expected. This assumes that verify.sh has been run
 #                      and that at least one RDC file is in /tmp/rdc. This script
-#                      will start the replay utility and a few pipe listeners to 
+#                      will start the replay utility and a few pipe listeners to
 #                      parse the data.
 #
 # Date:                19 November 2019
@@ -40,9 +40,10 @@ function set_wait_values {
 function run_replay {
        echo "starting replayer"
        file=$( ls ${stage_dir}/MCLT_*|head -1 )
+       chmod 644 $file
 
        set -x
-       /playpen/bin/rdc_replay -f $file -d $fifo_dir >/tmp/replay.log 2>&1
+       $bin_dir/rdc_replay -f $file -d $fifo_dir >$log_dir/replay.log 2>&1
        lpid=$!
        set +x
        echo "replay finished"
@@ -51,10 +52,9 @@ function run_replay {
 # run a pipe reader for one message type
 function run_pr {
        echo "starting pipe reader $1"
-       /playpen/bin/pipe_reader $ext_hdr -m $1 -d $fifo_dir  >/tmp/pr.$1.log 2>&1 &
-       #/playpen/bin/pipe_reader -m $1 -d $fifo_dir & # >/tmp/pr.$1.log 2>&1 
+       $bin_dir/pipe_reader $ext_hdr -m $1 -d $fifo_dir  >$log_dir/pr.$1.log 2>&1 &
        typeset prpid=$!
-       
+
        sleep $reader_wait
        echo "stopping pipe reader $1"
        kill -1 $prpid
@@ -62,11 +62,14 @@ function run_pr {
 
 # ---- run everything ---------------------------------------------------
 
+log_dir=/tmp/mcl_verify
+mkdir -p $log_dir
+
 ext_hdr=""                                     # run with extended header enabled (-e turns extended off)
 run_listener=0                         # -a turns on to run all
 while [[ $1 == -* ]]
 do
-       case $1 in 
+       case $1 in
                -a)     run_listener=1;;
                *)      echo "$1 is not a recognised option"
                        echo "usage: $0 [-a]"
@@ -78,6 +81,13 @@ do
        shift
 done
 
+if [[ -d /playpen/bin ]]       # designed to run in the container, but this allows unit test by jenkins to drive too
+then
+       bin_dir=/playpen/${si}bin
+else
+       bin_dir="."
+fi
+
 if (( run_listener ))
 then
        echo "running listener to generate test files to replay..."
@@ -130,7 +140,7 @@ errors=0
 
 # logs should be > 0 in size
 echo "----- logs ---------"
-ls -al /tmp/*.log
+ls -al $log_dir/*.log
 
 # pipe reader log files 1-6 should have 'stand up and cheer' messages
 # pipe reader log for MT 0 will likley be empty as sender sends only
@@ -138,20 +148,20 @@ ls -al /tmp/*.log
 #
 for l in 1 2 3 4 5 6
 do
-       if [[ ! -s /tmp/pr.$l.log ]]
+       if [[ ! -s $log_dir/pr.$l.log ]]
        then
                echo "[FAIL] log $l was empty"
                (( errors++ ))
        else
-               if ! grep -q -i "stand up and cheer" /tmp/pr.$l.log
+               if ! grep -q -i "stand up and cheer" $log_dir/pr.$l.log
                then
-                       echo "[FAIL] pipe reader log did not have any valid messages: /tmp/pr.$l.log"
+                       echo "[FAIL] pipe reader log did not have any valid messages: $log_dir/pr.$l.log"
                        (( errors++ ))
                fi
        fi
 done
 
-if (( ! errors )) 
+if (( ! errors ))
 then
        echo "[OK]    All logs seem good"
 fi