blob: 803464cfa2d4fe6688a620f6a63465d62feae118 [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",
101 "nacl-386",
102 "nacl-amd64p32",
103 "openbsd-amd64-64",
104 "windows-386-2008",
105 "windows-amd64-2016",
106 },
107 },
108 {
109 repo: "go",
110 branch: "release-branch.go1.12",
111 want: []string{
112 "freebsd-amd64-10_3",
113 "freebsd-amd64-12_0",
114 "js-wasm",
115 "linux-386",
116 "linux-amd64",
117 "linux-amd64-race",
118 "misc-compile",
119 "misc-compile-freebsd",
120 "misc-compile-mips",
121 "misc-compile-nacl",
122 "misc-compile-netbsd",
123 "misc-compile-openbsd",
124 "misc-compile-plan9",
125 "misc-compile-ppc",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000126 "nacl-386",
127 "nacl-amd64p32",
128 "openbsd-amd64-64",
129 "windows-386-2008",
130 "windows-amd64-2016",
131 },
132 },
133 {
134 repo: "mobile",
135 branch: "master",
136 want: []string{
137 "android-amd64-emu",
138 "linux-amd64-androidemu",
139 },
140 },
141 {
142 repo: "sys",
143 branch: "master",
144 want: []string{
Brad Fitzpatrick6d867c82019-04-26 14:04:00 +0000145 "android-amd64-emu",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000146 "freebsd-386-11_2",
147 "freebsd-amd64-11_2",
148 "freebsd-amd64-12_0",
149 "linux-386",
150 "linux-amd64",
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000151 "linux-amd64-race",
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000152 "netbsd-amd64-8_0",
153 "openbsd-386-64",
154 "openbsd-amd64-64",
155 "windows-386-2008",
156 "windows-amd64-2016",
157 },
158 },
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000159 {
160 repo: "exp",
161 branch: "master",
162 want: []string{
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000163 "linux-amd64",
164 "linux-amd64-race",
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000165 "windows-386-2008",
166 "windows-amd64-2016",
167 },
168 },
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000169 }
170 for i, tt := range tests {
171 if tt.branch == "" || tt.repo == "" {
172 t.Errorf("incomplete test entry %d", i)
173 return
174 }
175 t.Run(fmt.Sprintf("%s/%s", tt.repo, tt.branch), func(t *testing.T) {
176 var got []string
177 goBranch := tt.branch // hard-code the common case for now
178 for _, bc := range TryBuildersForProject(tt.repo, tt.branch, goBranch) {
179 got = append(got, bc.Name)
180 }
181 m := map[string]bool{}
182 for _, b := range tt.want {
183 m[b] = true
184 }
185 for _, b := range got {
186 if _, ok := m[b]; !ok {
187 t.Errorf("got unexpected %q", b)
188 }
189 delete(m, b)
190 }
191 for b := range m {
192 t.Errorf("missing expected %q", b)
Brad Fitzpatrickc517aed2018-10-26 19:21:58 +0000193 }
194 })
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000195 }
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000196}
197
198// TestBuilderConfig whether a given builder and repo at different
199// branches is either a post-submit builder, trybot, neither, or both.
200func TestBuilderConfig(t *testing.T) {
201 // builderConfigWant is bitmask of 4 different things to assert are wanted:
202 // - being a post-submit builder
203 // - NOT being a post-submit builder
204 // - being a trybot builder
205 // - NOT being a post-submit builder
206 type want uint8
207 const (
208 isTrybot want = 1 << iota
209 notTrybot
210 isBuilder // post-submit
211 notBuilder // not post-submit
212
213 none = notTrybot + notBuilder
214 both = isTrybot + isBuilder
215 onlyPost = notTrybot + isBuilder
216 )
217
218 type builderAndRepo struct {
219 testName string
220 builder string
221 repo string
222 branch string
223 goBranch string
224 }
225 // builder may end in "@go1.N" (as alias for "@release-branch.go1.N") or "@branch-name".
226 // repo may end in "@1.N" (as alias for "@release-branch.go1.N")
227 b := func(builder, repo string) builderAndRepo {
228 br := builderAndRepo{
229 testName: builder + "," + repo,
230 builder: builder,
231 goBranch: "master",
232 repo: repo,
233 branch: "master",
234 }
235 if strings.Contains(builder, "@") {
236 f := strings.SplitN(builder, "@", 2)
237 br.builder = f[0]
238 br.goBranch = f[1]
239 }
240 if strings.Contains(repo, "@") {
241 f := strings.SplitN(repo, "@", 2)
242 br.repo = f[0]
243 br.branch = f[1]
244 }
245 expandBranch := func(s *string) {
246 if strings.HasPrefix(*s, "go1.") {
247 *s = "release-branch." + *s
248 } else if strings.HasPrefix(*s, "1.") {
249 *s = "release-branch.go" + *s
250 }
251 }
252 expandBranch(&br.branch)
253 expandBranch(&br.goBranch)
254 if br.repo == "go" {
255 br.branch = br.goBranch
256 }
257 return br
258 }
259 tests := []struct {
260 br builderAndRepo
261 want want
262 }{
263 {b("linux-amd64", "go"), both},
264 {b("linux-amd64", "net"), both},
265 {b("linux-amd64", "sys"), both},
266
Brad Fitzpatrickc75979e2019-03-26 16:33:00 +0000267 {b("misc-vet-vetall", "go"), both},
268 {b("misc-vet-vetall@go1.11", "go"), none},
269 {b("misc-vet-vetall@go1.12", "go"), none},
270
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000271 // Don't test all subrepos on all the builders.
272 {b("linux-amd64-ssacheck", "net"), none},
273 {b("linux-amd64-ssacheck@go1.10", "net"), none},
274 {b("linux-amd64-noopt@go1.11", "net"), none},
275 {b("linux-386-387@go1.11", "net"), none},
276 {b("linux-386-387@go1.11", "go"), onlyPost},
277 {b("linux-386-387", "crypto"), onlyPost},
278 {b("linux-arm-arm5spacemonkey@go1.11", "net"), none},
279 {b("linux-arm-arm5spacemonkey@go1.12", "net"), none},
280
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000281 // The mobile repo requires Go 1.13+.
Brad Fitzpatrick4e29d672019-04-18 19:45:32 +0000282 {b("android-amd64-emu", "go"), both},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000283 {b("android-amd64-emu", "mobile"), both},
284 {b("android-amd64-emu", "mobile@1.10"), none},
285 {b("android-amd64-emu", "mobile@1.11"), none},
286 {b("android-amd64-emu@go1.10", "mobile"), none},
287 {b("android-amd64-emu@go1.11", "mobile"), none},
288 {b("android-amd64-emu@go1.12", "mobile"), none},
289 {b("android-amd64-emu@go1.13", "mobile"), both},
290 {b("android-amd64-emu", "mobile@1.13"), both},
Brad Fitzpatrick6d867c82019-04-26 14:04:00 +0000291 {b("android-amd64-emu", "crypto"), both},
292 {b("android-amd64-emu", "net"), both},
293 {b("android-amd64-emu", "sync"), both},
294 {b("android-amd64-emu", "sys"), both},
295 {b("android-amd64-emu", "text"), both},
296 {b("android-amd64-emu", "time"), both},
297 {b("android-amd64-emu", "tools"), both},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000298
299 {b("android-386-emu", "go"), onlyPost},
300 {b("android-386-emu", "mobile"), onlyPost},
301 {b("android-386-emu", "mobile@1.10"), none},
302 {b("android-386-emu", "mobile@1.11"), none},
303 {b("android-386-emu@go1.10", "mobile"), none},
304 {b("android-386-emu@go1.11", "mobile"), none},
305 {b("android-386-emu@go1.12", "mobile"), none},
306 {b("android-386-emu@go1.13", "mobile"), onlyPost},
307 {b("android-386-emu", "mobile@1.13"), onlyPost},
308
309 {b("linux-amd64", "net"), both},
310 {b("linux-amd64", "net@1.12"), both},
311 {b("linux-amd64@go1.12", "net@1.12"), both},
312 {b("linux-amd64", "net@1.11"), both},
313 {b("linux-amd64", "net@1.11"), both},
314 {b("linux-amd64", "net@1.10"), none}, // too old
315 {b("linux-amd64@go1.10", "net"), none}, // too old
316 {b("linux-amd64@go1.11", "net"), both},
317 {b("linux-amd64@go1.11", "net@1.11"), both},
318 {b("linux-amd64@go1.12", "net@1.12"), both},
319
320 // go1.12.html: "Go 1.12 is the last release that is
321 // supported on FreeBSD 10.x [... and 11.1]"
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000322 {b("freebsd-386-10_3", "go"), none},
323 {b("freebsd-386-10_3", "net"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000324 {b("freebsd-amd64-10_3", "go"), none},
325 {b("freebsd-amd64-10_3", "net"), none},
326 {b("freebsd-amd64-11_1", "go"), none},
327 {b("freebsd-amd64-11_1", "net"), none},
328 {b("freebsd-amd64-10_3@go1.12", "go"), both},
329 {b("freebsd-amd64-10_3@go1.12", "net@1.12"), both},
330 {b("freebsd-amd64-10_3@go1.11", "go"), both},
331 {b("freebsd-amd64-10_3@go1.11", "net@1.11"), both},
332 {b("freebsd-amd64-11_1@go1.13", "go"), none},
333 {b("freebsd-amd64-11_1@go1.13", "net@1.12"), none},
334 {b("freebsd-amd64-11_1@go1.12", "go"), isBuilder},
335 {b("freebsd-amd64-11_1@go1.12", "net@1.12"), isBuilder},
336 {b("freebsd-amd64-11_1@go1.11", "go"), isBuilder},
337 {b("freebsd-amd64-11_1@go1.11", "net@1.11"), isBuilder},
338
Brad Fitzpatrick9e52fce2019-03-12 21:13:50 +0000339 // FreeBSD 12.0
340 {b("freebsd-amd64-12_0", "go"), both},
341 {b("freebsd-amd64-12_0", "net"), both},
342 {b("freebsd-386-12_0", "go"), onlyPost},
343 {b("freebsd-386-12_0", "net"), onlyPost},
344
Tobias Klauserb7b66932019-03-13 09:29:15 +0100345 // AIX starts at Go 1.12
346 {b("aix-ppc64", "go"), onlyPost},
347 {b("aix-ppc64", "net"), onlyPost},
348 {b("aix-ppc64@go1.12", "go"), onlyPost},
Brad Fitzpatrick0bbb12f2019-04-19 14:37:11 +0000349 {b("aix-ppc64@go1.12", "net"), none},
350 {b("aix-ppc64@go1.13", "net"), onlyPost},
Tobias Klauserb7b66932019-03-13 09:29:15 +0100351 {b("aix-ppc64@go1.11", "go"), none},
352 {b("aix-ppc64@go1.11", "net"), none},
353
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000354 {b("linux-amd64-nocgo", "mobile"), none},
355
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000356 // The physical ARM Androids only runs "go":
357 // They run on GOOS=android mode which is not
358 // interesting for x/mobile. The interesting tests run
359 // on the darwin-amd64-wikofever below where
360 // GOOS=darwin.
361 {b("android-arm-wikofever", "go"), isBuilder},
362 {b("android-arm-wikofever", "mobile"), notBuilder},
363 {b("android-arm64-wikofever", "go"), isBuilder},
364 {b("android-arm64-wikofever", "mobile"), notBuilder},
365 {b("android-arm64-wikofever", "net"), notBuilder},
366
367 // A GOOS=darwin variant of the physical ARM Androids
368 // runs x/mobile and nothing else:
369 {b("darwin-amd64-wikofever", "mobile"), isBuilder},
370 {b("darwin-amd64-wikofever", "go"), notBuilder},
371 {b("darwin-amd64-wikofever", "net"), notBuilder},
372
Brad Fitzpatrick13f1da92019-03-12 16:21:55 +0000373 // Mobile builders that run with GOOS=linux/darwin and have
374 // a device attached.
375 {b("linux-amd64-androidemu", "mobile"), both},
376 {b("darwin-amd64-wikofever", "mobile"), onlyPost},
377
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000378 // But the emulators run all:
379 {b("android-amd64-emu", "mobile"), isBuilder},
380 {b("android-386-emu", "mobile"), isBuilder},
381 {b("android-amd64-emu", "net"), isBuilder},
382 {b("android-386-emu", "net"), isBuilder},
383 {b("android-amd64-emu", "go"), isBuilder},
384 {b("android-386-emu", "go"), isBuilder},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000385
386 {b("nacl-386", "go"), both},
387 {b("nacl-386", "net"), none},
388 {b("nacl-amd64p32", "go"), both},
389 {b("nacl-amd64p32", "net"), none},
390
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000391 // Only test tip for js/wasm, and only for some repos:
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000392 {b("js-wasm", "go"), both},
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000393 {b("js-wasm", "arch"), onlyPost},
394 {b("js-wasm", "crypto"), onlyPost},
395 {b("js-wasm", "sys"), onlyPost},
Brad Fitzpatrickb8db43d2019-03-11 04:20:46 +0000396 {b("js-wasm", "net"), onlyPost},
397 {b("js-wasm@go1.12", "net"), none},
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000398 {b("js-wasm", "benchmarks"), none},
399 {b("js-wasm", "debug"), none},
400 {b("js-wasm", "mobile"), none},
401 {b("js-wasm", "perf"), none},
402 {b("js-wasm", "talks"), none},
403 {b("js-wasm", "tools"), none},
404 {b("js-wasm", "tour"), none},
405 {b("js-wasm", "website"), none},
406
407 // Race builders. Linux for all, GCE buidlers for
408 // post-submit, and only post-submit for "go" for
409 // Darwin (limited resources).
410 {b("linux-amd64-race", "go"), both},
411 {b("linux-amd64-race", "net"), both},
412 {b("windows-amd64-race", "go"), onlyPost},
413 {b("windows-amd64-race", "net"), onlyPost},
414 {b("freebsd-amd64-race", "go"), onlyPost},
415 {b("freebsd-amd64-race", "net"), onlyPost},
416 {b("darwin-amd64-race", "go"), onlyPost},
417 {b("darwin-amd64-race", "net"), none},
418
419 // Long test.
420 {b("linux-amd64-longtest", "go"), onlyPost},
421 {b("linux-amd64-longtest", "net"), onlyPost},
422 {b("linux-amd64-longtest@go1.12", "go"), onlyPost},
423 {b("linux-amd64-longtest@go1.12", "net"), none},
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000424
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000425 // Experimental exp repo runs in very few places.
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000426 {b("linux-amd64", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000427 {b("linux-amd64-race", "exp"), both},
428 {b("linux-amd64-longtest", "exp"), onlyPost},
Brad Fitzpatrick83c6b6a2019-03-14 20:35:32 +0000429 {b("windows-386-2008", "exp"), both},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000430 {b("windows-amd64-2016", "exp"), both},
431 {b("darwin-amd64-10_12", "exp"), onlyPost},
432 {b("darwin-amd64-10_14", "exp"), onlyPost},
433 // ... but not on most others:
434 {b("freebsd-386-11_2", "exp"), none},
435 {b("freebsd-386-12_0", "exp"), none},
436 {b("freebsd-amd64-11_2", "exp"), none},
437 {b("freebsd-amd64-12_0", "exp"), none},
438 {b("openbsd-amd64-62", "exp"), none},
439 {b("openbsd-amd64-64", "exp"), none},
440 {b("js-wasm", "exp"), none},
441
442 // exp is experimental; it doesn't test against release branches.
443 {b("linux-amd64@go1.11", "exp"), none},
444 {b("linux-amd64@go1.12", "exp"), none},
Brad Fitzpatrick8a071d42019-03-18 16:48:22 +0000445
446 // Only use latest macOS for subrepos, and only amd64:
447 {b("darwin-amd64-10_12", "net"), onlyPost},
448 {b("darwin-amd64-10_12@go1.11", "net"), onlyPost},
449 {b("darwin-amd64-10_11", "net"), none},
450 {b("darwin-amd64-10_11@go1.11", "net"), none},
451 {b("darwin-amd64-10_11@go1.12", "net"), none},
Brad Fitzpatrickd5a76402019-04-29 16:41:45 +0000452 {b("darwin-386-10_14@go1.11", "net"), none},
Brad Fitzpatrick8bd8e0e2019-03-26 23:04:31 +0000453
454 {b("darwin-amd64-10_14", "go"), onlyPost},
455 {b("darwin-amd64-10_12", "go"), onlyPost},
456 {b("darwin-amd64-10_11", "go"), onlyPost},
457 {b("darwin-amd64-10_10", "go"), none},
458 {b("darwin-amd64-10_10@go1.12", "go"), onlyPost},
459 {b("darwin-amd64-10_10@go1.11", "go"), onlyPost},
Brad Fitzpatrickd5a76402019-04-29 16:41:45 +0000460 {b("darwin-386-10_14", "go"), onlyPost},
461 {b("darwin-386-10_14@go1.12", "go"), onlyPost},
462 {b("darwin-386-10_14@go1.11", "go"), onlyPost},
Brad Fitzpatrick85a73d72019-04-03 04:45:29 +0000463
Brad Fitzpatrick67073b92019-04-18 19:33:19 +0000464 // plan9 only lived at master. We didn't support any past releases.
465 // But it's off for now as it's always failing.
466 {b("plan9-386", "go"), none}, // temporarily disabled
467 {b("plan9-386", "net"), none}, // temporarily disabled
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000468 {b("plan9-386@go1.11", "go"), none},
469 {b("plan9-386@go1.12", "go"), none},
Brad Fitzpatrickf7a5fcf2019-04-03 05:03:37 +0000470 {b("plan9-386@go1.11", "net"), none},
471 {b("plan9-386@go1.12", "net"), none},
472 {b("plan9-amd64-9front", "go"), onlyPost},
473 {b("plan9-amd64-9front@go1.11", "go"), none},
474 {b("plan9-amd64-9front@go1.12", "go"), none},
475 {b("plan9-amd64-9front", "net"), onlyPost},
476 {b("plan9-amd64-9front@go1.11", "net"), none},
477 {b("plan9-amd64-9front@go1.12", "net"), none},
478 {b("plan9-arm", "go"), onlyPost},
479 {b("plan9-arm@go1.11", "go"), none},
480 {b("plan9-arm@go1.12", "go"), none},
481 {b("plan9-arm", "net"), onlyPost},
482 {b("plan9-arm@go1.11", "net"), none},
483 {b("plan9-arm@go1.12", "net"), none},
Brad Fitzpatrickd6a8c272019-04-05 05:26:05 +0000484
485 // x/net master with Go 1.11 doesn't work on our builders
486 // on 32-bit FreeBSD. Remove distracting red from the dashboard
487 // that'll never be fixed.
488 {b("freebsd-386-11_2@go1.11", "net"), none},
489 {b("freebsd-386-12_0@go1.11", "net"), none},
Brad Fitzpatrick756764c2019-03-07 17:44:41 +0000490 }
491 for _, tt := range tests {
492 t.Run(tt.br.testName, func(t *testing.T) {
493 bc, ok := Builders[tt.br.builder]
494 if !ok {
495 t.Fatalf("unknown builder %q", tt.br.builder)
496 }
497 gotPost := bc.BuildsRepoPostSubmit(tt.br.repo, tt.br.branch, tt.br.goBranch)
498 if tt.want&isBuilder != 0 && !gotPost {
499 t.Errorf("not a post-submit builder, but expected")
500 }
501 if tt.want&notBuilder != 0 && gotPost {
502 t.Errorf("unexpectedly a post-submit builder")
503 }
504
505 gotTry := bc.BuildsRepoTryBot(tt.br.repo, tt.br.branch, tt.br.goBranch)
506 if tt.want&isTrybot != 0 && !gotTry {
507 t.Errorf("not trybot, but expected")
508 }
509 if tt.want&notTrybot != 0 && gotTry {
510 t.Errorf("unexpectedly a trybot")
511 }
512
513 if t.Failed() {
514 t.Logf("For: %+v", tt.br)
515 }
516 })
517 }
Brad Fitzpatrickc328d042017-04-12 00:35:37 +0000518}
519
520func TestHostConfigsAllUsed(t *testing.T) {
521 used := map[string]bool{}
522 for _, conf := range Builders {
523 used[conf.HostType] = true
524 }
525 for hostType := range Hosts {
526 if !used[hostType] {
527 // Currently host-linux-armhf-cross and host-linux-armel-cross aren't
528 // referenced, but the coordinator hard-codes them, so don't make
529 // this an error for now.
530 t.Logf("warning: host type %q is not referenced from any build config", hostType)
531 }
532 }
533}
Brad Fitzpatrick86650282019-03-11 18:49:56 +0000534
535// tests that goBranch is optional for repo == "go"
536func TestBuildsRepoAtAllImplicitGoBranch(t *testing.T) {
537 builder := Builders["android-amd64-emu"]
538 got := builder.buildsRepoAtAll("go", "master", "")
539 if !got {
540 t.Error("got = false; want true")
541 }
542}
Brad Fitzpatrick43eb39e2019-04-02 15:27:10 +0000543
544func TestShouldRunDistTest(t *testing.T) {
545 type buildMode int
546 const (
547 tryMode buildMode = 0
548 postSubmit buildMode = 1
549 )
550
551 tests := []struct {
552 builder string
553 test string
554 mode buildMode
555 want bool
556 }{
557 {"linux-amd64", "api", postSubmit, true},
558 {"linux-amd64", "api", tryMode, true},
559
560 {"linux-amd64", "reboot", tryMode, true},
561 {"linux-amd64-race", "reboot", tryMode, false},
562
563 {"darwin-amd64-10_10", "test:foo", postSubmit, false},
564 {"darwin-amd64-10_11", "test:foo", postSubmit, false},
565 {"darwin-amd64-10_12", "test:foo", postSubmit, false},
566 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
567 {"darwin-amd64-10_14", "test:foo", postSubmit, false},
568 {"darwin-amd64-10_14", "reboot", postSubmit, false},
569 {"darwin-amd64-10_14", "api", postSubmit, false},
570 {"darwin-amd64-10_14", "codewalk", postSubmit, false},
571 }
572 for _, tt := range tests {
573 bc, ok := Builders[tt.builder]
574 if !ok {
575 t.Errorf("unknown builder %q", tt.builder)
576 continue
577 }
578 isTry := tt.mode == tryMode
579 if isTry && !bc.BuildsRepoTryBot("go", "master", "master") {
580 t.Errorf("builder %q is not a trybot, so can't run test %q in try mode", tt.builder, tt.test)
581 continue
582 }
583 got := bc.ShouldRunDistTest(tt.test, isTry)
584 if got != tt.want {
585 t.Errorf("%q.ShouldRunDistTest(%q, try %v) = %v; want %v", tt.builder, tt.test, isTry, got, tt.want)
586 }
587 }
588}