diff options
author | Ines KCHELFI <ines.kchelfi@smile.fr> | 2025-04-24 14:32:17 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-04-29 09:55:32 +0100 |
commit | 9019308b31b70045a30c9fed2fb5bacd7609f9a0 (patch) | |
tree | 7871cfb041df664cdbfbe09083e0440087d07c8c | |
parent | 40346626ec9bb5d0b12bab602da52181f2e3551f (diff) | |
download | poky-9019308b31b70045a30c9fed2fb5bacd7609f9a0.tar.gz |
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.
(From OE-Core rev: 039708d2aa578da755d5b6eadd6f549121a93186)
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>
-rw-r--r-- | meta/classes-recipe/ptest-cargo.bbclass | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/meta/classes-recipe/ptest-cargo.bbclass b/meta/classes-recipe/ptest-cargo.bbclass index d19617aa50..7b18d43c38 100644 --- a/meta/classes-recipe/ptest-cargo.bbclass +++ b/meta/classes-recipe/ptest-cargo.bbclass | |||
@@ -102,14 +102,15 @@ python do_install_ptest_cargo() { | |||
102 | with open(ptest_script, "a") as f: | 102 | with open(ptest_script, "a") as f: |
103 | if not script_exists: | 103 | if not script_exists: |
104 | f.write("#!/bin/sh\n") | 104 | f.write("#!/bin/sh\n") |
105 | 105 | f.write("rc=0\n") | |
106 | else: | 106 | else: |
107 | f.write(f"\necho \"\"\n") | 107 | f.write(f"\necho \"\"\n") |
108 | f.write(f"echo \"## starting to run rust tests ##\"\n") | 108 | f.write(f"echo \"## starting to run rust tests ##\"\n") |
109 | |||
110 | for test_path in test_paths: | 109 | for test_path in test_paths: |
111 | f.write(f"{test_path} {rust_test_args}\n") | 110 | f.write(f"if ! {test_path} {rust_test_args}; then rc=1; fi\n") |
112 | 111 | ||
112 | f.write("exit $rc\n") | ||
113 | |||
113 | if not script_exists: | 114 | if not script_exists: |
114 | os.chmod(ptest_script, 0o755) | 115 | os.chmod(ptest_script, 0o755) |
115 | 116 | ||