From: Ines KCHELFI Date: Thu, 24 Apr 2025 12:32:17 +0000 (+0200) Subject: ptest-cargo: fix incorrect FAIL count when multiple tests are run X-Git-Tag: uninative-4.8~649 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=039708d2aa578da755d5b6eadd6f549121a93186;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git ptest-cargo: fix incorrect FAIL count when multiple tests are run 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 Reviewed-by: Yoann Congal Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/classes-recipe/ptest-cargo.bbclass b/meta/classes-recipe/ptest-cargo.bbclass index d19617aa50e..7b18d43c381 100644 --- a/meta/classes-recipe/ptest-cargo.bbclass +++ b/meta/classes-recipe/ptest-cargo.bbclass @@ -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)