aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2024-01-25 17:23:15 +0000
committerMichael Knyszek <mknyszek@google.com>2024-02-08 16:18:37 +0000
commit20107e05a609b8f2e61a6b5e8dc258237ad046e7 (patch)
tree0090bf2bdedc226a44ed0f59857001520da83ee6
parent53d1b73dffb567f1d568140e8692a34b3f96a79b (diff)
downloadgo-20107e05a609b8f2e61a6b5e8dc258237ad046e7.tar.gz
go-20107e05a609b8f2e61a6b5e8dc258237ad046e7.zip
[release-branch.go1.22] internal/testenv: support the LUCI mobile builders in tests
This change updates the testenv tests to correctly match on future LUCI builder names for mobile builders. This isn't a problem today because those haven't been set up yet, but the builder names are structured and it's clear where the modifiers will appear. Might as well set them up now. For #65473. Fixes #65474. Change-Id: I244b88a62a90312c0f3ff2360527d58531070362 Reviewed-on: https://go-review.googlesource.com/c/go/+/558597 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> (cherry picked from commit 5c7c24ce827b10982245951f6c2b1bbf0abc5aae) Reviewed-on: https://go-review.googlesource.com/c/go/+/560536
-rw-r--r--src/internal/testenv/testenv_test.go26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/internal/testenv/testenv_test.go b/src/internal/testenv/testenv_test.go
index 71cf9977e4..769db3a033 100644
--- a/src/internal/testenv/testenv_test.go
+++ b/src/internal/testenv/testenv_test.go
@@ -78,7 +78,7 @@ func TestHasGoBuild(t *testing.T) {
// we will presumably find out about it when those tests fail.)
switch runtime.GOOS {
case "ios":
- if strings.HasSuffix(b, "-corellium") {
+ if isCorelliumBuilder(b) {
// The corellium environment is self-hosting, so it should be able
// to build even though real "ios" devices can't exec.
} else {
@@ -89,7 +89,7 @@ func TestHasGoBuild(t *testing.T) {
return
}
case "android":
- if strings.HasSuffix(b, "-emu") && platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH, false) {
+ if isEmulatedBuilder(b) && platform.MustLinkExternal(runtime.GOOS, runtime.GOARCH, false) {
// As of 2023-05-02, the test environment on the emulated builders is
// missing a C linker.
t.Logf("HasGoBuild is false on %s", b)
@@ -153,7 +153,7 @@ func TestMustHaveExec(t *testing.T) {
t.Errorf("expected MustHaveExec to skip on %v", runtime.GOOS)
}
case "ios":
- if b := testenv.Builder(); strings.HasSuffix(b, "-corellium") && !hasExec {
+ if b := testenv.Builder(); isCorelliumBuilder(b) && !hasExec {
// Most ios environments can't exec, but the corellium builder can.
t.Errorf("expected MustHaveExec not to skip on %v", b)
}
@@ -186,3 +186,23 @@ func TestCleanCmdEnvPWD(t *testing.T) {
}
t.Error("PWD not set in cmd.Env")
}
+
+func isCorelliumBuilder(builderName string) bool {
+ // Support both the old infra's builder names and the LUCI builder names.
+ // The former's names are ad-hoc so we could maintain this invariant on
+ // the builder side. The latter's names are structured, and "corellium" will
+ // appear as a "host" suffix after the GOOS and GOARCH, which always begin
+ // with an underscore.
+ return strings.HasSuffix(builderName, "-corellium") || strings.Contains(builderName, "_corellium")
+}
+
+func isEmulatedBuilder(builderName string) bool {
+ // Support both the old infra's builder names and the LUCI builder names.
+ // The former's names are ad-hoc so we could maintain this invariant on
+ // the builder side. The latter's names are structured, and the signifier
+ // of emulation "emu" will appear as a "host" suffix after the GOOS and
+ // GOARCH because it modifies the run environment in such a way that it
+ // the target GOOS and GOARCH may not match the host. This suffix always
+ // begins with an underscore.
+ return strings.HasSuffix(builderName, "-emu") || strings.Contains(builderName, "_emu")
+}