public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Deepesh.Varatharajan@windriver.com
To: openembedded-core@lists.openembedded.org
Cc: Sundeep.Kokkonda@windriver.com, Deepesh.Varatharajan@windriver.com
Subject: [PATCH] rust: Fix flaky assertions in oneshot tests
Date: Wed, 25 Mar 2026 02:05:43 -0700	[thread overview]
Message-ID: <20260325090543.3489042-1-Deepesh.Varatharajan@windriver.com> (raw)

From: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>

Fixes [YOCTO #16199]

Backport three commits from upstream to fix flaky assertions in oneshot tests

https://github.com/rust-lang/rust/commit/6970849fee93900b6eb28a64cf957157a9fb51b3
https://github.com/rust-lang/rust/commit/dab350a3ed7691201f6752c4375e8e6ab40b58b9
https://github.com/rust-lang/rust/commit/d02743e2fd7433ba2320fc85421a8a5927235b65

Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
---
 ...ix-flaky-assertions-in-oneshot-tests.patch | 72 +++++++++++++++++++
 meta/recipes-devtools/rust/rust-source.inc    |  1 +
 2 files changed, 73 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/files/0001-Fix-flaky-assertions-in-oneshot-tests.patch

diff --git a/meta/recipes-devtools/rust/files/0001-Fix-flaky-assertions-in-oneshot-tests.patch b/meta/recipes-devtools/rust/files/0001-Fix-flaky-assertions-in-oneshot-tests.patch
new file mode 100644
index 0000000000..be0e85dfbb
--- /dev/null
+++ b/meta/recipes-devtools/rust/files/0001-Fix-flaky-assertions-in-oneshot-tests.patch
@@ -0,0 +1,72 @@
+Backport three commits from upstream to fix flaky assertions in oneshot tests
+
+Upstream-Status: Backport [https://github.com/rust-lang/rust/commit/6970849fee93900b6eb28a64cf957157a9fb51b3]
+Upstream-Status: Backport [https://github.com/rust-lang/rust/commit/dab350a3ed7691201f6752c4375e8e6ab40b58b9]
+Upstream-Status: Backport [https://github.com/rust-lang/rust/commit/d02743e2fd7433ba2320fc85421a8a5927235b65]
+
+Signed-off-by: Deepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
+
+diff --git a/library/std/tests/sync/oneshot.rs b/library/std/tests/sync/oneshot.rs
+index 6a87c72..d8f3cd7 100644
+--- a/library/std/tests/sync/oneshot.rs
++++ b/library/std/tests/sync/oneshot.rs
+@@ -89,15 +89,15 @@ fn send_before_recv_timeout() {
+ 
+     assert!(sender.send(22i128).is_ok());
+ 
+-    let start = Instant::now();
+-
+     let timeout = Duration::from_secs(1);
+     match receiver.recv_timeout(timeout) {
+         Ok(22) => {}
+         _ => panic!("expected Ok(22)"),
+     }
+ 
+-    assert!(start.elapsed() < timeout);
++    // FIXME(#152648): There previously was a timing assertion here.
++    // This was removed, because under load there's no guarantee that the main thread is
++    // scheduled and run before `timeout` expires
+ }
+ 
+ #[test]
+@@ -127,6 +127,7 @@ fn recv_before_send() {
+ }
+ 
+ #[test]
++#[ignore = "Inherently flaky and has caused several CI failures"]
+ fn recv_timeout_before_send() {
+     let (sender, receiver) = oneshot::channel();
+ 
+@@ -135,6 +136,8 @@ fn recv_timeout_before_send() {
+         sender.send(99u128).unwrap();
+     });
+ 
++    // FIXME(#152145): Under load, there's no guarantee that thread `t` has
++    // ever been scheduled and run before this timeout expires.
+     match receiver.recv_timeout(Duration::from_secs(1)) {
+         Ok(99) => {}
+         _ => panic!("expected Ok(99)"),
+@@ -240,7 +243,9 @@ fn recv_deadline_passed() {
+     }
+ 
+     assert!(start.elapsed() >= timeout);
+-    assert!(start.elapsed() < timeout * 3);
++    // FIXME(#152878): An upper-bound assertion on the elapsed time was removed,
++    // because CI runners can starve individual threads for a surprisingly long
++    // time, leading to flaky failures.
+ }
+ 
+ #[test]
+@@ -253,8 +258,11 @@ fn recv_time_passed() {
+         Err(RecvTimeoutError::Timeout(_)) => {}
+         _ => panic!("expected timeout error"),
+     }
++
+     assert!(start.elapsed() >= timeout);
+-    assert!(start.elapsed() < timeout * 3);
++    // FIXME(#152878): An upper-bound assertion on the elapsed time was removed,
++    // because CI runners can starve individual threads for a surprisingly long
++    // time, leading to flaky failures.
+ }
+ 
+ #[test]
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index 47a0154cdc..4579b6bf6a 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -7,6 +7,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
             file://0001-src-core-build_steps-tool.rs-switch-off-lto-for-rust.patch;patchdir=${RUSTSRC} \
             file://0001-riscv32-Define-plain-syscalls-as-their-time64-varian.patch;patchdir=${RUSTSRC} \
             file://0001-Update-call-llvm-intrinsics-test.patch;patchdir=${RUSTSRC} \
+            file://0001-Fix-flaky-assertions-in-oneshot-tests.patch;patchdir=${RUSTSRC} \
 "
 SRC_URI[rust.sha256sum] = "0b53ae34f5c0c3612cfe1de139f9167a018cd5737bc2205664fd69ba9b25f600"
 
-- 
2.49.0



                 reply	other threads:[~2026-03-25  9:06 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=20260325090543.3489042-1-Deepesh.Varatharajan@windriver.com \
    --to=deepesh.varatharajan@windriver.com \
    --cc=Sundeep.Kokkonda@windriver.com \
    --cc=openembedded-core@lists.openembedded.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