blob: d935e3c6ddb1c784c74d28eebf811b794033e487 [file] [log] [blame]
Brad Fitzpatrickf3c01932015-01-15 16:29:16 -08001// 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
5package dashboard
6
7import (
Brad Fitzpatrickaab85042019-10-16 06:02:29 +00008 "bytes"
Brad Fitzpatrick756764c2019-03-07 17:44:41 +00009 "fmt"
Brad Fitzpatrickaab85042019-10-16 06:02:29 +000010 "os/exec"
11 "path/filepath"
Tobias Klausercd82ecd2019-11-07 14:15:55 +010012 "regexp"
Brad Fitzpatrickaab85042019-10-16 06:02:29 +000013 "runtime"
14 "sort"
Brad Fitzpatrickf3c01932015-01-15 16:29:16 -080015 "strings"
16 "testing"
Brad Fitzpatrick34b995b2019-02-14 02:18:06 +000017 "time"
Carlos Amedee1e761992020-08-20 11:53:58 -040018
19 "github.com/google/go-cmp/cmp"
Brad Fitzpatrickf3c01932015-01-15 16:29:16 -080020)
21
22func 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 Fitzpatrickc328d042017-04-12 00:35:37 +000033
Brad Fitzpatrick34b995b2019-02-14 02:18:06 +000034func 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 Fitzpatrick756764c2019-03-07 17:44:41 +000081// 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.
84func 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 Fitzpatrick4e29d672019-04-18 19:45:32 +000094 "android-amd64-emu",
Carlos Amedee2ecf4242021-04-23 11:33:51 -040095 "freebsd-amd64-12_2",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +000096 "js-wasm",
97 "linux-386",
98 "linux-amd64",
99 "linux-amd64-race",
Matthew Dempsky4f8007b2021-08-12 15:11:41 -0700100 "linux-amd64-unified",
Carlos Amedeec1822c72021-03-19 13:54:17 -0400101 "linux-arm-aws",
Carlos Amedee34b0d642021-03-19 14:53:06 -0400102 "linux-arm64-aws",
Dmitri Shuralyov01e47d92020-12-21 14:12:25 -0500103 "openbsd-amd64-68",
Carlos Amedeef077b9b2021-11-11 15:05:21 -0500104 "windows-386-2012",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000105 "windows-amd64-2016",
Dmitri Shuralyov646d48d2021-04-23 16:56:37 -0400106
107 "misc-compile-darwinarm64",
108 "misc-compile-freebsd",
109 "misc-compile-mac-win",
110 "misc-compile-mips",
111 "misc-compile-mipsle",
112 "misc-compile-netbsd",
113 "misc-compile-netbsd-arm",
114 "misc-compile-openbsd",
115 "misc-compile-openbsd-arm",
116 "misc-compile-plan9",
117 "misc-compile-ppc",
118 "misc-compile-other-1",
119 "misc-compile-other-2",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000120 },
121 },
122 {
123 repo: "go",
Matthew Dempskydf58bba2021-06-16 23:08:22 -0700124 branch: "dev.typeparams",
Brad Fitzpatrick90670e12019-10-11 18:47:51 +0000125 want: []string{
Cherry Zhang50a78802020-03-13 17:09:21 -0400126 "android-amd64-emu",
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400127 "freebsd-amd64-12_2",
Brad Fitzpatrick90670e12019-10-11 18:47:51 +0000128 "js-wasm",
129 "linux-386",
130 "linux-amd64",
131 "linux-amd64-race",
Matthew Dempskydf58bba2021-06-16 23:08:22 -0700132 "linux-amd64-unified",
Carlos Amedeec1822c72021-03-19 13:54:17 -0400133 "linux-arm-aws",
Carlos Amedee34b0d642021-03-19 14:53:06 -0400134 "linux-arm64-aws",
Dmitri Shuralyov01e47d92020-12-21 14:12:25 -0500135 "openbsd-amd64-68",
Carlos Amedeef077b9b2021-11-11 15:05:21 -0500136 "windows-386-2012",
Brad Fitzpatrick90670e12019-10-11 18:47:51 +0000137 "windows-amd64-2016",
Dmitri Shuralyov646d48d2021-04-23 16:56:37 -0400138
139 "misc-compile-darwinarm64",
140 "misc-compile-freebsd",
141 "misc-compile-mac-win",
142 "misc-compile-mips",
143 "misc-compile-mipsle",
144 "misc-compile-netbsd",
145 "misc-compile-netbsd-arm",
146 "misc-compile-openbsd",
147 "misc-compile-openbsd-arm",
148 "misc-compile-plan9",
149 "misc-compile-ppc",
150 "misc-compile-other-1",
151 "misc-compile-other-2",
Brad Fitzpatrick90670e12019-10-11 18:47:51 +0000152 },
153 },
154 {
155 repo: "go",
Dmitri Shuralyov4c544cb2020-11-02 22:25:51 -0500156 branch: "release-branch.go1.16",
157 want: []string{
158 "android-amd64-emu",
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400159 "freebsd-amd64-12_2",
Dmitri Shuralyov4c544cb2020-11-02 22:25:51 -0500160 "js-wasm",
161 "linux-386",
162 "linux-amd64",
163 "linux-amd64-race",
Carlos Amedeec1822c72021-03-19 13:54:17 -0400164 "linux-arm-aws",
Carlos Amedee34b0d642021-03-19 14:53:06 -0400165 "linux-arm64-aws",
Dmitri Shuralyov01e47d92020-12-21 14:12:25 -0500166 "openbsd-amd64-68",
Dmitri Shuralyov4c544cb2020-11-02 22:25:51 -0500167 "windows-386-2008",
168 "windows-amd64-2016",
169
Dmitri Shuralyov646d48d2021-04-23 16:56:37 -0400170 "misc-compile-darwinarm64", // Starts with Go 1.16.
171 "misc-compile-freebsd",
172 "misc-compile-mac-win",
173 "misc-compile-mips",
174 "misc-compile-mipsle",
175 "misc-compile-netbsd",
176 "misc-compile-netbsd-arm",
177 "misc-compile-openbsd",
178 "misc-compile-openbsd-arm",
179 "misc-compile-plan9",
180 "misc-compile-ppc",
181 "misc-compile-other-1",
182 "misc-compile-other-2",
183
Dmitri Shuralyov4c544cb2020-11-02 22:25:51 -0500184 // Include longtest builders on Go repo release branches. See issue 37827.
185 "linux-386-longtest",
186 "linux-amd64-longtest",
187 "windows-amd64-longtest",
188 },
189 },
190 {
191 repo: "go",
Dmitri Shuralyov43ea6942021-02-19 12:17:28 -0500192 branch: "release-branch.go1.15",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000193 want: []string{
Dmitri Shuralyov9e7a7622020-05-26 18:12:12 -0400194 "android-amd64-emu",
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400195 "freebsd-amd64-12_2",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000196 "js-wasm",
197 "linux-386",
198 "linux-amd64",
199 "linux-amd64-race",
Carlos Amedeec1822c72021-03-19 13:54:17 -0400200 "linux-arm-aws",
Carlos Amedee34b0d642021-03-19 14:53:06 -0400201 "linux-arm64-aws",
Dmitri Shuralyov01e47d92020-12-21 14:12:25 -0500202 "openbsd-amd64-68",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000203 "windows-386-2008",
204 "windows-amd64-2016",
Dmitri Shuralyov5a8fb632020-05-26 18:19:05 -0400205
Dmitri Shuralyov646d48d2021-04-23 16:56:37 -0400206 "misc-compile-freebsd",
207 "misc-compile-mac-win",
208 "misc-compile-mips",
209 "misc-compile-mipsle",
210 "misc-compile-netbsd",
211 "misc-compile-netbsd-arm",
212 "misc-compile-openbsd",
213 "misc-compile-openbsd-arm",
214 "misc-compile-plan9",
215 "misc-compile-ppc",
216 "misc-compile-other-1",
217 "misc-compile-other-2",
218
Dmitri Shuralyov5a8fb632020-05-26 18:19:05 -0400219 // Include longtest builders on Go repo release branches. See issue 37827.
220 "linux-386-longtest",
221 "linux-amd64-longtest",
222 "windows-amd64-longtest",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000223 },
224 },
225 {
226 repo: "mobile",
227 branch: "master",
228 want: []string{
229 "android-amd64-emu",
230 "linux-amd64-androidemu",
231 },
232 },
233 {
234 repo: "sys",
235 branch: "master",
236 want: []string{
Brad Fitzpatrick6d867c82019-04-26 14:04:00 +0000237 "android-amd64-emu",
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400238 "freebsd-386-11_4",
239 "freebsd-amd64-11_4",
240 "freebsd-amd64-12_2",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000241 "linux-386",
242 "linux-amd64",
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000243 "linux-amd64-race",
Carlos Amedeec1822c72021-03-19 13:54:17 -0400244 "linux-arm-aws",
Carlos Amedee34b0d642021-03-19 14:53:06 -0400245 "linux-arm64-aws",
Dmitri Shuralyov5bbd5582020-04-08 12:43:09 -0400246 "netbsd-amd64-9_0",
Dmitri Shuralyov01e47d92020-12-21 14:12:25 -0500247 "openbsd-386-68",
248 "openbsd-amd64-68",
Carlos Amedeef077b9b2021-11-11 15:05:21 -0500249 "windows-386-2012",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000250 "windows-amd64-2016",
251 },
252 },
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000253 {
254 repo: "exp",
255 branch: "master",
256 want: []string{
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000257 "linux-amd64",
258 "linux-amd64-race",
Carlos Amedeef077b9b2021-11-11 15:05:21 -0500259 "windows-386-2012",
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000260 "windows-amd64-2016",
261 },
262 },
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000263 }
264 for i, tt := range tests {
265 if tt.branch == "" || tt.repo == "" {
266 t.Errorf("incomplete test entry %d", i)
267 return
268 }
269 t.Run(fmt.Sprintf("%s/%s", tt.repo, tt.branch), func(t *testing.T) {
270 var got []string
271 goBranch := tt.branch // hard-code the common case for now
272 for _, bc := range TryBuildersForProject(tt.repo, tt.branch, goBranch) {
273 got = append(got, bc.Name)
274 }
275 m := map[string]bool{}
276 for _, b := range tt.want {
277 m[b] = true
278 }
279 for _, b := range got {
280 if _, ok := m[b]; !ok {
281 t.Errorf("got unexpected %q", b)
282 }
283 delete(m, b)
284 }
285 for b := range m {
286 t.Errorf("missing expected %q", b)
Brad Fitzpatrickc517aed2018-10-26 19:21:58 +0000287 }
288 })
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000289 }
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000290}
291
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400292// TestBuilderConfig tests whether a given builder and repo at different branches is
293// completely disabled ("none"),
294// a TryBot and a post-submit builder ("both"), or
295// a post-submit only builder ("onlyPost").
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000296func TestBuilderConfig(t *testing.T) {
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400297 // want is a bitmask of 4 different things to assert are wanted:
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000298 // - being a post-submit builder
299 // - NOT being a post-submit builder
300 // - being a trybot builder
301 // - NOT being a post-submit builder
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400302 // Note: a builder cannot be configured as a TryBot without also being a post-submit builder.
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000303 type want uint8
304 const (
305 isTrybot want = 1 << iota
306 notTrybot
307 isBuilder // post-submit
308 notBuilder // not post-submit
309
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400310 // Available combinations:
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000311 none = notTrybot + notBuilder
312 both = isTrybot + isBuilder
313 onlyPost = notTrybot + isBuilder
314 )
315
316 type builderAndRepo struct {
317 testName string
318 builder string
319 repo string
320 branch string
321 goBranch string
322 }
Dmitri Shuralyov76fd6b52019-10-08 13:08:27 -0400323 // builder may end in "@go1.N" or "@1.N" (as alias for "@release-branch.go1.N") or "@branch-name".
324 // repo (other than "go") may end in "@go1.N" or "@1.N" (as alias for "@release-branch.go1.N").
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000325 b := func(builder, repo string) builderAndRepo {
326 br := builderAndRepo{
327 testName: builder + "," + repo,
328 builder: builder,
329 goBranch: "master",
330 repo: repo,
331 branch: "master",
332 }
333 if strings.Contains(builder, "@") {
334 f := strings.SplitN(builder, "@", 2)
335 br.builder = f[0]
336 br.goBranch = f[1]
337 }
338 if strings.Contains(repo, "@") {
339 f := strings.SplitN(repo, "@", 2)
340 br.repo = f[0]
341 br.branch = f[1]
Dmitri Shuralyov76fd6b52019-10-08 13:08:27 -0400342 if br.repo == "go" {
343 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))
344 }
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000345 }
346 expandBranch := func(s *string) {
347 if strings.HasPrefix(*s, "go1.") {
348 *s = "release-branch." + *s
349 } else if strings.HasPrefix(*s, "1.") {
350 *s = "release-branch.go" + *s
351 }
352 }
353 expandBranch(&br.branch)
354 expandBranch(&br.goBranch)
355 if br.repo == "go" {
356 br.branch = br.goBranch
357 }
358 return br
359 }
360 tests := []struct {
361 br builderAndRepo
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400362 want want // none, both, or onlyPost.
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000363 }{
364 {b("linux-amd64", "go"), both},
365 {b("linux-amd64", "net"), both},
366 {b("linux-amd64", "sys"), both},
Dmitri Shuralyov7aef06b2019-05-16 16:04:34 -0400367 {b("linux-amd64", "website"), both},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000368
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000369 // Don't test all subrepos on all the builders.
370 {b("linux-amd64-ssacheck", "net"), none},
Dmitri Shuralyovdf6c66f2020-10-05 12:20:33 -0400371 {b("linux-amd64-ssacheck@go1.15", "net"), none},
Dmitri Shuralyov0f5b1a72020-10-07 11:24:42 -0400372 {b("linux-386-softfloat", "crypto"), onlyPost},
373 {b("linux-386-softfloat@go1.16", "crypto"), onlyPost},
374 {b("linux-386-softfloat@go1.15", "crypto"), none},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000375
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000376 // The mobile repo requires Go 1.13+.
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000377 {b("android-amd64-emu", "mobile"), both},
378 {b("android-amd64-emu", "mobile@1.10"), none},
379 {b("android-amd64-emu", "mobile@1.11"), none},
380 {b("android-amd64-emu@go1.10", "mobile"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000381 {b("android-amd64-emu@go1.12", "mobile"), none},
382 {b("android-amd64-emu@go1.13", "mobile"), both},
383 {b("android-amd64-emu", "mobile@1.13"), both},
Dmitri Shuralyov220eca82020-01-10 15:53:25 -0500384
385 {b("android-amd64-emu", "go"), both},
Brad Fitzpatrick6d867c82019-04-26 14:04:00 +0000386 {b("android-amd64-emu", "crypto"), both},
387 {b("android-amd64-emu", "net"), both},
388 {b("android-amd64-emu", "sync"), both},
389 {b("android-amd64-emu", "sys"), both},
390 {b("android-amd64-emu", "text"), both},
391 {b("android-amd64-emu", "time"), both},
392 {b("android-amd64-emu", "tools"), both},
Dmitri Shuralyovbb0f2242019-08-29 09:22:13 -0400393 {b("android-amd64-emu", "website"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000394
395 {b("android-386-emu", "go"), onlyPost},
396 {b("android-386-emu", "mobile"), onlyPost},
397 {b("android-386-emu", "mobile@1.10"), none},
398 {b("android-386-emu", "mobile@1.11"), none},
399 {b("android-386-emu@go1.10", "mobile"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000400 {b("android-386-emu@go1.12", "mobile"), none},
401 {b("android-386-emu@go1.13", "mobile"), onlyPost},
402 {b("android-386-emu", "mobile@1.13"), onlyPost},
403
404 {b("linux-amd64", "net"), both},
405 {b("linux-amd64", "net@1.12"), both},
406 {b("linux-amd64@go1.12", "net@1.12"), both},
407 {b("linux-amd64", "net@1.11"), both},
408 {b("linux-amd64", "net@1.11"), both},
409 {b("linux-amd64", "net@1.10"), none}, // too old
410 {b("linux-amd64@go1.10", "net"), none}, // too old
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000411 {b("linux-amd64@go1.12", "net@1.12"), both},
412
Meng Zhuo88052792019-09-10 07:21:11 +0800413 {b("linux-mips64le-mengzhuo", "go"), onlyPost},
414 {b("linux-mips64le-mengzhuo", "sys"), onlyPost},
415 {b("linux-mips64le-mengzhuo", "net"), onlyPost},
416
Xiaodong Liu5eaa6e02021-09-02 15:51:28 +0800417 {b("linux-loong64-3a5000", "go"), onlyPost},
418 {b("linux-loong64-3a5000", "sys"), onlyPost},
419 {b("linux-loong64-3a5000", "net"), onlyPost},
420
Dmitri Shuralyov5f7fe5e2020-11-10 12:56:57 -0500421 // OpenBSD.
Dmitri Shuralyov01e47d92020-12-21 14:12:25 -0500422 {b("openbsd-amd64-68@go1.16", "go"), both},
423 {b("openbsd-amd64-68@go1.15", "go"), both},
424 {b("openbsd-amd64-68@go1.14", "go"), both},
Dmitri Shuralyov5f7fe5e2020-11-10 12:56:57 -0500425
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400426 // FreeBSD 12.2
427 {b("freebsd-amd64-12_2", "go"), both},
428 {b("freebsd-amd64-12_2", "net"), both},
429 {b("freebsd-amd64-12_2", "mobile"), none},
430 {b("freebsd-386-12_2", "go"), onlyPost},
431 {b("freebsd-386-12_2", "net"), onlyPost},
432 {b("freebsd-386-12_2", "mobile"), none},
433
434 // FreeBSD 11.2
435 // See golang.org/issue/45727
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400436 {b("freebsd-amd64-11_2@go1.15", "go"), onlyPost},
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400437 {b("freebsd-amd64-11_2@go1.15", "net"), onlyPost},
438 {b("freebsd-amd64-11_2@go1.15", "sys"), both},
439 {b("freebsd-amd64-11_2", "go"), none},
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400440 {b("freebsd-386-11_2@go1.16", "go"), onlyPost},
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400441 {b("freebsd-386-11_2@go1.16", "net"), onlyPost},
442 {b("freebsd-386-11_2@go1.16", "sys"), both},
443 {b("freebsd-386-11_2", "go"), none},
Brad Fitzpatrick9e52fce2019-03-12 21:13:50 +0000444
Brad Fitzpatrickfcf7a582019-04-30 22:37:31 +0000445 // NetBSD
Dmitri Shuralyov5bbd5582020-04-08 12:43:09 -0400446 {b("netbsd-amd64-9_0", "go"), onlyPost},
447 {b("netbsd-amd64-9_0", "net"), onlyPost},
Dmitri Shuralyovb7c61f72020-04-09 07:59:16 -0400448 {b("netbsd-amd64-9_0", "sys"), both},
Dmitri Shuralyov5bbd5582020-04-08 12:43:09 -0400449 {b("netbsd-386-9_0", "go"), onlyPost},
450 {b("netbsd-386-9_0", "net"), onlyPost},
Brad Fitzpatrickfcf7a582019-04-30 22:37:31 +0000451
Tobias Klauserb7b66932019-03-13 09:29:15 +0100452 // AIX starts at Go 1.12
453 {b("aix-ppc64", "go"), onlyPost},
454 {b("aix-ppc64", "net"), onlyPost},
Tobias Klauserc2ec9e42019-06-04 10:14:55 +0200455 {b("aix-ppc64", "mobile"), none},
456 {b("aix-ppc64", "exp"), none},
Tobias Klausercbdd89b2019-10-14 11:31:13 +0200457 {b("aix-ppc64", "term"), onlyPost},
Dmitri Shuralyov43ea6942021-02-19 12:17:28 -0500458 {b("aix-ppc64@go1.15", "go"), onlyPost},
459 {b("aix-ppc64@go1.15", "net"), onlyPost},
460 {b("aix-ppc64@go1.15", "mobile"), none},
461 {b("aix-ppc64@go1.16", "net"), onlyPost},
462 {b("aix-ppc64@go1.16", "mobile"), none},
Cherry Zhang50a78802020-03-13 17:09:21 -0400463 {b("aix-ppc64@dev.link", "go"), onlyPost},
Tobias Klauserb7b66932019-03-13 09:29:15 +0100464
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000465 {b("linux-amd64-nocgo", "mobile"), none},
466
Elias Naur4d0f77a2019-05-01 22:28:43 +0200467 // Virtual mobiledevices
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400468 {b("ios-arm64-corellium", "go"), onlyPost},
469 {b("android-arm64-corellium", "go"), onlyPost},
470 {b("android-arm-corellium", "go"), onlyPost},
Elias Naur6bebc8e2019-05-01 20:33:26 +0200471
Elias Naur18919d62020-10-03 11:37:07 +0200472 // Mobile builders that run with GOOS=linux/ios and have
Brad Fitzpatrick13f1da92019-03-12 16:21:55 +0000473 // a device attached.
474 {b("linux-amd64-androidemu", "mobile"), both},
Brad Fitzpatrick13f1da92019-03-12 16:21:55 +0000475
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000476 // But the emulators run all:
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400477 {b("android-amd64-emu", "mobile"), both},
478 {b("android-386-emu", "mobile"), onlyPost},
479 {b("android-amd64-emu", "net"), both},
480 {b("android-386-emu", "net"), onlyPost},
481 {b("android-amd64-emu", "go"), both},
482 {b("android-386-emu", "go"), onlyPost},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000483
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000484 // Only test tip for js/wasm, and only for some repos:
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000485 {b("js-wasm", "go"), both},
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000486 {b("js-wasm", "arch"), onlyPost},
487 {b("js-wasm", "crypto"), onlyPost},
488 {b("js-wasm", "sys"), onlyPost},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000489 {b("js-wasm", "net"), onlyPost},
490 {b("js-wasm@go1.12", "net"), none},
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000491 {b("js-wasm", "benchmarks"), none},
492 {b("js-wasm", "debug"), none},
493 {b("js-wasm", "mobile"), none},
494 {b("js-wasm", "perf"), none},
495 {b("js-wasm", "talks"), none},
496 {b("js-wasm", "tools"), none},
497 {b("js-wasm", "tour"), none},
498 {b("js-wasm", "website"), none},
499
500 // Race builders. Linux for all, GCE buidlers for
501 // post-submit, and only post-submit for "go" for
502 // Darwin (limited resources).
503 {b("linux-amd64-race", "go"), both},
504 {b("linux-amd64-race", "net"), both},
505 {b("windows-amd64-race", "go"), onlyPost},
506 {b("windows-amd64-race", "net"), onlyPost},
507 {b("freebsd-amd64-race", "go"), onlyPost},
508 {b("freebsd-amd64-race", "net"), onlyPost},
509 {b("darwin-amd64-race", "go"), onlyPost},
510 {b("darwin-amd64-race", "net"), none},
511
512 // Long test.
513 {b("linux-amd64-longtest", "go"), onlyPost},
514 {b("linux-amd64-longtest", "net"), onlyPost},
Dmitri Shuralyov5a8fb632020-05-26 18:19:05 -0400515 {b("linux-amd64-longtest@go1.14", "go"), both},
Dmitri Shuralyov9e7a7622020-05-26 18:12:12 -0400516 {b("linux-amd64-longtest@go1.14", "net"), none},
Brad Fitzpatrickf9c537e2019-10-28 20:16:36 +0000517 {b("windows-amd64-longtest", "go"), onlyPost},
Dmitri Shuralyov5a8fb632020-05-26 18:19:05 -0400518 {b("windows-amd64-longtest@go1.14", "go"), both},
Brad Fitzpatrickf9c537e2019-10-28 20:16:36 +0000519 {b("windows-amd64-longtest", "net"), onlyPost},
520 {b("windows-amd64-longtest", "exp"), onlyPost},
521 {b("windows-amd64-longtest", "mobile"), none},
Dmitri Shuralyovdd5ac552020-07-01 14:14:47 -0400522 {b("linux-386-longtest", "go"), onlyPost},
523 {b("linux-386-longtest", "net"), onlyPost},
524 {b("linux-386-longtest", "exp"), none},
525 {b("linux-386-longtest", "mobile"), none},
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000526
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000527 // Experimental exp repo runs in very few places.
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000528 {b("linux-amd64", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000529 {b("linux-amd64-race", "exp"), both},
530 {b("linux-amd64-longtest", "exp"), onlyPost},
Carlos Amedeef077b9b2021-11-11 15:05:21 -0500531 {b("windows-386-2008", "exp"), none},
532 {b("windows-386-2012", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000533 {b("windows-amd64-2016", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000534 {b("darwin-amd64-10_14", "exp"), onlyPost},
Carlos Amedeed6dec9c2019-11-19 14:55:01 +0000535 {b("darwin-amd64-10_15", "exp"), onlyPost},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000536 // ... but not on most others:
Dmitri Shuralyov3b77b3a2019-09-28 17:43:42 +0000537 {b("darwin-amd64-10_12", "exp"), none},
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400538 {b("freebsd-386-11_4", "exp"), none},
539 {b("freebsd-386-12_2", "exp"), none},
540 {b("freebsd-amd64-11_4", "exp"), none},
541 {b("freebsd-amd64-12_2", "exp"), none},
Dmitri Shuralyov01e47d92020-12-21 14:12:25 -0500542 {b("openbsd-amd64-68", "exp"), none},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000543 {b("js-wasm", "exp"), none},
544
545 // exp is experimental; it doesn't test against release branches.
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000546 {b("linux-amd64@go1.12", "exp"), none},
Brad Fitzpatrick8a071d42019-03-18 16:48:22 +0000547
Brad Fitzpatrickc8ca9622019-12-07 05:14:28 +0000548 // the build repo is only really useful for linux-amd64 (where we run it),
549 // and darwin-amd64 and perhaps windows-amd64 (for stuff like gomote).
550 // No need for any other operating systems to use it.
551 {b("linux-amd64", "build"), both},
552 {b("linux-amd64-longtest", "build"), onlyPost},
553 {b("windows-amd64-2016", "build"), both},
554 {b("darwin-amd64-10_12", "build"), none},
555 {b("darwin-amd64-10_14", "build"), none},
556 {b("darwin-amd64-10_15", "build"), onlyPost},
Dmitri Shuralyov01e47d92020-12-21 14:12:25 -0500557 {b("openbsd-amd64-68", "build"), none},
Brad Fitzpatrickc8ca9622019-12-07 05:14:28 +0000558 {b("linux-amd64-fedora", "build"), none},
559 {b("linux-amd64-clang", "build"), none},
560 {b("linux-amd64-sid", "build"), none},
Carlos Amedee43864932021-08-16 15:35:39 -0400561 {b("linux-amd64-bullseye", "build"), none},
Brad Fitzpatrickf6d512d2019-12-12 17:43:59 +0000562 {b("linux-amd64-nocgo", "build"), none},
563 {b("linux-386-longtest", "build"), none},
Brad Fitzpatrickf6d512d2019-12-12 17:43:59 +0000564 {b("js-wasm", "build"), none},
565 {b("android-386-emu", "build"), none},
566 {b("android-amd64-emu", "build"), none},
Brad Fitzpatrickc8ca9622019-12-07 05:14:28 +0000567
Brad Fitzpatrick8a071d42019-03-18 16:48:22 +0000568 // Only use latest macOS for subrepos, and only amd64:
Carlos Amedee6469a762021-04-22 13:51:16 -0400569 {b("darwin-amd64-10_12@go1.16", "net"), onlyPost},
570 {b("darwin-amd64-10_12", "net"), none},
571 {b("darwin-amd64-10_14", "net"), onlyPost},
Brad Fitzpatrick8bd8e0e2019-03-26 23:04:31 +0000572
Carlos Amedeed6dec9c2019-11-19 14:55:01 +0000573 {b("darwin-amd64-10_15", "go"), onlyPost},
Brad Fitzpatrick8bd8e0e2019-03-26 23:04:31 +0000574 {b("darwin-amd64-10_14", "go"), onlyPost},
Carlos Amedee6469a762021-04-22 13:51:16 -0400575 {b("darwin-amd64-10_12", "go"), none},
576 {b("darwin-amd64-10_12@go1.16", "go"), onlyPost},
Brad Fitzpatrick85a73d72019-04-03 04:45:29 +0000577
Brad Fitzpatrick67073b92019-04-18 19:33:19 +0000578 // plan9 only lived at master. We didn't support any past releases.
579 // But it's off for now as it's always failing.
580 {b("plan9-386", "go"), none}, // temporarily disabled
581 {b("plan9-386", "net"), none}, // temporarily disabled
Tobias Klauser22d3b242019-11-28 11:33:00 +0100582 {b("plan9-386", "exp"), none},
583 {b("plan9-386", "mobile"), none},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000584 {b("plan9-386@go1.12", "go"), none},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000585 {b("plan9-386@go1.12", "net"), none},
David du Colombier9d711212021-04-05 20:42:05 +0200586 {b("plan9-amd64-0intro", "go"), onlyPost},
587 {b("plan9-amd64-0intro", "exp"), none},
588 {b("plan9-amd64-0intro", "mobile"), none},
589 {b("plan9-amd64-0intro@go1.12", "go"), none},
590 {b("plan9-amd64-0intro", "net"), onlyPost},
591 {b("plan9-amd64-0intro@go1.12", "net"), none},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000592 {b("plan9-arm", "go"), onlyPost},
Tobias Klauser22d3b242019-11-28 11:33:00 +0100593 {b("plan9-arm", "exp"), none},
594 {b("plan9-arm", "mobile"), none},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000595 {b("plan9-arm@go1.12", "go"), none},
596 {b("plan9-arm", "net"), onlyPost},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000597 {b("plan9-arm@go1.12", "net"), none},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000598
Brad Fitzpatrick58771952019-10-21 15:00:32 +0000599 {b("dragonfly-amd64", "go"), onlyPost},
600 {b("dragonfly-amd64", "net"), onlyPost},
601 {b("dragonfly-amd64@go1.13", "net"), none}, // Dragonfly ABI changes only supported by Go 1.14+
602 {b("dragonfly-amd64@go1.13", "go"), none}, // Dragonfly ABI changes only supported by Go 1.14+
Dmitri Shuralyov77c96bb2020-03-19 10:34:11 -0400603
604 {b("linux-amd64-staticlockranking", "go"), onlyPost},
605 {b("linux-amd64-staticlockranking@go1.15", "go"), onlyPost},
606 {b("linux-amd64-staticlockranking@go1.14", "go"), none},
607 {b("linux-amd64-staticlockranking", "net"), none},
Austin Clements80886082020-12-21 16:08:53 -0500608
Matthew Dempsky4f8007b2021-08-12 15:11:41 -0700609 {b("linux-amd64-unified", "go"), both},
610 {b("linux-amd64-unified", "tools"), both},
Matthew Dempskydf58bba2021-06-16 23:08:22 -0700611 {b("linux-amd64-unified", "net"), none},
612 {b("linux-amd64-unified@dev.typeparams", "go"), both},
613 {b("linux-amd64-unified@dev.typeparams", "tools"), both},
614 {b("linux-amd64-unified@dev.typeparams", "net"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000615 }
616 for _, tt := range tests {
617 t.Run(tt.br.testName, func(t *testing.T) {
Dmitri Shuralyove0288b02021-05-07 17:26:04 -0400618 // Require a want value that asserts both dimensions: try or not, post or not.
619 switch tt.want {
620 case none, both, onlyPost:
621 // OK.
622 default:
623 t.Fatalf("tt.want must be one of: none, both, or onlyPost")
624 }
625
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000626 bc, ok := Builders[tt.br.builder]
627 if !ok {
628 t.Fatalf("unknown builder %q", tt.br.builder)
629 }
630 gotPost := bc.BuildsRepoPostSubmit(tt.br.repo, tt.br.branch, tt.br.goBranch)
631 if tt.want&isBuilder != 0 && !gotPost {
632 t.Errorf("not a post-submit builder, but expected")
633 }
634 if tt.want&notBuilder != 0 && gotPost {
635 t.Errorf("unexpectedly a post-submit builder")
636 }
637
638 gotTry := bc.BuildsRepoTryBot(tt.br.repo, tt.br.branch, tt.br.goBranch)
639 if tt.want&isTrybot != 0 && !gotTry {
640 t.Errorf("not trybot, but expected")
641 }
642 if tt.want&notTrybot != 0 && gotTry {
643 t.Errorf("unexpectedly a trybot")
644 }
645
646 if t.Failed() {
647 t.Logf("For: %+v", tt.br)
648 }
649 })
650 }
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000651}
652
653func TestHostConfigsAllUsed(t *testing.T) {
Dmitri Shuralyov07688122020-08-04 12:01:34 -0400654 knownUnused := map[string]bool{
655 // Currently host-linux-armhf-cross and host-linux-armel-cross aren't
656 // referenced, but the coordinator hard-codes them, so don't make
657 // these two an error for now.
658 "host-linux-armhf-cross": true,
659 "host-linux-armel-cross": true,
660
661 "host-linux-x86-alpine": true, // TODO(golang.org/issue/19938): Fix the Alpine builder, or remove it.
Dmitri Shuralyov07688122020-08-04 12:01:34 -0400662 }
663
664 used := make(map[string]bool)
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000665 for _, conf := range Builders {
666 used[conf.HostType] = true
667 }
668 for hostType := range Hosts {
Dmitri Shuralyov07688122020-08-04 12:01:34 -0400669 if !used[hostType] && !knownUnused[hostType] {
670 t.Errorf("host type %q is not referenced from any build config", hostType)
671 }
672 if used[hostType] && knownUnused[hostType] {
673 t.Errorf("host type %q should not be listed in knownUnused since it's in use", hostType)
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000674 }
675 }
676}
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000677
Dmitri Shuralyov2891c2e2021-11-16 12:42:29 -0500678// Test that all specified builder owners are non-nil.
679func TestBuilderOwners(t *testing.T) {
680 for host, config := range Hosts {
681 for i, p := range config.Owners {
682 if p == nil {
683 t.Errorf("dashboard.Hosts[%q].Owners[%d] is nil, want non-nil", host, i)
684 }
685 }
686 }
687}
688
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000689// tests that goBranch is optional for repo == "go"
690func TestBuildsRepoAtAllImplicitGoBranch(t *testing.T) {
691 builder := Builders["android-amd64-emu"]
692 got := builder.buildsRepoAtAll("go", "master", "")
693 if !got {
694 t.Error("got = false; want true")
695 }
696}
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000697
698func TestShouldRunDistTest(t *testing.T) {
699 type buildMode int
700 const (
701 tryMode buildMode = 0
702 postSubmit buildMode = 1
703 )
704
705 tests := []struct {
706 builder string
707 test string
708 mode buildMode
709 want bool
710 }{
711 {"linux-amd64", "api", postSubmit, true},
712 {"linux-amd64", "api", tryMode, true},
Carlos Amedee2ecf4242021-04-23 11:33:51 -0400713 {"freebsd-amd64-12_2", "api", postSubmit, true}, // freebsd-amd64-12_2 uses fasterTrybots policy, should still build.
714 {"freebsd-amd64-12_2", "api", tryMode, false}, // freebsd-amd64-12_2 uses fasterTrybots policy, should skip in try mode.
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000715
716 {"linux-amd64", "reboot", tryMode, true},
717 {"linux-amd64-race", "reboot", tryMode, false},
718
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000719 {"darwin-amd64-10_12", "test:foo", postSubmit, false},
720 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000721 {"darwin-amd64-10_14", "reboot", postSubmit, false},
722 {"darwin-amd64-10_14", "api", postSubmit, false},
723 {"darwin-amd64-10_14", "codewalk", postSubmit, false},
Carlos Amedeed6dec9c2019-11-19 14:55:01 +0000724 {"darwin-amd64-10_15", "test:foo", postSubmit, false},
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000725 }
726 for _, tt := range tests {
727 bc, ok := Builders[tt.builder]
728 if !ok {
729 t.Errorf("unknown builder %q", tt.builder)
730 continue
731 }
732 isTry := tt.mode == tryMode
733 if isTry && !bc.BuildsRepoTryBot("go", "master", "master") {
734 t.Errorf("builder %q is not a trybot, so can't run test %q in try mode", tt.builder, tt.test)
735 continue
736 }
737 got := bc.ShouldRunDistTest(tt.test, isTry)
738 if got != tt.want {
739 t.Errorf("%q.ShouldRunDistTest(%q, try %v) = %v; want %v", tt.builder, tt.test, isTry, got, tt.want)
740 }
741 }
742}
Dmitri Shuralyov01fd2992019-09-09 16:48:08 -0400743
Brad Fitzpatrickaab85042019-10-16 06:02:29 +0000744func TestSlowBotAliases(t *testing.T) {
745 for term, name := range slowBotAliases {
746 if name == "" {
747 // Empty string means known missing builder.
748 continue
749 }
750 if _, ok := Builders[name]; !ok {
751 t.Errorf("slowbot term %q references unknown builder %q", term, name)
752 }
753 }
754
755 out, err := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "tool", "dist", "list").Output()
756 if err != nil {
757 t.Errorf("dist list: %v", err)
758 }
759 ports := strings.Fields(string(out))
760
761 done := map[string]bool{}
Carlos Amedee3e01d872020-04-22 18:52:59 -0400762
Brad Fitzpatrickaab85042019-10-16 06:02:29 +0000763 var add bytes.Buffer
764 check := func(term string, isArch bool) {
765 if done[term] {
766 return
767 }
768 done[term] = true
769 _, isBuilderName := Builders[term]
770 _, hasAlias := slowBotAliases[term]
771 if !isBuilderName && !hasAlias {
772 prefix := term
773 if isArch {
774 prefix = "linux-" + term
775 }
776 var matches []string
777 for name := range Builders {
778 if strings.HasPrefix(name, prefix) {
779 matches = append(matches, name)
780 }
781 }
782 sort.Strings(matches)
783 t.Errorf("term %q has no match in slowBotAliases", term)
784 if len(matches) == 1 {
785 fmt.Fprintf(&add, "%q: %q,\n", term, matches[0])
786 } else if len(matches) > 1 {
787 t.Errorf("maybe add: %q: %q, (matches=%q)", term, matches[len(matches)-1], matches)
788 }
789 }
790 }
791
792 for _, port := range ports {
793 slash := strings.IndexByte(port, '/')
794 if slash == -1 {
795 t.Fatalf("unexpected port %q", port)
796 }
797 goos, goarch := port[:slash], port[slash+1:]
798 check(goos+"-"+goarch, false)
799 check(goos, false)
800 check(goarch, true)
801 }
802
803 if add.Len() > 0 {
804 t.Errorf("Missing items from slowBotAliases:\n%s", add.String())
805 }
806}
Brad Fitzpatrickad7af462019-10-19 02:49:53 +0000807
808func TestCrossCompileConfigs(t *testing.T) {
809 // Verify that Builders.CrossCompileConfig have valid host types.
810 for name, bc := range Builders {
811 cc := bc.CrossCompileConfig
812 if cc == nil {
813 continue
814 }
815 if _, ok := Hosts[cc.CompileHostType]; !ok {
816 t.Errorf("unknown host type %q for builder %q", cc.CompileHostType, name)
817 }
818 }
819}
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100820
Dmitri Shuralyov646d48d2021-04-23 16:56:37 -0400821// TestTryBotsCompileAllPorts verifies that each port (go tool dist list)
822// is covered by either a real TryBot or a misc-compile TryBot.
823//
824// The special pseudo-port 'linux-arm-arm5' is tested in TestMiscCompileLinuxGOARM5.
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100825func TestTryBotsCompileAllPorts(t *testing.T) {
826 out, err := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "tool", "dist", "list").Output()
827 if err != nil {
828 t.Errorf("dist list: %v", err)
829 }
830 ports := strings.Fields(string(out))
831
Dmitri Shuralyovca017122021-04-23 14:08:15 -0400832 // knownMissing tracks Go ports that that are known to be
833 // completely missing TryBot (pre-submit) test coverage.
834 //
Dmitri Shuralyovf9ec3ca2021-04-27 15:33:27 -0400835 // All completed ports should have either a real TryBot or at least a misc-compile TryBot,
Dmitri Shuralyovca017122021-04-23 14:08:15 -0400836 // so this map is meant to be used to temporarily fix tests
837 // when the work of adding a new port is actively underway.
Dmitri Shuralyovf9ec3ca2021-04-27 15:33:27 -0400838 knownMissing := map[string]bool{}
Dmitri Shuralyovca017122021-04-23 14:08:15 -0400839
840 var done = make(map[string]bool)
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100841 check := func(goos, goarch string) {
Dmitri Shuralyov55e1ef62020-09-28 11:04:35 -0400842 if goos == "android" || goos == "ios" {
Brad Fitzpatrick8a3c1d92019-11-15 04:29:29 +0000843 // TODO(golang.org/issue/25963): support
Dmitri Shuralyov55e1ef62020-09-28 11:04:35 -0400844 // compilation-only Android and iOS trybots.
Brad Fitzpatrick8a3c1d92019-11-15 04:29:29 +0000845 // buildall.bash doesn't set the environment
846 // up enough for e.g. compiling android-386
847 // from linux-amd64. (Issue #35596 too)
Dmitri Shuralyov55e1ef62020-09-28 11:04:35 -0400848 // iOS likely needs to be built on macOS
849 // with Xcode available.
Brad Fitzpatrick8a3c1d92019-11-15 04:29:29 +0000850 return
851 }
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100852 goosArch := goos + "-" + goarch
853 if done[goosArch] {
854 return
855 }
856 for _, conf := range Builders {
Dmitri Shuralyov2e5c6aa2021-04-26 15:33:46 -0400857 if conf.GOOS() == goos && conf.GOARCH() == goarch &&
858 conf.BuildsRepoTryBot("go", "master", "master") {
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100859
Dmitri Shuralyov2e5c6aa2021-04-26 15:33:46 -0400860 // There's a real TryBot for this GOOS/GOARCH pair.
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100861 done[goosArch] = true
862 break
863 }
864
865 if strings.HasPrefix(conf.Name, "misc-compile-") {
866 re, err := regexp.Compile(conf.allScriptArgs[0])
867 if err != nil {
Dmitri Shuralyov2e5c6aa2021-04-26 15:33:46 -0400868 t.Fatalf("invalid misc-compile filtering pattern for builder %q: %q",
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100869 conf.Name, conf.allScriptArgs[0])
870 }
Dmitri Shuralyov2e5c6aa2021-04-26 15:33:46 -0400871 if re.MatchString(goosArch) {
872 // There's a misc-compile TryBot for this GOOS/GOARCH pair.
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100873 done[goosArch] = true
874 break
875 }
876 }
877 }
Dmitri Shuralyovca017122021-04-23 14:08:15 -0400878 if knownMissing[goosArch] && done[goosArch] {
879 // Make it visible when a builder is added but the old
880 // knownMissing entry isn't removed by failing the test.
881 t.Errorf("knownMissing[%q] is true, but a corresponding TryBot (real or misc-compile) exists", goosArch)
882 } else if _, ok := done[goosArch]; !ok && !knownMissing[goosArch] {
883 t.Errorf("missing real TryBot or misc-compile TryBot for %q", goosArch)
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100884 }
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100885 }
886
887 for _, port := range ports {
888 slash := strings.IndexByte(port, '/')
889 if slash == -1 {
890 t.Fatalf("unexpected port %q", port)
891 }
892 check(port[:slash], port[slash+1:])
893 }
Tobias Klausercd82ecd2019-11-07 14:15:55 +0100894}
Carlos Amedeed6dec9c2019-11-19 14:55:01 +0000895
Dmitri Shuralyov646d48d2021-04-23 16:56:37 -0400896// The 'linux-arm-arm5' pseduo-port is supported by src/buildall.bash
897// and tests linux/arm with GOARM=5 set. Since it's not a normal port,
898// the TestTryBotsCompileAllPorts wouldn't report if the misc-compile
899// TryBot that covers is is accidentally removed. Check it explicitly.
900func TestMiscCompileLinuxGOARM5(t *testing.T) {
901 var ok bool
902 for _, b := range Builders {
903 if !strings.HasPrefix(b.Name, "misc-compile-") {
904 continue
905 }
906 re, err := regexp.Compile(b.allScriptArgs[0])
907 if err != nil {
908 t.Fatalf("invalid misc-compile filtering pattern for builder %q: %q",
909 b.Name, b.allScriptArgs[0])
910 }
911 if re.MatchString("linux-arm-arm5") {
912 ok = true
913 break
914 }
915 }
916 if !ok {
917 // We get here if the linux-arm-arm5 port is no longer checked by
918 // a misc-compile TryBot. Report it as a failure in case the coverage
919 // was removed accidentally (e.g., as part of a refactor).
920 t.Errorf("no misc-compile TryBot coverage for the special 'linux-arm-arm5' pseudo-port")
921 }
922}
923
Carlos Amedeed6dec9c2019-11-19 14:55:01 +0000924// TestExpectedMacstadiumVMCount ensures that only 20 instances of macOS virtual machines
925// are expected at MacStadium.
926// TODO: remove once the scheduler allocates VMs based on demand https://golang.org/issue/35698
927func TestExpectedMacstadiumVMCount(t *testing.T) {
928 got := 0
929 for host, config := range Hosts {
Carlos Amedeed576fd32021-01-29 15:47:13 -0500930 if strings.HasPrefix(host, "host-darwin-10_") || strings.HasPrefix(host, "host-darwin-amd64-") {
Carlos Amedeed6dec9c2019-11-19 14:55:01 +0000931 got += config.ExpectNum
932 }
933 }
Carlos Amedeeb7678aa2021-04-06 11:28:57 -0400934 if got != 16 {
935 t.Fatalf("macstadium host count: got %d; want 16", got)
Carlos Amedeed6dec9c2019-11-19 14:55:01 +0000936 }
937}
Dmitri Shuralyovdf328b12020-05-13 14:30:25 -0400938
939// Test that we have a longtest builder and
940// that its environment configuration is okay.
941func TestLongTestBuilder(t *testing.T) {
942 long, ok := Builders["linux-amd64-longtest"]
943 if !ok {
944 t.Fatal("we don't have a linux-amd64-longtest builder anymore, is that intentional?")
945 }
946 if !long.IsLongTest() {
947 t.Error("the linux-amd64-longtest builder isn't a longtest builder, is that intentional?")
948 }
949 var shortDisabled bool
950 for _, e := range long.Env() {
951 if e == "GO_TEST_SHORT=0" {
952 shortDisabled = true
953 }
954 }
955 if !shortDisabled {
956 t.Error("the linux-amd64-longtest builder doesn't set GO_TEST_SHORT=0, is that intentional?")
957 }
958}
Carlos Amedeed77c6d02020-08-18 13:32:05 -0400959
960func TestHostConfigIsVM(t *testing.T) {
961 testCases := []struct {
962 desc string
963 config *HostConfig
964 want bool
965 }{
966 {
967 desc: "non-ec2-vm",
968 config: &HostConfig{
969 VMImage: "image-x",
970 ContainerImage: "",
971 isEC2: false,
972 },
973 want: true,
974 },
975 {
976 desc: "non-ec2-container",
977 config: &HostConfig{
978 VMImage: "",
979 ContainerImage: "container-image-x",
980 isEC2: false,
981 },
982 want: false,
983 },
984 {
985 desc: "ec2-container",
986 config: &HostConfig{
987 VMImage: "image-x",
988 ContainerImage: "container-image-x",
989 isEC2: true,
990 },
991 want: false,
992 },
993 {
994 desc: "ec2-vm",
995 config: &HostConfig{
996 VMImage: "image-x",
997 ContainerImage: "",
998 isEC2: true,
999 },
1000 want: true,
1001 },
1002 }
1003 for _, tc := range testCases {
1004 t.Run(fmt.Sprintf(tc.desc), func(t *testing.T) {
1005 if got := tc.config.IsVM(); got != tc.want {
1006 t.Errorf("HostConfig.IsVM() = %t; want %t", got, tc.want)
1007 }
1008 })
1009 }
1010}
Carlos Amedee1e761992020-08-20 11:53:58 -04001011
1012func TestModulesEnv(t *testing.T) {
1013 testCases := []struct {
1014 desc string
1015 buildConfig *BuildConfig
1016 repo string
1017 want []string
1018 }{
1019 {
1020 desc: "ec2-builder-repo-non-go",
1021 buildConfig: &BuildConfig{
1022 testHostConf: &HostConfig{
1023 IsReverse: false,
1024 isEC2: true,
1025 },
1026 },
1027 repo: "bar",
1028 want: []string{"GOPROXY=https://proxy.golang.org"},
1029 },
1030 {
1031 desc: "reverse-builder-repo-non-go",
1032 buildConfig: &BuildConfig{
1033 testHostConf: &HostConfig{
1034 IsReverse: true,
1035 isEC2: false,
1036 },
1037 },
1038 repo: "bar",
1039 want: []string{"GOPROXY=https://proxy.golang.org"},
1040 },
1041 {
1042 desc: "reverse-builder-repo-go",
1043 buildConfig: &BuildConfig{
1044 testHostConf: &HostConfig{
1045 IsReverse: true,
1046 isEC2: false,
1047 },
1048 },
1049 repo: "go",
1050 want: []string{"GOPROXY=off"},
1051 },
1052 {
1053 desc: "builder-repo-go",
1054 buildConfig: &BuildConfig{
1055 testHostConf: &HostConfig{
1056 IsReverse: false,
1057 isEC2: false,
1058 },
1059 },
1060 repo: "go",
1061 want: []string{"GOPROXY=off"},
1062 },
1063 {
1064 desc: "builder-repo-go-outbound-network-allowed",
1065 buildConfig: &BuildConfig{
1066 Name: "test-longtest",
1067 testHostConf: &HostConfig{
1068 IsReverse: false,
1069 isEC2: false,
1070 },
1071 },
1072 repo: "go",
1073 want: nil,
1074 },
1075 {
1076 desc: "builder-repo-special-case",
1077 buildConfig: &BuildConfig{
1078 testHostConf: &HostConfig{
1079 IsReverse: false,
1080 isEC2: false,
1081 },
1082 },
1083 repo: "build",
1084 want: []string{"GO111MODULE=on"},
1085 },
1086 {
1087 desc: "reverse-builder-repo-special-case",
1088 buildConfig: &BuildConfig{
1089 testHostConf: &HostConfig{
1090 IsReverse: true,
1091 isEC2: false,
1092 },
1093 },
1094 repo: "build",
1095 want: []string{"GOPROXY=https://proxy.golang.org", "GO111MODULE=on"},
1096 },
1097 {
1098 desc: "builder-repo-non-special-case",
1099 buildConfig: &BuildConfig{
1100 testHostConf: &HostConfig{
1101 IsReverse: false,
1102 isEC2: false,
1103 },
1104 },
1105 repo: "bar",
1106 want: nil,
1107 },
1108 }
1109 for _, tc := range testCases {
1110 t.Run(tc.desc, func(t *testing.T) {
1111 got := tc.buildConfig.ModulesEnv(tc.repo)
1112 if diff := cmp.Diff(tc.want, got); diff != "" {
1113 t.Errorf("BuildConfig.ModulesEnv(%q) mismatch (-want, +got)\n%s", tc.repo, diff)
1114 }
1115 })
1116 }
1117}