| 1 |
|
| 2 |
# shellcheck disable=SC2043 |
| 3 |
# shellcheck shell=bash |
| 4 |
# For the license, see the LICENSE file in the root directory. |
| 5 |
|
| 6 |
function wait_for_file() |
| 7 |
{ |
| 8 |
local filename="$1" |
| 9 |
local timeout="$2" |
| 10 |
|
| 11 |
local loops=$((timeout * 10)) loop |
| 12 |
|
| 13 |
for ((loop=0; loop<loops; loop++)); do |
| 14 |
[ -f "${filename}" ] && return 1 |
| 15 |
sleep 0.1 |
| 16 |
done |
| 17 |
return 0 |
| 18 |
} |
| 19 |
|
| 20 |
function check_logfile_patterns_level_20() |
| 21 |
{ |
| 22 |
local logfile="$1" |
| 23 |
|
| 24 |
for pattern in \ |
| 25 |
"^ [[:print:]]+$" \ |
| 26 |
"^ [[:print:]]+$" \ |
| 27 |
"^ [[:print:]]+$" \ |
| 28 |
"^ [[:print:]]+$" \ |
| 29 |
"^ [[:print:]]+$" \ |
| 30 |
"^ [[:print:]]+$" \ |
| 31 |
"^ [[:print:]]+$" \ |
| 32 |
; do |
| 33 |
shift |
| 34 |
ctr=$(grep -c -E "${pattern}" "$logfile") |
| 35 |
if [ "$ctr" -eq 0 ]; then |
| 36 |
echo "Counted $ctr occurrences of pattern '${pattern}' in logfile; expected at least 1" |
| 37 |
exit 1 |
| 38 |
fi |
| 39 |
echo "'${pattern}' occurrences: $ctr (OK)" |
| 40 |
done |
| 41 |
} |
| 42 |
|
| 43 |
function check_logfile_patterns_level_1() |
| 44 |
{ |
| 45 |
local logfile="$1" |
| 46 |
local minocc="$2" |
| 47 |
|
| 48 |
for pattern in \ |
| 49 |
"^[[:print:]]+$" \ |
| 50 |
; do |
| 51 |
shift |
| 52 |
ctr=$(grep -c -E "${pattern}" "$logfile") |
| 53 |
if [ "$ctr" -lt "$minocc" ]; then |
| 54 |
echo "Counted $ctr occurrences of pattern '${pattern}' in logfile; expected at least $minocc" |
| 55 |
exit 1 |
| 56 |
fi |
| 57 |
echo "'${pattern}' occurrences: $ctr (OK)" |
| 58 |
done |
| 59 |
} |