Brad Fitzpatrick | f3c0193 | 2015-01-15 16:29:16 -0800 | [diff] [blame] | 1 | // Copyright 2015 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package dashboard |
| 6 | |
| 7 | import ( |
Brad Fitzpatrick | aab8504 | 2019-10-16 06:02:29 +0000 | [diff] [blame] | 8 | "bytes" |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 9 | "fmt" |
Brad Fitzpatrick | aab8504 | 2019-10-16 06:02:29 +0000 | [diff] [blame] | 10 | "os/exec" |
| 11 | "path/filepath" |
Tobias Klauser | cd82ecd | 2019-11-07 14:15:55 +0100 | [diff] [blame] | 12 | "regexp" |
Brad Fitzpatrick | aab8504 | 2019-10-16 06:02:29 +0000 | [diff] [blame] | 13 | "runtime" |
| 14 | "sort" |
Brad Fitzpatrick | f3c0193 | 2015-01-15 16:29:16 -0800 | [diff] [blame] | 15 | "strings" |
| 16 | "testing" |
Brad Fitzpatrick | 34b995b | 2019-02-14 02:18:06 +0000 | [diff] [blame] | 17 | "time" |
Carlos Amedee | 1e76199 | 2020-08-20 11:53:58 -0400 | [diff] [blame] | 18 | |
| 19 | "github.com/google/go-cmp/cmp" |
Brad Fitzpatrick | f3c0193 | 2015-01-15 16:29:16 -0800 | [diff] [blame] | 20 | ) |
| 21 | |
| 22 | func TestOSARCHAccessors(t *testing.T) { |
| 23 | valid := func(s string) bool { return s != "" && !strings.Contains(s, "-") } |
| 24 | for _, conf := range Builders { |
| 25 | os := conf.GOOS() |
| 26 | arch := conf.GOARCH() |
| 27 | osArch := os + "-" + arch |
| 28 | if !valid(os) || !valid(arch) || !(conf.Name == osArch || strings.HasPrefix(conf.Name, osArch+"-")) { |
| 29 | t.Errorf("OS+ARCH(%q) = %q, %q; invalid", conf.Name, os, arch) |
| 30 | } |
| 31 | } |
| 32 | } |
Brad Fitzpatrick | c328d04 | 2017-04-12 00:35:37 +0000 | [diff] [blame] | 33 | |
Brad Fitzpatrick | 34b995b | 2019-02-14 02:18:06 +0000 | [diff] [blame] | 34 | func TestDistTestsExecTimeout(t *testing.T) { |
| 35 | tests := []struct { |
| 36 | c *BuildConfig |
| 37 | want time.Duration |
| 38 | }{ |
| 39 | { |
| 40 | &BuildConfig{ |
| 41 | env: []string{}, |
| 42 | testHostConf: &HostConfig{}, |
| 43 | }, |
| 44 | 20 * time.Minute, |
| 45 | }, |
| 46 | { |
| 47 | &BuildConfig{ |
| 48 | env: []string{"GO_TEST_TIMEOUT_SCALE=2"}, |
| 49 | testHostConf: &HostConfig{}, |
| 50 | }, |
| 51 | 40 * time.Minute, |
| 52 | }, |
| 53 | { |
| 54 | &BuildConfig{ |
| 55 | env: []string{}, |
| 56 | testHostConf: &HostConfig{ |
| 57 | env: []string{"GO_TEST_TIMEOUT_SCALE=3"}, |
| 58 | }, |
| 59 | }, |
| 60 | 60 * time.Minute, |
| 61 | }, |
| 62 | // BuildConfig's env takes precedence: |
| 63 | { |
| 64 | &BuildConfig{ |
| 65 | env: []string{"GO_TEST_TIMEOUT_SCALE=2"}, |
| 66 | testHostConf: &HostConfig{ |
| 67 | env: []string{"GO_TEST_TIMEOUT_SCALE=3"}, |
| 68 | }, |
| 69 | }, |
| 70 | 40 * time.Minute, |
| 71 | }, |
| 72 | } |
| 73 | for i, tt := range tests { |
| 74 | got := tt.c.DistTestsExecTimeout(nil) |
| 75 | if got != tt.want { |
| 76 | t.Errorf("%d. got %v; want %v", i, got, tt.want) |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 81 | // TestTrybots tests that a given repo & its branch yields the provided |
| 82 | // complete set of builders. See also: TestBuilders, which tests both trybots |
| 83 | // and post-submit builders, both at arbitrary branches. |
| 84 | func TestTrybots(t *testing.T) { |
| 85 | tests := []struct { |
| 86 | repo string // "go", "net", etc |
| 87 | branch string // of repo |
| 88 | want []string |
| 89 | }{ |
| 90 | { |
| 91 | repo: "go", |
| 92 | branch: "master", |
| 93 | want: []string{ |
Brad Fitzpatrick | 4e29d67 | 2019-04-18 19:45:32 +0000 | [diff] [blame] | 94 | "android-amd64-emu", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 95 | "freebsd-amd64-12_0", |
| 96 | "js-wasm", |
| 97 | "linux-386", |
| 98 | "linux-amd64", |
| 99 | "linux-amd64-race", |
Brad Fitzpatrick | 95bc93b | 2019-05-10 19:28:40 +0000 | [diff] [blame] | 100 | "misc-compile-other", |
| 101 | "misc-compile-darwin", |
Dmitri Shuralyov | 4c544cb | 2020-11-02 22:25:51 -0500 | [diff] [blame] | 102 | "misc-compile-darwinarm64", |
Brad Fitzpatrick | 95bc93b | 2019-05-10 19:28:40 +0000 | [diff] [blame] | 103 | "misc-compile-linuxarm", |
| 104 | "misc-compile-solaris", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 105 | "misc-compile-freebsd", |
| 106 | "misc-compile-mips", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 107 | "misc-compile-netbsd", |
| 108 | "misc-compile-openbsd", |
| 109 | "misc-compile-plan9", |
| 110 | "misc-compile-ppc", |
Dmitri Shuralyov | 01e47d9 | 2020-12-21 14:12:25 -0500 | [diff] [blame] | 111 | "openbsd-amd64-68", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 112 | "windows-386-2008", |
| 113 | "windows-amd64-2016", |
| 114 | }, |
| 115 | }, |
| 116 | { |
| 117 | repo: "go", |
Brad Fitzpatrick | 90670e1 | 2019-10-11 18:47:51 +0000 | [diff] [blame] | 118 | branch: "dev.link", |
| 119 | want: []string{ |
Cherry Zhang | 50a7880 | 2020-03-13 17:09:21 -0400 | [diff] [blame] | 120 | "android-amd64-emu", |
Brad Fitzpatrick | 90670e1 | 2019-10-11 18:47:51 +0000 | [diff] [blame] | 121 | "freebsd-amd64-12_0", |
| 122 | "js-wasm", |
| 123 | "linux-386", |
| 124 | "linux-amd64", |
| 125 | "linux-amd64-race", |
| 126 | "misc-compile-other", |
| 127 | "misc-compile-darwin", |
Dmitri Shuralyov | 4c544cb | 2020-11-02 22:25:51 -0500 | [diff] [blame] | 128 | "misc-compile-darwinarm64", |
Brad Fitzpatrick | 90670e1 | 2019-10-11 18:47:51 +0000 | [diff] [blame] | 129 | "misc-compile-linuxarm", |
| 130 | "misc-compile-solaris", |
| 131 | "misc-compile-freebsd", |
| 132 | "misc-compile-mips", |
| 133 | "misc-compile-netbsd", |
| 134 | "misc-compile-openbsd", |
| 135 | "misc-compile-plan9", |
| 136 | "misc-compile-ppc", |
Dmitri Shuralyov | 01e47d9 | 2020-12-21 14:12:25 -0500 | [diff] [blame] | 137 | "openbsd-amd64-68", |
Brad Fitzpatrick | 90670e1 | 2019-10-11 18:47:51 +0000 | [diff] [blame] | 138 | "windows-386-2008", |
| 139 | "windows-amd64-2016", |
| 140 | }, |
| 141 | }, |
| 142 | { |
| 143 | repo: "go", |
Dmitri Shuralyov | 4c544cb | 2020-11-02 22:25:51 -0500 | [diff] [blame] | 144 | branch: "release-branch.go1.16", |
| 145 | want: []string{ |
| 146 | "android-amd64-emu", |
| 147 | "freebsd-amd64-12_0", |
| 148 | "js-wasm", |
| 149 | "linux-386", |
| 150 | "linux-amd64", |
| 151 | "linux-amd64-race", |
| 152 | "misc-compile-darwin", |
| 153 | "misc-compile-darwinarm64", // Starts with Go 1.16. |
| 154 | "misc-compile-freebsd", |
| 155 | "misc-compile-linuxarm", |
| 156 | "misc-compile-mips", |
| 157 | "misc-compile-netbsd", |
| 158 | "misc-compile-openbsd", |
| 159 | "misc-compile-other", |
| 160 | "misc-compile-plan9", |
| 161 | "misc-compile-ppc", |
| 162 | "misc-compile-solaris", |
Dmitri Shuralyov | 01e47d9 | 2020-12-21 14:12:25 -0500 | [diff] [blame] | 163 | "openbsd-amd64-68", |
Dmitri Shuralyov | 4c544cb | 2020-11-02 22:25:51 -0500 | [diff] [blame] | 164 | "windows-386-2008", |
| 165 | "windows-amd64-2016", |
| 166 | |
| 167 | // Include longtest builders on Go repo release branches. See issue 37827. |
| 168 | "linux-386-longtest", |
| 169 | "linux-amd64-longtest", |
| 170 | "windows-amd64-longtest", |
| 171 | }, |
| 172 | }, |
| 173 | { |
| 174 | repo: "go", |
Dmitri Shuralyov | 43ea694 | 2021-02-19 12:17:28 -0500 | [diff] [blame] | 175 | branch: "release-branch.go1.15", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 176 | want: []string{ |
Dmitri Shuralyov | 9e7a762 | 2020-05-26 18:12:12 -0400 | [diff] [blame] | 177 | "android-amd64-emu", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 178 | "freebsd-amd64-12_0", |
| 179 | "js-wasm", |
| 180 | "linux-386", |
| 181 | "linux-amd64", |
| 182 | "linux-amd64-race", |
Brad Fitzpatrick | 95bc93b | 2019-05-10 19:28:40 +0000 | [diff] [blame] | 183 | "misc-compile-darwin", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 184 | "misc-compile-freebsd", |
Brad Fitzpatrick | 95bc93b | 2019-05-10 19:28:40 +0000 | [diff] [blame] | 185 | "misc-compile-linuxarm", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 186 | "misc-compile-mips", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 187 | "misc-compile-netbsd", |
| 188 | "misc-compile-openbsd", |
Brad Fitzpatrick | 95bc93b | 2019-05-10 19:28:40 +0000 | [diff] [blame] | 189 | "misc-compile-other", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 190 | "misc-compile-plan9", |
| 191 | "misc-compile-ppc", |
Brad Fitzpatrick | 95bc93b | 2019-05-10 19:28:40 +0000 | [diff] [blame] | 192 | "misc-compile-solaris", |
Dmitri Shuralyov | 01e47d9 | 2020-12-21 14:12:25 -0500 | [diff] [blame] | 193 | "openbsd-amd64-68", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 194 | "windows-386-2008", |
| 195 | "windows-amd64-2016", |
Dmitri Shuralyov | 5a8fb63 | 2020-05-26 18:19:05 -0400 | [diff] [blame] | 196 | |
| 197 | // Include longtest builders on Go repo release branches. See issue 37827. |
| 198 | "linux-386-longtest", |
| 199 | "linux-amd64-longtest", |
| 200 | "windows-amd64-longtest", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 201 | }, |
| 202 | }, |
| 203 | { |
| 204 | repo: "mobile", |
| 205 | branch: "master", |
| 206 | want: []string{ |
| 207 | "android-amd64-emu", |
| 208 | "linux-amd64-androidemu", |
| 209 | }, |
| 210 | }, |
| 211 | { |
| 212 | repo: "sys", |
| 213 | branch: "master", |
| 214 | want: []string{ |
Brad Fitzpatrick | 6d867c8 | 2019-04-26 14:04:00 +0000 | [diff] [blame] | 215 | "android-amd64-emu", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 216 | "freebsd-386-11_2", |
| 217 | "freebsd-amd64-11_2", |
| 218 | "freebsd-amd64-12_0", |
| 219 | "linux-386", |
| 220 | "linux-amd64", |
Brad Fitzpatrick | 8665028 | 2019-03-11 18:49:56 +0000 | [diff] [blame] | 221 | "linux-amd64-race", |
Dmitri Shuralyov | 5bbd558 | 2020-04-08 12:43:09 -0400 | [diff] [blame] | 222 | "netbsd-amd64-9_0", |
Dmitri Shuralyov | 01e47d9 | 2020-12-21 14:12:25 -0500 | [diff] [blame] | 223 | "openbsd-386-68", |
| 224 | "openbsd-amd64-68", |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 225 | "windows-386-2008", |
| 226 | "windows-amd64-2016", |
| 227 | }, |
| 228 | }, |
Brad Fitzpatrick | 83c6b6a | 2019-03-14 20:35:32 +0000 | [diff] [blame] | 229 | { |
| 230 | repo: "exp", |
| 231 | branch: "master", |
| 232 | want: []string{ |
Brad Fitzpatrick | 83c6b6a | 2019-03-14 20:35:32 +0000 | [diff] [blame] | 233 | "linux-amd64", |
| 234 | "linux-amd64-race", |
Brad Fitzpatrick | 83c6b6a | 2019-03-14 20:35:32 +0000 | [diff] [blame] | 235 | "windows-386-2008", |
| 236 | "windows-amd64-2016", |
| 237 | }, |
| 238 | }, |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 239 | } |
| 240 | for i, tt := range tests { |
| 241 | if tt.branch == "" || tt.repo == "" { |
| 242 | t.Errorf("incomplete test entry %d", i) |
| 243 | return |
| 244 | } |
| 245 | t.Run(fmt.Sprintf("%s/%s", tt.repo, tt.branch), func(t *testing.T) { |
| 246 | var got []string |
| 247 | goBranch := tt.branch // hard-code the common case for now |
| 248 | for _, bc := range TryBuildersForProject(tt.repo, tt.branch, goBranch) { |
| 249 | got = append(got, bc.Name) |
| 250 | } |
| 251 | m := map[string]bool{} |
| 252 | for _, b := range tt.want { |
| 253 | m[b] = true |
| 254 | } |
| 255 | for _, b := range got { |
| 256 | if _, ok := m[b]; !ok { |
| 257 | t.Errorf("got unexpected %q", b) |
| 258 | } |
| 259 | delete(m, b) |
| 260 | } |
| 261 | for b := range m { |
| 262 | t.Errorf("missing expected %q", b) |
Brad Fitzpatrick | c517aed | 2018-10-26 19:21:58 +0000 | [diff] [blame] | 263 | } |
| 264 | }) |
Brad Fitzpatrick | c328d04 | 2017-04-12 00:35:37 +0000 | [diff] [blame] | 265 | } |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | // TestBuilderConfig whether a given builder and repo at different |
| 269 | // branches is either a post-submit builder, trybot, neither, or both. |
| 270 | func TestBuilderConfig(t *testing.T) { |
| 271 | // builderConfigWant is bitmask of 4 different things to assert are wanted: |
| 272 | // - being a post-submit builder |
| 273 | // - NOT being a post-submit builder |
| 274 | // - being a trybot builder |
| 275 | // - NOT being a post-submit builder |
| 276 | type want uint8 |
| 277 | const ( |
| 278 | isTrybot want = 1 << iota |
| 279 | notTrybot |
| 280 | isBuilder // post-submit |
| 281 | notBuilder // not post-submit |
| 282 | |
| 283 | none = notTrybot + notBuilder |
| 284 | both = isTrybot + isBuilder |
| 285 | onlyPost = notTrybot + isBuilder |
| 286 | ) |
| 287 | |
| 288 | type builderAndRepo struct { |
| 289 | testName string |
| 290 | builder string |
| 291 | repo string |
| 292 | branch string |
| 293 | goBranch string |
| 294 | } |
Dmitri Shuralyov | 76fd6b5 | 2019-10-08 13:08:27 -0400 | [diff] [blame] | 295 | // builder may end in "@go1.N" or "@1.N" (as alias for "@release-branch.go1.N") or "@branch-name". |
| 296 | // repo (other than "go") may end in "@go1.N" or "@1.N" (as alias for "@release-branch.go1.N"). |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 297 | b := func(builder, repo string) builderAndRepo { |
| 298 | br := builderAndRepo{ |
| 299 | testName: builder + "," + repo, |
| 300 | builder: builder, |
| 301 | goBranch: "master", |
| 302 | repo: repo, |
| 303 | branch: "master", |
| 304 | } |
| 305 | if strings.Contains(builder, "@") { |
| 306 | f := strings.SplitN(builder, "@", 2) |
| 307 | br.builder = f[0] |
| 308 | br.goBranch = f[1] |
| 309 | } |
| 310 | if strings.Contains(repo, "@") { |
| 311 | f := strings.SplitN(repo, "@", 2) |
| 312 | br.repo = f[0] |
| 313 | br.branch = f[1] |
Dmitri Shuralyov | 76fd6b5 | 2019-10-08 13:08:27 -0400 | [diff] [blame] | 314 | if br.repo == "go" { |
| 315 | panic(fmt.Errorf(`b(%q, %q): for "go" repo, must use the @%s suffix on the builder, not on the repo`, builder, repo, br.branch)) |
| 316 | } |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 317 | } |
| 318 | expandBranch := func(s *string) { |
| 319 | if strings.HasPrefix(*s, "go1.") { |
| 320 | *s = "release-branch." + *s |
| 321 | } else if strings.HasPrefix(*s, "1.") { |
| 322 | *s = "release-branch.go" + *s |
| 323 | } |
| 324 | } |
| 325 | expandBranch(&br.branch) |
| 326 | expandBranch(&br.goBranch) |
| 327 | if br.repo == "go" { |
| 328 | br.branch = br.goBranch |
| 329 | } |
| 330 | return br |
| 331 | } |
| 332 | tests := []struct { |
| 333 | br builderAndRepo |
| 334 | want want |
| 335 | }{ |
| 336 | {b("linux-amd64", "go"), both}, |
| 337 | {b("linux-amd64", "net"), both}, |
| 338 | {b("linux-amd64", "sys"), both}, |
Dmitri Shuralyov | 7aef06b | 2019-05-16 16:04:34 -0400 | [diff] [blame] | 339 | {b("linux-amd64", "website"), both}, |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 340 | |
Brad Fitzpatrick | b8db43d | 2019-03-11 04:20:46 +0000 | [diff] [blame] | 341 | // Don't test all subrepos on all the builders. |
| 342 | {b("linux-amd64-ssacheck", "net"), none}, |
Dmitri Shuralyov | df6c66f | 2020-10-05 12:20:33 -0400 | [diff] [blame] | 343 | {b("linux-amd64-ssacheck@go1.15", "net"), none}, |
Dmitri Shuralyov | 0f5b1a7 | 2020-10-07 11:24:42 -0400 | [diff] [blame] | 344 | {b("linux-386-softfloat", "crypto"), onlyPost}, |
| 345 | {b("linux-386-softfloat@go1.16", "crypto"), onlyPost}, |
| 346 | {b("linux-386-softfloat@go1.15", "crypto"), none}, |
Dmitri Shuralyov | df6c66f | 2020-10-05 12:20:33 -0400 | [diff] [blame] | 347 | {b("linux-386-387", "crypto"), none}, |
| 348 | {b("linux-386-387@go1.16", "crypto"), none}, |
| 349 | {b("linux-386-387@go1.15", "crypto"), onlyPost}, |
| 350 | {b("linux-386-387@go1.15", "crypto@1.15"), onlyPost}, |
| 351 | {b("linux-386-387@go1.15", "build"), none}, |
| 352 | {b("linux-386-387@go1.14", "crypto"), onlyPost}, |
| 353 | {b("linux-arm-arm5spacemonkey@go1.15", "net"), none}, |
Tobias Klauser | 48cb6ed | 2019-11-25 10:00:55 +0100 | [diff] [blame] | 354 | {b("linux-arm-arm5spacemonkey", "exp"), none}, |
| 355 | {b("linux-arm-arm5spacemonkey", "mobile"), none}, |
Brad Fitzpatrick | b8db43d | 2019-03-11 04:20:46 +0000 | [diff] [blame] | 356 | |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 357 | // The mobile repo requires Go 1.13+. |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 358 | {b("android-amd64-emu", "mobile"), both}, |
| 359 | {b("android-amd64-emu", "mobile@1.10"), none}, |
| 360 | {b("android-amd64-emu", "mobile@1.11"), none}, |
| 361 | {b("android-amd64-emu@go1.10", "mobile"), none}, |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 362 | {b("android-amd64-emu@go1.12", "mobile"), none}, |
| 363 | {b("android-amd64-emu@go1.13", "mobile"), both}, |
| 364 | {b("android-amd64-emu", "mobile@1.13"), both}, |
Dmitri Shuralyov | 220eca8 | 2020-01-10 15:53:25 -0500 | [diff] [blame] | 365 | |
| 366 | {b("android-amd64-emu", "go"), both}, |
Brad Fitzpatrick | 6d867c8 | 2019-04-26 14:04:00 +0000 | [diff] [blame] | 367 | {b("android-amd64-emu", "crypto"), both}, |
| 368 | {b("android-amd64-emu", "net"), both}, |
| 369 | {b("android-amd64-emu", "sync"), both}, |
| 370 | {b("android-amd64-emu", "sys"), both}, |
| 371 | {b("android-amd64-emu", "text"), both}, |
| 372 | {b("android-amd64-emu", "time"), both}, |
| 373 | {b("android-amd64-emu", "tools"), both}, |
Dmitri Shuralyov | bb0f224 | 2019-08-29 09:22:13 -0400 | [diff] [blame] | 374 | {b("android-amd64-emu", "website"), none}, |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 375 | |
| 376 | {b("android-386-emu", "go"), onlyPost}, |
| 377 | {b("android-386-emu", "mobile"), onlyPost}, |
| 378 | {b("android-386-emu", "mobile@1.10"), none}, |
| 379 | {b("android-386-emu", "mobile@1.11"), none}, |
| 380 | {b("android-386-emu@go1.10", "mobile"), none}, |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 381 | {b("android-386-emu@go1.12", "mobile"), none}, |
| 382 | {b("android-386-emu@go1.13", "mobile"), onlyPost}, |
| 383 | {b("android-386-emu", "mobile@1.13"), onlyPost}, |
| 384 | |
| 385 | {b("linux-amd64", "net"), both}, |
| 386 | {b("linux-amd64", "net@1.12"), both}, |
| 387 | {b("linux-amd64@go1.12", "net@1.12"), both}, |
| 388 | {b("linux-amd64", "net@1.11"), both}, |
| 389 | {b("linux-amd64", "net@1.11"), both}, |
| 390 | {b("linux-amd64", "net@1.10"), none}, // too old |
| 391 | {b("linux-amd64@go1.10", "net"), none}, // too old |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 392 | {b("linux-amd64@go1.12", "net@1.12"), both}, |
| 393 | |
Meng Zhuo | 8805279 | 2019-09-10 07:21:11 +0800 | [diff] [blame] | 394 | {b("linux-mips64le-mengzhuo", "go"), onlyPost}, |
| 395 | {b("linux-mips64le-mengzhuo", "sys"), onlyPost}, |
| 396 | {b("linux-mips64le-mengzhuo", "net"), onlyPost}, |
| 397 | |
Dmitri Shuralyov | 5f7fe5e | 2020-11-10 12:56:57 -0500 | [diff] [blame] | 398 | // OpenBSD. |
Dmitri Shuralyov | 01e47d9 | 2020-12-21 14:12:25 -0500 | [diff] [blame] | 399 | {b("openbsd-amd64-68@go1.16", "go"), both}, |
| 400 | {b("openbsd-amd64-68@go1.15", "go"), both}, |
| 401 | {b("openbsd-amd64-68@go1.14", "go"), both}, |
| 402 | {b("openbsd-amd64-64@go1.16", "go"), onlyPost}, |
| 403 | {b("openbsd-amd64-64@go1.15", "go"), onlyPost}, |
| 404 | {b("openbsd-amd64-64@go1.14", "go"), onlyPost}, |
Dmitri Shuralyov | 5f7fe5e | 2020-11-10 12:56:57 -0500 | [diff] [blame] | 405 | {b("openbsd-amd64-62@go1.16", "go"), none}, // golang.org/issue/42426. |
| 406 | {b("openbsd-amd64-62@go1.15", "go"), onlyPost}, |
| 407 | {b("openbsd-amd64-62@go1.14", "go"), onlyPost}, |
| 408 | |
Brad Fitzpatrick | 9e52fce | 2019-03-12 21:13:50 +0000 | [diff] [blame] | 409 | // FreeBSD 12.0 |
| 410 | {b("freebsd-amd64-12_0", "go"), both}, |
| 411 | {b("freebsd-amd64-12_0", "net"), both}, |
Tobias Klauser | be84e8e | 2019-12-01 14:33:59 +0100 | [diff] [blame] | 412 | {b("freebsd-amd64-12_0", "mobile"), none}, |
Brad Fitzpatrick | 9e52fce | 2019-03-12 21:13:50 +0000 | [diff] [blame] | 413 | {b("freebsd-386-12_0", "go"), onlyPost}, |
| 414 | {b("freebsd-386-12_0", "net"), onlyPost}, |
Tobias Klauser | be84e8e | 2019-12-01 14:33:59 +0100 | [diff] [blame] | 415 | {b("freebsd-386-12_0", "mobile"), none}, |
Brad Fitzpatrick | 9e52fce | 2019-03-12 21:13:50 +0000 | [diff] [blame] | 416 | |
Brad Fitzpatrick | fcf7a58 | 2019-04-30 22:37:31 +0000 | [diff] [blame] | 417 | // NetBSD |
Dmitri Shuralyov | 5bbd558 | 2020-04-08 12:43:09 -0400 | [diff] [blame] | 418 | {b("netbsd-amd64-9_0", "go"), onlyPost}, |
| 419 | {b("netbsd-amd64-9_0", "net"), onlyPost}, |
Dmitri Shuralyov | b7c61f7 | 2020-04-09 07:59:16 -0400 | [diff] [blame] | 420 | {b("netbsd-amd64-9_0", "sys"), both}, |
Dmitri Shuralyov | 5bbd558 | 2020-04-08 12:43:09 -0400 | [diff] [blame] | 421 | {b("netbsd-386-9_0", "go"), onlyPost}, |
| 422 | {b("netbsd-386-9_0", "net"), onlyPost}, |
Brad Fitzpatrick | fcf7a58 | 2019-04-30 22:37:31 +0000 | [diff] [blame] | 423 | |
Tobias Klauser | b7b6693 | 2019-03-13 09:29:15 +0100 | [diff] [blame] | 424 | // AIX starts at Go 1.12 |
| 425 | {b("aix-ppc64", "go"), onlyPost}, |
| 426 | {b("aix-ppc64", "net"), onlyPost}, |
Tobias Klauser | c2ec9e4 | 2019-06-04 10:14:55 +0200 | [diff] [blame] | 427 | {b("aix-ppc64", "mobile"), none}, |
| 428 | {b("aix-ppc64", "exp"), none}, |
Tobias Klauser | cbdd89b | 2019-10-14 11:31:13 +0200 | [diff] [blame] | 429 | {b("aix-ppc64", "term"), onlyPost}, |
Dmitri Shuralyov | 43ea694 | 2021-02-19 12:17:28 -0500 | [diff] [blame] | 430 | {b("aix-ppc64@go1.15", "go"), onlyPost}, |
| 431 | {b("aix-ppc64@go1.15", "net"), onlyPost}, |
| 432 | {b("aix-ppc64@go1.15", "mobile"), none}, |
| 433 | {b("aix-ppc64@go1.16", "net"), onlyPost}, |
| 434 | {b("aix-ppc64@go1.16", "mobile"), none}, |
Cherry Zhang | 50a7880 | 2020-03-13 17:09:21 -0400 | [diff] [blame] | 435 | {b("aix-ppc64@dev.link", "go"), onlyPost}, |
Tobias Klauser | b7b6693 | 2019-03-13 09:29:15 +0100 | [diff] [blame] | 436 | |
Brad Fitzpatrick | b8db43d | 2019-03-11 04:20:46 +0000 | [diff] [blame] | 437 | {b("linux-amd64-nocgo", "mobile"), none}, |
| 438 | |
Elias Naur | 4d0f77a | 2019-05-01 22:28:43 +0200 | [diff] [blame] | 439 | // Virtual mobiledevices |
Elias Naur | 18919d6 | 2020-10-03 11:37:07 +0200 | [diff] [blame] | 440 | {b("ios-arm64-corellium", "go"), isBuilder}, |
Elias Naur | 4d0f77a | 2019-05-01 22:28:43 +0200 | [diff] [blame] | 441 | {b("android-arm64-corellium", "go"), isBuilder}, |
Elias Naur | 7ae7539 | 2019-05-02 00:54:54 +0200 | [diff] [blame] | 442 | {b("android-arm-corellium", "go"), isBuilder}, |
Elias Naur | 6bebc8e | 2019-05-01 20:33:26 +0200 | [diff] [blame] | 443 | |
Elias Naur | 18919d6 | 2020-10-03 11:37:07 +0200 | [diff] [blame] | 444 | // Mobile builders that run with GOOS=linux/ios and have |
Brad Fitzpatrick | 13f1da9 | 2019-03-12 16:21:55 +0000 | [diff] [blame] | 445 | // a device attached. |
| 446 | {b("linux-amd64-androidemu", "mobile"), both}, |
Brad Fitzpatrick | 13f1da9 | 2019-03-12 16:21:55 +0000 | [diff] [blame] | 447 | |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 448 | // But the emulators run all: |
| 449 | {b("android-amd64-emu", "mobile"), isBuilder}, |
| 450 | {b("android-386-emu", "mobile"), isBuilder}, |
| 451 | {b("android-amd64-emu", "net"), isBuilder}, |
| 452 | {b("android-386-emu", "net"), isBuilder}, |
| 453 | {b("android-amd64-emu", "go"), isBuilder}, |
| 454 | {b("android-386-emu", "go"), isBuilder}, |
Brad Fitzpatrick | b8db43d | 2019-03-11 04:20:46 +0000 | [diff] [blame] | 455 | |
Brad Fitzpatrick | 8665028 | 2019-03-11 18:49:56 +0000 | [diff] [blame] | 456 | // Only test tip for js/wasm, and only for some repos: |
Brad Fitzpatrick | b8db43d | 2019-03-11 04:20:46 +0000 | [diff] [blame] | 457 | {b("js-wasm", "go"), both}, |
Brad Fitzpatrick | 8665028 | 2019-03-11 18:49:56 +0000 | [diff] [blame] | 458 | {b("js-wasm", "arch"), onlyPost}, |
| 459 | {b("js-wasm", "crypto"), onlyPost}, |
| 460 | {b("js-wasm", "sys"), onlyPost}, |
Brad Fitzpatrick | b8db43d | 2019-03-11 04:20:46 +0000 | [diff] [blame] | 461 | {b("js-wasm", "net"), onlyPost}, |
| 462 | {b("js-wasm@go1.12", "net"), none}, |
Brad Fitzpatrick | 8665028 | 2019-03-11 18:49:56 +0000 | [diff] [blame] | 463 | {b("js-wasm", "benchmarks"), none}, |
| 464 | {b("js-wasm", "debug"), none}, |
| 465 | {b("js-wasm", "mobile"), none}, |
| 466 | {b("js-wasm", "perf"), none}, |
| 467 | {b("js-wasm", "talks"), none}, |
| 468 | {b("js-wasm", "tools"), none}, |
| 469 | {b("js-wasm", "tour"), none}, |
| 470 | {b("js-wasm", "website"), none}, |
| 471 | |
| 472 | // Race builders. Linux for all, GCE buidlers for |
| 473 | // post-submit, and only post-submit for "go" for |
| 474 | // Darwin (limited resources). |
| 475 | {b("linux-amd64-race", "go"), both}, |
| 476 | {b("linux-amd64-race", "net"), both}, |
| 477 | {b("windows-amd64-race", "go"), onlyPost}, |
| 478 | {b("windows-amd64-race", "net"), onlyPost}, |
| 479 | {b("freebsd-amd64-race", "go"), onlyPost}, |
| 480 | {b("freebsd-amd64-race", "net"), onlyPost}, |
| 481 | {b("darwin-amd64-race", "go"), onlyPost}, |
| 482 | {b("darwin-amd64-race", "net"), none}, |
| 483 | |
| 484 | // Long test. |
| 485 | {b("linux-amd64-longtest", "go"), onlyPost}, |
| 486 | {b("linux-amd64-longtest", "net"), onlyPost}, |
Dmitri Shuralyov | 5a8fb63 | 2020-05-26 18:19:05 -0400 | [diff] [blame] | 487 | {b("linux-amd64-longtest@go1.14", "go"), both}, |
Dmitri Shuralyov | 9e7a762 | 2020-05-26 18:12:12 -0400 | [diff] [blame] | 488 | {b("linux-amd64-longtest@go1.14", "net"), none}, |
Brad Fitzpatrick | f9c537e | 2019-10-28 20:16:36 +0000 | [diff] [blame] | 489 | {b("windows-amd64-longtest", "go"), onlyPost}, |
Dmitri Shuralyov | 5a8fb63 | 2020-05-26 18:19:05 -0400 | [diff] [blame] | 490 | {b("windows-amd64-longtest@go1.14", "go"), both}, |
Brad Fitzpatrick | f9c537e | 2019-10-28 20:16:36 +0000 | [diff] [blame] | 491 | {b("windows-amd64-longtest", "net"), onlyPost}, |
| 492 | {b("windows-amd64-longtest", "exp"), onlyPost}, |
| 493 | {b("windows-amd64-longtest", "mobile"), none}, |
Dmitri Shuralyov | dd5ac55 | 2020-07-01 14:14:47 -0400 | [diff] [blame] | 494 | {b("linux-386-longtest", "go"), onlyPost}, |
| 495 | {b("linux-386-longtest", "net"), onlyPost}, |
| 496 | {b("linux-386-longtest", "exp"), none}, |
| 497 | {b("linux-386-longtest", "mobile"), none}, |
Brad Fitzpatrick | 83c6b6a | 2019-03-14 20:35:32 +0000 | [diff] [blame] | 498 | |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 499 | // Experimental exp repo runs in very few places. |
Brad Fitzpatrick | 83c6b6a | 2019-03-14 20:35:32 +0000 | [diff] [blame] | 500 | {b("linux-amd64", "exp"), both}, |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 501 | {b("linux-amd64-race", "exp"), both}, |
| 502 | {b("linux-amd64-longtest", "exp"), onlyPost}, |
Brad Fitzpatrick | 83c6b6a | 2019-03-14 20:35:32 +0000 | [diff] [blame] | 503 | {b("windows-386-2008", "exp"), both}, |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 504 | {b("windows-amd64-2016", "exp"), both}, |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 505 | {b("darwin-amd64-10_14", "exp"), onlyPost}, |
Carlos Amedee | d6dec9c | 2019-11-19 14:55:01 +0000 | [diff] [blame] | 506 | {b("darwin-amd64-10_15", "exp"), onlyPost}, |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 507 | // ... but not on most others: |
Dmitri Shuralyov | 3b77b3a | 2019-09-28 17:43:42 +0000 | [diff] [blame] | 508 | {b("darwin-amd64-10_12", "exp"), none}, |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 509 | {b("freebsd-386-11_2", "exp"), none}, |
| 510 | {b("freebsd-386-12_0", "exp"), none}, |
| 511 | {b("freebsd-amd64-11_2", "exp"), none}, |
| 512 | {b("freebsd-amd64-12_0", "exp"), none}, |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 513 | {b("openbsd-amd64-64", "exp"), none}, |
Dmitri Shuralyov | 01e47d9 | 2020-12-21 14:12:25 -0500 | [diff] [blame] | 514 | {b("openbsd-amd64-68", "exp"), none}, |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 515 | {b("js-wasm", "exp"), none}, |
| 516 | |
| 517 | // exp is experimental; it doesn't test against release branches. |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 518 | {b("linux-amd64@go1.12", "exp"), none}, |
Brad Fitzpatrick | 8a071d4 | 2019-03-18 16:48:22 +0000 | [diff] [blame] | 519 | |
Brad Fitzpatrick | c8ca962 | 2019-12-07 05:14:28 +0000 | [diff] [blame] | 520 | // the build repo is only really useful for linux-amd64 (where we run it), |
| 521 | // and darwin-amd64 and perhaps windows-amd64 (for stuff like gomote). |
| 522 | // No need for any other operating systems to use it. |
| 523 | {b("linux-amd64", "build"), both}, |
| 524 | {b("linux-amd64-longtest", "build"), onlyPost}, |
| 525 | {b("windows-amd64-2016", "build"), both}, |
| 526 | {b("darwin-amd64-10_12", "build"), none}, |
| 527 | {b("darwin-amd64-10_14", "build"), none}, |
| 528 | {b("darwin-amd64-10_15", "build"), onlyPost}, |
Dmitri Shuralyov | 01e47d9 | 2020-12-21 14:12:25 -0500 | [diff] [blame] | 529 | {b("openbsd-amd64-68", "build"), none}, |
Brad Fitzpatrick | c8ca962 | 2019-12-07 05:14:28 +0000 | [diff] [blame] | 530 | {b("linux-amd64-fedora", "build"), none}, |
| 531 | {b("linux-amd64-clang", "build"), none}, |
| 532 | {b("linux-amd64-sid", "build"), none}, |
Brad Fitzpatrick | f6d512d | 2019-12-12 17:43:59 +0000 | [diff] [blame] | 533 | {b("linux-amd64-nocgo", "build"), none}, |
| 534 | {b("linux-386-longtest", "build"), none}, |
Brad Fitzpatrick | f6d512d | 2019-12-12 17:43:59 +0000 | [diff] [blame] | 535 | {b("js-wasm", "build"), none}, |
| 536 | {b("android-386-emu", "build"), none}, |
| 537 | {b("android-amd64-emu", "build"), none}, |
Brad Fitzpatrick | c8ca962 | 2019-12-07 05:14:28 +0000 | [diff] [blame] | 538 | |
Brad Fitzpatrick | 8a071d4 | 2019-03-18 16:48:22 +0000 | [diff] [blame] | 539 | // Only use latest macOS for subrepos, and only amd64: |
| 540 | {b("darwin-amd64-10_12", "net"), onlyPost}, |
Brad Fitzpatrick | 8bd8e0e | 2019-03-26 23:04:31 +0000 | [diff] [blame] | 541 | |
Carlos Amedee | d6dec9c | 2019-11-19 14:55:01 +0000 | [diff] [blame] | 542 | {b("darwin-amd64-10_15", "go"), onlyPost}, |
Brad Fitzpatrick | 8bd8e0e | 2019-03-26 23:04:31 +0000 | [diff] [blame] | 543 | {b("darwin-amd64-10_14", "go"), onlyPost}, |
| 544 | {b("darwin-amd64-10_12", "go"), onlyPost}, |
Brad Fitzpatrick | 85a73d7 | 2019-04-03 04:45:29 +0000 | [diff] [blame] | 545 | |
Brad Fitzpatrick | 67073b9 | 2019-04-18 19:33:19 +0000 | [diff] [blame] | 546 | // plan9 only lived at master. We didn't support any past releases. |
| 547 | // But it's off for now as it's always failing. |
| 548 | {b("plan9-386", "go"), none}, // temporarily disabled |
| 549 | {b("plan9-386", "net"), none}, // temporarily disabled |
Tobias Klauser | 22d3b24 | 2019-11-28 11:33:00 +0100 | [diff] [blame] | 550 | {b("plan9-386", "exp"), none}, |
| 551 | {b("plan9-386", "mobile"), none}, |
Brad Fitzpatrick | f7a5fcf | 2019-04-03 05:03:37 +0000 | [diff] [blame] | 552 | {b("plan9-386@go1.12", "go"), none}, |
Brad Fitzpatrick | f7a5fcf | 2019-04-03 05:03:37 +0000 | [diff] [blame] | 553 | {b("plan9-386@go1.12", "net"), none}, |
| 554 | {b("plan9-amd64-9front", "go"), onlyPost}, |
Tobias Klauser | 22d3b24 | 2019-11-28 11:33:00 +0100 | [diff] [blame] | 555 | {b("plan9-amd64-9front", "exp"), none}, |
| 556 | {b("plan9-amd64-9front", "mobile"), none}, |
Brad Fitzpatrick | f7a5fcf | 2019-04-03 05:03:37 +0000 | [diff] [blame] | 557 | {b("plan9-amd64-9front@go1.12", "go"), none}, |
| 558 | {b("plan9-amd64-9front", "net"), onlyPost}, |
Brad Fitzpatrick | f7a5fcf | 2019-04-03 05:03:37 +0000 | [diff] [blame] | 559 | {b("plan9-amd64-9front@go1.12", "net"), none}, |
| 560 | {b("plan9-arm", "go"), onlyPost}, |
Tobias Klauser | 22d3b24 | 2019-11-28 11:33:00 +0100 | [diff] [blame] | 561 | {b("plan9-arm", "exp"), none}, |
| 562 | {b("plan9-arm", "mobile"), none}, |
Brad Fitzpatrick | f7a5fcf | 2019-04-03 05:03:37 +0000 | [diff] [blame] | 563 | {b("plan9-arm@go1.12", "go"), none}, |
| 564 | {b("plan9-arm", "net"), onlyPost}, |
Brad Fitzpatrick | f7a5fcf | 2019-04-03 05:03:37 +0000 | [diff] [blame] | 565 | {b("plan9-arm@go1.12", "net"), none}, |
Brad Fitzpatrick | d6a8c27 | 2019-04-05 05:26:05 +0000 | [diff] [blame] | 566 | |
Brad Fitzpatrick | 5877195 | 2019-10-21 15:00:32 +0000 | [diff] [blame] | 567 | {b("dragonfly-amd64", "go"), onlyPost}, |
| 568 | {b("dragonfly-amd64", "net"), onlyPost}, |
| 569 | {b("dragonfly-amd64@go1.13", "net"), none}, // Dragonfly ABI changes only supported by Go 1.14+ |
| 570 | {b("dragonfly-amd64@go1.13", "go"), none}, // Dragonfly ABI changes only supported by Go 1.14+ |
Antonio Huete Jimenez | a39e467 | 2020-04-04 10:40:16 +0000 | [diff] [blame] | 571 | {b("dragonfly-amd64-5_8", "go"), onlyPost}, |
| 572 | {b("dragonfly-amd64-5_8", "net"), onlyPost}, |
| 573 | {b("dragonfly-amd64-5_8@go1.13", "net"), onlyPost}, |
Dmitri Shuralyov | 77c96bb | 2020-03-19 10:34:11 -0400 | [diff] [blame] | 574 | |
| 575 | {b("linux-amd64-staticlockranking", "go"), onlyPost}, |
| 576 | {b("linux-amd64-staticlockranking@go1.15", "go"), onlyPost}, |
| 577 | {b("linux-amd64-staticlockranking@go1.14", "go"), none}, |
| 578 | {b("linux-amd64-staticlockranking", "net"), none}, |
Austin Clements | 8088608 | 2020-12-21 16:08:53 -0500 | [diff] [blame] | 579 | |
| 580 | {b("linux-amd64-regabi", "go"), onlyPost}, |
| 581 | {b("linux-amd64-regabi", "net"), none}, |
Brad Fitzpatrick | 756764c | 2019-03-07 17:44:41 +0000 | [diff] [blame] | 582 | } |
| 583 | for _, tt := range tests { |
| 584 | t.Run(tt.br.testName, func(t *testing.T) { |
| 585 | bc, ok := Builders[tt.br.builder] |
| 586 | if !ok { |
| 587 | t.Fatalf("unknown builder %q", tt.br.builder) |
| 588 | } |
| 589 | gotPost := bc.BuildsRepoPostSubmit(tt.br.repo, tt.br.branch, tt.br.goBranch) |
| 590 | if tt.want&isBuilder != 0 && !gotPost { |
| 591 | t.Errorf("not a post-submit builder, but expected") |
| 592 | } |
| 593 | if tt.want¬Builder != 0 && gotPost { |
| 594 | t.Errorf("unexpectedly a post-submit builder") |
| 595 | } |
| 596 | |
| 597 | gotTry := bc.BuildsRepoTryBot(tt.br.repo, tt.br.branch, tt.br.goBranch) |
| 598 | if tt.want&isTrybot != 0 && !gotTry { |
| 599 | t.Errorf("not trybot, but expected") |
| 600 | } |
| 601 | if tt.want¬Trybot != 0 && gotTry { |
| 602 | t.Errorf("unexpectedly a trybot") |
| 603 | } |
| 604 | |
| 605 | if t.Failed() { |
| 606 | t.Logf("For: %+v", tt.br) |
| 607 | } |
| 608 | }) |
| 609 | } |
Brad Fitzpatrick | c328d04 | 2017-04-12 00:35:37 +0000 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | func TestHostConfigsAllUsed(t *testing.T) { |
Dmitri Shuralyov | 0768812 | 2020-08-04 12:01:34 -0400 | [diff] [blame] | 613 | knownUnused := map[string]bool{ |
| 614 | // Currently host-linux-armhf-cross and host-linux-armel-cross aren't |
| 615 | // referenced, but the coordinator hard-codes them, so don't make |
| 616 | // these two an error for now. |
| 617 | "host-linux-armhf-cross": true, |
| 618 | "host-linux-armel-cross": true, |
| 619 | |
| 620 | "host-linux-x86-alpine": true, // TODO(golang.org/issue/19938): Fix the Alpine builder, or remove it. |
Dmitri Shuralyov | 0768812 | 2020-08-04 12:01:34 -0400 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | used := make(map[string]bool) |
Brad Fitzpatrick | c328d04 | 2017-04-12 00:35:37 +0000 | [diff] [blame] | 624 | for _, conf := range Builders { |
| 625 | used[conf.HostType] = true |
| 626 | } |
| 627 | for hostType := range Hosts { |
Dmitri Shuralyov | 0768812 | 2020-08-04 12:01:34 -0400 | [diff] [blame] | 628 | if !used[hostType] && !knownUnused[hostType] { |
| 629 | t.Errorf("host type %q is not referenced from any build config", hostType) |
| 630 | } |
| 631 | if used[hostType] && knownUnused[hostType] { |
| 632 | t.Errorf("host type %q should not be listed in knownUnused since it's in use", hostType) |
Brad Fitzpatrick | c328d04 | 2017-04-12 00:35:37 +0000 | [diff] [blame] | 633 | } |
| 634 | } |
| 635 | } |
Brad Fitzpatrick | 8665028 | 2019-03-11 18:49:56 +0000 | [diff] [blame] | 636 | |
| 637 | // tests that goBranch is optional for repo == "go" |
| 638 | func TestBuildsRepoAtAllImplicitGoBranch(t *testing.T) { |
| 639 | builder := Builders["android-amd64-emu"] |
| 640 | got := builder.buildsRepoAtAll("go", "master", "") |
| 641 | if !got { |
| 642 | t.Error("got = false; want true") |
| 643 | } |
| 644 | } |
Brad Fitzpatrick | 43eb39e | 2019-04-02 15:27:10 +0000 | [diff] [blame] | 645 | |
| 646 | func TestShouldRunDistTest(t *testing.T) { |
| 647 | type buildMode int |
| 648 | const ( |
| 649 | tryMode buildMode = 0 |
| 650 | postSubmit buildMode = 1 |
| 651 | ) |
| 652 | |
| 653 | tests := []struct { |
| 654 | builder string |
| 655 | test string |
| 656 | mode buildMode |
| 657 | want bool |
| 658 | }{ |
| 659 | {"linux-amd64", "api", postSubmit, true}, |
| 660 | {"linux-amd64", "api", tryMode, true}, |
Dmitri Shuralyov | 75a37cb | 2020-04-09 12:47:03 -0400 | [diff] [blame] | 661 | {"freebsd-amd64-12_0", "api", postSubmit, true}, // freebsd-amd64-12_0 uses fasterTrybots policy, should still build. |
| 662 | {"freebsd-amd64-12_0", "api", tryMode, false}, // freebsd-amd64-12_0 uses fasterTrybots policy, should skip in try mode. |
Brad Fitzpatrick | 43eb39e | 2019-04-02 15:27:10 +0000 | [diff] [blame] | 663 | |
| 664 | {"linux-amd64", "reboot", tryMode, true}, |
| 665 | {"linux-amd64-race", "reboot", tryMode, false}, |
| 666 | |
Brad Fitzpatrick | 43eb39e | 2019-04-02 15:27:10 +0000 | [diff] [blame] | 667 | {"darwin-amd64-10_12", "test:foo", postSubmit, false}, |
| 668 | {"darwin-amd64-10_14", "test:foo", postSubmit, false}, |
Brad Fitzpatrick | 43eb39e | 2019-04-02 15:27:10 +0000 | [diff] [blame] | 669 | {"darwin-amd64-10_14", "reboot", postSubmit, false}, |
| 670 | {"darwin-amd64-10_14", "api", postSubmit, false}, |
| 671 | {"darwin-amd64-10_14", "codewalk", postSubmit, false}, |
Carlos Amedee | d6dec9c | 2019-11-19 14:55:01 +0000 | [diff] [blame] | 672 | {"darwin-amd64-10_15", "test:foo", postSubmit, false}, |
Brad Fitzpatrick | 43eb39e | 2019-04-02 15:27:10 +0000 | [diff] [blame] | 673 | } |
| 674 | for _, tt := range tests { |
| 675 | bc, ok := Builders[tt.builder] |
| 676 | if !ok { |
| 677 | t.Errorf("unknown builder %q", tt.builder) |
| 678 | continue |
| 679 | } |
| 680 | isTry := tt.mode == tryMode |
| 681 | if isTry && !bc.BuildsRepoTryBot("go", "master", "master") { |
| 682 | t.Errorf("builder %q is not a trybot, so can't run test %q in try mode", tt.builder, tt.test) |
| 683 | continue |
| 684 | } |
| 685 | got := bc.ShouldRunDistTest(tt.test, isTry) |
| 686 | if got != tt.want { |
| 687 | t.Errorf("%q.ShouldRunDistTest(%q, try %v) = %v; want %v", tt.builder, tt.test, isTry, got, tt.want) |
| 688 | } |
| 689 | } |
| 690 | } |
Dmitri Shuralyov | 01fd299 | 2019-09-09 16:48:08 -0400 | [diff] [blame] | 691 | |
| 692 | func TestShouldTestPackageInGOPATHMode(t *testing.T) { |
| 693 | // This function doesn't change behavior depending on the builder |
| 694 | // at this time, so just use a common one. |
| 695 | bc, ok := Builders["linux-amd64"] |
| 696 | if !ok { |
| 697 | t.Fatal("unknown builder") |
| 698 | } |
| 699 | |
| 700 | tests := []struct { |
| 701 | importPath string |
| 702 | want bool |
| 703 | }{ |
| 704 | {"golang.org/x/image/bmp", true}, |
| 705 | {"golang.org/x/tools/go/ast/astutil", true}, |
| 706 | {"golang.org/x/tools/go/packages", true}, |
| 707 | {"golang.org/x/tools", true}, // Three isn't a package there, but if there was, it should be tested. |
| 708 | {"golang.org/x/tools/gopls", false}, |
| 709 | {"golang.org/x/tools/gopls/internal/foobar", false}, |
| 710 | } |
| 711 | for _, tt := range tests { |
| 712 | got := bc.ShouldTestPackageInGOPATHMode(tt.importPath) |
| 713 | if got != tt.want { |
| 714 | t.Errorf("ShouldTestPackageInGOPATHMode(%q) = %v; want %v", tt.importPath, got, tt.want) |
| 715 | } |
| 716 | } |
| 717 | } |
Brad Fitzpatrick | aab8504 | 2019-10-16 06:02:29 +0000 | [diff] [blame] | 718 | |
| 719 | func TestSlowBotAliases(t *testing.T) { |
| 720 | for term, name := range slowBotAliases { |
| 721 | if name == "" { |
| 722 | // Empty string means known missing builder. |
| 723 | continue |
| 724 | } |
| 725 | if _, ok := Builders[name]; !ok { |
| 726 | t.Errorf("slowbot term %q references unknown builder %q", term, name) |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | out, err := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "tool", "dist", "list").Output() |
| 731 | if err != nil { |
| 732 | t.Errorf("dist list: %v", err) |
| 733 | } |
| 734 | ports := strings.Fields(string(out)) |
| 735 | |
| 736 | done := map[string]bool{} |
Carlos Amedee | 3e01d87 | 2020-04-22 18:52:59 -0400 | [diff] [blame] | 737 | |
Brad Fitzpatrick | aab8504 | 2019-10-16 06:02:29 +0000 | [diff] [blame] | 738 | var add bytes.Buffer |
| 739 | check := func(term string, isArch bool) { |
| 740 | if done[term] { |
| 741 | return |
| 742 | } |
| 743 | done[term] = true |
| 744 | _, isBuilderName := Builders[term] |
| 745 | _, hasAlias := slowBotAliases[term] |
| 746 | if !isBuilderName && !hasAlias { |
| 747 | prefix := term |
| 748 | if isArch { |
| 749 | prefix = "linux-" + term |
| 750 | } |
| 751 | var matches []string |
| 752 | for name := range Builders { |
| 753 | if strings.HasPrefix(name, prefix) { |
| 754 | matches = append(matches, name) |
| 755 | } |
| 756 | } |
| 757 | sort.Strings(matches) |
| 758 | t.Errorf("term %q has no match in slowBotAliases", term) |
| 759 | if len(matches) == 1 { |
| 760 | fmt.Fprintf(&add, "%q: %q,\n", term, matches[0]) |
| 761 | } else if len(matches) > 1 { |
| 762 | t.Errorf("maybe add: %q: %q, (matches=%q)", term, matches[len(matches)-1], matches) |
| 763 | } |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | for _, port := range ports { |
| 768 | slash := strings.IndexByte(port, '/') |
| 769 | if slash == -1 { |
| 770 | t.Fatalf("unexpected port %q", port) |
| 771 | } |
| 772 | goos, goarch := port[:slash], port[slash+1:] |
| 773 | check(goos+"-"+goarch, false) |
| 774 | check(goos, false) |
| 775 | check(goarch, true) |
| 776 | } |
| 777 | |
| 778 | if add.Len() > 0 { |
| 779 | t.Errorf("Missing items from slowBotAliases:\n%s", add.String()) |
| 780 | } |
| 781 | } |
Brad Fitzpatrick | ad7af46 | 2019-10-19 02:49:53 +0000 | [diff] [blame] | 782 | |
| 783 | func TestCrossCompileConfigs(t *testing.T) { |
| 784 | // Verify that Builders.CrossCompileConfig have valid host types. |
| 785 | for name, bc := range Builders { |
| 786 | cc := bc.CrossCompileConfig |
| 787 | if cc == nil { |
| 788 | continue |
| 789 | } |
| 790 | if _, ok := Hosts[cc.CompileHostType]; !ok { |
| 791 | t.Errorf("unknown host type %q for builder %q", cc.CompileHostType, name) |
| 792 | } |
| 793 | } |
| 794 | } |
Tobias Klauser | cd82ecd | 2019-11-07 14:15:55 +0100 | [diff] [blame] | 795 | |
| 796 | // TestTryBotsCompileAllPorts verifies that each port (go tool dist list) is covered by |
| 797 | // either a real trybot or a misc-compile trybot. |
| 798 | func TestTryBotsCompileAllPorts(t *testing.T) { |
| 799 | out, err := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "tool", "dist", "list").Output() |
| 800 | if err != nil { |
| 801 | t.Errorf("dist list: %v", err) |
| 802 | } |
| 803 | ports := strings.Fields(string(out)) |
| 804 | |
| 805 | done := map[string]bool{} |
Dmitri Shuralyov | fc63a04 | 2021-02-19 12:18:43 -0500 | [diff] [blame] | 806 | done["darwin-arm64"] = true // TODO(golang.org/issue/39782): Add builder for darwin/arm64. |
| 807 | done["windows-arm64"] = true // TODO(golang.org/issue/42604): Add builder for windows/arm64. |
Tobias Klauser | cd82ecd | 2019-11-07 14:15:55 +0100 | [diff] [blame] | 808 | check := func(goos, goarch string) { |
Dmitri Shuralyov | 55e1ef6 | 2020-09-28 11:04:35 -0400 | [diff] [blame] | 809 | if goos == "android" || goos == "ios" { |
Brad Fitzpatrick | 8a3c1d9 | 2019-11-15 04:29:29 +0000 | [diff] [blame] | 810 | // TODO(golang.org/issue/25963): support |
Dmitri Shuralyov | 55e1ef6 | 2020-09-28 11:04:35 -0400 | [diff] [blame] | 811 | // compilation-only Android and iOS trybots. |
Brad Fitzpatrick | 8a3c1d9 | 2019-11-15 04:29:29 +0000 | [diff] [blame] | 812 | // buildall.bash doesn't set the environment |
| 813 | // up enough for e.g. compiling android-386 |
| 814 | // from linux-amd64. (Issue #35596 too) |
Dmitri Shuralyov | 55e1ef6 | 2020-09-28 11:04:35 -0400 | [diff] [blame] | 815 | // iOS likely needs to be built on macOS |
| 816 | // with Xcode available. |
Brad Fitzpatrick | 8a3c1d9 | 2019-11-15 04:29:29 +0000 | [diff] [blame] | 817 | return |
| 818 | } |
Tobias Klauser | cd82ecd | 2019-11-07 14:15:55 +0100 | [diff] [blame] | 819 | goosArch := goos + "-" + goarch |
| 820 | if done[goosArch] { |
| 821 | return |
| 822 | } |
| 823 | for _, conf := range Builders { |
| 824 | os := conf.GOOS() |
| 825 | arch := conf.GOARCH() |
| 826 | |
| 827 | if os == goos && arch == goarch && (conf.tryOnly || conf.tryBot != nil) { |
| 828 | done[goosArch] = true |
| 829 | break |
| 830 | } |
| 831 | |
| 832 | if strings.HasPrefix(conf.Name, "misc-compile-") { |
| 833 | re, err := regexp.Compile(conf.allScriptArgs[0]) |
| 834 | if err != nil { |
| 835 | t.Errorf("Invalid misc-compile filtering pattern for builder %q: %q", |
| 836 | conf.Name, conf.allScriptArgs[0]) |
| 837 | } |
| 838 | |
| 839 | if re.MatchString(goosArch) || re.MatchString(goos) { |
| 840 | done[goosArch] = true |
| 841 | break |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | if _, ok := done[goosArch]; !ok { |
| 846 | t.Errorf("Missing trybot or misc-compile trybot: %q", goosArch) |
| 847 | } |
Tobias Klauser | cd82ecd | 2019-11-07 14:15:55 +0100 | [diff] [blame] | 848 | } |
| 849 | |
| 850 | for _, port := range ports { |
| 851 | slash := strings.IndexByte(port, '/') |
| 852 | if slash == -1 { |
| 853 | t.Fatalf("unexpected port %q", port) |
| 854 | } |
| 855 | check(port[:slash], port[slash+1:]) |
| 856 | } |
| 857 | |
| 858 | } |
Carlos Amedee | d6dec9c | 2019-11-19 14:55:01 +0000 | [diff] [blame] | 859 | |
| 860 | // TestExpectedMacstadiumVMCount ensures that only 20 instances of macOS virtual machines |
| 861 | // are expected at MacStadium. |
| 862 | // TODO: remove once the scheduler allocates VMs based on demand https://golang.org/issue/35698 |
| 863 | func TestExpectedMacstadiumVMCount(t *testing.T) { |
| 864 | got := 0 |
| 865 | for host, config := range Hosts { |
Carlos Amedee | d576fd3 | 2021-01-29 15:47:13 -0500 | [diff] [blame] | 866 | if strings.HasPrefix(host, "host-darwin-10_") || strings.HasPrefix(host, "host-darwin-amd64-") { |
Carlos Amedee | d6dec9c | 2019-11-19 14:55:01 +0000 | [diff] [blame] | 867 | got += config.ExpectNum |
| 868 | } |
| 869 | } |
| 870 | if got != 20 { |
| 871 | t.Fatalf("macstadium host count: got %d; want 20", got) |
| 872 | } |
| 873 | } |
Dmitri Shuralyov | df328b1 | 2020-05-13 14:30:25 -0400 | [diff] [blame] | 874 | |
| 875 | // Test that we have a longtest builder and |
| 876 | // that its environment configuration is okay. |
| 877 | func TestLongTestBuilder(t *testing.T) { |
| 878 | long, ok := Builders["linux-amd64-longtest"] |
| 879 | if !ok { |
| 880 | t.Fatal("we don't have a linux-amd64-longtest builder anymore, is that intentional?") |
| 881 | } |
| 882 | if !long.IsLongTest() { |
| 883 | t.Error("the linux-amd64-longtest builder isn't a longtest builder, is that intentional?") |
| 884 | } |
| 885 | var shortDisabled bool |
| 886 | for _, e := range long.Env() { |
| 887 | if e == "GO_TEST_SHORT=0" { |
| 888 | shortDisabled = true |
| 889 | } |
| 890 | } |
| 891 | if !shortDisabled { |
| 892 | t.Error("the linux-amd64-longtest builder doesn't set GO_TEST_SHORT=0, is that intentional?") |
| 893 | } |
| 894 | } |
Carlos Amedee | d77c6d0 | 2020-08-18 13:32:05 -0400 | [diff] [blame] | 895 | |
| 896 | func TestHostConfigIsVM(t *testing.T) { |
| 897 | testCases := []struct { |
| 898 | desc string |
| 899 | config *HostConfig |
| 900 | want bool |
| 901 | }{ |
| 902 | { |
| 903 | desc: "non-ec2-vm", |
| 904 | config: &HostConfig{ |
| 905 | VMImage: "image-x", |
| 906 | ContainerImage: "", |
| 907 | isEC2: false, |
| 908 | }, |
| 909 | want: true, |
| 910 | }, |
| 911 | { |
| 912 | desc: "non-ec2-container", |
| 913 | config: &HostConfig{ |
| 914 | VMImage: "", |
| 915 | ContainerImage: "container-image-x", |
| 916 | isEC2: false, |
| 917 | }, |
| 918 | want: false, |
| 919 | }, |
| 920 | { |
| 921 | desc: "ec2-container", |
| 922 | config: &HostConfig{ |
| 923 | VMImage: "image-x", |
| 924 | ContainerImage: "container-image-x", |
| 925 | isEC2: true, |
| 926 | }, |
| 927 | want: false, |
| 928 | }, |
| 929 | { |
| 930 | desc: "ec2-vm", |
| 931 | config: &HostConfig{ |
| 932 | VMImage: "image-x", |
| 933 | ContainerImage: "", |
| 934 | isEC2: true, |
| 935 | }, |
| 936 | want: true, |
| 937 | }, |
| 938 | } |
| 939 | for _, tc := range testCases { |
| 940 | t.Run(fmt.Sprintf(tc.desc), func(t *testing.T) { |
| 941 | if got := tc.config.IsVM(); got != tc.want { |
| 942 | t.Errorf("HostConfig.IsVM() = %t; want %t", got, tc.want) |
| 943 | } |
| 944 | }) |
| 945 | } |
| 946 | } |
Carlos Amedee | 1e76199 | 2020-08-20 11:53:58 -0400 | [diff] [blame] | 947 | |
| 948 | func TestModulesEnv(t *testing.T) { |
| 949 | testCases := []struct { |
| 950 | desc string |
| 951 | buildConfig *BuildConfig |
| 952 | repo string |
| 953 | want []string |
| 954 | }{ |
| 955 | { |
| 956 | desc: "ec2-builder-repo-non-go", |
| 957 | buildConfig: &BuildConfig{ |
| 958 | testHostConf: &HostConfig{ |
| 959 | IsReverse: false, |
| 960 | isEC2: true, |
| 961 | }, |
| 962 | }, |
| 963 | repo: "bar", |
| 964 | want: []string{"GOPROXY=https://proxy.golang.org"}, |
| 965 | }, |
| 966 | { |
| 967 | desc: "reverse-builder-repo-non-go", |
| 968 | buildConfig: &BuildConfig{ |
| 969 | testHostConf: &HostConfig{ |
| 970 | IsReverse: true, |
| 971 | isEC2: false, |
| 972 | }, |
| 973 | }, |
| 974 | repo: "bar", |
| 975 | want: []string{"GOPROXY=https://proxy.golang.org"}, |
| 976 | }, |
| 977 | { |
| 978 | desc: "reverse-builder-repo-go", |
| 979 | buildConfig: &BuildConfig{ |
| 980 | testHostConf: &HostConfig{ |
| 981 | IsReverse: true, |
| 982 | isEC2: false, |
| 983 | }, |
| 984 | }, |
| 985 | repo: "go", |
| 986 | want: []string{"GOPROXY=off"}, |
| 987 | }, |
| 988 | { |
| 989 | desc: "builder-repo-go", |
| 990 | buildConfig: &BuildConfig{ |
| 991 | testHostConf: &HostConfig{ |
| 992 | IsReverse: false, |
| 993 | isEC2: false, |
| 994 | }, |
| 995 | }, |
| 996 | repo: "go", |
| 997 | want: []string{"GOPROXY=off"}, |
| 998 | }, |
| 999 | { |
| 1000 | desc: "builder-repo-go-outbound-network-allowed", |
| 1001 | buildConfig: &BuildConfig{ |
| 1002 | Name: "test-longtest", |
| 1003 | testHostConf: &HostConfig{ |
| 1004 | IsReverse: false, |
| 1005 | isEC2: false, |
| 1006 | }, |
| 1007 | }, |
| 1008 | repo: "go", |
| 1009 | want: nil, |
| 1010 | }, |
| 1011 | { |
| 1012 | desc: "builder-repo-special-case", |
| 1013 | buildConfig: &BuildConfig{ |
| 1014 | testHostConf: &HostConfig{ |
| 1015 | IsReverse: false, |
| 1016 | isEC2: false, |
| 1017 | }, |
| 1018 | }, |
| 1019 | repo: "build", |
| 1020 | want: []string{"GO111MODULE=on"}, |
| 1021 | }, |
| 1022 | { |
| 1023 | desc: "reverse-builder-repo-special-case", |
| 1024 | buildConfig: &BuildConfig{ |
| 1025 | testHostConf: &HostConfig{ |
| 1026 | IsReverse: true, |
| 1027 | isEC2: false, |
| 1028 | }, |
| 1029 | }, |
| 1030 | repo: "build", |
| 1031 | want: []string{"GOPROXY=https://proxy.golang.org", "GO111MODULE=on"}, |
| 1032 | }, |
| 1033 | { |
| 1034 | desc: "builder-repo-non-special-case", |
| 1035 | buildConfig: &BuildConfig{ |
| 1036 | testHostConf: &HostConfig{ |
| 1037 | IsReverse: false, |
| 1038 | isEC2: false, |
| 1039 | }, |
| 1040 | }, |
| 1041 | repo: "bar", |
| 1042 | want: nil, |
| 1043 | }, |
| 1044 | } |
| 1045 | for _, tc := range testCases { |
| 1046 | t.Run(tc.desc, func(t *testing.T) { |
| 1047 | got := tc.buildConfig.ModulesEnv(tc.repo) |
| 1048 | if diff := cmp.Diff(tc.want, got); diff != "" { |
| 1049 | t.Errorf("BuildConfig.ModulesEnv(%q) mismatch (-want, +got)\n%s", tc.repo, diff) |
| 1050 | } |
| 1051 | }) |
| 1052 | } |
| 1053 | } |