blob: 51f4f5fc22c0d817d9ea0851c55f8b457ae07787 [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 Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000461
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000462 // Experimental exp repo runs in very few places.
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000463 {b("linux-amd64", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000464 {b("linux-amd64-race", "exp"), both},
465 {b("linux-amd64-longtest", "exp"), onlyPost},
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000466 {b("windows-386-2008", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000467 {b("windows-amd64-2016", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000468 {b("darwin-amd64-10_14", "exp"), onlyPost},
469 // ... but not on most others:
Dmitri Shuralyov3b77b3a2019-09-28 17:43:42 +0000470 {b("darwin-amd64-10_12", "exp"), none},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000471 {b("freebsd-386-11_2", "exp"), none},
472 {b("freebsd-386-12_0", "exp"), none},
473 {b("freebsd-amd64-11_2", "exp"), none},
474 {b("freebsd-amd64-12_0", "exp"), none},
475 {b("openbsd-amd64-62", "exp"), none},
476 {b("openbsd-amd64-64", "exp"), none},
477 {b("js-wasm", "exp"), none},
478
479 // exp is experimental; it doesn't test against release branches.
480 {b("linux-amd64@go1.11", "exp"), none},
481 {b("linux-amd64@go1.12", "exp"), none},
Brad Fitzpatrick8a071d42019-03-18 16:48:22 +0000482
483 // Only use latest macOS for subrepos, and only amd64:
484 {b("darwin-amd64-10_12", "net"), onlyPost},
485 {b("darwin-amd64-10_12@go1.11", "net"), onlyPost},
486 {b("darwin-amd64-10_11", "net"), none},
487 {b("darwin-amd64-10_11@go1.11", "net"), none},
488 {b("darwin-amd64-10_11@go1.12", "net"), none},
Brad Fitzpatrickd5a76402019-04-29 16:41:45 +0000489 {b("darwin-386-10_14@go1.11", "net"), none},
Brad Fitzpatrick8bd8e0e2019-03-26 23:04:31 +0000490
491 {b("darwin-amd64-10_14", "go"), onlyPost},
492 {b("darwin-amd64-10_12", "go"), onlyPost},
493 {b("darwin-amd64-10_11", "go"), onlyPost},
494 {b("darwin-amd64-10_10", "go"), none},
495 {b("darwin-amd64-10_10@go1.12", "go"), onlyPost},
496 {b("darwin-amd64-10_10@go1.11", "go"), onlyPost},
Brad Fitzpatrickd5a76402019-04-29 16:41:45 +0000497 {b("darwin-386-10_14", "go"), onlyPost},
Alexander Rakoczy2fe64f72019-08-26 16:40:35 -0400498 {b("darwin-386-10_14@go1.12", "go"), none},
499 {b("darwin-386-10_14@go1.13", "go"), onlyPost},
Brad Fitzpatrick85a73d72019-04-03 04:45:29 +0000500
Brad Fitzpatrick67073b92019-04-18 19:33:19 +0000501 // plan9 only lived at master. We didn't support any past releases.
502 // But it's off for now as it's always failing.
503 {b("plan9-386", "go"), none}, // temporarily disabled
504 {b("plan9-386", "net"), none}, // temporarily disabled
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000505 {b("plan9-386@go1.11", "go"), none},
506 {b("plan9-386@go1.12", "go"), none},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000507 {b("plan9-386@go1.11", "net"), none},
508 {b("plan9-386@go1.12", "net"), none},
509 {b("plan9-amd64-9front", "go"), onlyPost},
510 {b("plan9-amd64-9front@go1.11", "go"), none},
511 {b("plan9-amd64-9front@go1.12", "go"), none},
512 {b("plan9-amd64-9front", "net"), onlyPost},
513 {b("plan9-amd64-9front@go1.11", "net"), none},
514 {b("plan9-amd64-9front@go1.12", "net"), none},
515 {b("plan9-arm", "go"), onlyPost},
516 {b("plan9-arm@go1.11", "go"), none},
517 {b("plan9-arm@go1.12", "go"), none},
518 {b("plan9-arm", "net"), onlyPost},
519 {b("plan9-arm@go1.11", "net"), none},
520 {b("plan9-arm@go1.12", "net"), none},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000521
522 // x/net master with Go 1.11 doesn't work on our builders
523 // on 32-bit FreeBSD. Remove distracting red from the dashboard
524 // that'll never be fixed.
525 {b("freebsd-386-11_2@go1.11", "net"), none},
526 {b("freebsd-386-12_0@go1.11", "net"), none},
Brad Fitzpatrick58771952019-10-21 15:00:32 +0000527
528 {b("dragonfly-amd64", "go"), onlyPost},
529 {b("dragonfly-amd64", "net"), onlyPost},
530 {b("dragonfly-amd64@go1.13", "net"), none}, // Dragonfly ABI changes only supported by Go 1.14+
531 {b("dragonfly-amd64@go1.13", "go"), none}, // Dragonfly ABI changes only supported by Go 1.14+
532 {b("dragonfly-amd64-5_6", "go"), onlyPost},
533 {b("dragonfly-amd64-5_6", "net"), onlyPost},
534 {b("dragonfly-amd64-5_6@go1.13", "net"), onlyPost},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000535 }
536 for _, tt := range tests {
537 t.Run(tt.br.testName, func(t *testing.T) {
538 bc, ok := Builders[tt.br.builder]
539 if !ok {
540 t.Fatalf("unknown builder %q", tt.br.builder)
541 }
542 gotPost := bc.BuildsRepoPostSubmit(tt.br.repo, tt.br.branch, tt.br.goBranch)
543 if tt.want&isBuilder != 0 && !gotPost {
544 t.Errorf("not a post-submit builder, but expected")
545 }
546 if tt.want&notBuilder != 0 && gotPost {
547 t.Errorf("unexpectedly a post-submit builder")
548 }
549
550 gotTry := bc.BuildsRepoTryBot(tt.br.repo, tt.br.branch, tt.br.goBranch)
551 if tt.want&isTrybot != 0 && !gotTry {
552 t.Errorf("not trybot, but expected")
553 }
554 if tt.want&notTrybot != 0 && gotTry {
555 t.Errorf("unexpectedly a trybot")
556 }
557
558 if t.Failed() {
559 t.Logf("For: %+v", tt.br)
560 }
561 })
562 }
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000563}
564
565func TestHostConfigsAllUsed(t *testing.T) {
566 used := map[string]bool{}
567 for _, conf := range Builders {
568 used[conf.HostType] = true
569 }
570 for hostType := range Hosts {
571 if !used[hostType] {
572 // Currently host-linux-armhf-cross and host-linux-armel-cross aren't
573 // referenced, but the coordinator hard-codes them, so don't make
574 // this an error for now.
575 t.Logf("warning: host type %q is not referenced from any build config", hostType)
576 }
577 }
578}
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000579
580// tests that goBranch is optional for repo == "go"
581func TestBuildsRepoAtAllImplicitGoBranch(t *testing.T) {
582 builder := Builders["android-amd64-emu"]
583 got := builder.buildsRepoAtAll("go", "master", "")
584 if !got {
585 t.Error("got = false; want true")
586 }
587}
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000588
589func TestShouldRunDistTest(t *testing.T) {
590 type buildMode int
591 const (
592 tryMode buildMode = 0
593 postSubmit buildMode = 1
594 )
595
596 tests := []struct {
597 builder string
598 test string
599 mode buildMode
600 want bool
601 }{
602 {"linux-amd64", "api", postSubmit, true},
603 {"linux-amd64", "api", tryMode, true},
604
605 {"linux-amd64", "reboot", tryMode, true},
606 {"linux-amd64-race", "reboot", tryMode, false},
607
608 {"darwin-amd64-10_10", "test:foo", postSubmit, false},
609 {"darwin-amd64-10_11", "test:foo", postSubmit, false},
610 {"darwin-amd64-10_12", "test:foo", postSubmit, false},
611 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
612 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
613 {"darwin-amd64-10_14", "reboot", postSubmit, false},
614 {"darwin-amd64-10_14", "api", postSubmit, false},
615 {"darwin-amd64-10_14", "codewalk", postSubmit, false},
616 }
617 for _, tt := range tests {
618 bc, ok := Builders[tt.builder]
619 if !ok {
620 t.Errorf("unknown builder %q", tt.builder)
621 continue
622 }
623 isTry := tt.mode == tryMode
624 if isTry && !bc.BuildsRepoTryBot("go", "master", "master") {
625 t.Errorf("builder %q is not a trybot, so can't run test %q in try mode", tt.builder, tt.test)
626 continue
627 }
628 got := bc.ShouldRunDistTest(tt.test, isTry)
629 if got != tt.want {
630 t.Errorf("%q.ShouldRunDistTest(%q, try %v) = %v; want %v", tt.builder, tt.test, isTry, got, tt.want)
631 }
632 }
633}
Dmitri Shuralyov01fd2992019-09-09 16:48:08 -0400634
635func TestShouldTestPackageInGOPATHMode(t *testing.T) {
636 // This function doesn't change behavior depending on the builder
637 // at this time, so just use a common one.
638 bc, ok := Builders["linux-amd64"]
639 if !ok {
640 t.Fatal("unknown builder")
641 }
642
643 tests := []struct {
644 importPath string
645 want bool
646 }{
647 {"golang.org/x/image/bmp", true},
648 {"golang.org/x/tools/go/ast/astutil", true},
649 {"golang.org/x/tools/go/packages", true},
650 {"golang.org/x/tools", true}, // Three isn't a package there, but if there was, it should be tested.
651 {"golang.org/x/tools/gopls", false},
652 {"golang.org/x/tools/gopls/internal/foobar", false},
653 }
654 for _, tt := range tests {
655 got := bc.ShouldTestPackageInGOPATHMode(tt.importPath)
656 if got != tt.want {
657 t.Errorf("ShouldTestPackageInGOPATHMode(%q) = %v; want %v", tt.importPath, got, tt.want)
658 }
659 }
660}
Brad Fitzpatrickaab85042019-10-16 06:02:29 +0000661
662func TestSlowBotAliases(t *testing.T) {
663 for term, name := range slowBotAliases {
664 if name == "" {
665 // Empty string means known missing builder.
666 continue
667 }
668 if _, ok := Builders[name]; !ok {
669 t.Errorf("slowbot term %q references unknown builder %q", term, name)
670 }
671 }
672
673 out, err := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "tool", "dist", "list").Output()
674 if err != nil {
675 t.Errorf("dist list: %v", err)
676 }
677 ports := strings.Fields(string(out))
678
679 done := map[string]bool{}
680 var add bytes.Buffer
681 check := func(term string, isArch bool) {
682 if done[term] {
683 return
684 }
685 done[term] = true
686 _, isBuilderName := Builders[term]
687 _, hasAlias := slowBotAliases[term]
688 if !isBuilderName && !hasAlias {
689 prefix := term
690 if isArch {
691 prefix = "linux-" + term
692 }
693 var matches []string
694 for name := range Builders {
695 if strings.HasPrefix(name, prefix) {
696 matches = append(matches, name)
697 }
698 }
699 sort.Strings(matches)
700 t.Errorf("term %q has no match in slowBotAliases", term)
701 if len(matches) == 1 {
702 fmt.Fprintf(&add, "%q: %q,\n", term, matches[0])
703 } else if len(matches) > 1 {
704 t.Errorf("maybe add: %q: %q, (matches=%q)", term, matches[len(matches)-1], matches)
705 }
706 }
707 }
708
709 for _, port := range ports {
710 slash := strings.IndexByte(port, '/')
711 if slash == -1 {
712 t.Fatalf("unexpected port %q", port)
713 }
714 goos, goarch := port[:slash], port[slash+1:]
715 check(goos+"-"+goarch, false)
716 check(goos, false)
717 check(goarch, true)
718 }
719
720 if add.Len() > 0 {
721 t.Errorf("Missing items from slowBotAliases:\n%s", add.String())
722 }
723}
Brad Fitzpatrickad7af462019-10-19 02:49:53 +0000724
725func TestCrossCompileConfigs(t *testing.T) {
726 // Verify that Builders.CrossCompileConfig have valid host types.
727 for name, bc := range Builders {
728 cc := bc.CrossCompileConfig
729 if cc == nil {
730 continue
731 }
732 if _, ok := Hosts[cc.CompileHostType]; !ok {
733 t.Errorf("unknown host type %q for builder %q", cc.CompileHostType, name)
734 }
735 }
736}