Skip to content

Commit

Permalink
Separate exit code for skipped tests
Browse files Browse the repository at this point in the history
This way we can distinguish such tests in the viewer
  • Loading branch information
jpopelka committed Jan 18, 2024
1 parent 87bd959 commit cc5d83f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
14 changes: 8 additions & 6 deletions mtps-pkg-test
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

: "${PROG:=${0##*/}}"

EXIT_CODE_SKIP=7

# Source `mtps-setup' from $PATH
if command -v "mtps-setup" >/dev/null; then source "mtps-setup"; fi
# If previous fails source `mtps-setup` from this script dir
Expand Down Expand Up @@ -594,7 +596,7 @@ fi
if [[ "$TEST" == "install" || "$TEST" == "remove" ]]; then
if ! pkg_can_be_removed "$NEVRA"; then
echo "Skipping test: $TEST for $NEVRA. Package cannot be clearly removed."
exit 0
exit $EXIT_CODE_SKIP
fi
fi

Expand All @@ -621,7 +623,7 @@ case $TEST in
old_nevra="$(get_old_nevra "$NEVRA" || true)"
if [ -z "$old_nevra" ]; then
echo "Cannot find older package than $NEVRA. Skipping test."
exit 0
exit $EXIT_CODE_SKIP
fi
# If there's a bug preventing the old package from installing
# the dnf downgrade fails but we can't say whether it's because
Expand All @@ -635,7 +637,7 @@ case $TEST in
fi
if ! pkg_install_if_absent "$old_nevra"; then
echo "Failed to install $old_nevra. Skipping test."
exit 0
exit $EXIT_CODE_SKIP
fi
# At this point pkg is installed, but can be many installonlypkg(foo) packages
pkg_remove_any_newer "$NEVRA"
Expand All @@ -658,13 +660,13 @@ case $TEST in
old_nevra="$(get_old_nevra "$NEVRA" || true)"
if [ -z "$old_nevra" ]; then
echo "Cannot find older package than $NEVRA. Skipping test."
exit 0
exit $EXIT_CODE_SKIP
fi
echo "Older available package is: $old_nevra"
pkg_update_to_new_if_present "$NEVRA"
if ! pkg_install_if_absent "$NEVRA"; then
echo "Failed to install $NEVRA. Skipping test."
exit 0
exit $EXIT_CODE_SKIP
fi
pkg_remove_any_older "$NEVRA" # This is for installonlypkg(foo) packages, like kernel
msg_run "downgrade" "$NEVRA"
Expand All @@ -685,7 +687,7 @@ case $TEST in
# it uninstallable.
if ! pkg_can_be_removed "$NEVRA"; then
echo "Skipping test: $TEST for $NEVRA. Package cannot be clearly removed."
exit 0
exit $EXIT_CODE_SKIP
fi

msg_run "remove" "$NEVRA"
Expand Down
9 changes: 6 additions & 3 deletions mtps-run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

: "${PROG:=${0##*/}}"

EXIT_CODE_SKIP=7

# Source `mtps-setup' from $PATH
if command -v "mtps-setup" >/dev/null; then source "mtps-setup"; fi
# If previous fails source `mtps-setup` from this script dir
Expand Down Expand Up @@ -205,18 +207,19 @@ for nevra in $nevras_in_repo; do
## Ignore errors on rollback due to: https://bugzilla.redhat.com/show_bug.cgi?id=1614346
## Rollback fails after Downgrade / Update tests
#yum -y history rollback "$START" || echo "Ignoring rollback error: RHBZ#1614346"
if [ "$test_status" -ne "0" ]; then
if [ "$test_status" -eq $EXIT_CODE_SKIP ]; then
new_logfname="$(dirname "$logfname")/SKIP-$(basename "$logfname")"
elif [ "$test_status" -ne 0 ]; then
ret=1
if [ -n "$CRITICAL" ]; then
new_logfname="$(dirname "$logfname")/FAIL-$(basename "$logfname")"
else
new_logfname="$(dirname "$logfname")/WARN-$(basename "$logfname")"
fi
mv "$logfname" "$new_logfname"
else
new_logfname="$(dirname "$logfname")/PASS-$(basename "$logfname")"
mv "$logfname" "$new_logfname"
fi
mv "$logfname" "$new_logfname"
if [ -n "$SELINUX" ] && rpm --quiet -q audit; then
selinux_status=0
ausearch --format raw -m avc,user_avc,selinux_err,user_selinux_err -ts "$START_DATE" "$START_TIME" 2>&1 | sed -e '/received policyload notice/d' | grep -s -o '^' && selinux_status=1
Expand Down

0 comments on commit cc5d83f

Please sign in to comment.