From 933d2cf4e7c15efb440affcb2f42c3e400b2941f Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Thu, 15 Dec 2022 20:41:33 +0000 Subject: [PATCH] Change the default architecture in test.py from x64 to host. This brings test.py into agreement with build.py, and makes development on arm64 hosts nicer. Change-Id: Ic544b4eee0e27d9f395328297ed6108d4e4689f7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257800 Reviewed-by: Jonas Termansen Commit-Queue: Ryan Macnak --- pkg/smith/lib/configuration.dart | 39 ++++++++++++++++++++++++++++ pkg/test_runner/lib/src/options.dart | 4 +-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/pkg/smith/lib/configuration.dart b/pkg/smith/lib/configuration.dart index 85a11f3f0ba..ec3167e37f8 100644 --- a/pkg/smith/lib/configuration.dart +++ b/pkg/smith/lib/configuration.dart @@ -622,6 +622,45 @@ class Architecture extends NamedEnum { } const Architecture._(String name) : super(name); + + static final Architecture host = _computeHost(); + static Architecture _computeHost() { + String? arch; + if (Platform.isWindows) { + arch = Platform.environment["PROCESSOR_ARCHITECTURE"]; + } else { + arch = (Process.runSync("uname", ["-m"]).stdout as String).trim(); + } + + switch (arch) { + case "i386": + case "i686": + case "ia32": + case "x86": + case "X86": + return ia32; + case "x64": + case "x86-64": + case "x86_64": + case "amd64": + case "AMD64": + return x64; + case "armv7l": + case "ARM": + return arm; + case "aarch64": + case "arm64": + case "arm64e": + case "ARM64": + return arm64; + case "riscv32": + return riscv32; + case "riscv64": + return riscv64; + } + + throw "Unknown host architecture: $arch"; + } } class Compiler extends NamedEnum { diff --git a/pkg/test_runner/lib/src/options.dart b/pkg/test_runner/lib/src/options.dart index 3f8451a12c9..ed15fda4cb5 100644 --- a/pkg/test_runner/lib/src/options.dart +++ b/pkg/test_runner/lib/src/options.dart @@ -107,7 +107,7 @@ none: No runtime, compile only.''') ..addMultiOption('arch', abbr: 'a', allowed: ['all', ...Architecture.names], - defaultsTo: [Architecture.x64.name], + defaultsTo: [Architecture.host.name], hide: true, help: '''The architecture to run tests for. @@ -935,7 +935,7 @@ void findConfigurations(Map options) { var architectureOption = options['arch'] as List; var architectures = [ if (architectureOption.isEmpty) - Architecture.x64 + Architecture.host else if (!architectureOption.contains('all')) ...architectureOption.map(Architecture.find) ];