mirror of
https://github.com/stefanberger/swtpm.git
synced 2025-08-22 19:04:35 +00:00

Add the --log parameter to test log levels 1 and 20. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
58 lines
1.1 KiB
Plaintext
58 lines
1.1 KiB
Plaintext
|
|
# 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 -E "${pattern}" $logfile | wc -l)
|
|
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 -E "${pattern}" $logfile | wc -l)
|
|
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
|
|
}
|