Skip to content

Commit 7fbec1f

Browse files
committed
adjust the script to handle selinux
1 parent 19064f6 commit 7fbec1f

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

util/analyze-gnu-results.sh

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,36 @@ set -e
66
# to present the merge results
77
# this script will export the values in the term
88

9-
if test $# -ne 2; then
9+
if test $# -ne 4; then
1010
echo "syntax:"
11-
echo "$0 testsuite.log root-testsuite.log"
11+
echo "$0 testsuite.log root-testsuite.log selinux-testsuite.log selinux-root-testsuite.log"
1212
fi
1313

1414
SUITE_LOG_FILE=$1
1515
ROOT_SUITE_LOG_FILE=$2
16+
SELINUX_SUITE_LOG_FILE=$3
17+
SELINUX_ROOT_SUITE_LOG_FILE=$4
1618

1719
if test ! -f "${SUITE_LOG_FILE}"; then
1820
echo "${SUITE_LOG_FILE} has not been found"
1921
exit 1
2022
fi
23+
2124
if test ! -f "${ROOT_SUITE_LOG_FILE}"; then
2225
echo "${ROOT_SUITE_LOG_FILE} has not been found"
2326
exit 1
2427
fi
2528

29+
if test ! -f "${SELINUX_SUITE_LOG_FILE}"; then
30+
echo "${SELINUX_SUITE_LOG_FILE} has not been found"
31+
exit 1
32+
fi
33+
34+
if test ! -f "${SELINUX_ROOT_SUITE_LOG_FILE}"; then
35+
echo "${SELINUX_ROOT_SUITE_LOG_FILE} has not been found"
36+
exit 1
37+
fi
38+
2639
function get_total {
2740
# Total of tests executed
2841
# They are the normal number of tests as they are skipped in the normal run
@@ -35,24 +48,38 @@ function get_pass {
3548
# In the normal run, they are SKIP
3649
NON_ROOT=$(sed -n "s/.*# PASS: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
3750
AS_ROOT=$(sed -n "s/.*# PASS: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
51+
SELINUX_NON_ROOT=$(sed -n "s/.*# PASS: \(.*\)/\1/p" "${SELINUX_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
52+
SELINUX_AS_ROOT=$(sed -n "s/.*# PASS: \(.*\)/\1/p" "${SELINUX_ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
3853
echo $((NON_ROOT + AS_ROOT))
3954
}
4055

4156
function get_skip {
42-
# As some of the tests executed as root as still SKIP (ex: selinux), we
43-
# need to some maths:
44-
# Number of tests skip as user - total test as root + skipped as root
57+
# Calculate skips accounting for all test runs
58+
# Number of tests skip as user - total test as root + skipped as root - total selinux + skipped selinux - total selinux_root + skipped selinux_root
4559
TOTAL_AS_ROOT=$(sed -n "s/.*# TOTAL: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
4660
NON_ROOT=$(sed -n "s/.*# SKIP: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
4761
AS_ROOT=$(sed -n "s/.*# SKIP: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
48-
echo $((NON_ROOT - TOTAL_AS_ROOT + AS_ROOT))
62+
63+
TOTAL_SELINUX=$(sed -n "s/.*# TOTAL: \(.*\)/\1/p" "${SELINUX_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
64+
SELINUX=$(sed -n "s/.*# SKIP: \(.*\)/\1/p" "${SELINUX_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
65+
66+
TOTAL_SELINUX_ROOT=$(sed -n "s/.*# TOTAL: \(.*\)/\1/p" "${SELINUX_ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
67+
SELINUX_ROOT=$(sed -n "s/.*# SKIP: \(.*\)/\1/p" "${SELINUX_ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
68+
69+
ADJUSTED_SKIP=$((NON_ROOT - TOTAL_AS_ROOT + AS_ROOT - TOTAL_SELINUX + SELINUX - TOTAL_SELINUX_ROOT + SELINUX_ROOT))
70+
if [[ $ADJUSTED_SKIP -lt 0 ]]; then
71+
ADJUSTED_SKIP=0
72+
fi
73+
echo $ADJUSTED_SKIP
4974
}
5075

5176
function get_fail {
5277
# They used to be SKIP, now they fail (this is a good news)
5378
NON_ROOT=$(sed -n "s/.*# FAIL: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
5479
AS_ROOT=$(sed -n "s/.*# FAIL: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
55-
echo $((NON_ROOT + AS_ROOT))
80+
SELINUX_NON_ROOT=$(sed -n "s/.*# FAIL: \(.*\)/\1/p" "${SELINUX_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
81+
SELINUX_AS_ROOT=$(sed -n "s/.*# FAIL: \(.*\)/\1/p" "${SELINUX_ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
82+
echo $((NON_ROOT + AS_ROOT + SELINUX_NON_ROOT + SELINUX_AS_ROOT))
5683
}
5784

5885
function get_xpass {
@@ -64,6 +91,8 @@ function get_error {
6491
# They used to be SKIP, now they error (this is a good news)
6592
NON_ROOT=$(sed -n "s/.*# ERROR: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
6693
AS_ROOT=$(sed -n "s/.*# ERROR:: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
94+
SELINUX_NON_ROOT=$(sed -n "s/.*# ERROR: \(.*\)/\1/p" "${SELINUX_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
95+
SELINUX_AS_ROOT=$(sed -n "s/.*# ERROR:: \(.*\)/\1/p" "${SELINUX_ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
6796
echo $((NON_ROOT + AS_ROOT))
6897
}
6998

0 commit comments

Comments
 (0)