OpenWrtScripts/tests/test_summary.sh
Rich Brown eac7700c14 Factor out summarize_pings();
Display summary even after Ctl-C;
Add some test code for the awk summarize_pings() function.
2022-01-01 17:41:23 -05:00

23 lines
737 B
Bash

# Test scaffolding for the summarize_pings() subroutine.
# Take a known set of ping readings (in ./pingsamples.txt), strip out bogus stuff,
# then pass the first N lines (passed in as an argument) to the summarize_pings() function
#
# include the summarize_pings() function from the library
. "../lib/summarize_pings.sh"
PINGFILE=$(mktemp /tmp/measurepings.XXXXXX) || exit 1
# pre-format the pingsamples for ease of counting...
# strip out any line that doesn't contain "time" (e.g., not time= or timeout)
# Only send the specified number of lines into $PINGFILE
cat < pingsamples.txt | \
grep time | \
head -n "$1" > "$PINGFILE"
echo "=== PINGFILE ==="
cat "$PINGFILE"
echo "========"
summarize_pings "$PINGFILE"
rm "$PINGFILE"