Skip to content

Commit

Permalink
fmf: Plumb through $TEST_* variables for unexpected messages
Browse files Browse the repository at this point in the history
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 cockpit-project/cockpit-podman@c38692fa4ce66
  • Loading branch information
martinpitt committed Aug 28, 2023
1 parent d4986c3 commit 6123ae1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions plans/all.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -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+:
Expand Down
7 changes: 6 additions & 1 deletion test/browser/browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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}
5 changes: 5 additions & 0 deletions test/browser/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6123ae1

Please sign in to comment.