Skip to content

Commit f8c9de7

Browse files
Merge pull request #3948 from sylvestre/gnu-root
Agregate the root GNU testsuite results
2 parents efe8a2c + 20af659 commit f8c9de7

File tree

5 files changed

+116
-15
lines changed

5 files changed

+116
-15
lines changed

.github/workflows/GnuTests.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ jobs:
3434
outputs repo_default_branch repo_GNU_ref repo_reference_branch
3535
#
3636
SUITE_LOG_FILE="${path_GNU_tests}/test-suite.log"
37+
ROOT_SUITE_LOG_FILE="${path_GNU_tests}/test-suite-root.log"
3738
TEST_LOGS_GLOB="${path_GNU_tests}/**/*.log" ## note: not usable at bash CLI; [why] double globstar not enabled by default b/c MacOS includes only bash v3 which doesn't have double globstar support
3839
TEST_FILESET_PREFIX='test-fileset-IDs.sha1#'
3940
TEST_FILESET_SUFFIX='.txt'
4041
TEST_SUMMARY_FILE='gnu-result.json'
4142
TEST_FULL_SUMMARY_FILE='gnu-full-result.json'
42-
outputs SUITE_LOG_FILE TEST_FILESET_PREFIX TEST_FILESET_SUFFIX TEST_LOGS_GLOB TEST_SUMMARY_FILE TEST_FULL_SUMMARY_FILE
43+
outputs SUITE_LOG_FILE ROOT_SUITE_LOG_FILE TEST_FILESET_PREFIX TEST_FILESET_SUFFIX TEST_LOGS_GLOB TEST_SUMMARY_FILE TEST_FULL_SUMMARY_FILE
4344
- name: Checkout code (uutil)
4445
uses: actions/checkout@v3
4546
with:
@@ -104,6 +105,12 @@ jobs:
104105
path_GNU='${{ steps.vars.outputs.path_GNU }}'
105106
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
106107
bash "${path_UUTILS}/util/run-gnu-test.sh"
108+
- name: Run GNU root tests
109+
shell: bash
110+
run: |
111+
path_GNU='${{ steps.vars.outputs.path_GNU }}'
112+
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
113+
bash "${path_UUTILS}/util/run-gnu-test.sh" run-root
107114
- name: Extract testing info into JSON
108115
shell: bash
109116
run : |
@@ -113,18 +120,17 @@ jobs:
113120
id: summary
114121
shell: bash
115122
run: |
123+
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
116124
## Extract/summarize testing info
117125
outputs() { step_id="summary"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo ::set-output name=${var}::${!var}; done; }
118126
#
119127
SUITE_LOG_FILE='${{ steps.vars.outputs.SUITE_LOG_FILE }}'
128+
ROOT_SUITE_LOG_FILE='${{ steps.vars.outputs.ROOT_SUITE_LOG_FILE }}'
129+
ls -al ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE}
130+
120131
if test -f "${SUITE_LOG_FILE}"
121132
then
122-
TOTAL=$(sed -n "s/.*# TOTAL: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
123-
PASS=$(sed -n "s/.*# PASS: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
124-
SKIP=$(sed -n "s/.*# SKIP: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
125-
FAIL=$(sed -n "s/.*# FAIL: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
126-
XPASS=$(sed -n "s/.*# XPASS: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
127-
ERROR=$(sed -n "s/.*# ERROR: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
133+
source ${path_UUTILS}/util/analyze-gnu-results.sh ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE}
128134
if [[ "$TOTAL" -eq 0 || "$TOTAL" -eq 1 ]]; then
129135
echo "::error ::Failed to parse test results from '${SUITE_LOG_FILE}'; failing early"
130136
exit 1

DEVELOPER_INSTRUCTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Running GNU tests
2121
At the end you should have uutils, gnu and gnulib checked out next to each other.
2222

2323
- Run `cd uutils && ./util/build-gnu.sh && cd ..` to get everything ready (this may take a while)
24-
- Finally, you can run tests with `bash uutils/util/run-gnu-test.sh <test>`. Instead of `<test>` insert the test you want to run, e.g. `tests/misc/wc-proc.sh`.
24+
- Finally, you can run tests with `bash uutils/util/run-gnu-test.sh <tests>`. Instead of `<tests>` insert the tests you want to run, e.g. `tests/misc/wc-proc.sh`.
2525

2626

2727
Code Coverage Report Generation

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ $ bash util/build-gnu.sh
369369
$ bash util/run-gnu-test.sh
370370
# To run a single test:
371371
$ bash util/run-gnu-test.sh tests/touch/not-owner.sh # for example
372+
# To run several tests:
373+
$ bash util/run-gnu-test.sh tests/touch/not-owner.sh tests/rm/no-give-up.sh # for example
372374
# If this is a perl (.pl) test, to run in debug:
373375
$ DEBUG=1 bash util/run-gnu-test.sh tests/misc/sm3sum.pl
374376
```

util/analyze-gnu-results.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/sh
2+
# spell-checker:ignore xpass XPASS testsuite
3+
set -e
4+
5+
# As we do two builds (with and without root), we need to do some trivial maths
6+
# to present the merge results
7+
# this script will export the values in the term
8+
9+
if test $# -ne 2; then
10+
echo "syntax:"
11+
echo "$0 testsuite.log root-testsuite.log"
12+
fi
13+
14+
SUITE_LOG_FILE=$1
15+
ROOT_SUITE_LOG_FILE=$2
16+
17+
if test ! -f "${SUITE_LOG_FILE}"; then
18+
echo "${SUITE_LOG_FILE} has not been found"
19+
exit 1
20+
fi
21+
if test ! -f "${ROOT_SUITE_LOG_FILE}"; then
22+
echo "${ROOT_SUITE_LOG_FILE} has not been found"
23+
exit 1
24+
fi
25+
26+
function get_total {
27+
# Total of tests executed
28+
# They are the normal number of tests as they are skipped in the normal run
29+
NON_ROOT=$(sed -n "s/.*# TOTAL: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
30+
echo $NON_ROOT
31+
}
32+
33+
function get_pass {
34+
# This is the sum of the two test suites.
35+
# In the normal run, they are SKIP
36+
NON_ROOT=$(sed -n "s/.*# PASS: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
37+
AS_ROOT=$(sed -n "s/.*# PASS: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
38+
echo $((NON_ROOT + AS_ROOT))
39+
}
40+
41+
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
45+
TOTAL_AS_ROOT=$(sed -n "s/.*# TOTAL: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
46+
NON_ROOT=$(sed -n "s/.*# SKIP: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
47+
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))
49+
}
50+
51+
function get_fail {
52+
# They used to be SKIP, now they fail (this is a good news)
53+
NON_ROOT=$(sed -n "s/.*# FAIL: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
54+
AS_ROOT=$(sed -n "s/.*# FAIL: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
55+
echo $((NON_ROOT + AS_ROOT))
56+
}
57+
58+
function get_xpass {
59+
NON_ROOT=$(sed -n "s/.*# XPASS: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
60+
echo $NON_ROOT
61+
}
62+
63+
function get_error {
64+
# They used to be SKIP, now they error (this is a good news)
65+
NON_ROOT=$(sed -n "s/.*# ERROR: \(.*\)/\1/p" "${SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
66+
AS_ROOT=$(sed -n "s/.*# ERROR:: \(.*\)/\1/p" "${ROOT_SUITE_LOG_FILE}" | tr -d '\r' | head -n1)
67+
echo $((NON_ROOT + AS_ROOT))
68+
}
69+
70+
export TOTAL=$(get_total)
71+
export PASS=$(get_pass)
72+
export SKIP=$(get_skip)
73+
export FAIL=$(get_fail)
74+
export XPASS=$(get_xpass)
75+
export ERROR=$(get_error)

util/run-gnu-test.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,35 @@ cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
3131

3232
export RUST_BACKTRACE=1
3333

34-
if test -n "$1"; then
35-
# if set, run only the test passed
36-
export RUN_TEST="TESTS=$1"
34+
if test $# -ge 1; then
35+
# if set, run only the tests passed
36+
SPECIFIC_TESTS=""
37+
for t in "$@"; do
38+
SPECIFIC_TESTS="$SPECIFIC_TESTS $t"
39+
done
40+
# trim it
41+
SPECIFIC_TESTS=$(echo $SPECIFIC_TESTS| xargs)
42+
echo "Running specific tests: $SPECIFIC_TESTS"
3743
fi
3844

3945
# * timeout used to kill occasionally errant/"stuck" processes (note: 'release' testing takes ~1 hour; 'debug' testing takes ~2.5 hours)
4046
# * `gl_public_submodule_commit=` disables testing for use of a "public" gnulib commit (which will fail when using shallow gnulib checkouts)
4147
# * `srcdir=..` specifies the GNU source directory for tests (fixing failing/confused 'tests/factor/tNN.sh' tests and causing no harm to other tests)
4248
#shellcheck disable=SC2086
43-
timeout -sKILL 4h make -j "$(nproc)" check ${RUN_TEST} SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
4449

45-
if test -z "$1" && test -n "$CI"; then
46-
sudo make -j "$(nproc)" check-root SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" TEST_SUITE_LOG="tests/test-suite-root.log" || :
47-
fi
50+
if test "$1" != "run-root"; then
51+
# run the regular tests
52+
if test $# -ge 1; then
53+
timeout -sKILL 4h make -j "$(nproc)" check TESTS="$SPECIFIC_TESTS" SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
54+
else
55+
timeout -sKILL 4h make -j "$(nproc)" check SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
56+
fi
57+
else
58+
# in case we would like to run tests requiring root
59+
if test -z "$1" -o "$1" == "run-root"; then
60+
if test -n "$CI"; then
61+
echo "Running check-root to run only root tests"
62+
sudo make -j "$(nproc)" check-root SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" TEST_SUITE_LOG="tests/test-suite-root.log" || :
63+
fi
64+
fi
65+
fi

0 commit comments

Comments
 (0)