]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
ptest-cargo: fix incorrect FAIL count when multiple tests are run
authorInes KCHELFI <ines.kchelfi@smile.fr>
Thu, 24 Apr 2025 12:32:17 +0000 (14:32 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 29 Apr 2025 08:54:15 +0000 (09:54 +0100)
When using the ptest-cargo class with multiple Rust test binaries, ptest-runner
may report FAIL: 0 even if one of the tests fails, as long as the last test passes.

This happens because the run-ptest script, as generated by the class, does not
track failures and simply returns the exit code of the last test.
To fix this, each test binary is checked individually for failure. If any test fails,
a non-zero exit code is returned.

This ensures that test failures are not silently ignored and are properly reported
by ptest-runner in multi-test scenarios.

Signed-off-by: Ines KCHELFI <ines.kchelfi@smile.fr>
Reviewed-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/ptest-cargo.bbclass

index d19617aa50eec4121aa35b72acd1cc4d3cf6460c..7b18d43c38170d5517e3157698beb5123e904b64 100644 (file)
@@ -102,14 +102,15 @@ python do_install_ptest_cargo() {
     with open(ptest_script, "a") as f:
         if not script_exists:
             f.write("#!/bin/sh\n")
-                
+            f.write("rc=0\n")                
         else:
             f.write(f"\necho \"\"\n")
-            f.write(f"echo \"## starting to run rust tests ##\"\n")
-                
+            f.write(f"echo \"## starting to run rust tests ##\"\n")               
         for test_path in test_paths:
-            f.write(f"{test_path} {rust_test_args}\n")
+            f.write(f"if ! {test_path} {rust_test_args}; then rc=1; fi\n")
         
+        f.write("exit $rc\n")
+
     if not script_exists:
         os.chmod(ptest_script, 0o755)