From f97978863022327a5bdd75cd8c3f79edc85f3266 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Fri, 10 Jan 2025 10:25:02 +0100 Subject: [PATCH 01/20] Update wasm/wasi tests This commit contains the following changes: * Remove wasm32-wasi package requirement in rust-1.84 and newer * Compatibility fixes for nodejs in older RHEL, which is used to test wasi. --- tests/Sanity/rust-wasi-smoke-test/main.fmf | 11 ++++++++--- tests/Sanity/rust-wasi-smoke-test/runtest.sh | 13 ++++++------- tests/Sanity/rust-wasm-smoke-test/main.fmf | 5 ++++- tests/Sanity/rust-wasm-smoke-test/runtest.sh | 9 ++++++++- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/tests/Sanity/rust-wasi-smoke-test/main.fmf b/tests/Sanity/rust-wasi-smoke-test/main.fmf index 259de1d..8786e9e 100644 --- a/tests/Sanity/rust-wasi-smoke-test/main.fmf +++ b/tests/Sanity/rust-wasi-smoke-test/main.fmf @@ -1,7 +1,5 @@ summary: Compile and run a wasi app from rust description: Test the WASI targets currently shipped with rust -require+: - - rust-std-static-wasm32-wasi duration: 5m tier: 1 tag: @@ -10,10 +8,17 @@ link: - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1980080 - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1980082 adjust+: + - because: "wasm32-wasi target not available after rust 1.84" + require+: + - rust-std-static-wasm32-wasi + when: distro == fedora and distro < fedora-42 or + distro == rhel-8 and distro < rhel-8.10 or + distro == rhel-9 and distro < rhel-9.6 + - because: "wasm32-wasip1 target added in rust 1.78" require+: - rust-std-static-wasm32-wasip1 - when: distro >= fedora-39,rhel-9.5,rhel-10 + when: distro >= fedora-39,rhel-8.10,rhel-9.5,rhel-10 - because: "WASI target not supported in s390x older RHEL" enabled: false diff --git a/tests/Sanity/rust-wasi-smoke-test/runtest.sh b/tests/Sanity/rust-wasi-smoke-test/runtest.sh index fa0b880..27a2c2b 100755 --- a/tests/Sanity/rust-wasi-smoke-test/runtest.sh +++ b/tests/Sanity/rust-wasi-smoke-test/runtest.sh @@ -28,7 +28,7 @@ # Include Beaker environment . /usr/share/beakerlib/beakerlib.sh || exit 1 -PACKAGES="$(rpm -qf $(which rustc))" +PACKAGES="$(rpm -qf "$(which rustc)")" PACKAGES+=" $(rlGetYAMLdeps)" # TMT will decide which targets to install depending on the distro/arch context. @@ -43,12 +43,11 @@ rlJournalStart rlPhaseStartSetup rlAssertRpm --all rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - # Because we need a specific nodejs version (>=16) that supports WASI. - # In RHEL 8 we need to do it via modules, which tmt does not support, - # so we need to do it right in the script. - if rlIsRHEL 8; then - # nodejs-16 has support for wasi. - rlRun "yum -y module switch-to nodejs:16" + if rlIsRHEL 8 9; then + # In RHEL 8 and 9 nodejs is shipped in different versions using modules. + # We always want to use the latest version. + rlRun "NODE_VER=\"$(dnf module info nodejs | sed -n -E 's|^Stream\s+:\s*([0-9]+).*|\1|p' | sort | tail -1)\"" + rlRun "yum -y module switch-to nodejs:$NODE_VER" rlRun "yum -y module install nodejs" fi # Example taken from WASI documentation: diff --git a/tests/Sanity/rust-wasm-smoke-test/main.fmf b/tests/Sanity/rust-wasm-smoke-test/main.fmf index fb79999..ed3f40e 100644 --- a/tests/Sanity/rust-wasm-smoke-test/main.fmf +++ b/tests/Sanity/rust-wasm-smoke-test/main.fmf @@ -2,7 +2,6 @@ summary: rust wasm smoke test description: 'Test that the rust wasm target is enabled and can compile correctly' require+: - rust-std-static-wasm32-unknown-unknown - - nodejs duration: 5m tier: 1 tag: @@ -19,6 +18,10 @@ adjust+: enabled: false when: distro < rhel-8 continue: false + - because: "nodejs needs to be installed differently in RHEL-8" + require+: + - "nodejs" + when: distro != rhel-8 extra-nitrate: TC#0611164 extra-summary: /tools/rust/Sanity/rust-wasm-smoke-test extra-task: /tools/rust/Sanity/rust-wasm-smoke-test diff --git a/tests/Sanity/rust-wasm-smoke-test/runtest.sh b/tests/Sanity/rust-wasm-smoke-test/runtest.sh index 2de8b84..40a82d2 100755 --- a/tests/Sanity/rust-wasm-smoke-test/runtest.sh +++ b/tests/Sanity/rust-wasm-smoke-test/runtest.sh @@ -28,12 +28,19 @@ # Include Beaker environment . /usr/share/beakerlib/beakerlib.sh || exit 1 -PACKAGES="$(rpm -qf $(which rustc)) rust-std-static-wasm32-unknown-unknown" +PACKAGES="$(rpm -qf "$(which rustc)") rust-std-static-wasm32-unknown-unknown" rlJournalStart rlPhaseStartSetup rlAssertRpm --all rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + if rlIsRHEL 8 9; then + # In RHEL 8 and 9 nodejs is shipped in different versions using modules. + # We always want to use the latest version. + rlRun "NODE_VER=\"$(dnf module info nodejs | sed -n -E 's|^Stream\s+:\s*([0-9]+).*|\1|p' | sort | tail -1)\"" + rlRun "yum -y module switch-to nodejs:$NODE_VER" + rlRun "yum -y module install nodejs" + fi rlRun "cp lib.rs $TmpDir" rlRun "cp test.js $TmpDir" rlRun "pushd $TmpDir" From 1716d90a4a5a96e6948c50e3038f5df4354e183c Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Fri, 10 Jan 2025 10:31:38 +0100 Subject: [PATCH 02/20] rust-rpmmacros: Improve test functionality * Use arguments in cargo_build/install/test/license rpmmacros * RHEL and CentOS 10 behaves like Fedora. --- tests/Sanity/rust-rpmmacros/rust-rpmtest.spec | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/Sanity/rust-rpmmacros/rust-rpmtest.spec b/tests/Sanity/rust-rpmmacros/rust-rpmtest.spec index abe8c12..34d87a0 100644 --- a/tests/Sanity/rust-rpmmacros/rust-rpmtest.spec +++ b/tests/Sanity/rust-rpmmacros/rust-rpmtest.spec @@ -38,14 +38,29 @@ Summary: %{summary} %endif %build -%cargo_build +# cargo_build/install/test don't use -n/-a/-f in rhel/centos < 10 to avoid breaking +# existing packages using arguments. +%if 0%{?rhel} && 0%{?rhel} < 10 +%cargo_build --all-features +%else +%cargo_build -a +%endif + # cargo_license(_summary) macros is not available in rust 1.73 and older. -%{?cargo_license} -%{?cargo_license_summary} +%{?cargo_license:%cargo_license -a} +%{?cargo_license_summary:%cargo_license_summary -a} %install -%cargo_install +%if 0%{?rhel} && 0%{?rhel} < 10 +%cargo_install --all-features +%else +%cargo_install -a +%endif %check -%cargo_test +%%if 0%{?rhel} && 0%{?rhel} < 10 +%cargo_test --all-features +%else +%cargo_test -a +%endif %{buildroot}/%{_bindir}/rpmtest | grep -E "The answer is [0-9]+" From c64c527829c07517330a623e2a7ab9913889bc28 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Fri, 10 Jan 2025 10:25:02 +0100 Subject: [PATCH 03/20] Update wasm/wasi tests This commit contains the following changes: * Remove wasm32-wasi package requirement in rust-1.84 and newer * Compatibility fixes for nodejs in older RHEL, which is used to test wasi. --- tests/Sanity/rust-wasi-smoke-test/main.fmf | 11 ++++++++--- tests/Sanity/rust-wasi-smoke-test/runtest.sh | 13 ++++++------- tests/Sanity/rust-wasm-smoke-test/main.fmf | 5 ++++- tests/Sanity/rust-wasm-smoke-test/runtest.sh | 9 ++++++++- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/tests/Sanity/rust-wasi-smoke-test/main.fmf b/tests/Sanity/rust-wasi-smoke-test/main.fmf index 259de1d..c67644d 100644 --- a/tests/Sanity/rust-wasi-smoke-test/main.fmf +++ b/tests/Sanity/rust-wasi-smoke-test/main.fmf @@ -1,7 +1,5 @@ summary: Compile and run a wasi app from rust description: Test the WASI targets currently shipped with rust -require+: - - rust-std-static-wasm32-wasi duration: 5m tier: 1 tag: @@ -10,10 +8,17 @@ link: - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1980080 - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1980082 adjust+: + - because: "wasm32-wasi target not available after rust 1.84" + require+: + - rust-std-static-wasm32-wasi + when: distro == fedora and distro < fedora-40 or + distro == rhel-8 and distro < rhel-8.10 or + distro == rhel-9 and distro < rhel-9.6 + - because: "wasm32-wasip1 target added in rust 1.78" require+: - rust-std-static-wasm32-wasip1 - when: distro >= fedora-39,rhel-9.5,rhel-10 + when: distro >= fedora-39,rhel-8.10,rhel-9.5,rhel-10 - because: "WASI target not supported in s390x older RHEL" enabled: false diff --git a/tests/Sanity/rust-wasi-smoke-test/runtest.sh b/tests/Sanity/rust-wasi-smoke-test/runtest.sh index fa0b880..27a2c2b 100755 --- a/tests/Sanity/rust-wasi-smoke-test/runtest.sh +++ b/tests/Sanity/rust-wasi-smoke-test/runtest.sh @@ -28,7 +28,7 @@ # Include Beaker environment . /usr/share/beakerlib/beakerlib.sh || exit 1 -PACKAGES="$(rpm -qf $(which rustc))" +PACKAGES="$(rpm -qf "$(which rustc)")" PACKAGES+=" $(rlGetYAMLdeps)" # TMT will decide which targets to install depending on the distro/arch context. @@ -43,12 +43,11 @@ rlJournalStart rlPhaseStartSetup rlAssertRpm --all rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - # Because we need a specific nodejs version (>=16) that supports WASI. - # In RHEL 8 we need to do it via modules, which tmt does not support, - # so we need to do it right in the script. - if rlIsRHEL 8; then - # nodejs-16 has support for wasi. - rlRun "yum -y module switch-to nodejs:16" + if rlIsRHEL 8 9; then + # In RHEL 8 and 9 nodejs is shipped in different versions using modules. + # We always want to use the latest version. + rlRun "NODE_VER=\"$(dnf module info nodejs | sed -n -E 's|^Stream\s+:\s*([0-9]+).*|\1|p' | sort | tail -1)\"" + rlRun "yum -y module switch-to nodejs:$NODE_VER" rlRun "yum -y module install nodejs" fi # Example taken from WASI documentation: diff --git a/tests/Sanity/rust-wasm-smoke-test/main.fmf b/tests/Sanity/rust-wasm-smoke-test/main.fmf index fb79999..ed3f40e 100644 --- a/tests/Sanity/rust-wasm-smoke-test/main.fmf +++ b/tests/Sanity/rust-wasm-smoke-test/main.fmf @@ -2,7 +2,6 @@ summary: rust wasm smoke test description: 'Test that the rust wasm target is enabled and can compile correctly' require+: - rust-std-static-wasm32-unknown-unknown - - nodejs duration: 5m tier: 1 tag: @@ -19,6 +18,10 @@ adjust+: enabled: false when: distro < rhel-8 continue: false + - because: "nodejs needs to be installed differently in RHEL-8" + require+: + - "nodejs" + when: distro != rhel-8 extra-nitrate: TC#0611164 extra-summary: /tools/rust/Sanity/rust-wasm-smoke-test extra-task: /tools/rust/Sanity/rust-wasm-smoke-test diff --git a/tests/Sanity/rust-wasm-smoke-test/runtest.sh b/tests/Sanity/rust-wasm-smoke-test/runtest.sh index 2de8b84..40a82d2 100755 --- a/tests/Sanity/rust-wasm-smoke-test/runtest.sh +++ b/tests/Sanity/rust-wasm-smoke-test/runtest.sh @@ -28,12 +28,19 @@ # Include Beaker environment . /usr/share/beakerlib/beakerlib.sh || exit 1 -PACKAGES="$(rpm -qf $(which rustc)) rust-std-static-wasm32-unknown-unknown" +PACKAGES="$(rpm -qf "$(which rustc)") rust-std-static-wasm32-unknown-unknown" rlJournalStart rlPhaseStartSetup rlAssertRpm --all rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + if rlIsRHEL 8 9; then + # In RHEL 8 and 9 nodejs is shipped in different versions using modules. + # We always want to use the latest version. + rlRun "NODE_VER=\"$(dnf module info nodejs | sed -n -E 's|^Stream\s+:\s*([0-9]+).*|\1|p' | sort | tail -1)\"" + rlRun "yum -y module switch-to nodejs:$NODE_VER" + rlRun "yum -y module install nodejs" + fi rlRun "cp lib.rs $TmpDir" rlRun "cp test.js $TmpDir" rlRun "pushd $TmpDir" From 11e16f99f1759b55b9404766fb090153fd15ead8 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 17 Nov 2025 18:32:29 +0100 Subject: [PATCH 04/20] Add Sanity/net_err_suggests_fetch_with_cli test. Downstreamed version of the upstream test net_fetch_with_cli: https://github.com/rust-lang/cargo/blob/37b85ad9/tests/testsuite/git_auth.rs#L350 This test needs DNS resolving so cargo is unable to reach the git repo provided as dependency, hence suggesting to enable the git-fetch-with-cli config: https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli We need to downstream this test because koji builders don't have DNS resolving hence it's impossible to pass the test there. Additionally, we use https instead ssh for the remote because cargo does not support libssh2 in RHEL/CentOS. --- .../Cargo.toml | 8 +++ .../net_err_suggests_fetch_with_cli/main.fmf | 15 +++++ .../runtest.sh | 59 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/Sanity/net_err_suggests_fetch_with_cli/Cargo.toml create mode 100644 tests/Sanity/net_err_suggests_fetch_with_cli/main.fmf create mode 100755 tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh diff --git a/tests/Sanity/net_err_suggests_fetch_with_cli/Cargo.toml b/tests/Sanity/net_err_suggests_fetch_with_cli/Cargo.toml new file mode 100644 index 0000000..24ea143 --- /dev/null +++ b/tests/Sanity/net_err_suggests_fetch_with_cli/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "foo" +version = "0.0.0" +edition = "2015" +authors = [] + +[dependencies] +foo = { git = "https://needs-proxy.invalid/git" } diff --git a/tests/Sanity/net_err_suggests_fetch_with_cli/main.fmf b/tests/Sanity/net_err_suggests_fetch_with_cli/main.fmf new file mode 100644 index 0000000..0de32b5 --- /dev/null +++ b/tests/Sanity/net_err_suggests_fetch_with_cli/main.fmf @@ -0,0 +1,15 @@ +summary: Test cargo net_fetch_with_cli option +description: | + Downstreamed version of the upstream test net_fetch_with_cli: + https://github.com/rust-lang/cargo/blob/37b85ad9/tests/testsuite/git_auth.rs#L350 + This test needs DNS resolving so cargo is unable to reach the git repo provided + as dependency, hence suggesting to enable the git-fetch-with-cli config: + https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli + + We need to downstream this test because koji builders don't have DNS resolving + hence it's impossible to pass the test there. + + Additionally, we use https instead ssh for the remote because cargo does not + support libssh2 in RHEL/CentOS. + +tier: 1 diff --git a/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh b/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh new file mode 100755 index 0000000..2094ae0 --- /dev/null +++ b/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +function generate_cargo_conffile() { + mkdir ".cargo" + cat >> .cargo/config.toml < $log_file" 101 + rlAssertGrep 'Unable to update https://needs-proxy.invalid/git' "$log_file" || cat "$log_file" + rlAssertNotGrep "net.git-fetch-with-cli" "$log_file" || cat "$log_file" + + rm -f "$log_file" +} + +rlJournalStart + rlPhaseStartSetup + declare tmp + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "cp Cargo.toml $tmp" + rlRun "pushd $tmp" + rlRun "mkdir src && touch src/lib.rs" + rlRun "set -o pipefail" + + rlPhaseEnd + + rlPhaseStartTest + rlRun "cargo check -v 2> output.log" 101 + # Ensure DNS was not able to resolve the remote + rlAssertGrep 'spurious network error \([0-9]+ .* remaining\): .*resolve .*needs-proxy\.invalid: .*known' output.log -E + rlAssertGrep 'Unable to update https://needs-proxy.invalid/git' output.log + # Ensure cargo suggests using net.git-fetch-with-cli + rlAssertGrep "net.git-fetch-with-cli" output.log + + # Use git-fetch-with-cli via envvar. + test_git-fetch-with-cli "CARGO_NET_GIT_FETCH_WITH_CLI=true cargo check -v" + + # With cli override + test_git-fetch-with-cli "cargo --config net.git-fetch-with-cli=true check -v" + + # With config file + generate_cargo_conffile + test_git-fetch-with-cli "cargo check -v" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd From 1e333e618997241d0f9617ccc6f275a00bdfa0ef Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Wed, 28 Jan 2026 12:56:18 +0100 Subject: [PATCH 05/20] rust-wasi-smoke-test: Fix warning in installed requirements assertion --- tests/Sanity/rust-wasi-smoke-test/runtest.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/Sanity/rust-wasi-smoke-test/runtest.sh b/tests/Sanity/rust-wasi-smoke-test/runtest.sh index 27a2c2b..dfac3c0 100755 --- a/tests/Sanity/rust-wasi-smoke-test/runtest.sh +++ b/tests/Sanity/rust-wasi-smoke-test/runtest.sh @@ -28,9 +28,6 @@ # Include Beaker environment . /usr/share/beakerlib/beakerlib.sh || exit 1 -PACKAGES="$(rpm -qf "$(which rustc)")" -PACKAGES+=" $(rlGetYAMLdeps)" - # TMT will decide which targets to install depending on the distro/arch context. # Here we only check which ones were installed. ALL_TARGETS=(wasm32-wasi wasm32-wasip1 wasm32-wasip2) @@ -41,7 +38,12 @@ done rlJournalStart rlPhaseStartSetup - rlAssertRpm --all + # Newer nodejs have versioned packages, which makes it tricky to assert + # its presence with a plain rlAssertRpm --all. Instead we verify that + # there's an installed package providing each requirement. + for pkg in $(rlGetYAMLdeps); do + rlRun "rpm -q --whatprovides $pkg" + done rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" if rlIsRHEL 8 9; then # In RHEL 8 and 9 nodejs is shipped in different versions using modules. From e071728eed83e0ee732afdc39005311b598ec25e Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Tue, 3 Feb 2026 15:26:29 -0600 Subject: [PATCH 06/20] Update rust-profiler sanity test Desugar the for-loop to minimize ambiguity when testing the profiler. The original regression is tracked upstream as rust#151554. For: RUST-52 --- tests/Sanity/rust-profiler/coverage.exp | 19 ++++++++++--------- tests/Sanity/rust-profiler/main.rs | 7 ++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/Sanity/rust-profiler/coverage.exp b/tests/Sanity/rust-profiler/coverage.exp index eafa341..b24c031 100644 --- a/tests/Sanity/rust-profiler/coverage.exp +++ b/tests/Sanity/rust-profiler/coverage.exp @@ -1,10 +1,11 @@ - 1| 1|fn main(){ + 1| 1|fn main() { 2| 1| let mut sum: u32 = 0; - 3| 10| for i in 1..10 { - 4| 9| sum += i; - 5| 9| } - 6| 1| if false{ - 7| 0| println!("This code can't be reached"); - 8| 1| } - 9| 1| println!("Sum: {}", sum); - 10| 1|} + 3| 1| let mut iter = 1..10; + 4| 10| while let Some(i) = iter.next() { + 5| 9| sum += i; + 6| 9| } + 7| 1| if false { + 8| 0| println!("This code can't be reached"); + 9| 1| } + 10| 1| println!("Sum: {}", sum); + 11| 1|} diff --git a/tests/Sanity/rust-profiler/main.rs b/tests/Sanity/rust-profiler/main.rs index 8550df0..8db0150 100644 --- a/tests/Sanity/rust-profiler/main.rs +++ b/tests/Sanity/rust-profiler/main.rs @@ -1,9 +1,10 @@ -fn main(){ +fn main() { let mut sum: u32 = 0; - for i in 1..10 { + let mut iter = 1..10; + while let Some(i) = iter.next() { sum += i; } - if false{ + if false { println!("This code can't be reached"); } println!("Sum: {}", sum); From 0bb39d1c3489e796b2b2c616492eef3c201462c6 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Wed, 4 Feb 2026 15:36:05 +0100 Subject: [PATCH 07/20] Improve rpm-rebuild test Cleanup rpmbuild directory after test. Minor code cleaning. --- tests/Sanity/rpm-rebuild/runtest.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/Sanity/rpm-rebuild/runtest.sh b/tests/Sanity/rpm-rebuild/runtest.sh index 93588d5..cffaf8c 100755 --- a/tests/Sanity/rpm-rebuild/runtest.sh +++ b/tests/Sanity/rpm-rebuild/runtest.sh @@ -2,15 +2,16 @@ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k . /usr/share/beakerlib/beakerlib.sh || exit 1 -PACKAGE="$(rpm -qf $(which rustc))" +PACKAGE="$(rpm -qf "$(which rustc)")" rlJournalStart rlPhaseStartSetup - rlAssertRpm $PACKAGE || rlDie "rustc not found. Aborting testcase..." + declare TmpDir + rlAssertRpm "$PACKAGE" || rlDie "rustc not found. Aborting testcase..." rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" rlRun "pushd $TmpDir" - if [[ "x" == "x${PKG_TO_BUILD}" ]]; then + if [[ -z "${PKG_TO_BUILD}" ]]; then rlLogError "No package was configured to build." rlDie "The package must be passed over PKG_TO_BUILD environment variable." fi @@ -19,26 +20,27 @@ rlJournalStart # out of space, timeouts, or OOMs this will help identifying where # the issue might be. rlRun "free -h" 0 "Available memory" - rlRun 'echo "Processing units: $(nproc)"' 0 "Show processing units" + rlRun "echo \"Processing units: $(nproc)\"" 0 "Show processing units" rlRun "df -h" 0 "Storage space" rlPhaseEnd - rlPhaseStart FAIL ${PKG_TO_BUILD}FetchSrcAndInstallBuildDeps - if ! rlCheckRpm $PKG_TO_BUILD; then + rlPhaseStart FAIL "${PKG_TO_BUILD}"FetchSrcAndInstallBuildDeps + if ! rlCheckRpm "$PKG_TO_BUILD"; then rlRun "yum install -y $PKG_TO_BUILD ${YUM_SWITCHES}" - rlAssertRpm $PKG_TO_BUILD + rlAssertRpm "$PKG_TO_BUILD" fi - rlFetchSrcForInstalled $PKG_TO_BUILD - rlRun SRPM=$(ls -1 *.src.rpm) + rlFetchSrcForInstalled "$PKG_TO_BUILD" + rlRun SRPM="$(ls -1 ./*.src.rpm)" rlRun "rpm -ivh $SRPM" rlRun SPECDIR="$(rpm -E '%{_specdir}')" + rlRun TOPDIR="$(rpm -E '%{_topdir}')" # Note about the spec file name: When packaging rust crates, the package # is named rust-, as well as the spec file, but the rpm package # (the one we use in dnf to install and query) is named as the crate, # (without the "rust-" prefix). We have to take that into account to # find the spec: # https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/#_package_naming - rlRun "SPECNAME=$(rpm -ql $SRPM | grep .spec)" + rlRun "SPECNAME=$(rpm -ql "$SRPM" | grep .spec)" # Packages built with rust usually contains dynamic dependencies. # builddep needs to be run from the srpm, not the spec file, to be able @@ -56,6 +58,7 @@ rlJournalStart rlPhaseStartCleanup rlRun "popd" rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "rm -r $TOPDIR" 0 "Remove rpmbuild directory" rlPhaseEnd rlJournalPrintText rlJournalEnd From 6a6a8ff0ec53142f65ea1dc5fd80f1fb82ab5569 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Tue, 10 Mar 2026 19:50:25 +0100 Subject: [PATCH 08/20] rust-wasi-smoke-test: relax string matching Remove the "failed to find a pre-opened file..." string, as "error opening" is enough. The specific error message is subject to change and cause false positives. --- tests/Sanity/rust-wasi-smoke-test/runtest.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Sanity/rust-wasi-smoke-test/runtest.sh b/tests/Sanity/rust-wasi-smoke-test/runtest.sh index dfac3c0..76a319a 100755 --- a/tests/Sanity/rust-wasi-smoke-test/runtest.sh +++ b/tests/Sanity/rust-wasi-smoke-test/runtest.sh @@ -70,13 +70,12 @@ rlJournalStart rlRun "echo \"$TESTSTR\" > input.txt" # Test without preopening - rlRun "node --experimental-wasi-unstable-preview1 wasi_test_no_preopen.js 2> node.out" + rlRun "node --experimental-wasi-unstable-preview1 wasi_test_no_preopen.js |& tee node.out" rlAssertGrep "error opening" node.out - rlAssertGrep "failed to find a pre-opened file descriptor" node.out rlAssertNotExists "output.txt" # Test with pre-opened directory - rlRun "node --experimental-wasi-unstable-preview1 wasi_test_preopen.js 2> node.out" + rlRun "node --experimental-wasi-unstable-preview1 wasi_test_preopen.js |& tee node.out" rlAssertNotGrep "error opening" node.out rlAssertExists "output.txt" rlAssertGrep "$TESTSTR" output.txt From 9a016593cb3e5ecfca1e35e51bc306f14b4bcd35 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Tue, 10 Mar 2026 19:03:10 +0100 Subject: [PATCH 09/20] rpm-rebuild: remove use of yum, move to dnf --- tests/Sanity/rpm-rebuild/runtest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Sanity/rpm-rebuild/runtest.sh b/tests/Sanity/rpm-rebuild/runtest.sh index cffaf8c..5499b64 100755 --- a/tests/Sanity/rpm-rebuild/runtest.sh +++ b/tests/Sanity/rpm-rebuild/runtest.sh @@ -26,7 +26,7 @@ rlJournalStart rlPhaseStart FAIL "${PKG_TO_BUILD}"FetchSrcAndInstallBuildDeps if ! rlCheckRpm "$PKG_TO_BUILD"; then - rlRun "yum install -y $PKG_TO_BUILD ${YUM_SWITCHES}" + rlRun "dnf install -y $PKG_TO_BUILD" rlAssertRpm "$PKG_TO_BUILD" fi rlFetchSrcForInstalled "$PKG_TO_BUILD" @@ -46,7 +46,7 @@ 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 "yum-builddep -y ${SRPM} ${YUM_SWITCHES}" + rlRun "dnf builddep -y ${SRPM}" rlPhaseEnd rlPhaseStartTest From 31f14ab1464a300f040676b6cbee18e9af72f519 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Wed, 11 Mar 2026 09:56:17 +0100 Subject: [PATCH 10/20] rpm-rebulid: update requirement Replace yum-utils with the proper dnf plugins package depending on wether dnf4 or dnf5 is used --- tests/Sanity/rpm-rebuild/main.fmf | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/Sanity/rpm-rebuild/main.fmf b/tests/Sanity/rpm-rebuild/main.fmf index 47b7a61..8688b85 100644 --- a/tests/Sanity/rpm-rebuild/main.fmf +++ b/tests/Sanity/rpm-rebuild/main.fmf @@ -2,5 +2,13 @@ summary: rpmbuild package with rust description: 'Ensure that rust does not break rpmbuild' require+: - rpm-build - - yum-utils duration: 1h + +adjust: + - require+: + - dnf5-plugins + when: distro == fedora or distro > rhel-10 or distro > centos-stream-10 + + - require+: + - dnf-plugins-core + when: distro <= rhel-10 or distro <= centos-stream-10 From 58f9334383fb8fe84f79df7c0a476608859143b5 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Tue, 17 Mar 2026 19:18:23 +0100 Subject: [PATCH 11/20] Sanity/publish_to_crates_io_warns: create test Verify that cargo warns when publishng to crates.io Downstreamed version of the upstream test publish_to_crates_io_warns: https://github.com/rust-lang/cargo/blob/0.94.0/tests/testsuite/package.rs#L7741 Originally implemented in https://github.com/rust-lang/cargo/pull/16241 --- .../publish_to_crates_io_warns/main.fmf | 12 +++++ .../publish_to_crates_io_warns/runtest.sh | 51 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tests/Sanity/publish_to_crates_io_warns/main.fmf create mode 100755 tests/Sanity/publish_to_crates_io_warns/runtest.sh diff --git a/tests/Sanity/publish_to_crates_io_warns/main.fmf b/tests/Sanity/publish_to_crates_io_warns/main.fmf new file mode 100644 index 0000000..8f5a071 --- /dev/null +++ b/tests/Sanity/publish_to_crates_io_warns/main.fmf @@ -0,0 +1,12 @@ +summary: Test cargo warning when publish to crates.io +description: | + Downstreamed version of the upstream test publish_to_crates_io_warns: + https://github.com/rust-lang/cargo/blob/0.94.0/tests/testsuite/package.rs#L7741 + + Originally implemented in https://github.com/rust-lang/cargo/pull/16241 + + We need to downstream this test because koji builders don't have DNS resolving + to reach crates.io index. Hence, running this during the build will always + fail with an unexpected "Could not resolve host: index.crates.io" message. + +tier: 1 diff --git a/tests/Sanity/publish_to_crates_io_warns/runtest.sh b/tests/Sanity/publish_to_crates_io_warns/runtest.sh new file mode 100755 index 0000000..0fefc15 --- /dev/null +++ b/tests/Sanity/publish_to_crates_io_warns/runtest.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +CRATE_NAME="foo" +CRATE_VER="0.1.0" + +function generate_cargo_toml() { + local dest_dir=$1 + tee "$dest_dir/Cargo.toml" < src/main.rs" + rlRun "set -o pipefail" + rlPhaseEnd + + rlPhaseStartTest + # Publish using dry-run to avoid real operations. + rlRun "cargo publish --dry-run |& tee output.log" + # Ensure DNS was not able to resolve the remote + rlAssertGrep 'Updating crates.io index' output.log + # Verify that cargo raises the warning + rlAssertGrep 'warning: manifest' output.log + # Verify packaging is done + rlAssertGrep "Packaging $CRATE_NAME v$CRATE_VER" output.log + rlAssertGrep "Verifying $CRATE_NAME v$CRATE_VER" output.log + rlAssertGrep "Compiling $CRATE_NAME v$CRATE_VER" output.log + rlAssertGrep "Uploading $CRATE_NAME v$CRATE_VER" output.log + # Verify warning about upload cancel + rlAssertGrep 'warning: aborting upload due to dry run' output.log + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd From 78a9ec15fcb8efd2fcfa066843db3c894d7299e1 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 23 Mar 2026 11:59:53 +0100 Subject: [PATCH 12/20] net_err_suggests_fetch_with_cli: fix false positives Some test systems have catch-all DNS resolvers that point needs-proxy.invalid to loopback, resulting in a connection refused OS error instead the expected Net error. This change uses a known invalid IP to bypass any potential DNS, and also adds an extremely short timeout to enforce a Net error. Also make the test pattern matching a bit more fuzzy to avoid future false positives. Remove the standalone Cargo.toml file and integrate it into the main script to be able to parametrize it. --- .../Cargo.toml | 8 ---- .../runtest.sh | 46 ++++++++++++++++--- 2 files changed, 39 insertions(+), 15 deletions(-) delete mode 100644 tests/Sanity/net_err_suggests_fetch_with_cli/Cargo.toml diff --git a/tests/Sanity/net_err_suggests_fetch_with_cli/Cargo.toml b/tests/Sanity/net_err_suggests_fetch_with_cli/Cargo.toml deleted file mode 100644 index 24ea143..0000000 --- a/tests/Sanity/net_err_suggests_fetch_with_cli/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "foo" -version = "0.0.0" -edition = "2015" -authors = [] - -[dependencies] -foo = { git = "https://needs-proxy.invalid/git" } diff --git a/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh b/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh index 2094ae0..4acce0a 100755 --- a/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh +++ b/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh @@ -2,6 +2,34 @@ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k . /usr/share/beakerlib/beakerlib.sh || exit 1 +# For the test remote depenency, we use a TEST-NET-1 address (192.0.2.1) instead +# "needs-proxy.invalid" like upstream, to deal with potential catch-all DNS +# resolvers that redirect any invalid domain to loopback. These result in a +# connection refused (OS error) for any invalid host, but we need a network +# error for cargo to recommend using fetch-with-cli.SS +# To achieve it we use a documented test IP with a very short timeout that +# will simulate the same effect of unreachable host, causing cargo to suggest +# using the git fetch option. + +CRATE_NAME="foo" +CRATE_VER="0.0.0" +REMOTE_URL="https://192.0.2.1/git" + + +function generate_cargo_toml() { + local dest_dir=$1 + cat >> "$dest_dir/Cargo.toml" <> .cargo/config.toml < $log_file" 101 - rlAssertGrep 'Unable to update https://needs-proxy.invalid/git' "$log_file" || cat "$log_file" + rlRun "$cargo_cmd |& tee $log_file" 101 + rlAssertGrep "Unable to update $REMOTE_URL" "$log_file" || cat "$log_file" rlAssertNotGrep "net.git-fetch-with-cli" "$log_file" || cat "$log_file" rm -f "$log_file" @@ -26,18 +54,22 @@ rlJournalStart rlPhaseStartSetup declare tmp rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" - rlRun "cp Cargo.toml $tmp" + # rlRun "cp Cargo.toml $tmp" + rlRun "generate_cargo_toml $tmp" rlRun "pushd $tmp" rlRun "mkdir src && touch src/lib.rs" rlRun "set -o pipefail" - + # Cargo will try to resolve an IP that will never reply back. + # To make the test run faster, reduce the timeout to 1 second instead + # the default 30s + rlRun "export HTTP_TIMEOUT=1" rlPhaseEnd rlPhaseStartTest - rlRun "cargo check -v 2> output.log" 101 + rlRun "cargo check -v |& tee output.log" 101 # Ensure DNS was not able to resolve the remote - rlAssertGrep 'spurious network error \([0-9]+ .* remaining\): .*resolve .*needs-proxy\.invalid: .*known' output.log -E - rlAssertGrep 'Unable to update https://needs-proxy.invalid/git' output.log + rlAssertGrep 'spurious network error' output.log + rlAssertGrep "Unable to update $REMOTE_URL" output.log # Ensure cargo suggests using net.git-fetch-with-cli rlAssertGrep "net.git-fetch-with-cli" output.log From ff5a5aa59121a18dfda37750de273654871dac4c Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Mon, 20 Apr 2026 10:50:04 -0500 Subject: [PATCH 13/20] Update net_err_sugest_fetch_with_cli test The case of the error message was updated in Rust 1.95, ignore the case on this error message for backwards compatability. --- tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh b/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh index 4acce0a..ba7ed8a 100755 --- a/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh +++ b/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh @@ -44,7 +44,7 @@ function test_git-fetch-with-cli() { log_file=$(mktemp) rlRun "$cargo_cmd |& tee $log_file" 101 - rlAssertGrep "Unable to update $REMOTE_URL" "$log_file" || cat "$log_file" + rlAssertGrep "unable to update $REMOTE_URL" "$log_file" -i || cat "$log_file" rlAssertNotGrep "net.git-fetch-with-cli" "$log_file" || cat "$log_file" rm -f "$log_file" @@ -69,7 +69,7 @@ rlJournalStart rlRun "cargo check -v |& tee output.log" 101 # Ensure DNS was not able to resolve the remote rlAssertGrep 'spurious network error' output.log - rlAssertGrep "Unable to update $REMOTE_URL" output.log + rlAssertGrep "unable to update $REMOTE_URL" output.log -i # Ensure cargo suggests using net.git-fetch-with-cli rlAssertGrep "net.git-fetch-with-cli" output.log From cca2ad09efbec0813316f3b21e77ee7c578e46d9 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 11 Jun 2026 17:12:22 +0200 Subject: [PATCH 14/20] Add regression test for Cargo SCP-like Git submodule URLs Add downstreamed version of upstream test git::dep_with_scp_like_submodule_url to verify that Cargo correctly handles SCP-like URLs (git@host:path format) in Git submodules and preserves them in error messages. This is a regression test for https://github.com/rust-lang/cargo/pull/16727 The test is enabled on distributions with Rust >= 1.96.0. Upstream reference: https://github.com/rust-lang/cargo/blob/master/tests/testsuite/git.rs --- .pre-commit-config.yaml | 4 +- .../cargo-git-submodule-scp-url/main.fmf | 31 +++++ .../cargo-git-submodule-scp-url/runtest.sh | 122 ++++++++++++++++++ 3 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 tests/Regression/cargo-git-submodule-scp-url/main.fmf create mode 100755 tests/Regression/cargo-git-submodule-scp-url/runtest.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8b17cbf..a965ddd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,6 +10,6 @@ repos: args: [--unsafe] - id: check-added-large-files - repo: https://github.com/teemtee/tmt.git - rev: "1.31.0" + rev: "1.75.0" hooks: - id: tmt-lint diff --git a/tests/Regression/cargo-git-submodule-scp-url/main.fmf b/tests/Regression/cargo-git-submodule-scp-url/main.fmf new file mode 100644 index 0000000..1f81f1b --- /dev/null +++ b/tests/Regression/cargo-git-submodule-scp-url/main.fmf @@ -0,0 +1,31 @@ +summary: Test cargo handles SCP-like Git submodule URLs +description: | + Downstreamed version of the upstream test git::dep_with_scp_like_submodule_url + https://github.com/rust-lang/cargo/blob/master/tests/testsuite/git.rs + + This test verifies that Cargo correctly handles Git submodules with SCP-like + URLs (git@github.com:foo/bar.git format) and preserves the original URL format + in error messages. + + This is a regression test for https://github.com/rust-lang/cargo/pull/16727 + + The test uses git-fetch-with-cli to enable SSH support via /usr/bin/git, which + works even on RHEL/CentOS where Cargo is built without libssh2 (rhbz#1732949). + + The test is enabled on distributions with Rust >= 1.96.0. + +tier: 1 +require+: + - git +adjust+: + - enabled: false + when: distro ~< rhel-8.10 + continue: false + + - enabled: false + when: distro ~< rhel-9.9 + continue: false + + - enabled: false + when: distro ~< rhel-10.3 + continue: false diff --git a/tests/Regression/cargo-git-submodule-scp-url/runtest.sh b/tests/Regression/cargo-git-submodule-scp-url/runtest.sh new file mode 100755 index 0000000..b55259f --- /dev/null +++ b/tests/Regression/cargo-git-submodule-scp-url/runtest.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# +# Downstreamed adaptation of the upstream Cargo test: +# git::dep_with_scp_like_submodule_url +# https://github.com/rust-lang/cargo/blob/master/tests/testsuite/git.rs +# +# REGRESSION TEST for https://github.com/rust-lang/cargo/pull/16727 +# +# This test verifies that Cargo correctly handles SCP-like URLs (git@host:path) +# in git submodules and preserves them in error messages. +# +# The test uses --config net.git-fetch-with-cli=true to delegate Git operations +# to /usr/bin/git, which has SSH support even on RHEL/CentOS where Cargo is built +# without libssh2 (rhbz#1732949). +# +# Expected behavior WITH the PR #16727 fix (Rust >= 1.96.0): +# - Cargo accepts SCP-like URLs in .gitmodules +# - Attempts to fetch the submodule via /usr/bin/git (with SSH support) +# - On failure, shows: "failed to fetch submodule `submod` from git@github.com:foo/bar.git" +# +# Expected behavior WITHOUT the fix (Rust < 1.96.0): +# - Cargo rejects SCP-like URLs as invalid +# - Shows: "invalid url `git@github.com:foo/bar.git`: relative URL without a base" +# - This test will FAIL (expected for a regression test before the fix is applied) +# +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +CRATE_NAME="foo" +CRATE_VER="0.5.0" +DEP1_NAME="dep1" +DEP2_NAME="dep2" +SCP_URL="git@github.com:foo/bar.git" + +rlJournalStart + rlPhaseStartSetup + declare tmp + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd $tmp" + + # Create dep2 git repository (will be used as submodule) + rlRun "mkdir $DEP2_NAME && cd $DEP2_NAME" + rlRun "git init" + rlRun "echo 'pub fn dep2() {}' > lib.rs" + rlRun "git add lib.rs" + rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Initial commit'" + rlRun "DEP2_PATH=\$(pwd)" + rlRun "cd .." + + # Create dep1 git repository with Cargo.toml + rlRun "mkdir $DEP1_NAME && cd $DEP1_NAME" + rlRun "git init" + rlRun "mkdir src" + rlRun "echo 'pub fn dep() {}' > src/lib.rs" + cat > Cargo.toml < .gitmodules < Cargo.toml <&1 | tee output.log" 101 + + # Verify the exact error message that indicates PR #16727 is applied + # The test expects Cargo to: + # 1. Show it's updating the git submodule with the SCP URL + # 2. Fail with a specific message that includes the SCP URL + rlAssertGrep "git submodule.*$SCP_URL" output.log -Ei + rlAssertGrep "failed to fetch submodule.*submod.*from.*$SCP_URL" output.log -Ei + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -rf $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd From 875db0af2d3768fc2d3649f1911479a85df2f6f6 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Wed, 24 Jun 2026 08:45:55 +0200 Subject: [PATCH 15/20] net_err_suggests_fetch_with_cli: Try to fix timeouts once again Do not rely on negative matches such as "cargo output does not suggest using fetch_with_cli". Instead, verify that cargo actually calls git fetch on the remote repo. Use timeout to cover systems where git ignores the http timeout. Increase test timeout to 15m --- .../net_err_suggests_fetch_with_cli/main.fmf | 1 + .../runtest.sh | 50 +++++++++---------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/tests/Sanity/net_err_suggests_fetch_with_cli/main.fmf b/tests/Sanity/net_err_suggests_fetch_with_cli/main.fmf index 0de32b5..8d6c70a 100644 --- a/tests/Sanity/net_err_suggests_fetch_with_cli/main.fmf +++ b/tests/Sanity/net_err_suggests_fetch_with_cli/main.fmf @@ -13,3 +13,4 @@ description: | support libssh2 in RHEL/CentOS. tier: 1 +duration: 15m diff --git a/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh b/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh index ba7ed8a..bca1cc5 100755 --- a/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh +++ b/tests/Sanity/net_err_suggests_fetch_with_cli/runtest.sh @@ -2,20 +2,17 @@ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k . /usr/share/beakerlib/beakerlib.sh || exit 1 -# For the test remote depenency, we use a TEST-NET-1 address (192.0.2.1) instead -# "needs-proxy.invalid" like upstream, to deal with potential catch-all DNS -# resolvers that redirect any invalid domain to loopback. These result in a -# connection refused (OS error) for any invalid host, but we need a network -# error for cargo to recommend using fetch-with-cli.SS -# To achieve it we use a documented test IP with a very short timeout that -# will simulate the same effect of unreachable host, causing cargo to suggest -# using the git fetch option. +# Use TEST-NET-1 address (192.0.2.1) instead of "needs-proxy.invalid" to avoid +# corporate DNS resolvers that redirect invalid domains to loopback, which would +# cause OS errors instead of network errors. Cargo only suggests git-fetch-with-cli +# for network errors, not OS errors. CRATE_NAME="foo" CRATE_VER="0.0.0" REMOTE_URL="https://192.0.2.1/git" +# Generate Cargo.toml with a git dependency pointing to an unreachable URL function generate_cargo_toml() { local dest_dir=$1 cat >> "$dest_dir/Cargo.toml" <> .cargo/config.toml < Date: Thu, 2 Jul 2026 17:59:45 +0200 Subject: [PATCH 16/20] 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 --- tests/Sanity/rpm-rebuild/main.fmf | 2 +- tests/Sanity/rpm-rebuild/runtest.sh | 64 +++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 4 deletions(-) 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 From 1ce23fd6bd0f20f4445482bc771d94a87285cbf0 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Wed, 22 Jul 2026 16:06:07 +0200 Subject: [PATCH 17/20] rpm-rebuild/stratisd: limit paralellism Newer versions of stratisd have an obscene memory consumption, reaching peaks of >5GiB in some rustc calls. This commit adds logic to calculate a ratio of MiB per core in the system running the test, then apply that number of cores to RPM_BUILD_NCPUS. Start using 4GiB for building stratisd. Older versions (RHEL 9 and older) are not affected --- tests/Sanity/rpm-rebuild/runtest.sh | 35 ++++++++++++++++++++++++--- tests/Sanity/rpm-rebuild/stratisd.fmf | 8 +++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/tests/Sanity/rpm-rebuild/runtest.sh b/tests/Sanity/rpm-rebuild/runtest.sh index f3537b0..261766f 100755 --- a/tests/Sanity/rpm-rebuild/runtest.sh +++ b/tests/Sanity/rpm-rebuild/runtest.sh @@ -2,6 +2,10 @@ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k . /usr/share/beakerlib/beakerlib.sh || exit 1 +# Available environment variables to configure +# PKG_TO_BUILD (mandatory): rpm packages to run rpmbuild on. +# MB_PER_CPU (optional): How many MB of ram per number of cpus should have. + # Analyze build failure and determine if it's a resource issue or real failure analyze_build_failure() { local logfile="$1" @@ -38,6 +42,25 @@ analyze_build_failure() { fi } +function get_memory_limited_cores() { + # Return the number of cores in a way that each core has access to at least + # the specified MB of physical RAM (default 1024MB). + # Swap is not counted to avoid severe performance degradation. + local mb_ram="$(free -m | awk '/Mem:/ {print $2}')" + local cores="$(nproc)" + local mb_per_core="${1:-1024}" + + local max_cores=$((mb_ram / mb_per_core)) + + if [ "$max_cores" -le "0" ]; then + echo "1" + elif [ "$max_cores" -lt "$cores" ]; then + echo "$max_cores" + else + echo "$cores" + fi +} + PACKAGE="$(rpm -qf "$(which rustc)")" rlJournalStart @@ -59,6 +82,12 @@ rlJournalStart rlDie "The package must be passed over PKG_TO_BUILD environment variable." fi + if [[ -n "${MB_PER_CPU}" ]]; then + MAX_CPUS=$(get_memory_limited_cores "$MB_PER_CPU") + rlLog "Running rpmbuild with max cores: $MAX_CPUS" + export RPM_BUILD_NCPUS="$MAX_CPUS" + fi + # Log basic system resources. If we start seeing failures due to disk # out of space, timeouts, or OOMs this will help identifying where # the issue might be. @@ -95,13 +124,13 @@ rlJournalStart rlPhaseStartTest set -o pipefail LOGFILE="${SRPM}_rpmbuild.log" - BUILD_CMD="rpmbuild -bb ${SPECDIR}/${SPECNAME}" + BUILD_CMD=(rpmbuild -bb "${SPECDIR}"/"${SPECNAME}") # Log the command being executed (for visibility in test output) - rlLog "Executing: $BUILD_CMD" + rlLog "Executing: ${BUILD_CMD[*]}" # Execute rpmbuild silently, saving complete log to file - if $BUILD_CMD &> "$LOGFILE"; then + if "${BUILD_CMD[@]}" &> "$LOGFILE"; then rlPass "rpmbuild succeeded" else # Analyze cause of failure diff --git a/tests/Sanity/rpm-rebuild/stratisd.fmf b/tests/Sanity/rpm-rebuild/stratisd.fmf index b3698fe..e01d5b4 100644 --- a/tests/Sanity/rpm-rebuild/stratisd.fmf +++ b/tests/Sanity/rpm-rebuild/stratisd.fmf @@ -3,7 +3,8 @@ require+: - stratisd environment+: PKG_TO_BUILD: "stratisd" -duration: 2h + MB_PER_CPU: "4096" +duration: 3h tier: 1 tag: @@ -15,3 +16,8 @@ adjust+: - enabled: false when: distro == rhel-8 and distro >= rhel-8.9 continue: false + + # Older stratisd packages (RHEL 9 and older) are much less RAM demanding + - environment+: + MB_PER_CPU: 2048 + when: distro < rhel-10 From b3bb3e8b771d55998232d4da9a8ab1ac6e0cd028 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 10 Aug 2026 10:04:22 +0200 Subject: [PATCH 18/20] shadow-stack-smoke test Rust will start marking all x86_64 code with SHSTK for CET support in RHEL, CentOS and Fedora, by default and without need to pass any flags. This new test verifies that rust code always contain the SHSTK mark, testing both binary and cdylib cases --- tests/Sanity/shadow-stack-smoke/hello.rs | 3 ++ tests/Sanity/shadow-stack-smoke/main.fmf | 27 +++++++++++++++ tests/Sanity/shadow-stack-smoke/runtest.sh | 40 ++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 tests/Sanity/shadow-stack-smoke/hello.rs create mode 100644 tests/Sanity/shadow-stack-smoke/main.fmf create mode 100755 tests/Sanity/shadow-stack-smoke/runtest.sh diff --git a/tests/Sanity/shadow-stack-smoke/hello.rs b/tests/Sanity/shadow-stack-smoke/hello.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/tests/Sanity/shadow-stack-smoke/hello.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/tests/Sanity/shadow-stack-smoke/main.fmf b/tests/Sanity/shadow-stack-smoke/main.fmf new file mode 100644 index 0000000..565ad68 --- /dev/null +++ b/tests/Sanity/shadow-stack-smoke/main.fmf @@ -0,0 +1,27 @@ +summary: Verify rustc enables Shadow Stack by default +description: | + rustc must emit the SHSTK GNU property note on binaries and shared + libraries by default for x86_64-unknown-linux-gnu, without any extra + flags, so glibc can enable Intel CET Shadow Stack for them. +duration: 5m +tier: 1 +tag+: + - CI-Tier-1 +link+: + - verifies: https://redhat.atlassian.net/browse/RHEL-213919 + - verifies: https://redhat.atlassian.net/browse/RHEL-223924 + - relates: https://fedoraproject.org/wiki/Changes/ShadowStack +adjust+: + - when: arch != x86_64 + enabled: false + continue: false + because: Shadow Stack (Intel CET) is x86_64 only + + # Shadow stack enabled only in RHEL 9.9+ and 10.3+ and F45+ + # Centos Stream is RHEL upstream, available always. + # Not supported in RHEL-8 and older + - when: distro == rhel-9 and distro < rhel-9.9 or + distro == rhel-10 and distro < rhel-10.3 or + distro == fedora and distro < fedora-45 or + distro <= rhel-8 + enabled: false diff --git a/tests/Sanity/shadow-stack-smoke/runtest.sh b/tests/Sanity/shadow-stack-smoke/runtest.sh new file mode 100755 index 0000000..103a7a2 --- /dev/null +++ b/tests/Sanity/shadow-stack-smoke/runtest.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="$(rpm -qf $(which rustc))" +PACKAGES=${PACKAGES:-$PACKAGE} + +# rustc must mark x86_64-unknown-linux-gnu output as Shadow Stack (SHSTK) +# compatible by default, without any extra flags: +# https://fedoraproject.org/wiki/Changes/ShadowStack +# https://issues.redhat.com/browse/RHEL-213919 +TARGET="x86_64-unknown-linux-gnu" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "cp hello.rs $tmp" + rlRun "pushd $tmp" + rlRun "set -o pipefail" + rlPhaseEnd + + rlPhaseStartTest "binary is marked SHSTK by default" + rlRun "rustc --target $TARGET hello.rs -o hello" + rlRun "./hello | grep 'Hello, world!'" + rlRun "readelf -n hello > hello-notes.out" + rlAssertGrep "SHSTK" hello-notes.out + rlPhaseEnd + + rlPhaseStartTest "cdylib is marked SHSTK by default" + rlRun "rustc --target $TARGET --crate-type cdylib hello.rs -o libhello.so" + rlRun "readelf -n libhello.so > libhello-notes.out" + rlAssertGrep "SHSTK" libhello-notes.out + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd From bc84e882082324fb9a131e90438224e755de1840 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Tue, 16 Sep 2025 12:53:23 +0200 Subject: [PATCH 19/20] Update rpmmacros test Starting with rhel 9.8 we are using the same rpmmacros format as Fedora and RHEL 10, while RHEL older than 9.8 and 8 are using the "legacy" format which pass-through the arguments to the cargo macros. --- tests/Sanity/rust-rpmmacros/runtest.sh | 8 +++++++- tests/Sanity/rust-rpmmacros/rust-rpmtest.spec | 12 +++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/Sanity/rust-rpmmacros/runtest.sh b/tests/Sanity/rust-rpmmacros/runtest.sh index bfca5d4..e5312c5 100755 --- a/tests/Sanity/rust-rpmmacros/runtest.sh +++ b/tests/Sanity/rust-rpmmacros/runtest.sh @@ -36,7 +36,13 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest - rlRun "rpmbuild --define '_topdir $tmp' -ba $tmp/SPECS/$SPECFILE" + # Rpmmacros depending on RHEL version + # https://issues.redhat.com/browse/RHEL-104777 + LEGACY_MACROS="" + if rlIsRHEL 8 || rlIsRHEL "<9.8"; then + LEGACY_MACROS="--with legacy_rpmmacros" + fi + rlRun "rpmbuild --define '_topdir $tmp' -ba ${LEGACY_MACROS} $tmp/SPECS/$SPECFILE" rlPhaseEnd rlPhaseStartCleanup diff --git a/tests/Sanity/rust-rpmmacros/rust-rpmtest.spec b/tests/Sanity/rust-rpmmacros/rust-rpmtest.spec index 34d87a0..d97088c 100644 --- a/tests/Sanity/rust-rpmmacros/rust-rpmtest.spec +++ b/tests/Sanity/rust-rpmmacros/rust-rpmtest.spec @@ -1,5 +1,8 @@ %global crate rpmtest +# Build condition for legacy RPM macros (disabled by default) +%bcond_with legacy_rpmmacros + Name: rust-rpmtest Version: 0.1.0 Release: 1 @@ -38,9 +41,8 @@ Summary: %{summary} %endif %build -# cargo_build/install/test don't use -n/-a/-f in rhel/centos < 10 to avoid breaking -# existing packages using arguments. -%if 0%{?rhel} && 0%{?rhel} < 10 +# Use legacy cargo macros when requested +%if %{with legacy_rpmmacros} %cargo_build --all-features %else %cargo_build -a @@ -51,14 +53,14 @@ Summary: %{summary} %{?cargo_license_summary:%cargo_license_summary -a} %install -%if 0%{?rhel} && 0%{?rhel} < 10 +%if %{with legacy_rpmmacros} %cargo_install --all-features %else %cargo_install -a %endif %check -%%if 0%{?rhel} && 0%{?rhel} < 10 +%if %{with legacy_rpmmacros} %cargo_test --all-features %else %cargo_test -a From 804bb6656719e3084b8a997ae61fb9b91fc96b19 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 24 Aug 2026 08:52:35 +0200 Subject: [PATCH 20/20] shadow-stack-smoke: extend coverage to fedora 43 and newer --- tests/Sanity/shadow-stack-smoke/main.fmf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Sanity/shadow-stack-smoke/main.fmf b/tests/Sanity/shadow-stack-smoke/main.fmf index 565ad68..ed48a81 100644 --- a/tests/Sanity/shadow-stack-smoke/main.fmf +++ b/tests/Sanity/shadow-stack-smoke/main.fmf @@ -22,6 +22,6 @@ adjust+: # Not supported in RHEL-8 and older - when: distro == rhel-9 and distro < rhel-9.9 or distro == rhel-10 and distro < rhel-10.3 or - distro == fedora and distro < fedora-45 or + distro == fedora and distro < fedora-43 or distro <= rhel-8 enabled: false