Skip to content

Use triple rather than arch for fuchsia test-runner #107608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 23 additions & 28 deletions src/ci/docker/scripts/fuchsia-test-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
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
Expand All @@ -40,6 +40,15 @@ def tmp_dir():
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")
Expand All @@ -49,7 +58,7 @@ def from_args(cls, args):
return cls(
os.path.abspath(args.rust),
os.path.abspath(args.sdk),
args.target_arch,
args.target,
verbose=args.verbose,
)

Expand All @@ -60,21 +69,14 @@ def read_from_file(cls):
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"],
package_server_pid=test_env["package_server_pid"],
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__))
Expand Down Expand Up @@ -108,13 +110,6 @@ def output_dir(self):
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,
Expand All @@ -125,7 +120,7 @@ def rustlibs_dir(self):
return os.path.join(
self.libs_dir(),
"rustlib",
self.rustlib_dir(),
self.target,
"lib",
)

Expand Down Expand Up @@ -384,7 +379,7 @@ def start(self):
"--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(),
Expand Down Expand Up @@ -642,11 +637,11 @@ def log(msg):
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:
Expand Down Expand Up @@ -969,8 +964,8 @@ def print_help(args):
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)
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support/fuchsia.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ test environment with:
src/ci/docker/scripts/fuchsia-test-runner.py start
--rust ${RUST_SRC_PATH}/install
--sdk ${SDK_PATH}
--target-arch {x64,arm64}
--target-triple {x86_64-unknown-fuchsia|aarch64-unknown-fuchsia}
```

Where `${RUST_SRC_PATH}/install` is the `prefix` set in `config.toml` and
Expand Down