public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/rust] main: rust-profiler: replace expect file with awk-based line-matching
@ 2026-11-20 7:59 Jesus Checa Hidalgo
0 siblings, 0 replies; only message in thread
From: Jesus Checa Hidalgo @ 2026-11-20 7:59 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : tests/rust
Branch : main
Commit : 8a384ba2e20637560d3542f1bfdba8654a58684f
Author : Jesus Checa Hidalgo <jchecahi@redhat.com>
Date : 2026-11-17T11:49:58+01:00
Stats : +16/-17 in 2 file(s)
URL : https://src.fedoraproject.org/tests/rust/c/8a384ba2e20637560d3542f1bfdba8654a58684f?branch=main
Log:
rust-profiler: replace expect file with awk-based line-matching
Starting 1.100 coverage spans are changed and the exp file no longer
match.
Rewriting the test to use a table of line number and hit count for
the relevant lines (dead code, loop iteration and body) rather than
a matching 1:1 diff should keep the test compatible with pre and post
1.100 rust, as well as potential changes in future updates.
---
diff --git a/tests/Sanity/rust-profiler/coverage.exp b/tests/Sanity/rust-profiler/coverage.exp
deleted file mode 100644
index b24c031..0000000
--- a/tests/Sanity/rust-profiler/coverage.exp
+++ /dev/null
@@ -1,11 +0,0 @@
- 1| 1|fn main() {
- 2| 1| let mut sum: u32 = 0;
- 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/runtest.sh b/tests/Sanity/rust-profiler/runtest.sh
index d247350..7dca547 100755
--- a/tests/Sanity/rust-profiler/runtest.sh
+++ b/tests/Sanity/rust-profiler/runtest.sh
@@ -9,7 +9,7 @@ rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
- rlRun "cp main.rs coverage.exp $tmp"
+ rlRun "cp main.rs $tmp"
rlRun "pushd $tmp"
rlRun "set -o pipefail"
rlPhaseEnd
@@ -19,11 +19,21 @@ rlJournalStart
rlRun "LLVM_PROFILE_FILE='testprof.profraw' ./main"
# Convert and inspect the profile data
rlRun "llvm-profdata merge -sparse testprof.profraw -o testprof.profdata"
- rlRun "llvm-cov show main -instr-profile=testprof.profdata > coverage.out"
- # Remove the trailing newline from dumping llvm-cov output into the file.
- rlRun "truncate -s -1 coverage.out"
- # Check coverage reports as expected
- rlRun "diff coverage.exp coverage.out"
+ rlRun "llvm-cov show main -instr-profile=testprof.profdata > coverage.out"
+ rlRun "cat coverage.out"
+
+ # main.rs line -> expected execution count
+ declare -A EXPECTED=(
+ [4]=10 # while let Some(i) = iter.next() 9 iterations + final None
+ [5]=9 # sum += i; runs once per Some(i)
+ [7]=1 # if false { condition is checked once...
+ [8]=0 # println!("unreachable"); ...but the body never runs
+ )
+
+ for line in "${!EXPECTED[@]}"; do
+ count=$(awk -F'|' -v ln="$line" '{gsub(/ /,"",$1); if ($1==ln){gsub(/ /,"",$2); print $2}}' coverage.out)
+ rlAssertEquals "line $line executed ${EXPECTED[$line]} time(s)" "$count" "${EXPECTED[$line]}"
+ done
rlPhaseEnd
rlPhaseStartTest "Test PGO build"
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-20 7:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 7:59 [tests/rust] main: rust-profiler: replace expect file with awk-based line-matching 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