| |
| # shellcheck disable=SC2043 |
| # shellcheck shell=bash |
| # For the license, see the LICENSE file in the root directory. |
| |
| function wait_for_file() |
| { |
| local filename="$1" |
| local timeout="$2" |
| |
| local loops=$((timeout * 10)) loop |
| |
| for ((loop=0; loop<loops; loop++)); do |
| [ -f "${filename}" ] && return 1 |
| sleep 0.1 |
| done |
| return 0 |
| } |
| |
| function check_logfile_patterns_level_20() |
| { |
| local logfile="$1" |
| |
| for pattern in \ |
| "^ [[:print:]]+$" \ |
| "^ [[:print:]]+$" \ |
| "^ [[:print:]]+$" \ |
| "^ [[:print:]]+$" \ |
| "^ [[:print:]]+$" \ |
| "^ [[:print:]]+$" \ |
| "^ [[:print:]]+$" \ |
| ; do |
| shift |
| ctr=$(grep -c -E "${pattern}" "$logfile") |
| if [ "$ctr" -eq 0 ]; then |
| echo "Counted $ctr occurrences of pattern '${pattern}' in logfile; expected at least 1" |
| exit 1 |
| fi |
| echo "'${pattern}' occurrences: $ctr (OK)" |
| done |
| } |
| |
| function check_logfile_patterns_level_1() |
| { |
| local logfile="$1" |
| local minocc="$2" |
| |
| for pattern in \ |
| "^[[:print:]]+$" \ |
| ; do |
| shift |
| ctr=$(grep -c -E "${pattern}" "$logfile") |
| if [ "$ctr" -lt "$minocc" ]; then |
| echo "Counted $ctr occurrences of pattern '${pattern}' in logfile; expected at least $minocc" |
| exit 1 |
| fi |
| echo "'${pattern}' occurrences: $ctr (OK)" |
| done |
| } |