fmf: Plumb through $TEST_* variables for unexpected messages

This will allow us to control the value from test plans, in particular
for disabling at least some unexpected message checks for reverse
dependency testing. We don't want to disable unexpected messages
in general for fmf, as we are looking for exactly these in e.g.
selinux-policy reverse dependency tests.

Move from `su` to `runtest`, as with the former it's impossible to plumb
through variables with non-trivial characters, as they cannot be quoted.

Taken from https://github.com/cockpit-project/cockpit-podman/commit/c38692fa4ce66
This commit is contained in:
Martin Pitt 2023-08-26 10:13:49 +02:00 committed by Martin Pitt
parent d4986c3ba1
commit 6123ae1e6f
3 changed files with 15 additions and 1 deletions

View File

@ -7,6 +7,10 @@ discover:
execute:
how: tmt
# Let's handle them upstream only, don't break Fedora/RHEL reverse dependency gating
environment:
TEST_AUDIT_NO_SELINUX: 1
/basic:
summary: Run tests for basic packages
discover+:

View File

@ -5,10 +5,13 @@ set -eux
# like "basic", passed on to run-test.sh
PLAN="$1"
export TEST_BROWSER=${TEST_BROWSER:-firefox}
MYDIR="$(realpath $(dirname "$0"))"
SOURCE="$(realpath $MYDIR/../..)"
# https://tmt.readthedocs.io/en/stable/overview.html#variables
LOGS="${TMT_TEST_DATA:-$(pwd)/logs}"
export SOURCE LOGS
mkdir -p "$LOGS"
chmod a+w "$LOGS"
@ -84,7 +87,9 @@ firewall-cmd --add-service=cockpit --permanent
firewall-cmd --add-service=cockpit
# Run tests as unprivileged user
su - -c "env TEST_BROWSER=firefox SOURCE=$SOURCE LOGS=$LOGS $MYDIR/run-test.sh $PLAN" runtest
# once we drop support for RHEL 8, use this:
# runuser -u runtest --whitelist-environment=TEST_BROWSER,TEST_ALLOW_JOURNAL_MESSAGES,TEST_AUDIT_NO_SELINUX,SOURCE,LOGS "$MYDIR/run-test.sh" "$PLAN"
runuser -u runtest --preserve-environment env USER=runtest HOME="$(getent passwd runtest | cut -f6 -d:)" "$MYDIR/run-test.sh" "$PLAN"
RC=$(cat $LOGS/exitcode)
exit ${RC:-1}

View File

@ -62,6 +62,11 @@ export TEST_ALLOW_JOURNAL_MESSAGES
TESTS=""
EXCLUDES=""
RC=0
# make it easy to check in logs
echo "TEST_ALLOW_JOURNAL_MESSAGES: ${TEST_ALLOW_JOURNAL_MESSAGES:-}"
echo "TEST_AUDIT_NO_SELINUX: ${TEST_AUDIT_NO_SELINUX:-}"
if [ "$PLAN" = "optional" ]; then
TESTS="$TESTS
TestAutoUpdates