Compare commits

..

19 commits

Author SHA1 Message Date
Jesus Checa Hidalgo
804bb66567 shadow-stack-smoke: extend coverage to fedora 43 and newer 2026-08-24 08:52:35 +02:00
Jesus Checa Hidalgo
bc84e88208 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.
2026-08-14 12:12:59 +02:00
Jesus Checa Hidalgo
b3bb3e8b77 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
2026-08-14 11:49:56 +02:00
Jesus Checa Hidalgo
1ce23fd6bd 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
2026-08-14 11:49:52 +02:00
Jesus Checa Hidalgo
ebef0ebe6c 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
2026-08-14 11:49:41 +02:00
Jesus Checa Hidalgo
875db0af2d 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
2026-06-24 08:45:55 +02:00
Jesus Checa Hidalgo
cca2ad09ef 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
2026-06-15 16:47:51 +02:00
Paul Murphy
ff5a5aa591 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.
2026-04-20 11:06:35 -05:00
Jesus Checa Hidalgo
78a9ec15fc 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.
2026-04-07 07:48:50 +00:00
Jesus Checa Hidalgo
58f9334383 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
2026-03-18 17:48:53 +01:00
Jesus Checa Hidalgo
31f14ab146 rpm-rebulid: update requirement
Replace yum-utils with the proper dnf plugins package depending on
wether dnf4 or dnf5 is used
2026-03-11 09:56:17 +01:00
Jesus Checa Hidalgo
9a016593cb rpm-rebuild: remove use of yum, move to dnf 2026-03-10 19:32:47 +00:00
Jesus Checa Hidalgo
6a6a8ff0ec 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.
2026-03-10 19:50:25 +01:00
Jesus Checa Hidalgo
0bb39d1c34 Improve rpm-rebuild test
Cleanup rpmbuild directory after test.
Minor code cleaning.
2026-02-04 15:39:16 +01:00
Paul Murphy
e071728eed 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
2026-02-03 15:35:46 -06:00
Jesus Checa Hidalgo
1e333e6189 rust-wasi-smoke-test: Fix warning in installed requirements assertion 2026-01-28 12:56:18 +01:00
Jesus Checa Hidalgo
11e16f99f1 Add Sanity/net_err_suggests_fetch_with_cli test.
Downstreamed version of the upstream test net_fetch_with_cli:
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.
2025-11-17 18:34:13 +01:00
Jesus Checa Hidalgo
c64c527829 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.
2025-01-10 18:45:50 +01:00
Jesus Checa Hidalgo
1716d90a4a rust-rpmmacros: Improve test functionality
* Use arguments in cargo_build/install/test/license rpmmacros
* RHEL and CentOS 10 behaves like Fedora.
2025-01-10 10:31:38 +01:00
19 changed files with 563 additions and 44 deletions

View file

@ -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

View file

@ -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

View file

@ -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 <<EOF
[package]
name = "$DEP1_NAME"
version = "$CRATE_VER"
edition = "2015"
EOF
rlRun "git add ."
rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Initial commit'"
# Manually add dep2 as submodule to avoid file:// protocol restrictions
# Use git -c to allow file:// protocol temporarily
rlRun "git -c protocol.file.allow=always submodule add \$DEP2_PATH submod"
rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Add submodule'"
# Change .gitmodules to use SCP-like URL
cat > .gitmodules <<EOF
[submodule "submod"]
path = submod
url = $SCP_URL
EOF
rlRun "git add .gitmodules"
rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Change to SCP URL'"
rlRun "DEP1_PATH=\$(pwd)"
rlRun "cd .."
# Create main project that depends on dep1
rlRun "mkdir $CRATE_NAME && cd $CRATE_NAME"
rlRun "mkdir src"
rlRun "touch src/lib.rs"
# Create Cargo.toml with proper variable expansion
rlRun "cat > Cargo.toml <<CARGO_EOF
[package]
name = \"$CRATE_NAME\"
version = \"$CRATE_VER\"
edition = \"2015\"
[dependencies.$DEP1_NAME]
git = \"file://\$DEP1_PATH\"
CARGO_EOF
"
rlPhaseEnd
rlPhaseStartTest
rlRun "set -o pipefail"
# Set GIT_SSH_COMMAND to match upstream test behavior
# This ensures Git attempts SSH connection (even though it will fail)
rlRun "export GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no -o LogLevel=ERROR'"
# Execute cargo fetch - should fail with exit code 101
# Let cargo invoke git cli, as in RHEL it doesn't have libssh2 support
rlRun "cargo --config net.git-fetch-with-cli=true fetch -v 2>&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

