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.
  • Loading branch information
martinpitt committed Aug 25, 2023
1 parent 4c8e6a2 commit 61f7565
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions plans/all.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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

/system:
summary: Run tests on system podman
discover+:
Expand Down
10 changes: 7 additions & 3 deletions test/browser/browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ set -eux
# test plan name, passed on to run-test.sh
PLAN="$1"

export TEST_BROWSER=${TEST_BROWSER:-firefox}

TESTS="$(realpath $(dirname "$0"))"
SOURCE="$(realpath $TESTS/../..)"
export SOURCE="$(realpath $TESTS/../..)"

# https://tmt.readthedocs.io/en/stable/overview.html#variables
LOGS="${TMT_TEST_DATA:-$(pwd)/logs}"
export LOGS="${TMT_TEST_DATA:-$(pwd)/logs}"
mkdir -p "$LOGS"
chmod a+w "$LOGS"

Expand Down Expand Up @@ -74,7 +76,9 @@ loginctl disable-linger $(id -u admin)
systemctl enable --now cockpit.socket podman.socket

# Run tests as unprivileged user
su - -c "env TEST_BROWSER=firefox SOURCE=$SOURCE LOGS=$LOGS $TESTS/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 $TESTS/run-test.sh $PLAN
runuser -u runtest --preserve-environment $TESTS/run-test.sh $PLAN

RC=$(cat $LOGS/exitcode)
exit ${RC:-1}
5 changes: 4 additions & 1 deletion test/browser/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ fi

. /etc/os-release
export TEST_OS="${ID}-${VERSION_ID/./-}"
export TEST_AUDIT_NO_SELINUX=1

if [ "${TEST_OS#centos-}" != "$TEST_OS" ]; then
TEST_OS="${TEST_OS}-stream"
Expand All @@ -36,6 +35,10 @@ esac

EXCLUDES=""

# 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:-}"

RC=0
test/common/run-tests --nondestructive --machine 127.0.0.1:22 --browser 127.0.0.1:9090 $TESTS $EXCLUDES || RC=$?

Expand Down

0 comments on commit 61f7565

Please sign in to comment.