about summary refs log tree commit diff
path: root/src/ci/docker/scripts
diff options
context:
space:
mode:
authorJoseph Ryan <josephry@google.com>2023-02-02 11:23:48 -0800
committerJoseph Ryan <josephry@google.com>2023-02-02 13:29:03 -0800
commiteb5e9713b5fc4da7cb9dbdc9d302de10126b3287 (patch)
treeaf12d5fe2a424064d48ce8e28dce2da727cdf3e1 /src/ci/docker/scripts
parent97872b792c9dd6a9bc5c3f4e62a0bd5958b09cdc (diff)
downloadrust-eb5e9713b5fc4da7cb9dbdc9d302de10126b3287.tar.gz
rust-eb5e9713b5fc4da7cb9dbdc9d302de10126b3287.zip
Use triple rather than arch for fuchsia test runner
Diffstat (limited to 'src/ci/docker/scripts')
-rwxr-xr-xsrc/ci/docker/scripts/fuchsia-test-runner.py51
1 files changed, 23 insertions, 28 deletions
diff --git a/src/ci/docker/scripts/fuchsia-test-runner.py b/src/ci/docker/scripts/fuchsia-test-runner.py
index c8d1ff9aefb..a6d84a3c18a 100755
--- a/src/ci/docker/scripts/fuchsia-test-runner.py
+++ b/src/ci/docker/scripts/fuchsia-test-runner.py
@@ -19,18 +19,18 @@ import shutil
 import signal
 import subprocess
 import sys
-from typing import ClassVar, List
+from typing import ClassVar, List, Optional
 
 
 @dataclass
 class TestEnvironment:
     rust_dir: str
     sdk_dir: str
-    target_arch: str
-    package_server_pid: int = None
-    emu_addr: str = None
-    libstd_name: str = None
-    libtest_name: str = None
+    target: str
+    package_server_pid: Optional[int] = None
+    emu_addr: Optional[str] = None
+    libstd_name: Optional[str] = None
+    libtest_name: Optional[str] = None
     verbose: bool = False
 
     @staticmethod
@@ -40,6 +40,15 @@ class TestEnvironment:
             return os.path.abspath(tmp_dir)
         return os.path.join(os.path.dirname(__file__), "tmp~")
 
+    @staticmethod
+    def triple_to_arch(triple):
+        if "x86_64" in triple:
+            return "x64"
+        elif "aarch64" in triple:
+            return "arm64"
+        else:
+            raise Exception(f"Unrecognized target triple {triple}")
+
     @classmethod
     def env_file_path(cls):
         return os.path.join(cls.tmp_dir(), "test_env.json")
@@ -49,7 +58,7 @@ class TestEnvironment:
         return cls(
             os.path.abspath(args.rust),
             os.path.abspath(args.sdk),
-            args.target_arch,
+            args.target,
             verbose=args.verbose,
         )
 
@@ -60,7 +69,7 @@ class TestEnvironment:
             return cls(
                 test_env["rust_dir"],
                 test_env["sdk_dir"],
-                test_env["target_arch"],
+                test_env["target"],
                 libstd_name=test_env["libstd_name"],
                 libtest_name=test_env["libtest_name"],
                 emu_addr=test_env["emu_addr"],
@@ -68,13 +77,6 @@ class TestEnvironment:
                 verbose=test_env["verbose"],
             )
 
-    def image_name(self):
-        if self.target_arch == "x64":
-            return "qemu-x64"
-        if self.target_arch == "arm64":
-            return "qemu-arm64"
-        raise Exception(f"Unrecognized target architecture {self.target_arch}")
-
     def write_to_file(self):
         with open(self.env_file_path(), "w", encoding="utf-8") as f:
             f.write(json.dumps(self.__dict__))
@@ -108,13 +110,6 @@ class TestEnvironment:
     def repo_dir(self):
         return os.path.join(self.tmp_dir(), self.TEST_REPO_NAME)
 
-    def rustlib_dir(self):
-        if self.target_arch == "x64":
-            return "x86_64-unknown-fuchsia"
-        if self.target_arch == "arm64":
-            return "aarch64-unknown-fuchsia"
-        raise Exception(f"Unrecognized target architecture {self.target_arch}")
-
     def libs_dir(self):
         return os.path.join(
             self.rust_dir,
@@ -125,7 +120,7 @@ class TestEnvironment:
         return os.path.join(
             self.libs_dir(),
             "rustlib",
-            self.rustlib_dir(),
+            self.target,
             "lib",
         )
 
@@ -384,7 +379,7 @@ class TestEnvironment:
                 "--emulator-log",
                 self.emulator_log_path(),
                 "--image-name",
-                self.image_name(),
+                "qemu-" + self.triple_to_arch(self.target),
             ],
             stdout=self.subprocess_output(),
             stderr=self.subprocess_output(),
@@ -642,11 +637,11 @@ class TestEnvironment:
                         package_dir=package_dir,
                         package_name=package_name,
                         rust_dir=self.rust_dir,
-                        rustlib_dir=self.rustlib_dir(),
+                        rustlib_dir=self.target,
                         sdk_dir=self.sdk_dir,
                         libstd_name=self.libstd_name,
                         libtest_name=self.libtest_name,
-                        target_arch=self.target_arch,
+                        target_arch=self.triple_to_arch(self.target),
                     )
                 )
                 for shared_lib in shared_libs:
@@ -969,8 +964,8 @@ def main():
         action="store_true",
     )
     start_parser.add_argument(
-        "--target-arch",
-        help="the architecture of the image to test",
+        "--target",
+        help="the target platform to test",
         required=True,
     )
     start_parser.set_defaults(func=start)