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