From: Harish Sadineni <[email protected]> Ensure that cargo build successfully builds the binary for the target by default. This test validates whether the default build process produces the expected output for the specified target.
Signed-off-by: Harish Sadineni <[email protected]> --- meta/lib/oeqa/sdk/cases/rust.py | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/meta/lib/oeqa/sdk/cases/rust.py b/meta/lib/oeqa/sdk/cases/rust.py index 4b115bebf5..831994c14a 100644 --- a/meta/lib/oeqa/sdk/cases/rust.py +++ b/meta/lib/oeqa/sdk/cases/rust.py @@ -7,6 +7,7 @@ import os import shutil import unittest +import json from oeqa.sdk.case import OESDKTestCase @@ -33,6 +34,39 @@ class RustCompileTest(OESDKTestCase): def test_cargo_build(self): self._run('cd %s/hello; cargo add zstd' % (self.tc.sdk_dir)) self._run('cd %s/hello; cargo build' % self.tc.sdk_dir) + def test_check_cargo_build_default_target(self): + result_env = self._run("echo $RUST_TARGET_SYS_VALUE") + rust_target_sys = result_env.strip() + result = self._run( + "cd %s/hello; cargo build --message-format=json" + % self.tc.sdk_dir + ) + + executable_path = None + for line in result.splitlines(): + try: + msg = json.loads(line) + except json.JSONDecodeError: + continue + + # Cargo emits multiple JSON messages; we want the executable + if isinstance(msg, dict) and msg.get("executable"): + executable_path = msg["executable"] + + self.assertIsNotNone( + executable_path, + "No executable found in cargo JSON output" + ) + + parts = executable_path.split(os.sep) + target_index = parts.index("target") + target_triple = parts[target_index + 1] + + self.assertEqual( + rust_target_sys, + target_triple, + f"Target triple mismatch: env '{rust_target_sys}' != path '{target_triple}'" + ) class RustHostCompileTest(OESDKTestCase): td_vars = ['MACHINE', 'SDK_SYS'] -- 2.51.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#241824): https://lists.openembedded.org/g/openembedded-core/message/241824 Mute This Topic: https://lists.openembedded.org/mt/120408882/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
