-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathrq_nfit_results.sh
executable file
·124 lines (106 loc) · 2.37 KB
/
rq_nfit_results.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# SPDX-License-Identifier: CC0-1.0
# Copyright (C) 2021 Intel Corporation. All rights reserved.
logfile="$1"
# lines we expect to find in the serial log
# if any of these are not found, this is an error
find_lines_re=(
"auto-running .*rq_nfit_tests.sh"
"[0-9]+/[0-9]+ ndctl:.*OK.*"
"Ok:[ \t]+[0-9]+"
"Fail:[ \t]+0"
"Skipped:[ \t]+0"
"Timeout:[ \t]+0"
"Done .*rq_nfit_tests.sh"
)
# lines that we should know about, but are not necessarily an error
# so long as all the other error/no-error conditions are met
# e.g 'Call trace' or so
warn_lines_re=(
".*-+\[ cut here \]-+"
".*-+\[ end trace [0-9a-f]+ \]-+"
"Call Trace:"
"WARNING:"
"kernel BUG"
)
raw_command_re=(
".*raw command path used"
)
# lines that indicate a fatal error if present
error_lines_re=(
"make:.*[Makefile:.*check] Error"
"ninja: build stopped: subcommand failed"
"[0-9]+/[0-9]+ ndctl:.*FAIL.*"
)
warn_count=0
exit_success()
{
# bold green
tput bold; tput setaf 2
cat <<- EOF
+------------------------+
| NFIT Tests - Success |
+------------------------+
EOF
tput sgr0
exit 0
}
exit_fail()
{
reason="$1"
# bold red
tput bold; tput setaf 1
cat <<- EOF
+---------------------+
| NFIT Tests - FAIL |
+---------------------+
$reason
EOF
tput sgr0
exit 1
}
exit_warn()
{
# bold yellow
tput bold; tput setaf 3
cat <<- EOF
+--------------------------------+
| NFIT Tests - Success |
| **with warnings - see log** |
+--------------------------------+
warn_count: $warn_count
EOF
tput sgr0
exit 125
}
# main
# if all of the find_lines are not found, it is an automatic failure
for re in "${find_lines_re[@]}"; do
if grep -qE "$re" "$logfile"; then
continue
fi
exit_fail "failed to find line: $re"
done
# if any of the error_lines are found, it is an automatic failure
for re in "${error_lines_re[@]}"; do
if grep -qE "$re" "$logfile"; then
exit_fail "found error line: $re"
fi
done
# if any warn_lines are found, keep a count
for re in "${warn_lines_re[@]}"; do
if grep -qE "$re" "$logfile"; then
warn_count=$((warn_count + 1))
fi
done
# using raw commands produces a taint warning, which adds 4 warn count
# if this was found, adjust the warn count so this isn't flagged
for re in "${raw_command_re[@]}"; do
if grep -qE "$re" "$logfile"; then
warn_count=$((warn_count - 4))
fi
done
if (( warn_count > 0 )); then
exit_warn
fi
exit_success