public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/rust] main: refactor(rpm-rebuild): reduce log verbosity and detect resource failures
@ 2026-08-24 17:23 Jesus Checa Hidalgo
0 siblings, 0 replies; only message in thread
From: Jesus Checa Hidalgo @ 2026-08-24 17:23 UTC (permalink / raw)
To: git-commits
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-24 17:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-24 17:23 [tests/rust] main: refactor(rpm-rebuild): reduce log verbosity and detect resource failures Jesus Checa Hidalgo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox