blob: f2ec21c9688782164d327b6414acd4138ce2793b [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 Fitzpatrick756764c2019-03-07 17:44:41 +00008 "fmt"
Brad Fitzpatrickf3c01932015-01-15 16:29:16 -08009 "strings"
10 "testing"
Brad Fitzpatrick34b995b2019-02-14 02:18:06 +000011 "time"
Brad Fitzpatrickf3c01932015-01-15 16:29:16 -080012)
13
14func TestOSARCHAccessors(t *testing.T) {
15 valid := func(s string) bool { return s != "" && !strings.Contains(s, "-") }
16 for _, conf := range Builders {
17 os := conf.GOOS()
18 arch := conf.GOARCH()
19 osArch := os + "-" + arch
20 if !valid(os) || !valid(arch) || !(conf.Name == osArch || strings.HasPrefix(conf.Name, osArch+"-")) {
21 t.Errorf("OS+ARCH(%q) = %q, %q; invalid", conf.Name, os, arch)
22 }
23 }
24}
Brad Fitzpatrickc328d042017-04-12 00:35:37 +000025
Brad Fitzpatrick34b995b2019-02-14 02:18:06 +000026func TestDistTestsExecTimeout(t *testing.T) {
27 tests := []struct {
28 c *BuildConfig
29 want time.Duration
30 }{
31 {
32 &BuildConfig{
33 env: []string{},
34 testHostConf: &HostConfig{},
35 },
36 20 * time.Minute,
37 },
38 {
39 &BuildConfig{
40 env: []string{"GO_TEST_TIMEOUT_SCALE=2"},
41 testHostConf: &HostConfig{},
42 },
43 40 * time.Minute,
44 },
45 {
46 &BuildConfig{
47 env: []string{},
48 testHostConf: &HostConfig{
49 env: []string{"GO_TEST_TIMEOUT_SCALE=3"},
50 },
51 },
52 60 * time.Minute,
53 },
54 // BuildConfig's env takes precedence:
55 {
56 &BuildConfig{
57 env: []string{"GO_TEST_TIMEOUT_SCALE=2"},
58 testHostConf: &HostConfig{
59 env: []string{"GO_TEST_TIMEOUT_SCALE=3"},
60 },
61 },
62 40 * time.Minute,
63 },
64 }
65 for i, tt := range tests {
66 got := tt.c.DistTestsExecTimeout(nil)
67 if got != tt.want {
68 t.Errorf("%d. got %v; want %v", i, got, tt.want)
69 }
70 }
71}
72
Brad Fitzpatrick756764c2019-03-07 17:44:41 +000073// TestTrybots tests that a given repo & its branch yields the provided
74// complete set of builders. See also: TestBuilders, which tests both trybots
75// and post-submit builders, both at arbitrary branches.
76func TestTrybots(t *testing.T) {
77 tests := []struct {
78 repo string // "go", "net", etc
79 branch string // of repo
80 want []string
81 }{
82 {
83 repo: "go",
84 branch: "master",
85 want: []string{
Brad Fitzpatrick4e29d672019-04-18 19:45:32 +000086 "android-amd64-emu",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +000087 "freebsd-amd64-12_0",
88 "js-wasm",
89 "linux-386",
90 "linux-amd64",
91 "linux-amd64-race",
92 "misc-compile",
93 "misc-compile-freebsd",
94 "misc-compile-mips",
95 "misc-compile-nacl",
96 "misc-compile-netbsd",
97 "misc-compile-openbsd",
98 "misc-compile-plan9",
99 "misc-compile-ppc",
100 "misc-vet-vetall",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000101 "nacl-amd64p32",
102 "openbsd-amd64-64",
103 "windows-386-2008",
104 "windows-amd64-2016",
105 },
106 },
107 {
108 repo: "go",
109 branch: "release-branch.go1.12",
110 want: []string{
111 "freebsd-amd64-10_3",
112 "freebsd-amd64-12_0",
113 "js-wasm",
114 "linux-386",
115 "linux-amd64",
116 "linux-amd64-race",
117 "misc-compile",
118 "misc-compile-freebsd",
119 "misc-compile-mips",
120 "misc-compile-nacl",
121 "misc-compile-netbsd",
122 "misc-compile-openbsd",
123 "misc-compile-plan9",
124 "misc-compile-ppc",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000125 "nacl-amd64p32",
126 "openbsd-amd64-64",
127 "windows-386-2008",
128 "windows-amd64-2016",
129 },
130 },
131 {
132 repo: "mobile",
133 branch: "master",
134 want: []string{
135 "android-amd64-emu",
136 "linux-amd64-androidemu",
137 },
138 },
139 {
140 repo: "sys",
141 branch: "master",
142 want: []string{
Brad Fitzpatrick6d867c82019-04-26 14:04:00 +0000143 "android-amd64-emu",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000144 "freebsd-386-11_2",
145 "freebsd-amd64-11_2",
146 "freebsd-amd64-12_0",
147 "linux-386",
148 "linux-amd64",
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000149 "linux-amd64-race",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000150 "netbsd-amd64-8_0",
151 "openbsd-386-64",
152 "openbsd-amd64-64",
153 "windows-386-2008",
154 "windows-amd64-2016",
155 },
156 },
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000157 {
158 repo: "exp",
159 branch: "master",
160 want: []string{
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000161 "linux-amd64",
162 "linux-amd64-race",
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000163 "windows-386-2008",
164 "windows-amd64-2016",
165 },
166 },
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000167 }
168 for i, tt := range tests {
169 if tt.branch == "" || tt.repo == "" {
170 t.Errorf("incomplete test entry %d", i)
171 return
172 }
173 t.Run(fmt.Sprintf("%s/%s", tt.repo, tt.branch), func(t *testing.T) {
174 var got []string
175 goBranch := tt.branch // hard-code the common case for now
176 for _, bc := range TryBuildersForProject(tt.repo, tt.branch, goBranch) {
177 got = append(got, bc.Name)
178 }
179 m := map[string]bool{}
180 for _, b := range tt.want {
181 m[b] = true
182 }
183 for _, b := range got {
184 if _, ok := m[b]; !ok {
185 t.Errorf("got unexpected %q", b)
186 }
187 delete(m, b)
188 }
189 for b := range m {
190 t.Errorf("missing expected %q", b)
Brad Fitzpatrickc517aed2018-10-26 19:21:58 +0000191 }
192 })
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000193 }
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000194}
195
196// TestBuilderConfig whether a given builder and repo at different
197// branches is either a post-submit builder, trybot, neither, or both.
198func TestBuilderConfig(t *testing.T) {
199 // builderConfigWant is bitmask of 4 different things to assert are wanted:
200 // - being a post-submit builder
201 // - NOT being a post-submit builder
202 // - being a trybot builder
203 // - NOT being a post-submit builder
204 type want uint8
205 const (
206 isTrybot want = 1 << iota
207 notTrybot
208 isBuilder // post-submit
209 notBuilder // not post-submit
210
211 none = notTrybot + notBuilder
212 both = isTrybot + isBuilder
213 onlyPost = notTrybot + isBuilder
214 )
215
216 type builderAndRepo struct {
217 testName string
218 builder string
219 repo string
220 branch string
221 goBranch string
222 }
223 // builder may end in "@go1.N" (as alias for "@release-branch.go1.N") or "@branch-name".
224 // repo may end in "@1.N" (as alias for "@release-branch.go1.N")
225 b := func(builder, repo string) builderAndRepo {
226 br := builderAndRepo{
227 testName: builder + "," + repo,
228 builder: builder,
229 goBranch: "master",
230 repo: repo,
231 branch: "master",
232 }
233 if strings.Contains(builder, "@") {
234 f := strings.SplitN(builder, "@", 2)
235 br.builder = f[0]
236 br.goBranch = f[1]
237 }
238 if strings.Contains(repo, "@") {
239 f := strings.SplitN(repo, "@", 2)
240 br.repo = f[0]
241 br.branch = f[1]
242 }
243 expandBranch := func(s *string) {
244 if strings.HasPrefix(*s, "go1.") {
245 *s = "release-branch." + *s
246 } else if strings.HasPrefix(*s, "1.") {
247 *s = "release-branch.go" + *s
248 }
249 }
250 expandBranch(&br.branch)
251 expandBranch(&br.goBranch)
252 if br.repo == "go" {
253 br.branch = br.goBranch
254 }
255 return br
256 }
257 tests := []struct {
258 br builderAndRepo
259 want want
260 }{
261 {b("linux-amd64", "go"), both},
262 {b("linux-amd64", "net"), both},
263 {b("linux-amd64", "sys"), both},
264
Brad Fitzpatrickc75979e2019-03-26 16:33:00 +0000265 {b("misc-vet-vetall", "go"), both},
266 {b("misc-vet-vetall@go1.11", "go"), none},
267 {b("misc-vet-vetall@go1.12", "go"), none},
268
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000269 // Don't test all subrepos on all the builders.
270 {b("linux-amd64-ssacheck", "net"), none},
271 {b("linux-amd64-ssacheck@go1.10", "net"), none},
272 {b("linux-amd64-noopt@go1.11", "net"), none},
273 {b("linux-386-387@go1.11", "net"), none},
274 {b("linux-386-387@go1.11", "go"), onlyPost},
275 {b("linux-386-387", "crypto"), onlyPost},
276 {b("linux-arm-arm5spacemonkey@go1.11", "net"), none},
277 {b("linux-arm-arm5spacemonkey@go1.12", "net"), none},
278
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000279 // The mobile repo requires Go 1.13+.
Brad Fitzpatrick4e29d672019-04-18 19:45:32 +0000280 {b("android-amd64-emu", "go"), both},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000281 {b("android-amd64-emu", "mobile"), both},
282 {b("android-amd64-emu", "mobile@1.10"), none},
283 {b("android-amd64-emu", "mobile@1.11"), none},
284 {b("android-amd64-emu@go1.10", "mobile"), none},
285 {b("android-amd64-emu@go1.11", "mobile"), none},
286 {b("android-amd64-emu@go1.12", "mobile"), none},
287 {b("android-amd64-emu@go1.13", "mobile"), both},
288 {b("android-amd64-emu", "mobile@1.13"), both},
Brad Fitzpatrick6d867c82019-04-26 14:04:00 +0000289 {b("android-amd64-emu", "crypto"), both},
290 {b("android-amd64-emu", "net"), both},
291 {b("android-amd64-emu", "sync"), both},
292 {b("android-amd64-emu", "sys"), both},
293 {b("android-amd64-emu", "text"), both},
294 {b("android-amd64-emu", "time"), both},
295 {b("android-amd64-emu", "tools"), both},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000296
297 {b("android-386-emu", "go"), onlyPost},
298 {b("android-386-emu", "mobile"), onlyPost},
299 {b("android-386-emu", "mobile@1.10"), none},
300 {b("android-386-emu", "mobile@1.11"), none},
301 {b("android-386-emu@go1.10", "mobile"), none},
302 {b("android-386-emu@go1.11", "mobile"), none},
303 {b("android-386-emu@go1.12", "mobile"), none},
304 {b("android-386-emu@go1.13", "mobile"), onlyPost},
305 {b("android-386-emu", "mobile@1.13"), onlyPost},
306
307 {b("linux-amd64", "net"), both},
308 {b("linux-amd64", "net@1.12"), both},
309 {b("linux-amd64@go1.12", "net@1.12"), both},
310 {b("linux-amd64", "net@1.11"), both},
311 {b("linux-amd64", "net@1.11"), both},
312 {b("linux-amd64", "net@1.10"), none}, // too old
313 {b("linux-amd64@go1.10", "net"), none}, // too old
314 {b("linux-amd64@go1.11", "net"), both},
315 {b("linux-amd64@go1.11", "net@1.11"), both},
316 {b("linux-amd64@go1.12", "net@1.12"), both},
317
318 // go1.12.html: "Go 1.12 is the last release that is
319 // supported on FreeBSD 10.x [... and 11.1]"
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000320 {b("freebsd-386-10_3", "go"), none},
321 {b("freebsd-386-10_3", "net"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000322 {b("freebsd-amd64-10_3", "go"), none},
323 {b("freebsd-amd64-10_3", "net"), none},
324 {b("freebsd-amd64-11_1", "go"), none},
325 {b("freebsd-amd64-11_1", "net"), none},
326 {b("freebsd-amd64-10_3@go1.12", "go"), both},
327 {b("freebsd-amd64-10_3@go1.12", "net@1.12"), both},
328 {b("freebsd-amd64-10_3@go1.11", "go"), both},
329 {b("freebsd-amd64-10_3@go1.11", "net@1.11"), both},
330 {b("freebsd-amd64-11_1@go1.13", "go"), none},
331 {b("freebsd-amd64-11_1@go1.13", "net@1.12"), none},
332 {b("freebsd-amd64-11_1@go1.12", "go"), isBuilder},
333 {b("freebsd-amd64-11_1@go1.12", "net@1.12"), isBuilder},
334 {b("freebsd-amd64-11_1@go1.11", "go"), isBuilder},
335 {b("freebsd-amd64-11_1@go1.11", "net@1.11"), isBuilder},
336
Brad Fitzpatrick9e52fce2019-03-12 21:13:50 +0000337 // FreeBSD 12.0
338 {b("freebsd-amd64-12_0", "go"), both},
339 {b("freebsd-amd64-12_0", "net"), both},
340 {b("freebsd-386-12_0", "go"), onlyPost},
341 {b("freebsd-386-12_0", "net"), onlyPost},
342
Brad Fitzpatrickfcf7a582019-04-30 22:37:31 +0000343 // NetBSD
344 {b("netbsd-amd64-8_0", "go"), onlyPost},
345 {b("netbsd-amd64-8_0", "net"), onlyPost},
346 {b("netbsd-386-8_0", "go"), none},
347 {b("netbsd-386-8_0", "net"), none},
348
Tobias Klauserb7b66932019-03-13 09:29:15 +0100349 // AIX starts at Go 1.12
350 {b("aix-ppc64", "go"), onlyPost},
351 {b("aix-ppc64", "net"), onlyPost},
352 {b("aix-ppc64@go1.12", "go"), onlyPost},
Brad Fitzpatrick0bbb12f2019-04-19 14:37:11 +0000353 {b("aix-ppc64@go1.12", "net"), none},
354 {b("aix-ppc64@go1.13", "net"), onlyPost},
Tobias Klauserb7b66932019-03-13 09:29:15 +0100355 {b("aix-ppc64@go1.11", "go"), none},
356 {b("aix-ppc64@go1.11", "net"), none},
357
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000358 {b("linux-amd64-nocgo", "mobile"), none},
359
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000360 // The physical ARM Androids only runs "go":
361 // They run on GOOS=android mode which is not
362 // interesting for x/mobile. The interesting tests run
363 // on the darwin-amd64-wikofever below where
364 // GOOS=darwin.
365 {b("android-arm-wikofever", "go"), isBuilder},
366 {b("android-arm-wikofever", "mobile"), notBuilder},
367 {b("android-arm64-wikofever", "go"), isBuilder},
368 {b("android-arm64-wikofever", "mobile"), notBuilder},
369 {b("android-arm64-wikofever", "net"), notBuilder},
370
Elias Naur4d0f77a2019-05-01 22:28:43 +0200371 // Virtual mobiledevices
Elias Naur6bebc8e2019-05-01 20:33:26 +0200372 {b("darwin-arm64-corellium", "go"), isBuilder},
Elias Naur4d0f77a2019-05-01 22:28:43 +0200373 {b("android-arm64-corellium", "go"), isBuilder},
Elias Naur6bebc8e2019-05-01 20:33:26 +0200374
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000375 // A GOOS=darwin variant of the physical ARM Androids
376 // runs x/mobile and nothing else:
377 {b("darwin-amd64-wikofever", "mobile"), isBuilder},
378 {b("darwin-amd64-wikofever", "go"), notBuilder},
379 {b("darwin-amd64-wikofever", "net"), notBuilder},
380
Brad Fitzpatrick13f1da92019-03-12 16:21:55 +0000381 // Mobile builders that run with GOOS=linux/darwin and have
382 // a device attached.
383 {b("linux-amd64-androidemu", "mobile"), both},
384 {b("darwin-amd64-wikofever", "mobile"), onlyPost},
385
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000386 // But the emulators run all:
387 {b("android-amd64-emu", "mobile"), isBuilder},
388 {b("android-386-emu", "mobile"), isBuilder},
389 {b("android-amd64-emu", "net"), isBuilder},
390 {b("android-386-emu", "net"), isBuilder},
391 {b("android-amd64-emu", "go"), isBuilder},
392 {b("android-386-emu", "go"), isBuilder},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000393
Brad Fitzpatrickfcf7a582019-04-30 22:37:31 +0000394 {b("nacl-386", "go"), onlyPost},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000395 {b("nacl-386", "net"), none},
396 {b("nacl-amd64p32", "go"), both},
397 {b("nacl-amd64p32", "net"), none},
398
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000399 // Only test tip for js/wasm, and only for some repos:
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000400 {b("js-wasm", "go"), both},
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000401 {b("js-wasm", "arch"), onlyPost},
402 {b("js-wasm", "crypto"), onlyPost},
403 {b("js-wasm", "sys"), onlyPost},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000404 {b("js-wasm", "net"), onlyPost},
405 {b("js-wasm@go1.12", "net"), none},
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000406 {b("js-wasm", "benchmarks"), none},
407 {b("js-wasm", "debug"), none},
408 {b("js-wasm", "mobile"), none},
409 {b("js-wasm", "perf"), none},
410 {b("js-wasm", "talks"), none},
411 {b("js-wasm", "tools"), none},
412 {b("js-wasm", "tour"), none},
413 {b("js-wasm", "website"), none},
414
415 // Race builders. Linux for all, GCE buidlers for
416 // post-submit, and only post-submit for "go" for
417 // Darwin (limited resources).
418 {b("linux-amd64-race", "go"), both},
419 {b("linux-amd64-race", "net"), both},
420 {b("windows-amd64-race", "go"), onlyPost},
421 {b("windows-amd64-race", "net"), onlyPost},
422 {b("freebsd-amd64-race", "go"), onlyPost},
423 {b("freebsd-amd64-race", "net"), onlyPost},
424 {b("darwin-amd64-race", "go"), onlyPost},
425 {b("darwin-amd64-race", "net"), none},
426
427 // Long test.
428 {b("linux-amd64-longtest", "go"), onlyPost},
429 {b("linux-amd64-longtest", "net"), onlyPost},
430 {b("linux-amd64-longtest@go1.12", "go"), onlyPost},
431 {b("linux-amd64-longtest@go1.12", "net"), none},
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000432
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000433 // Experimental exp repo runs in very few places.
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000434 {b("linux-amd64", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000435 {b("linux-amd64-race", "exp"), both},
436 {b("linux-amd64-longtest", "exp"), onlyPost},
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000437 {b("windows-386-2008", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000438 {b("windows-amd64-2016", "exp"), both},
439 {b("darwin-amd64-10_12", "exp"), onlyPost},
440 {b("darwin-amd64-10_14", "exp"), onlyPost},
441 // ... but not on most others:
442 {b("freebsd-386-11_2", "exp"), none},
443 {b("freebsd-386-12_0", "exp"), none},
444 {b("freebsd-amd64-11_2", "exp"), none},
445 {b("freebsd-amd64-12_0", "exp"), none},
446 {b("openbsd-amd64-62", "exp"), none},
447 {b("openbsd-amd64-64", "exp"), none},
448 {b("js-wasm", "exp"), none},
449
450 // exp is experimental; it doesn't test against release branches.
451 {b("linux-amd64@go1.11", "exp"), none},
452 {b("linux-amd64@go1.12", "exp"), none},
Brad Fitzpatrick8a071d42019-03-18 16:48:22 +0000453
454 // Only use latest macOS for subrepos, and only amd64:
455 {b("darwin-amd64-10_12", "net"), onlyPost},
456 {b("darwin-amd64-10_12@go1.11", "net"), onlyPost},
457 {b("darwin-amd64-10_11", "net"), none},
458 {b("darwin-amd64-10_11@go1.11", "net"), none},
459 {b("darwin-amd64-10_11@go1.12", "net"), none},
Brad Fitzpatrickd5a76402019-04-29 16:41:45 +0000460 {b("darwin-386-10_14@go1.11", "net"), none},
Brad Fitzpatrick8bd8e0e2019-03-26 23:04:31 +0000461
462 {b("darwin-amd64-10_14", "go"), onlyPost},
463 {b("darwin-amd64-10_12", "go"), onlyPost},
464 {b("darwin-amd64-10_11", "go"), onlyPost},
465 {b("darwin-amd64-10_10", "go"), none},
466 {b("darwin-amd64-10_10@go1.12", "go"), onlyPost},
467 {b("darwin-amd64-10_10@go1.11", "go"), onlyPost},
Brad Fitzpatrickd5a76402019-04-29 16:41:45 +0000468 {b("darwin-386-10_14", "go"), onlyPost},
469 {b("darwin-386-10_14@go1.12", "go"), onlyPost},
470 {b("darwin-386-10_14@go1.11", "go"), onlyPost},
Brad Fitzpatrick85a73d72019-04-03 04:45:29 +0000471
Brad Fitzpatrick67073b92019-04-18 19:33:19 +0000472 // plan9 only lived at master. We didn't support any past releases.
473 // But it's off for now as it's always failing.
474 {b("plan9-386", "go"), none}, // temporarily disabled
475 {b("plan9-386", "net"), none}, // temporarily disabled
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000476 {b("plan9-386@go1.11", "go"), none},
477 {b("plan9-386@go1.12", "go"), none},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000478 {b("plan9-386@go1.11", "net"), none},
479 {b("plan9-386@go1.12", "net"), none},
480 {b("plan9-amd64-9front", "go"), onlyPost},
481 {b("plan9-amd64-9front@go1.11", "go"), none},
482 {b("plan9-amd64-9front@go1.12", "go"), none},
483 {b("plan9-amd64-9front", "net"), onlyPost},
484 {b("plan9-amd64-9front@go1.11", "net"), none},
485 {b("plan9-amd64-9front@go1.12", "net"), none},
486 {b("plan9-arm", "go"), onlyPost},
487 {b("plan9-arm@go1.11", "go"), none},
488 {b("plan9-arm@go1.12", "go"), none},
489 {b("plan9-arm", "net"), onlyPost},
490 {b("plan9-arm@go1.11", "net"), none},
491 {b("plan9-arm@go1.12", "net"), none},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000492
493 // x/net master with Go 1.11 doesn't work on our builders
494 // on 32-bit FreeBSD. Remove distracting red from the dashboard
495 // that'll never be fixed.
496 {b("freebsd-386-11_2@go1.11", "net"), none},
497 {b("freebsd-386-12_0@go1.11", "net"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000498 }
499 for _, tt := range tests {
500 t.Run(tt.br.testName, func(t *testing.T) {
501 bc, ok := Builders[tt.br.builder]
502 if !ok {
503 t.Fatalf("unknown builder %q", tt.br.builder)
504 }
505 gotPost := bc.BuildsRepoPostSubmit(tt.br.repo, tt.br.branch, tt.br.goBranch)
506 if tt.want&isBuilder != 0 && !gotPost {
507 t.Errorf("not a post-submit builder, but expected")
508 }
509 if tt.want&notBuilder != 0 && gotPost {
510 t.Errorf("unexpectedly a post-submit builder")
511 }
512
513 gotTry := bc.BuildsRepoTryBot(tt.br.repo, tt.br.branch, tt.br.goBranch)
514 if tt.want&isTrybot != 0 && !gotTry {
515 t.Errorf("not trybot, but expected")
516 }
517 if tt.want&notTrybot != 0 && gotTry {
518 t.Errorf("unexpectedly a trybot")
519 }
520
521 if t.Failed() {
522 t.Logf("For: %+v", tt.br)
523 }
524 })
525 }
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000526}
527
528func TestHostConfigsAllUsed(t *testing.T) {
529 used := map[string]bool{}
530 for _, conf := range Builders {
531 used[conf.HostType] = true
532 }
533 for hostType := range Hosts {
534 if !used[hostType] {
535 // Currently host-linux-armhf-cross and host-linux-armel-cross aren't
536 // referenced, but the coordinator hard-codes them, so don't make
537 // this an error for now.
538 t.Logf("warning: host type %q is not referenced from any build config", hostType)
539 }
540 }
541}
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000542
543// tests that goBranch is optional for repo == "go"
544func TestBuildsRepoAtAllImplicitGoBranch(t *testing.T) {
545 builder := Builders["android-amd64-emu"]
546 got := builder.buildsRepoAtAll("go", "master", "")
547 if !got {
548 t.Error("got = false; want true")
549 }
550}
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000551
552func TestShouldRunDistTest(t *testing.T) {
553 type buildMode int
554 const (
555 tryMode buildMode = 0
556 postSubmit buildMode = 1
557 )
558
559 tests := []struct {
560 builder string
561 test string
562 mode buildMode
563 want bool
564 }{
565 {"linux-amd64", "api", postSubmit, true},
566 {"linux-amd64", "api", tryMode, true},
567
568 {"linux-amd64", "reboot", tryMode, true},
569 {"linux-amd64-race", "reboot", tryMode, false},
570
571 {"darwin-amd64-10_10", "test:foo", postSubmit, false},
572 {"darwin-amd64-10_11", "test:foo", postSubmit, false},
573 {"darwin-amd64-10_12", "test:foo", postSubmit, false},
574 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
575 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
576 {"darwin-amd64-10_14", "reboot", postSubmit, false},
577 {"darwin-amd64-10_14", "api", postSubmit, false},
578 {"darwin-amd64-10_14", "codewalk", postSubmit, false},
579 }
580 for _, tt := range tests {
581 bc, ok := Builders[tt.builder]
582 if !ok {
583 t.Errorf("unknown builder %q", tt.builder)
584 continue
585 }
586 isTry := tt.mode == tryMode
587 if isTry && !bc.BuildsRepoTryBot("go", "master", "master") {
588 t.Errorf("builder %q is not a trybot, so can't run test %q in try mode", tt.builder, tt.test)
589 continue
590 }
591 got := bc.ShouldRunDistTest(tt.test, isTry)
592 if got != tt.want {
593 t.Errorf("%q.ShouldRunDistTest(%q, try %v) = %v; want %v", tt.builder, tt.test, isTry, got, tt.want)
594 }
595 }
596}