View file

@ -0,0 +1,16 @@
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
duration: 15m

View file

@ -0,0 +1,87 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
# 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" <<EOF
[package]
name = "$CRATE_NAME"
version = "$CRATE_VER"
edition = "2015"
authors = []
[dependencies]
foo = { git = "$REMOTE_URL" }
EOF
}
# Generate .cargo/config.toml enabling git-fetch-with-cli
function generate_cargo_conffile() {
mkdir ".cargo"
cat >> .cargo/config.toml <<EOF
[net]
git-fetch-with-cli = true
EOF
}
# Verify that cargo invokes system git when git-fetch-with-cli is enabled.
# Accepts exit codes 101 (cargo error) and 124 (timeout), as git may hang
# on systems where it doesn't respect timeout configuration.
function test_git-fetch-with-cli() {
local cargo_cmd="$1"
local log_file
log_file=$(mktemp)
rlRun "$cargo_cmd |& tee $log_file" "101, 124"
rlAssertGrep "Updating.*$REMOTE_URL" "$log_file" -E || cat "$log_file"
# Verify cargo executed git (not just suggested it)
rlAssertGrep "git fetch.*$REMOTE_URL" "$log_file" -E || 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 "generate_cargo_toml $tmp"
rlRun "pushd $tmp"
rlRun "mkdir src && touch src/lib.rs"
rlRun "set -o pipefail"
# Reduce timeout for cargo's built-in HTTP client (used without git-fetch-with-cli)
rlRun "export HTTP_TIMEOUT=1"
rlPhaseEnd
rlPhaseStartTest
# Test 1: Verify cargo suggests git-fetch-with-cli on network errors
rlRun "cargo check -v |& tee output.log" 101
rlAssertGrep "Unable to update $REMOTE_URL" output.log -i
rlAssertGrep "net.git-fetch-with-cli" output.log
# Test 2-4: Verify cargo uses system git when git-fetch-with-cli is enabled
# (via environment variable, CLI flag, and config file respectively)
test_git-fetch-with-cli "CARGO_NET_GIT_FETCH_WITH_CLI=true timeout 5 cargo check -v"
test_git-fetch-with-cli "timeout 5 cargo --config net.git-fetch-with-cli=true check -v"
generate_cargo_conffile
test_git-fetch-with-cli "timeout 5 cargo check -v"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd

View file

@ -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

View file

@ -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" <<EOF
[package]
name = "$CRATE_NAME"
version = "$CRATE_VER"
description = "$CRATE_NAME"
edition = "2015"
EOF
}
rlJournalStart
rlPhaseStartSetup
declare tmp
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "generate_cargo_toml $tmp"
rlRun "pushd $tmp"
rlRun "mkdir src"
rlRun "echo 'fn main () {}' > 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

View file

@ -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

View file

@ -2,60 +2,150 @@
# 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))"
# 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"
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
}
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
rlPhaseStartSetup
rlAssertRpm $PACKAGE || rlDie "rustc not found. Aborting testcase..."
# 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"
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
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.
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
rlRun "yum install -y $PKG_TO_BUILD ${YUM_SWITCHES}"
rlAssertRpm $PKG_TO_BUILD
rlPhaseStart FAIL "${PKG_TO_BUILD}"FetchSrcAndInstallBuildDeps
if ! rlCheckRpm "$PKG_TO_BUILD"; then
rlRun "dnf install -y $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-<crate>, 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
# to generate them:
# https://fedoraproject.org/wiki/Changes/DynamicBuildRequires#rpmbuild
rlRun "yum-builddep -y ${SRPM} ${YUM_SWITCHES}"
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
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlRun "rm -r $TOPDIR" 0 "Remove rpmbuild directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -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

View file

@ -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|}

View file

@ -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);

View file

@ -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

View file

@ -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,14 +41,28 @@ Summary: %{summary}
%endif
%build
%cargo_build
# Use legacy cargo macros when requested
%if %{with legacy_rpmmacros}
%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 %{with legacy_rpmmacros}
%cargo_install --all-features
%else
%cargo_install -a
%endif
%check
%cargo_test
%if %{with legacy_rpmmacros}
%cargo_test --all-features
%else
%cargo_test -a
%endif
%{buildroot}/%{_bindir}/rpmtest | grep -E "The answer is [0-9]+"

View file

@ -11,7 +11,7 @@ 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
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

View file

@ -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.
@ -68,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

View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View file

@ -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-43 or
distro <= rhel-8
enabled: false

View file

@ -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