]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
rust: Fix flaky assertions in oneshot tests
authorDeepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
Wed, 25 Mar 2026 09:05:43 +0000 (02:05 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 26 Mar 2026 11:14:46 +0000 (11:14 +0000)
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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/rust/files/0001-Fix-flaky-assertions-in-oneshot-tests.patch [new file with mode: 0644]
meta/recipes-devtools/rust/rust-source.inc

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 (file)
index 0000000..be0e85d
--- /dev/null
@@ -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]
index 47a0154cdcbba6b46a28fd705270778743813756..4579b6bf6aaefda4e297cadb2f10314077540cd7 100644 (file)
@@ -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"