# and then will cat a few lines from one of the FIFOs.
# This script is designed to run using the geneated runtime
# image; in other words, it expects to find the binaries
-# in /playpen/bin.
+# in /playpen/bin if that directory exists. If it does not it
+# assumes the current working directory is where the binaries
+# exist.
#
# Date: 26 August 2019
# Author: E. Scott Daniels
#
function run_sender {
echo "starting sender"
- RMR_SEED_RT=/tmp/local.rt RMR_RTG_SVC=9989 /playpen/${si}bin/sender 43086 10000 >/tmp/sender.log 2>&1 &
+ RMR_SEED_RT=/tmp/local.rt RMR_RTG_SVC=9989 $bin_dir/sender 43086 10000 >/tmp/sender.log 2>&1 &
spid=$!
sleep $sender_wait
- echo "stopping sender"
+ echo "stopping sender $spid"
kill -15 $spid
}
function run_listener {
echo "starting listener"
- /playpen/${si}bin/mc_listener $ext_hdr -r 1 -d $fifo_dir >/tmp/listen.log 2>&1 &
+ $bin_dir/mc_listener $ext_hdr -r 1 -d $fifo_dir >/tmp/listen.log 2>&1 &
lpid=$!
sleep $listener_wait
- echo "stopping listener"
+ echo "stopping listener $lpid"
kill -15 $lpid
}
# 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
+ echo "starting pipe reader $1 $max_flag"
+ set -x
+ $bin_dir/pipe_reader $ext_hdr $max_flag -m $1 -d $fifo_dir >/tmp/pr.$1.log 2>&1 &
+ set +x
typeset prpid=$!
-
+
sleep $reader_wait
- echo "stopping pipe reader $1"
- kill -1 $prpid
+ echo "stopping pipe reader $ppid"
+ kill -15 $prpid
}
# generate a dummy route table that the sender needs
function gen_rt {
cat <<endKat >/tmp/local.rt
newrt|start
- mse | 0 | -1 | localhost:4560
- mse | 1 | -1 | localhost:4560
- mse | 2 | -1 | localhost:4560
- mse | 3 | -1 | localhost:4560
- mse | 4 | -1 | localhost:4560
- mse | 5 | -1 | localhost:4560
- mse | 6 | -1 | localhost:4560
+ mse | 0 | -1 | localhost:4560
+ mse | 1 | -1 | localhost:4560
+ mse | 2 | -1 | localhost:4560
+ mse | 3 | -1 | localhost:4560
+ mse | 4 | -1 | localhost:4560
+ mse | 5 | -1 | localhost:4560
+ mse | 6 | -1 | localhost:4560
+ mse | 7 | -1 | localhost:4560
+ mse | 8 | -1 | localhost:4560
+ mse | 9 | -1 | localhost:4560
newrt|end
endKat
}
ext_hdr="" # run with extended header enabled (-e turns extended off)
long_test=0
raw_capture=1
+verbose=0
while [[ $1 == -* ]]
do
- case $1 in
+ case $1 in
-l) long_test=1;;
-n) raw_capture=0;;
-s) si="si_";;
+ -v) verbose=1;;
*) echo "$1 is not a recognised option"
exit 1
;;
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
+
set_wait_values
if (( ! raw_capture )) # -n set, turn off capture
run_listener &
sleep 4
-for p in 0 1 2 3 4 5 6
+# the sender will send types 0-8 inclusive; we only start 7 readers to
+# endure listener doesn't hang on pipes without a reader
+#
+for p in 0 1 2 3 4 5
do
- run_pr $p &
+ run_pr $p & # all but last have no max read
done
-sleep 1
+max_flag="-M 10"
+run_pr 6 &
+
+sleep 1 # let the readers settle
run_sender &
sleep $main_wait # long enough for all functions to finish w/o having to risk a wait hanging
echo "all functions stopped; looking at logs"
+if (( verbose ))
+then
+ echo "[INFO] ---- mc_lisener log follwos --------------------------"
+ cat /tmp/listen.log
+ echo "[INFO] ------------------------------------------------------"
+fi
+
+
# ---------- validation -------------------------------------------------
errors=0
fi
done
-if (( ! errors ))
+if (( ! errors ))
then
echo "[OK] All logs seem good"
fi
then
echo "[OK] Found final direcory ($final_dir)"
ls -al $final_dir
-
+
if (( long_test )) # look for files in final dir to ensure roll
then
found=$( ls $final_dir/MC* | wc -l )