Skip to content

Commit ad6723c

Browse files
committed
selinux test: collect and process the results
1 parent 5917a6c commit ad6723c

File tree

3 files changed

+53
-9
lines changed

3 files changed

+53
-9
lines changed

.github/workflows/GnuTests.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ jobs:
5555
#
5656
SUITE_LOG_FILE="${path_GNU_tests}/test-suite.log"
5757
ROOT_SUITE_LOG_FILE="${path_GNU_tests}/test-suite-root.log"
58+
SELINUX_SUITE_LOG_FILE="${path_GNU_tests}/selinux-test-suite.log"
59+
SELINUX_ROOT_SUITE_LOG_FILE="${path_GNU_tests}/selinux-test-suite-root.log"
5860
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
5961
TEST_FILESET_PREFIX='test-fileset-IDs.sha1#'
6062
TEST_FILESET_SUFFIX='.txt'
6163
TEST_SUMMARY_FILE='gnu-result.json'
6264
TEST_FULL_SUMMARY_FILE='gnu-full-result.json'
63-
outputs SUITE_LOG_FILE ROOT_SUITE_LOG_FILE TEST_FILESET_PREFIX TEST_FILESET_SUFFIX TEST_LOGS_GLOB TEST_SUMMARY_FILE TEST_FULL_SUMMARY_FILE
65+
outputs SUITE_LOG_FILE ROOT_SUITE_LOG_FILE SELINUX_SUITE_LOG_FILE SELINUX_ROOT_SUITE_LOG_FILE TEST_FILESET_PREFIX TEST_FILESET_SUFFIX TEST_LOGS_GLOB TEST_SUMMARY_FILE TEST_FULL_SUMMARY_FILE
6466
- name: Checkout code (uutil)
6567
uses: actions/checkout@v4
6668
with:
@@ -198,6 +200,19 @@ jobs:
198200
- name: Selinux - Run selinux tests as root
199201
run: |
200202
lima bash -c "cd ~/work/uutils/ && CI=1 bash util/run-gnu-test.sh run-root \$(cat selinux-tests.txt)"
203+
- name: Selinux - Collect test logs
204+
run: |
205+
# Create directories for SELinux test logs
206+
mkdir -p ${{ steps.vars.outputs.path_GNU_tests }}-selinux
207+
208+
# Copy the test logs from the Lima VM to the host
209+
lima bash -c "mkdir -p ~/work/gnu/tests-selinux && cp ~/work/gnu/tests/test-suite.log ~/work/gnu/tests-selinux/ || echo 'No test-suite.log found'"
210+
lima bash -c "cp ~/work/gnu/tests/test-suite-root.log ~/work/gnu/tests-selinux/ || echo 'No test-suite-root.log found'"
211+
rsync -v -a -e ssh lima-default:~/work/gnu/tests-selinux/ ./${{ steps.vars.outputs.path_GNU_tests }}-selinux/
212+
213+
# Copy SELinux logs to the main test directory for integrated processing
214+
cp -f ${{ steps.vars.outputs.path_GNU_tests }}-selinux/test-suite.log ${{ steps.vars.outputs.path_GNU_tests }}/selinux-test-suite.log || echo "No SELinux test-suite.log found"
215+
cp -f ${{ steps.vars.outputs.path_GNU_tests }}-selinux/test-suite-root.log ${{ steps.vars.outputs.path_GNU_tests }}/selinux-test-suite-root.log || echo "No SELinux test-suite-root.log found"
201216
202217
- name: Run GNU tests
203218
shell: bash
@@ -230,11 +245,13 @@ jobs:
230245
#
231246
SUITE_LOG_FILE='${{ steps.vars.outputs.SUITE_LOG_FILE }}'
232247
ROOT_SUITE_LOG_FILE='${{ steps.vars.outputs.ROOT_SUITE_LOG_FILE }}'
233-
ls -al ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE}
248+
SELINUX_SUITE_LOG_FILE='${{ steps.vars.outputs.SELINUX_SUITE_LOG_FILE }}'
249+
SELINUX_ROOT_SUITE_LOG_FILE='${{ steps.vars.outputs.SELINUX_ROOT_SUITE_LOG_FILE }}'
250+
ls -al ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE} ${SELINUX_SUITE_LOG_FILE} ${SELINUX_ROOT_SUITE_LOG_FILE}
234251
235252
if test -f "${SUITE_LOG_FILE}"
236253
then
237-
source ${path_UUTILS}/util/analyze-gnu-results.sh ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE}
254+
source ${path_UUTILS}/util/analyze-gnu-results.sh ${SUITE_LOG_FILE} ${ROOT_SUITE_LOG_FILE} ${SELINUX_SUITE_LOG_FILE} ${SELINUX_ROOT_SUITE_LOG_FILE}
238255
if [[ "$TOTAL" -eq 0 || "$TOTAL" -eq 1 ]]; then
239256
echo "::error ::Failed to parse test results from '${SUITE_LOG_FILE}'; failing early"
240257
exit 1
@@ -287,7 +304,11 @@ jobs:
287304
have_new_failures=""
288305
REF_LOG_FILE='${{ steps.vars.outputs.path_reference }}/test-logs/test-suite.log'
289306
ROOT_REF_LOG_FILE='${{ steps.vars.outputs.path_reference }}/test-logs/test-suite-root.log'
307+
SELINUX_REF_LOG_FILE='${{ steps.vars.outputs.path_reference }}/test-logs/selinux-test-suite.log'
308+
SELINUX_ROOT_REF_LOG_FILE='${{ steps.vars.outputs.path_reference }}/test-logs/selinux-test-suite-root.log'
290309
REF_SUMMARY_FILE='${{ steps.vars.outputs.path_reference }}/test-summary/gnu-result.json'
310+
311+
291312
REPO_DEFAULT_BRANCH='${{ steps.vars.outputs.repo_default_branch }}'
292313
path_UUTILS='${{ steps.vars.outputs.path_UUTILS }}'
293314
# https://github.com/uutils/coreutils/issues/4294

GNUmakefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ SELINUX_PROGS := \
181181

182182
ifneq ($(OS),Windows_NT)
183183
PROGS := $(PROGS) $(UNIX_PROGS)
184-
endif
185-
186-
ifeq ($(SELINUX_ENABLED),1)
184+
# Build the selinux command even if not on the system
187185
PROGS := $(PROGS) $(SELINUX_PROGS)
188186
endif
189187

util/run-gnu-test.sh

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,27 @@ cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
4343

4444
export RUST_BACKTRACE=1
4545

46-
if test "$1" != "run-root"; then
46+
# Determine if we have SELinux tests
47+
has_selinux_tests=false
48+
if test $# -ge 1; then
49+
for t in "$@"; do
50+
if [[ "$t" == *"selinux"* ]]; then
51+
has_selinux_tests=true
52+
break
53+
fi
54+
done
55+
fi
56+
57+
if [[ "$1" == "run-root" && "$has_selinux_tests" == true ]]; then
58+
# Handle SELinux root tests separately
59+
shift
60+
if test -n "$CI"; then
61+
echo "Running SELinux tests as root"
62+
# Don't use check-root here as the upstream root tests is hardcoded
63+
sudo "${MAKE}" -j "$("${NPROC}")" check TESTS="$*" 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" || :
64+
fi
65+
exit 0
66+
elif test "$1" != "run-root"; then
4767
if test $# -ge 1; then
4868
# if set, run only the tests passed
4969
SPECIFIC_TESTS=""
@@ -82,8 +102,13 @@ else
82102
# in case we would like to run tests requiring root
83103
if test -z "$1" -o "$1" == "run-root"; then
84104
if test -n "$CI"; then
85-
echo "Running check-root to run only root tests"
86-
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" || :
105+
if test $# -ge 2; then
106+
echo "Running check-root to run only root tests"
107+
sudo "${MAKE}" -j "$("${NPROC}")" check-root TESTS="$2" 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" || :
108+
else
109+
echo "Running check-root to run only root tests"
110+
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" || :
111+
fi
87112
fi
88113
fi
89114
fi

0 commit comments

Comments
 (0)