diff mbox series

[meta-lts-mixins,scarthgap/rust,8/9] ptest-cargo.bbclass: sort binaries for reproducibility

Message ID 17d79ec169633c06dc7a4274a9b2664f46029f4a.1757443674.git.scott.murray@konsulko.com
State New
Headers show
Series Update to Rust 1.89.0 | expand

Commit Message

Scott Murray Sept. 9, 2025, 6:49 p.m. UTC
From: Gyorgy Sarvari <skandigraun@gmail.com>

When compiling tests with cargo, the produced binaries are created
in a non-deterministic order. The list of binaries themselves are taken from
some of the log info produced by cargo, which contains them in the order
as they were created. The class later writes this list of binaries
in the run-ptest script in the order that it found them.

In case the test suite contains more than 1 or 2 binaries, then the
order of these binaries is different almost each run, making the
resulting ptest package non-reproducible.

To avoid this, sort the list of test binaries before storing them.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(adapted from oe-core commit 0fdc3ce4e3ecc6519aef680884d88f33c805a20d)
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
---
 classes-recipe/ptest-cargo.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/classes-recipe/ptest-cargo.bbclass b/classes-recipe/ptest-cargo.bbclass
index 8351644..30463e1 100644
--- a/classes-recipe/ptest-cargo.bbclass
+++ b/classes-recipe/ptest-cargo.bbclass
@@ -70,7 +70,7 @@  python do_compile_ptest_cargo() {
     cargo_test_binaries_file = d.getVar('CARGO_TEST_BINARIES_FILES')
     bb.note(f"Found {len(test_bins)} tests, write their paths into {cargo_test_binaries_file}")
     with open(cargo_test_binaries_file, "w") as f:
-        for test_bin in test_bins:
+        for test_bin in sorted(test_bins):
             f.write(f"{test_bin}\n")
 
 }