public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Jesus Checa Hidalgo <jchecahi@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/rust] main: rust-profiler: replace expect file with awk-based line-matching
Date: Fri, 20 Nov 2026 07:59:20 GMT	[thread overview]
Message-ID: <179516156021.1.18256680145097985385.tests-rust-8a384ba2e206@fedoraproject.org> (raw)

            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"

                 reply	other threads:[~2026-11-20  7:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179516156021.1.18256680145097985385.tests-rust-8a384ba2e206@fedoraproject.org \
    --to=jchecahi@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox