Skip to content

Commit 23b564a

Browse files
committed
fetch selinux denials on every failed test
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent 9bf5c12 commit 23b564a

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

test/podman-tests.sh

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ for pkg in container-selinux crun golang podman podman-tests selinux-policy; do
2828
fi
2929
done
3030

31+
fetch_selinux_denials() {
32+
echo "Fetching AVC denials..."
33+
ausearch -m AVC,USER_AVC,SELINUX_ERR,USER_SELINUX_ERR -ts recent
34+
}
35+
3136
if [[ "$TEST_TYPE" == "e2e" ]]; then
3237
# /tmp is often unsufficient
3338
export TMPDIR=/var/tmp
@@ -60,19 +65,21 @@ if [[ "$TEST_TYPE" == "e2e" ]]; then
6065

6166
# Run podman e2e tests
6267
pushd "$PODMAN_DIR"/podman-*/test/e2e
63-
go test -v config.go config_test.go config_"$ARCH".go common_test.go libpod_suite_test.go run_selinux_test.go
64-
go test -v config.go config_test.go config_"$ARCH".go common_test.go libpod_suite_test.go checkpoint_test.go
68+
if ! go test -v config.go config_test.go config_"$ARCH".go common_test.go libpod_suite_test.go run_selinux_test.go; then
69+
fetch_selinux_denials
70+
fi
71+
if ! go test -v config.go config_test.go config_"$ARCH".go common_test.go libpod_suite_test.go checkpoint_test.go; then
72+
fetch_selinux_denials
73+
fi
6574
popd
6675
fi
6776

6877
if [[ "$TEST_TYPE" == "system" ]]; then
6978
# Run podman system tests
70-
bats /usr/share/podman/test/system/410-selinux.bats
71-
bats /usr/share/podman/test/system/520-checkpoint.bats
72-
fi
73-
74-
# shellcheck disable=SC2181
75-
if [[ $? -ne 0 ]]; then
76-
echo "Fetching AVC denials..."
77-
ausearch -m AVC,USER_AVC,SELINUX_ERR,USER_SELINUX_ERR -ts recent
79+
if ! bats /usr/share/podman/test/system/410-selinux.bats; then
80+
fetch_selinux_denials
81+
fi
82+
if ! bats /usr/share/podman/test/system/520-checkpoint.bats; then
83+
fetch_selinux_denials
84+
fi
7885
fi

0 commit comments

Comments
 (0)