public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jesus Checa Hidalgo <jchecahi@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/rust] main: refactor(rpm-rebuild): reduce log verbosity and detect resource failures
Date: Mon, 24 Aug 2026 17:23:22 GMT [thread overview]
Message-ID: <178759220288.1.9467241999465760633.tests-rust-ebef0ebe6c4e@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : tests/rust
Branch : main
Commit : ebef0ebe6c4e5b69e91bc3750bce768bdd4d1d9a
Author : Jesus Checa Hidalgo <jchecahi@redhat.com>
Date : 2026-08-14T11:49:41+02:00
Stats : +62/-4 in 2 file(s)
URL : https://src.fedoraproject.org/tests/rust/c/ebef0ebe6c4e5b69e91bc3750bce768bdd4d1d9a?branch=main
Log:
refactor(rpm-rebuild): reduce log verbosity and detect resource failures
- Add analyze_build_failure() to distinguish resource failures from build failures
- Add EXIT trap to guarantee cleanup on timeout/SIGTERM/rlDie
- Execute rpmbuild silently, show only command and result
- Detect patterns: disk full, SIGKILL, missing dependencies
---
diff --git a/tests/Sanity/rpm-rebuild/main.fmf b/tests/Sanity/rpm-rebuild/main.fmf
index 8688b85..baac489 100644
--- a/tests/Sanity/rpm-rebuild/main.fmf
+++ b/tests/Sanity/rpm-rebuild/main.fmf
@@ -4,7 +4,7 @@ require+:
- rpm-build
duration: 1h
-adjust:
+adjust+:
- require+:
- dnf5-plugins
when: distro == fedora or distro > rhel-10 or distro > centos-stream-10
diff --git a/tests/Sanity/rpm-rebuild/runtest.sh b/tests/Sanity/rpm-rebuild/runtest.sh
index 5499b64..f3537b0 100755
--- a/tests/Sanity/rpm-rebuild/runtest.sh
+++ b/tests/Sanity/rpm-rebuild/runtest.sh
@@ -2,10 +2,53 @@
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
+# Analyze build failure and determine if it's a resource issue or real failure
+analyze_build_failure() {
+ local logfile="$1"
+ local detected_cause=""
+
+ # Extensible table of known resource failure patterns
+ # Format: "regex_pattern|diagnostic_message"
+ local -a RESOURCE_PATTERNS=(
+ "No space left on device|Disk space exhausted"
+ "signal: 9|Build killed with SIGKILL"
+ "SIGKILL: kill|Build killed with SIGKILL"
+ "Failed build dependencies|Missing build dependencies. Is CRB repo enabled?"
+ )
+
+ # Search for each pattern in the log (first match wins)
+ for pattern_entry in "${RESOURCE_PATTERNS[@]}"; do
+ IFS='|' read -r pattern message <<< "$pattern_entry"
+ if grep -qiE "$pattern" "$logfile"; then
+ detected_cause="$message"
+ break
+ fi
+ done
+
+ # Always show tail of log
+ rlLogInfo "Last 20 lines of build log:"
+ tail -n 20 "$logfile" | while IFS= read -r line; do
+ rlLogInfo "$line"
+ done
+
+ if [[ -n "$detected_cause" ]]; then
+ rlFileSubmit "$logfile"
+ rlDie "Fail reason (likely): $detected_cause"
+ # rlDie aborts here, but trap guarantees cleanup
+ fi
+}
+
PACKAGE="$(rpm -qf "$(which rustc)")"
rlJournalStart
rlPhaseStartSetup
+ # Trap for guaranteed cleanup (even with rlDie, TMT timeouts, SIGTERM)
+ cleanup_on_exit() {
+ [[ -n "$TmpDir" && -d "$TmpDir" ]] && rm -rf "$TmpDir"
+ [[ -n "$TOPDIR" && -d "$TOPDIR" ]] && rm -rf "$TOPDIR"
+ }
+ trap cleanup_on_exit EXIT
+
declare TmpDir
rlAssertRpm "$PACKAGE" || rlDie "rustc not found. Aborting testcase..."
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
@@ -46,13 +89,28 @@ rlJournalStart
# builddep needs to be run from the srpm, not the spec file, to be able
# to generate them:
# https://fedoraproject.org/wiki/Changes/DynamicBuildRequires#rpmbuild
- rlRun "dnf builddep -y ${SRPM}"
+ rlRun "dnf -q builddep -y ${SRPM}"
rlPhaseEnd
rlPhaseStartTest
set -o pipefail
- rlRun "rpmbuild -bb ${SPECDIR}/${SPECNAME} |& tee ${SRPM}_rpmbuild.log"
- rlFileSubmit "${SRPM}_rpmbuild.log"
+ LOGFILE="${SRPM}_rpmbuild.log"
+ BUILD_CMD="rpmbuild -bb ${SPECDIR}/${SPECNAME}"
+
+ # Log the command being executed (for visibility in test output)
+ rlLog "Executing: $BUILD_CMD"
+
+ # Execute rpmbuild silently, saving complete log to file
+ if $BUILD_CMD &> "$LOGFILE"; then
+ rlPass "rpmbuild succeeded"
+ else
+ # Analyze cause of failure
+ analyze_build_failure "$LOGFILE"
+ # If analyze_build_failure returns (didn't rlDie), it's a real failure
+ rlFail "rpmbuild failed"
+ fi
+
+ rlFileSubmit "$LOGFILE"
rlPhaseEnd
rlPhaseStartCleanup
reply other threads:[~2026-08-24 17:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178759220288.1.9467241999465760633.tests-rust-ebef0ebe6c4e@fedoraproject.org \
--to=jchecahi@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox