blob: 0fe9072807ac7671a4d21a0f7c44a253fc82815e [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"
12 "runtime"
13 "sort"
Brad Fitzpatrickf3c01932015-01-15 16:29:16 -080014 "strings"
15 "testing"
Brad Fitzpatrick34b995b2019-02-14 02:18:06 +000016 "time"
Brad Fitzpatrickf3c01932015-01-15 16:29:16 -080017)
18
19func TestOSARCHAccessors(t *testing.T) {
20 valid := func(s string) bool { return s != "" && !strings.Contains(s, "-") }
21 for _, conf := range Builders {
22 os := conf.GOOS()
23 arch := conf.GOARCH()
24 osArch := os + "-" + arch
25 if !valid(os) || !valid(arch) || !(conf.Name == osArch || strings.HasPrefix(conf.Name, osArch+"-")) {
26 t.Errorf("OS+ARCH(%q) = %q, %q; invalid", conf.Name, os, arch)
27 }
28 }
29}
Brad Fitzpatrickc328d042017-04-12 00:35:37 +000030
Brad Fitzpatrick34b995b2019-02-14 02:18:06 +000031func TestDistTestsExecTimeout(t *testing.T) {
32 tests := []struct {
33 c *BuildConfig
34 want time.Duration
35 }{
36 {
37 &BuildConfig{
38 env: []string{},
39 testHostConf: &HostConfig{},
40 },
41 20 * time.Minute,
42 },
43 {
44 &BuildConfig{
45 env: []string{"GO_TEST_TIMEOUT_SCALE=2"},
46 testHostConf: &HostConfig{},
47 },
48 40 * time.Minute,
49 },
50 {
51 &BuildConfig{
52 env: []string{},
53 testHostConf: &HostConfig{
54 env: []string{"GO_TEST_TIMEOUT_SCALE=3"},
55 },
56 },
57 60 * time.Minute,
58 },
59 // BuildConfig's env takes precedence:
60 {
61 &BuildConfig{
62 env: []string{"GO_TEST_TIMEOUT_SCALE=2"},
63 testHostConf: &HostConfig{
64 env: []string{"GO_TEST_TIMEOUT_SCALE=3"},
65 },
66 },
67 40 * time.Minute,
68 },
69 }
70 for i, tt := range tests {
71 got := tt.c.DistTestsExecTimeout(nil)
72 if got != tt.want {
73 t.Errorf("%d. got %v; want %v", i, got, tt.want)
74 }
75 }
76}
77
Brad Fitzpatrick756764c2019-03-07 17:44:41 +000078// TestTrybots tests that a given repo & its branch yields the provided
79// complete set of builders. See also: TestBuilders, which tests both trybots
80// and post-submit builders, both at arbitrary branches.
81func TestTrybots(t *testing.T) {
82 tests := []struct {
83 repo string // "go", "net", etc
84 branch string // of repo
85 want []string
86 }{
87 {
88 repo: "go",
89 branch: "master",
90 want: []string{
Brad Fitzpatrick4e29d672019-04-18 19:45:32 +000091 "android-amd64-emu",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +000092 "freebsd-amd64-12_0",
93 "js-wasm",
94 "linux-386",
95 "linux-amd64",
96 "linux-amd64-race",
Brad Fitzpatrick95bc93b2019-05-10 19:28:40 +000097 "misc-compile-other",
98 "misc-compile-darwin",
99 "misc-compile-linuxarm",
100 "misc-compile-solaris",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000101 "misc-compile-freebsd",
102 "misc-compile-mips",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000103 "misc-compile-netbsd",
104 "misc-compile-openbsd",
105 "misc-compile-plan9",
106 "misc-compile-ppc",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000107 "openbsd-amd64-64",
108 "windows-386-2008",
109 "windows-amd64-2016",
110 },
111 },
112 {
113 repo: "go",
Brad Fitzpatrick90670e12019-10-11 18:47:51 +0000114 branch: "dev.link",
115 want: []string{
116 "freebsd-amd64-12_0",
117 "js-wasm",
118 "linux-386",
119 "linux-amd64",
120 "linux-amd64-race",
121 "misc-compile-other",
122 "misc-compile-darwin",
123 "misc-compile-linuxarm",
124 "misc-compile-solaris",
125 "misc-compile-freebsd",
126 "misc-compile-mips",
127 "misc-compile-netbsd",
128 "misc-compile-openbsd",
129 "misc-compile-plan9",
130 "misc-compile-ppc",
131 "openbsd-amd64-64",
132 "windows-386-2008",
133 "windows-amd64-2016",
134 },
135 },
136 {
137 repo: "go",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000138 branch: "release-branch.go1.12",
139 want: []string{
140 "freebsd-amd64-10_3",
141 "freebsd-amd64-12_0",
142 "js-wasm",
143 "linux-386",
144 "linux-amd64",
145 "linux-amd64-race",
Brad Fitzpatrick95bc93b2019-05-10 19:28:40 +0000146 "misc-compile-darwin",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000147 "misc-compile-freebsd",
Brad Fitzpatrick95bc93b2019-05-10 19:28:40 +0000148 "misc-compile-linuxarm",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000149 "misc-compile-mips",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000150 "misc-compile-netbsd",
151 "misc-compile-openbsd",
Brad Fitzpatrick95bc93b2019-05-10 19:28:40 +0000152 "misc-compile-other",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000153 "misc-compile-plan9",
154 "misc-compile-ppc",
Brad Fitzpatrick95bc93b2019-05-10 19:28:40 +0000155 "misc-compile-solaris",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000156 "nacl-amd64p32",
157 "openbsd-amd64-64",
158 "windows-386-2008",
159 "windows-amd64-2016",
160 },
161 },
162 {
163 repo: "mobile",
164 branch: "master",
165 want: []string{
166 "android-amd64-emu",
167 "linux-amd64-androidemu",
168 },
169 },
170 {
171 repo: "sys",
172 branch: "master",
173 want: []string{
Brad Fitzpatrick6d867c82019-04-26 14:04:00 +0000174 "android-amd64-emu",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000175 "freebsd-386-11_2",
176 "freebsd-amd64-11_2",
177 "freebsd-amd64-12_0",
178 "linux-386",
179 "linux-amd64",
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000180 "linux-amd64-race",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000181 "netbsd-amd64-8_0",
182 "openbsd-386-64",
183 "openbsd-amd64-64",
184 "windows-386-2008",
185 "windows-amd64-2016",
186 },
187 },
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000188 {
189 repo: "exp",
190 branch: "master",
191 want: []string{
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000192 "linux-amd64",
193 "linux-amd64-race",
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000194 "windows-386-2008",
195 "windows-amd64-2016",
196 },
197 },
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000198 }
199 for i, tt := range tests {
200 if tt.branch == "" || tt.repo == "" {
201 t.Errorf("incomplete test entry %d", i)
202 return
203 }
204 t.Run(fmt.Sprintf("%s/%s", tt.repo, tt.branch), func(t *testing.T) {
205 var got []string
206 goBranch := tt.branch // hard-code the common case for now
207 for _, bc := range TryBuildersForProject(tt.repo, tt.branch, goBranch) {
208 got = append(got, bc.Name)
209 }
210 m := map[string]bool{}
211 for _, b := range tt.want {
212 m[b] = true
213 }
214 for _, b := range got {
215 if _, ok := m[b]; !ok {
216 t.Errorf("got unexpected %q", b)
217 }
218 delete(m, b)
219 }
220 for b := range m {
221 t.Errorf("missing expected %q", b)
Brad Fitzpatrickc517aed2018-10-26 19:21:58 +0000222 }
223 })
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000224 }
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000225}
226
227// TestBuilderConfig whether a given builder and repo at different
228// branches is either a post-submit builder, trybot, neither, or both.
229func TestBuilderConfig(t *testing.T) {
230 // builderConfigWant is bitmask of 4 different things to assert are wanted:
231 // - being a post-submit builder
232 // - NOT being a post-submit builder
233 // - being a trybot builder
234 // - NOT being a post-submit builder
235 type want uint8
236 const (
237 isTrybot want = 1 << iota
238 notTrybot
239 isBuilder // post-submit
240 notBuilder // not post-submit
241
242 none = notTrybot + notBuilder
243 both = isTrybot + isBuilder
244 onlyPost = notTrybot + isBuilder
245 )
246
247 type builderAndRepo struct {
248 testName string
249 builder string
250 repo string
251 branch string
252 goBranch string
253 }
Dmitri Shuralyov76fd6b52019-10-08 13:08:27 -0400254 // builder may end in "@go1.N" or "@1.N" (as alias for "@release-branch.go1.N") or "@branch-name".
255 // 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 +0000256 b := func(builder, repo string) builderAndRepo {
257 br := builderAndRepo{
258 testName: builder + "," + repo,
259 builder: builder,
260 goBranch: "master",
261 repo: repo,
262 branch: "master",
263 }
264 if strings.Contains(builder, "@") {
265 f := strings.SplitN(builder, "@", 2)
266 br.builder = f[0]
267 br.goBranch = f[1]
268 }
269 if strings.Contains(repo, "@") {
270 f := strings.SplitN(repo, "@", 2)
271 br.repo = f[0]
272 br.branch = f[1]
Dmitri Shuralyov76fd6b52019-10-08 13:08:27 -0400273 if br.repo == "go" {
274 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))
275 }
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000276 }
277 expandBranch := func(s *string) {
278 if strings.HasPrefix(*s, "go1.") {
279 *s = "release-branch." + *s
280 } else if strings.HasPrefix(*s, "1.") {
281 *s = "release-branch.go" + *s
282 }
283 }
284 expandBranch(&br.branch)
285 expandBranch(&br.goBranch)
286 if br.repo == "go" {
287 br.branch = br.goBranch
288 }
289 return br
290 }
291 tests := []struct {
292 br builderAndRepo
293 want want
294 }{
295 {b("linux-amd64", "go"), both},
296 {b("linux-amd64", "net"), both},
297 {b("linux-amd64", "sys"), both},
Dmitri Shuralyov7aef06b2019-05-16 16:04:34 -0400298 {b("linux-amd64", "website"), both},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000299
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000300 // Don't test all subrepos on all the builders.
301 {b("linux-amd64-ssacheck", "net"), none},
302 {b("linux-amd64-ssacheck@go1.10", "net"), none},
303 {b("linux-amd64-noopt@go1.11", "net"), none},
304 {b("linux-386-387@go1.11", "net"), none},
305 {b("linux-386-387@go1.11", "go"), onlyPost},
306 {b("linux-386-387", "crypto"), onlyPost},
307 {b("linux-arm-arm5spacemonkey@go1.11", "net"), none},
308 {b("linux-arm-arm5spacemonkey@go1.12", "net"), none},
309
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000310 // The mobile repo requires Go 1.13+.
Brad Fitzpatrick4e29d672019-04-18 19:45:32 +0000311 {b("android-amd64-emu", "go"), both},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000312 {b("android-amd64-emu", "mobile"), both},
313 {b("android-amd64-emu", "mobile@1.10"), none},
314 {b("android-amd64-emu", "mobile@1.11"), none},
315 {b("android-amd64-emu@go1.10", "mobile"), none},
316 {b("android-amd64-emu@go1.11", "mobile"), none},
317 {b("android-amd64-emu@go1.12", "mobile"), none},
318 {b("android-amd64-emu@go1.13", "mobile"), both},
319 {b("android-amd64-emu", "mobile@1.13"), both},
Brad Fitzpatrick6d867c82019-04-26 14:04:00 +0000320 {b("android-amd64-emu", "crypto"), both},
321 {b("android-amd64-emu", "net"), both},
322 {b("android-amd64-emu", "sync"), both},
323 {b("android-amd64-emu", "sys"), both},
324 {b("android-amd64-emu", "text"), both},
325 {b("android-amd64-emu", "time"), both},
326 {b("android-amd64-emu", "tools"), both},
Dmitri Shuralyovbb0f2242019-08-29 09:22:13 -0400327 {b("android-amd64-emu", "website"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000328
329 {b("android-386-emu", "go"), onlyPost},
330 {b("android-386-emu", "mobile"), onlyPost},
331 {b("android-386-emu", "mobile@1.10"), none},
332 {b("android-386-emu", "mobile@1.11"), none},
333 {b("android-386-emu@go1.10", "mobile"), none},
334 {b("android-386-emu@go1.11", "mobile"), none},
335 {b("android-386-emu@go1.12", "mobile"), none},
336 {b("android-386-emu@go1.13", "mobile"), onlyPost},
337 {b("android-386-emu", "mobile@1.13"), onlyPost},
338
339 {b("linux-amd64", "net"), both},
340 {b("linux-amd64", "net@1.12"), both},
341 {b("linux-amd64@go1.12", "net@1.12"), both},
342 {b("linux-amd64", "net@1.11"), both},
343 {b("linux-amd64", "net@1.11"), both},
344 {b("linux-amd64", "net@1.10"), none}, // too old
345 {b("linux-amd64@go1.10", "net"), none}, // too old
346 {b("linux-amd64@go1.11", "net"), both},
347 {b("linux-amd64@go1.11", "net@1.11"), both},
348 {b("linux-amd64@go1.12", "net@1.12"), both},
349
Meng Zhuo88052792019-09-10 07:21:11 +0800350 {b("linux-mips64le-mengzhuo", "go"), onlyPost},
351 {b("linux-mips64le-mengzhuo", "sys"), onlyPost},
352 {b("linux-mips64le-mengzhuo", "net"), onlyPost},
353
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000354 // go1.12.html: "Go 1.12 is the last release that is
355 // supported on FreeBSD 10.x [... and 11.1]"
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000356 {b("freebsd-386-10_3", "go"), none},
357 {b("freebsd-386-10_3", "net"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000358 {b("freebsd-amd64-10_3", "go"), none},
359 {b("freebsd-amd64-10_3", "net"), none},
360 {b("freebsd-amd64-11_1", "go"), none},
361 {b("freebsd-amd64-11_1", "net"), none},
362 {b("freebsd-amd64-10_3@go1.12", "go"), both},
363 {b("freebsd-amd64-10_3@go1.12", "net@1.12"), both},
364 {b("freebsd-amd64-10_3@go1.11", "go"), both},
365 {b("freebsd-amd64-10_3@go1.11", "net@1.11"), both},
366 {b("freebsd-amd64-11_1@go1.13", "go"), none},
367 {b("freebsd-amd64-11_1@go1.13", "net@1.12"), none},
368 {b("freebsd-amd64-11_1@go1.12", "go"), isBuilder},
369 {b("freebsd-amd64-11_1@go1.12", "net@1.12"), isBuilder},
370 {b("freebsd-amd64-11_1@go1.11", "go"), isBuilder},
371 {b("freebsd-amd64-11_1@go1.11", "net@1.11"), isBuilder},
372
Brad Fitzpatrick9e52fce2019-03-12 21:13:50 +0000373 // FreeBSD 12.0
374 {b("freebsd-amd64-12_0", "go"), both},
375 {b("freebsd-amd64-12_0", "net"), both},
376 {b("freebsd-386-12_0", "go"), onlyPost},
377 {b("freebsd-386-12_0", "net"), onlyPost},
378
Brad Fitzpatrickfcf7a582019-04-30 22:37:31 +0000379 // NetBSD
380 {b("netbsd-amd64-8_0", "go"), onlyPost},
381 {b("netbsd-amd64-8_0", "net"), onlyPost},
382 {b("netbsd-386-8_0", "go"), none},
383 {b("netbsd-386-8_0", "net"), none},
384
Tobias Klauserb7b66932019-03-13 09:29:15 +0100385 // AIX starts at Go 1.12
386 {b("aix-ppc64", "go"), onlyPost},
387 {b("aix-ppc64", "net"), onlyPost},
Tobias Klauserc2ec9e42019-06-04 10:14:55 +0200388 {b("aix-ppc64", "mobile"), none},
389 {b("aix-ppc64", "exp"), none},
Tobias Klausercbdd89b2019-10-14 11:31:13 +0200390 {b("aix-ppc64", "term"), onlyPost},
Tobias Klauserb7b66932019-03-13 09:29:15 +0100391 {b("aix-ppc64@go1.12", "go"), onlyPost},
Brad Fitzpatrick0bbb12f2019-04-19 14:37:11 +0000392 {b("aix-ppc64@go1.12", "net"), none},
Tobias Klauserc2ec9e42019-06-04 10:14:55 +0200393 {b("aix-ppc64@go1.12", "mobile"), none},
Brad Fitzpatrick0bbb12f2019-04-19 14:37:11 +0000394 {b("aix-ppc64@go1.13", "net"), onlyPost},
Tobias Klauserc2ec9e42019-06-04 10:14:55 +0200395 {b("aix-ppc64@go1.13", "mobile"), none},
Tobias Klauserb7b66932019-03-13 09:29:15 +0100396 {b("aix-ppc64@go1.11", "go"), none},
397 {b("aix-ppc64@go1.11", "net"), none},
Tobias Klauserc2ec9e42019-06-04 10:14:55 +0200398 {b("aix-ppc64@go1.11", "mobile"), none},
Tobias Klauserb7b66932019-03-13 09:29:15 +0100399
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000400 {b("linux-amd64-nocgo", "mobile"), none},
401
Elias Naur4d0f77a2019-05-01 22:28:43 +0200402 // Virtual mobiledevices
Elias Naur6bebc8e2019-05-01 20:33:26 +0200403 {b("darwin-arm64-corellium", "go"), isBuilder},
Elias Naur4d0f77a2019-05-01 22:28:43 +0200404 {b("android-arm64-corellium", "go"), isBuilder},
Elias Naur7ae75392019-05-02 00:54:54 +0200405 {b("android-arm-corellium", "go"), isBuilder},
Elias Naur6bebc8e2019-05-01 20:33:26 +0200406
Brad Fitzpatrick13f1da92019-03-12 16:21:55 +0000407 // Mobile builders that run with GOOS=linux/darwin and have
408 // a device attached.
409 {b("linux-amd64-androidemu", "mobile"), both},
Brad Fitzpatrick13f1da92019-03-12 16:21:55 +0000410
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000411 // But the emulators run all:
412 {b("android-amd64-emu", "mobile"), isBuilder},
413 {b("android-386-emu", "mobile"), isBuilder},
414 {b("android-amd64-emu", "net"), isBuilder},
415 {b("android-386-emu", "net"), isBuilder},
416 {b("android-amd64-emu", "go"), isBuilder},
417 {b("android-386-emu", "go"), isBuilder},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000418
Bryan C. Mills4c2de3e2019-08-30 08:34:16 -0400419 {b("nacl-386", "go"), none},
Brad Fitzpatrick90670e12019-10-11 18:47:51 +0000420 {b("nacl-386@dev.link", "go"), none},
Bryan C. Mills4c2de3e2019-08-30 08:34:16 -0400421 {b("nacl-386@go1.13", "go"), onlyPost},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000422 {b("nacl-386", "net"), none},
Bryan C. Mills4c2de3e2019-08-30 08:34:16 -0400423 {b("nacl-amd64p32", "go"), none},
Brad Fitzpatrick90670e12019-10-11 18:47:51 +0000424 {b("nacl-amd64p32@dev.link", "go"), none},
Bryan C. Mills4c2de3e2019-08-30 08:34:16 -0400425 {b("nacl-amd64p32@go1.13", "go"), both},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000426 {b("nacl-amd64p32", "net"), none},
427
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000428 // Only test tip for js/wasm, and only for some repos:
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000429 {b("js-wasm", "go"), both},
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000430 {b("js-wasm", "arch"), onlyPost},
431 {b("js-wasm", "crypto"), onlyPost},
432 {b("js-wasm", "sys"), onlyPost},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000433 {b("js-wasm", "net"), onlyPost},
434 {b("js-wasm@go1.12", "net"), none},
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000435 {b("js-wasm", "benchmarks"), none},
436 {b("js-wasm", "debug"), none},
437 {b("js-wasm", "mobile"), none},
438 {b("js-wasm", "perf"), none},
439 {b("js-wasm", "talks"), none},
440 {b("js-wasm", "tools"), none},
441 {b("js-wasm", "tour"), none},
442 {b("js-wasm", "website"), none},
443
444 // Race builders. Linux for all, GCE buidlers for
445 // post-submit, and only post-submit for "go" for
446 // Darwin (limited resources).
447 {b("linux-amd64-race", "go"), both},
448 {b("linux-amd64-race", "net"), both},
449 {b("windows-amd64-race", "go"), onlyPost},
450 {b("windows-amd64-race", "net"), onlyPost},
451 {b("freebsd-amd64-race", "go"), onlyPost},
452 {b("freebsd-amd64-race", "net"), onlyPost},
453 {b("darwin-amd64-race", "go"), onlyPost},
454 {b("darwin-amd64-race", "net"), none},
455
456 // Long test.
457 {b("linux-amd64-longtest", "go"), onlyPost},
458 {b("linux-amd64-longtest", "net"), onlyPost},
459 {b("linux-amd64-longtest@go1.12", "go"), onlyPost},
460 {b("linux-amd64-longtest@go1.12", "net"), none},
Brad Fitzpatrickf9c537e2019-10-28 20:16:36 +0000461 {b("windows-amd64-longtest", "go"), onlyPost},
462 {b("windows-amd64-longtest@go1.13", "go"), onlyPost},
463 {b("windows-amd64-longtest", "net"), onlyPost},
464 {b("windows-amd64-longtest", "exp"), onlyPost},
465 {b("windows-amd64-longtest", "mobile"), none},
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000466
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000467 // Experimental exp repo runs in very few places.
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000468 {b("linux-amd64", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000469 {b("linux-amd64-race", "exp"), both},
470 {b("linux-amd64-longtest", "exp"), onlyPost},
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000471 {b("windows-386-2008", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000472 {b("windows-amd64-2016", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000473 {b("darwin-amd64-10_14", "exp"), onlyPost},
474 // ... but not on most others:
Dmitri Shuralyov3b77b3a2019-09-28 17:43:42 +0000475 {b("darwin-amd64-10_12", "exp"), none},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000476 {b("freebsd-386-11_2", "exp"), none},
477 {b("freebsd-386-12_0", "exp"), none},
478 {b("freebsd-amd64-11_2", "exp"), none},
479 {b("freebsd-amd64-12_0", "exp"), none},
480 {b("openbsd-amd64-62", "exp"), none},
481 {b("openbsd-amd64-64", "exp"), none},
482 {b("js-wasm", "exp"), none},
483
484 // exp is experimental; it doesn't test against release branches.
485 {b("linux-amd64@go1.11", "exp"), none},
486 {b("linux-amd64@go1.12", "exp"), none},
Brad Fitzpatrick8a071d42019-03-18 16:48:22 +0000487
488 // Only use latest macOS for subrepos, and only amd64:
489 {b("darwin-amd64-10_12", "net"), onlyPost},
490 {b("darwin-amd64-10_12@go1.11", "net"), onlyPost},
491 {b("darwin-amd64-10_11", "net"), none},
492 {b("darwin-amd64-10_11@go1.11", "net"), none},
493 {b("darwin-amd64-10_11@go1.12", "net"), none},
Brad Fitzpatrickd5a76402019-04-29 16:41:45 +0000494 {b("darwin-386-10_14@go1.11", "net"), none},
Brad Fitzpatrick8bd8e0e2019-03-26 23:04:31 +0000495
496 {b("darwin-amd64-10_14", "go"), onlyPost},
497 {b("darwin-amd64-10_12", "go"), onlyPost},
498 {b("darwin-amd64-10_11", "go"), onlyPost},
499 {b("darwin-amd64-10_10", "go"), none},
500 {b("darwin-amd64-10_10@go1.12", "go"), onlyPost},
501 {b("darwin-amd64-10_10@go1.11", "go"), onlyPost},
Brad Fitzpatrickd5a76402019-04-29 16:41:45 +0000502 {b("darwin-386-10_14", "go"), onlyPost},
Alexander Rakoczy2fe64f72019-08-26 16:40:35 -0400503 {b("darwin-386-10_14@go1.12", "go"), none},
504 {b("darwin-386-10_14@go1.13", "go"), onlyPost},
Brad Fitzpatrick85a73d72019-04-03 04:45:29 +0000505
Brad Fitzpatrick67073b92019-04-18 19:33:19 +0000506 // plan9 only lived at master. We didn't support any past releases.
507 // But it's off for now as it's always failing.
508 {b("plan9-386", "go"), none}, // temporarily disabled
509 {b("plan9-386", "net"), none}, // temporarily disabled
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000510 {b("plan9-386@go1.11", "go"), none},
511 {b("plan9-386@go1.12", "go"), none},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000512 {b("plan9-386@go1.11", "net"), none},
513 {b("plan9-386@go1.12", "net"), none},
514 {b("plan9-amd64-9front", "go"), onlyPost},
515 {b("plan9-amd64-9front@go1.11", "go"), none},
516 {b("plan9-amd64-9front@go1.12", "go"), none},
517 {b("plan9-amd64-9front", "net"), onlyPost},
518 {b("plan9-amd64-9front@go1.11", "net"), none},
519 {b("plan9-amd64-9front@go1.12", "net"), none},
520 {b("plan9-arm", "go"), onlyPost},
521 {b("plan9-arm@go1.11", "go"), none},
522 {b("plan9-arm@go1.12", "go"), none},
523 {b("plan9-arm", "net"), onlyPost},
524 {b("plan9-arm@go1.11", "net"), none},
525 {b("plan9-arm@go1.12", "net"), none},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000526
527 // x/net master with Go 1.11 doesn't work on our builders
528 // on 32-bit FreeBSD. Remove distracting red from the dashboard
529 // that'll never be fixed.
530 {b("freebsd-386-11_2@go1.11", "net"), none},
531 {b("freebsd-386-12_0@go1.11", "net"), none},
Brad Fitzpatrick58771952019-10-21 15:00:32 +0000532
533 {b("dragonfly-amd64", "go"), onlyPost},
534 {b("dragonfly-amd64", "net"), onlyPost},
535 {b("dragonfly-amd64@go1.13", "net"), none}, // Dragonfly ABI changes only supported by Go 1.14+
536 {b("dragonfly-amd64@go1.13", "go"), none}, // Dragonfly ABI changes only supported by Go 1.14+
537 {b("dragonfly-amd64-5_6", "go"), onlyPost},
538 {b("dragonfly-amd64-5_6", "net"), onlyPost},
539 {b("dragonfly-amd64-5_6@go1.13", "net"), onlyPost},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000540 }
541 for _, tt := range tests {
542 t.Run(tt.br.testName, func(t *testing.T) {
543 bc, ok := Builders[tt.br.builder]
544 if !ok {
545 t.Fatalf("unknown builder %q", tt.br.builder)
546 }
547 gotPost := bc.BuildsRepoPostSubmit(tt.br.repo, tt.br.branch, tt.br.goBranch)
548 if tt.want&isBuilder != 0 && !gotPost {
549 t.Errorf("not a post-submit builder, but expected")
550 }
551 if tt.want&notBuilder != 0 && gotPost {
552 t.Errorf("unexpectedly a post-submit builder")
553 }
554
555 gotTry := bc.BuildsRepoTryBot(tt.br.repo, tt.br.branch, tt.br.goBranch)
556 if tt.want&isTrybot != 0 && !gotTry {
557 t.Errorf("not trybot, but expected")
558 }
559 if tt.want&notTrybot != 0 && gotTry {
560 t.Errorf("unexpectedly a trybot")
561 }
562
563 if t.Failed() {
564 t.Logf("For: %+v", tt.br)
565 }
566 })
567 }
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000568}
569
570func TestHostConfigsAllUsed(t *testing.T) {
571 used := map[string]bool{}
572 for _, conf := range Builders {
573 used[conf.HostType] = true
574 }
575 for hostType := range Hosts {
576 if !used[hostType] {
577 // Currently host-linux-armhf-cross and host-linux-armel-cross aren't
578 // referenced, but the coordinator hard-codes them, so don't make
579 // this an error for now.
580 t.Logf("warning: host type %q is not referenced from any build config", hostType)
581 }
582 }
583}
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000584
585// tests that goBranch is optional for repo == "go"
586func TestBuildsRepoAtAllImplicitGoBranch(t *testing.T) {
587 builder := Builders["android-amd64-emu"]
588 got := builder.buildsRepoAtAll("go", "master", "")
589 if !got {
590 t.Error("got = false; want true")
591 }
592}
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000593
594func TestShouldRunDistTest(t *testing.T) {
595 type buildMode int
596 const (
597 tryMode buildMode = 0
598 postSubmit buildMode = 1
599 )
600
601 tests := []struct {
602 builder string
603 test string
604 mode buildMode
605 want bool
606 }{
607 {"linux-amd64", "api", postSubmit, true},
608 {"linux-amd64", "api", tryMode, true},
609
610 {"linux-amd64", "reboot", tryMode, true},
611 {"linux-amd64-race", "reboot", tryMode, false},
612
613 {"darwin-amd64-10_10", "test:foo", postSubmit, false},
614 {"darwin-amd64-10_11", "test:foo", postSubmit, false},
615 {"darwin-amd64-10_12", "test:foo", postSubmit, false},
616 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
617 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
618 {"darwin-amd64-10_14", "reboot", postSubmit, false},
619 {"darwin-amd64-10_14", "api", postSubmit, false},
620 {"darwin-amd64-10_14", "codewalk", postSubmit, false},
621 }
622 for _, tt := range tests {
623 bc, ok := Builders[tt.builder]
624 if !ok {
625 t.Errorf("unknown builder %q", tt.builder)
626 continue
627 }
628 isTry := tt.mode == tryMode
629 if isTry && !bc.BuildsRepoTryBot("go", "master", "master") {
630 t.Errorf("builder %q is not a trybot, so can't run test %q in try mode", tt.builder, tt.test)
631 continue
632 }
633 got := bc.ShouldRunDistTest(tt.test, isTry)
634 if got != tt.want {
635 t.Errorf("%q.ShouldRunDistTest(%q, try %v) = %v; want %v", tt.builder, tt.test, isTry, got, tt.want)
636 }
637 }
638}
Dmitri Shuralyov01fd2992019-09-09 16:48:08 -0400639
640func TestShouldTestPackageInGOPATHMode(t *testing.T) {
641 // This function doesn't change behavior depending on the builder
642 // at this time, so just use a common one.
643 bc, ok := Builders["linux-amd64"]
644 if !ok {
645 t.Fatal("unknown builder")
646 }
647
648 tests := []struct {
649 importPath string
650 want bool
651 }{
652 {"golang.org/x/image/bmp", true},
653 {"golang.org/x/tools/go/ast/astutil", true},
654 {"golang.org/x/tools/go/packages", true},
655 {"golang.org/x/tools", true}, // Three isn't a package there, but if there was, it should be tested.
656 {"golang.org/x/tools/gopls", false},
657 {"golang.org/x/tools/gopls/internal/foobar", false},
658 }
659 for _, tt := range tests {
660 got := bc.ShouldTestPackageInGOPATHMode(tt.importPath)
661 if got != tt.want {
662 t.Errorf("ShouldTestPackageInGOPATHMode(%q) = %v; want %v", tt.importPath, got, tt.want)
663 }
664 }
665}
Brad Fitzpatrickaab85042019-10-16 06:02:29 +0000666
667func TestSlowBotAliases(t *testing.T) {
668 for term, name := range slowBotAliases {
669 if name == "" {
670 // Empty string means known missing builder.
671 continue
672 }
673 if _, ok := Builders[name]; !ok {
674 t.Errorf("slowbot term %q references unknown builder %q", term, name)
675 }
676 }
677
678 out, err := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "tool", "dist", "list").Output()
679 if err != nil {
680 t.Errorf("dist list: %v", err)
681 }
682 ports := strings.Fields(string(out))
683
684 done := map[string]bool{}
685 var add bytes.Buffer
686 check := func(term string, isArch bool) {
687 if done[term] {
688 return
689 }
690 done[term] = true
691 _, isBuilderName := Builders[term]
692 _, hasAlias := slowBotAliases[term]
693 if !isBuilderName && !hasAlias {
694 prefix := term
695 if isArch {
696 prefix = "linux-" + term
697 }
698 var matches []string
699 for name := range Builders {
700 if strings.HasPrefix(name, prefix) {
701 matches = append(matches, name)
702 }
703 }
704 sort.Strings(matches)
705 t.Errorf("term %q has no match in slowBotAliases", term)
706 if len(matches) == 1 {
707 fmt.Fprintf(&add, "%q: %q,\n", term, matches[0])
708 } else if len(matches) > 1 {
709 t.Errorf("maybe add: %q: %q, (matches=%q)", term, matches[len(matches)-1], matches)
710 }
711 }
712 }
713
714 for _, port := range ports {
715 slash := strings.IndexByte(port, '/')
716 if slash == -1 {
717 t.Fatalf("unexpected port %q", port)
718 }
719 goos, goarch := port[:slash], port[slash+1:]
720 check(goos+"-"+goarch, false)
721 check(goos, false)
722 check(goarch, true)
723 }
724
725 if add.Len() > 0 {
726 t.Errorf("Missing items from slowBotAliases:\n%s", add.String())
727 }
728}
Brad Fitzpatrickad7af462019-10-19 02:49:53 +0000729
730func TestCrossCompileConfigs(t *testing.T) {
731 // Verify that Builders.CrossCompileConfig have valid host types.
732 for name, bc := range Builders {
733 cc := bc.CrossCompileConfig
734 if cc == nil {
735 continue
736 }
737 if _, ok := Hosts[cc.CompileHostType]; !ok {
738 t.Errorf("unknown host type %q for builder %q", cc.CompileHostType, name)
739 }
740 }
741}