forked from google/syzkaller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjobs_test.go
689 lines (583 loc) · 21.9 KB
/
jobs_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package main
import (
"bytes"
"fmt"
"strings"
"testing"
"time"
"github.com/google/syzkaller/dashboard/dashapi"
"github.com/google/syzkaller/pkg/email"
db "google.golang.org/appengine/datastore"
)
// nolint: funlen
func TestJob(t *testing.T) {
c := NewCtx(t)
defer c.Close()
build := testBuild(1)
c.client2.UploadBuild(build)
patch := `--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
- current->kasan_depth++;
+ current->kasan_depth--;
`
// Report crash without repro, check that test requests are not accepted.
crash := testCrash(build, 1)
crash.Maintainers = []string{"[email protected]"}
c.client2.ReportCrash(crash)
sender := c.pollEmailBug().Sender
c.incomingEmail(sender, "#syz upstream\n")
sender = c.pollEmailBug().Sender
_, extBugID, err := email.RemoveAddrContext(sender)
c.expectOK(err)
mailingList := config.Namespaces["test2"].Reporting[1].Config.(*EmailConfig).Email
c.incomingEmail(sender, "bla-bla-bla", EmailOptFrom("[email protected]"),
EmailOptCC([]string{mailingList, "[email protected]"}))
c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+patch,
EmailOptFrom("[email protected]"), EmailOptCC([]string{mailingList}))
body := c.pollEmailBug().Body
c.expectEQ(strings.Contains(body, "This crash does not have a reproducer"), true)
// Report crash with repro.
crash.ReproOpts = []byte("repro opts")
crash.ReproSyz = []byte("repro syz")
crash.ReproC = []byte("repro C")
c.client2.ReportCrash(crash)
c.client2.pollAndFailBisectJob(build.Manager)
body = c.pollEmailBug().Body
c.expectEQ(strings.Contains(body, "syzbot has found a reproducer"), true)
c.incomingEmail(sender, "#syz test: repo",
EmailOptFrom("[email protected]"), EmailOptSubject("my-subject"), EmailOptCC([]string{mailingList}))
msg := c.pollEmailBug()
c.expectEQ(strings.Contains(msg.Body, "want 2 args"), true)
c.expectEQ(msg.Subject, "Re: my-subject")
c.incomingEmail(sender, "#syz test: repo branch commit",
EmailOptFrom("[email protected]"), EmailOptSubject("Re: my-subject"), EmailOptCC([]string{mailingList}))
msg = c.pollEmailBug()
c.expectEQ(strings.Contains(msg.Body, "want 2 args"), true)
c.expectEQ(msg.Subject, "Re: my-subject")
c.incomingEmail(sender, "#syz test: repo branch",
EmailOptFrom("[email protected]"), EmailOptCC([]string{mailingList}))
body = c.pollEmailBug().Body
c.expectEQ(strings.Contains(body, "does not look like a valid git repo"), true)
c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+patch,
EmailOptFrom("\"foo\" <[email protected]>"))
c.expectNoEmail()
pollResp := c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp.ID, "")
// This submits actual test request.
c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+patch,
EmailOptMessageID(1), EmailOptFrom("[email protected]"),
EmailOptCC([]string{"[email protected]"}))
c.expectNoEmail()
// A dup of the same request with the same Message-ID.
c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+patch,
EmailOptMessageID(1), EmailOptFrom("[email protected]"),
EmailOptCC([]string{"[email protected]"}))
c.expectNoEmail()
pollResp = c.client2.pollJobs("foobar")
c.expectEQ(pollResp.ID, "")
pollResp = c.client2.pollJobs(build.Manager)
c.expectNE(pollResp.ID, "")
c.expectEQ(pollResp.Type, dashapi.JobTestPatch)
c.expectEQ(pollResp.Manager, build.Manager)
c.expectEQ(pollResp.KernelRepo, "git://git.git/git.git")
c.expectEQ(pollResp.KernelBranch, "kernel-branch")
c.expectEQ(pollResp.KernelConfig, build.KernelConfig)
c.expectEQ(pollResp.SyzkallerCommit, build.SyzkallerCommit)
c.expectEQ(pollResp.Patch, []byte(patch))
c.expectEQ(pollResp.ReproOpts, []byte("repro opts"))
c.expectEQ(pollResp.ReproSyz, []byte(
"# See https://goo.gl/kgGztJ for information about syzkaller reproducers.\n"+
"#repro opts\n"+
"repro syz"))
c.expectEQ(pollResp.ReproC, []byte("repro C"))
pollResp2 := c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp2, pollResp)
jobDoneReq := &dashapi.JobDoneReq{
ID: pollResp.ID,
Build: *build,
CrashTitle: "test crash title",
CrashLog: []byte("test crash log"),
CrashReport: []byte("test crash report"),
}
c.client2.JobDone(jobDoneReq)
{
dbJob, dbBuild, _ := c.loadJob(pollResp.ID)
patchLink := externalLink(c.ctx, textPatch, dbJob.Patch)
kernelConfigLink := externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig)
logLink := externalLink(c.ctx, textCrashLog, dbJob.CrashLog)
msg := c.pollEmailBug()
to := email.MergeEmailLists([]string{"[email protected]", "[email protected]", mailingList})
c.expectEQ(msg.To, to)
c.expectEQ(msg.Subject, "Re: [syzbot] "+crash.Title)
c.expectEQ(len(msg.Attachments), 0)
c.expectEQ(msg.Body, fmt.Sprintf(`Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
test crash title
test crash report
Tested on:
commit: 11111111 kernel_commit_title1
git tree: repo1 branch1
console output: %[3]v
kernel config: %[2]v
dashboard link: https://testapp.appspot.com/bug?extid=%[4]v
compiler: compiler1
patch: %[1]v
`, patchLink, kernelConfigLink, logLink, extBugID))
c.checkURLContents(patchLink, []byte(patch))
c.checkURLContents(kernelConfigLink, build.KernelConfig)
c.checkURLContents(logLink, jobDoneReq.CrashLog)
}
// Testing fails with an error.
c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+patch, EmailOptMessageID(2))
pollResp = c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp.Type, dashapi.JobTestPatch)
jobDoneReq = &dashapi.JobDoneReq{
ID: pollResp.ID,
Build: *build,
Error: []byte("failed to apply patch"),
}
c.client2.JobDone(jobDoneReq)
{
dbJob, dbBuild, _ := c.loadJob(pollResp.ID)
patchLink := externalLink(c.ctx, textPatch, dbJob.Patch)
kernelConfigLink := externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig)
msg := c.pollEmailBug()
c.expectEQ(len(msg.Attachments), 0)
c.expectEQ(msg.Body, fmt.Sprintf(`Hello,
syzbot tried to test the proposed patch but the build/boot failed:
failed to apply patch
Tested on:
commit: 11111111 kernel_commit_title1
git tree: repo1 branch1
kernel config: %[2]v
dashboard link: https://testapp.appspot.com/bug?extid=%[3]v
compiler: compiler1
patch: %[1]v
`, patchLink, kernelConfigLink, extBugID))
c.checkURLContents(patchLink, []byte(patch))
c.checkURLContents(kernelConfigLink, build.KernelConfig)
}
// Testing fails with a huge error that can't be inlined in email.
c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+patch, EmailOptMessageID(3))
pollResp = c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp.Type, dashapi.JobTestPatch)
jobDoneReq = &dashapi.JobDoneReq{
ID: pollResp.ID,
Build: *build,
Error: bytes.Repeat([]byte{'a', 'b', 'c'}, (maxInlineError+100)/3),
}
c.client2.JobDone(jobDoneReq)
{
dbJob, dbBuild, _ := c.loadJob(pollResp.ID)
patchLink := externalLink(c.ctx, textPatch, dbJob.Patch)
errorLink := externalLink(c.ctx, textError, dbJob.Error)
kernelConfigLink := externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig)
msg := c.pollEmailBug()
c.expectEQ(len(msg.Attachments), 0)
truncatedError := string(jobDoneReq.Error[len(jobDoneReq.Error)-maxInlineError:])
c.expectEQ(msg.Body, fmt.Sprintf(`Hello,
syzbot tried to test the proposed patch but the build/boot failed:
%[1]v
Error text is too large and was truncated, full error text is at:
%[2]v
Tested on:
commit: 11111111 kernel_commit_title1
git tree: repo1 branch1
kernel config: %[4]v
dashboard link: https://testapp.appspot.com/bug?extid=%[5]v
compiler: compiler1
patch: %[3]v
`, truncatedError, errorLink, patchLink, kernelConfigLink, extBugID))
c.checkURLContents(patchLink, []byte(patch))
c.checkURLContents(errorLink, jobDoneReq.Error)
c.checkURLContents(kernelConfigLink, build.KernelConfig)
}
c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+patch, EmailOptMessageID(4))
pollResp = c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp.Type, dashapi.JobTestPatch)
jobDoneReq = &dashapi.JobDoneReq{
ID: pollResp.ID,
Build: *build,
}
c.client2.JobDone(jobDoneReq)
{
dbJob, dbBuild, _ := c.loadJob(pollResp.ID)
patchLink := externalLink(c.ctx, textPatch, dbJob.Patch)
kernelConfigLink := externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig)
msg := c.pollEmailBug()
c.expectEQ(len(msg.Attachments), 0)
c.expectEQ(msg.Body, fmt.Sprintf(`Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-and-tested-by: syzbot+%[email protected]
Tested on:
commit: 11111111 kernel_commit_title1
git tree: repo1 branch1
kernel config: %[3]v
dashboard link: https://testapp.appspot.com/bug?extid=%[1]v
compiler: compiler1
patch: %[2]v
Note: testing is done by a robot and is best-effort only.
`, extBugID, patchLink, kernelConfigLink))
c.checkURLContents(patchLink, []byte(patch))
c.checkURLContents(kernelConfigLink, build.KernelConfig)
}
pollResp = c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp.ID, "")
}
// Test on particular commit and without a patch.
func TestJobWithoutPatch(t *testing.T) {
c := NewCtx(t)
defer c.Close()
build := testBuild(1)
c.client2.UploadBuild(build)
crash := testCrash(build, 1)
crash.ReproOpts = []byte("repro opts")
crash.ReproSyz = []byte("repro syz")
c.client2.ReportCrash(crash)
c.client2.pollAndFailBisectJob(build.Manager)
sender := c.pollEmailBug().Sender
_, extBugID, err := email.RemoveAddrContext(sender)
c.expectOK(err)
// Patch testing should happen for bugs with fix commits too.
c.incomingEmail(sender, "#syz fix: some commit title\n")
c.incomingEmail(sender, "#syz test git://mygit.com/git.git 5e6a2eea\n", EmailOptMessageID(1))
c.expectNoEmail()
pollResp := c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp.Type, dashapi.JobTestPatch)
testBuild := testBuild(2)
testBuild.KernelRepo = "git://mygit.com/git.git"
testBuild.KernelBranch = ""
testBuild.KernelCommit = "5e6a2eea5e6a2eea5e6a2eea5e6a2eea5e6a2eea"
jobDoneReq := &dashapi.JobDoneReq{
ID: pollResp.ID,
Build: *testBuild,
}
c.client2.JobDone(jobDoneReq)
{
_, dbBuild, _ := c.loadJob(pollResp.ID)
kernelConfigLink := externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig)
msg := c.pollEmailBug()
c.expectEQ(len(msg.Attachments), 0)
c.expectEQ(msg.Body, fmt.Sprintf(`Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-and-tested-by: syzbot+%[email protected]
Tested on:
commit: 5e6a2eea kernel_commit_title2
git tree: git://mygit.com/git.git
kernel config: %[2]v
dashboard link: https://testapp.appspot.com/bug?extid=%[1]v
compiler: compiler2
Note: testing is done by a robot and is best-effort only.
`, extBugID, kernelConfigLink))
c.checkURLContents(kernelConfigLink, testBuild.KernelConfig)
}
pollResp = c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp.ID, "")
}
// Test on a restricted manager.
func TestJobRestrictedManager(t *testing.T) {
c := NewCtx(t)
defer c.Close()
build := testBuild(1)
build.Manager = restrictedManager
c.client2.UploadBuild(build)
crash := testCrash(build, 1)
crash.ReproSyz = []byte("repro syz")
c.client2.ReportCrash(crash)
c.client2.pollAndFailBisectJob(build.Manager)
sender := c.pollEmailBug().Sender
// Testing on a wrong repo must fail and no test jobs passed to manager.
c.incomingEmail(sender, "#syz test: git://mygit.com/git.git master\n", EmailOptMessageID(1))
c.expectEQ(strings.Contains((<-c.emailSink).Body, "you should test only on restricted.git"), true)
pollResp := c.client2.pollJobs(build.Manager)
c.expectEQ(pollResp.ID, "")
// Testing on the right repo must succeed.
c.incomingEmail(sender, "#syz test: git://restricted.git/restricted.git master\n", EmailOptMessageID(2))
pollResp = c.client2.pollJobs(build.Manager)
c.expectNE(pollResp.ID, "")
c.expectEQ(pollResp.Type, dashapi.JobTestPatch)
c.expectEQ(pollResp.Manager, build.Manager)
c.expectEQ(pollResp.KernelRepo, "git://restricted.git/restricted.git")
}
// Test that JobBisectFix is returned only after 30 days.
func TestBisectFixJob(t *testing.T) {
c := NewCtx(t)
defer c.Close()
// Upload a crash report.
build := testBuild(1)
c.client2.UploadBuild(build)
crash := testCrashWithRepro(build, 1)
c.client2.ReportCrash(crash)
c.client2.pollEmailBug()
// Receive the JobBisectCause.
resp := c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectCause)
done := &dashapi.JobDoneReq{
ID: resp.ID,
Error: []byte("testBisectFixJob:JobBisectCause"),
}
c.client2.expectOK(c.client2.JobDone(done))
// Ensure no more jobs.
resp = c.client2.pollJobs(build.Manager)
c.client2.expectEQ(resp.ID, "")
// Advance time by 30 days and read out any notification emails.
{
c.advanceTime(30 * 24 * time.Hour)
msg := c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "title1")
c.expectTrue(strings.Contains(msg.Body, "Sending this report upstream."))
msg = c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "[syzbot] title1")
c.expectTrue(strings.Contains(msg.Body, "syzbot found the following issue"))
}
// Ensure that we get a JobBisectFix.
resp = c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectFix)
done = &dashapi.JobDoneReq{
ID: resp.ID,
Error: []byte("testBisectFixJob:JobBisectFix"),
}
c.client2.expectOK(c.client2.JobDone(done))
}
// Test that JobBisectFix jobs are re-tried if crash occurs on ToT.
func TestBisectFixRetry(t *testing.T) {
c := NewCtx(t)
defer c.Close()
// Upload a crash report.
build := testBuild(1)
c.client2.UploadBuild(build)
crash := testCrashWithRepro(build, 1)
c.client2.ReportCrash(crash)
c.client2.pollEmailBug()
// Receive the JobBisectCause.
resp := c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectCause)
done := &dashapi.JobDoneReq{
ID: resp.ID,
Error: []byte("testBisectFixRetry:JobBisectCause"),
}
c.client2.expectOK(c.client2.JobDone(done))
// Advance time by 30 days and read out any notification emails.
{
c.advanceTime(30 * 24 * time.Hour)
msg := c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "title1")
c.expectTrue(strings.Contains(msg.Body, "Sending this report upstream."))
msg = c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "[syzbot] title1")
c.expectTrue(strings.Contains(msg.Body, "syzbot found the following issue"))
}
// Ensure that we get a JobBisectFix. We send back a crashlog, no error, no commits.
resp = c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectFix)
done = &dashapi.JobDoneReq{
Build: dashapi.Build{
ID: "build1",
},
ID: resp.ID,
CrashLog: []byte("this is a crashlog"),
CrashReport: []byte("this is a crashreport"),
}
c.client2.expectOK(c.client2.JobDone(done))
// Advance time by 30 days. No notification emails.
{
c.advanceTime(30 * 24 * time.Hour)
}
// Ensure that we get a JobBisectFix retry.
resp = c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectFix)
done = &dashapi.JobDoneReq{
ID: resp.ID,
Error: []byte("testBisectFixRetry:JobBisectFix"),
}
c.client2.expectOK(c.client2.JobDone(done))
}
// Test that bisection results are not reported for bugs that are already marked as fixed.
func TestNotReportingAlreadyFixed(t *testing.T) {
c := NewCtx(t)
defer c.Close()
// Upload a crash report.
build := testBuild(1)
c.client2.UploadBuild(build)
crash := testCrashWithRepro(build, 1)
c.client2.ReportCrash(crash)
c.client2.pollEmailBug()
// Receive the JobBisectCause.
resp := c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectCause)
done := &dashapi.JobDoneReq{
ID: resp.ID,
Error: []byte("testBisectFixRetry:JobBisectCause"),
}
c.client2.expectOK(c.client2.JobDone(done))
sender := ""
// Advance time by 30 days and read out any notification emails.
{
c.advanceTime(30 * 24 * time.Hour)
msg := c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "title1")
c.expectTrue(strings.Contains(msg.Body, "Sending this report upstream."))
msg = c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "[syzbot] title1")
c.expectTrue(strings.Contains(msg.Body, "syzbot found the following issue"))
sender = msg.Sender
}
// Poll for a BisectFix job.
resp = c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectFix)
// Meanwhile, the bug is marked as fixed separately.
c.incomingEmail(sender, "#syz fix: kernel: add a fix", EmailOptCC(nil))
{
// Email notification of "Your 'fix:' command is accepted, but please keep
// [email protected] mailing list in CC next time."
c.client2.pollEmailBug()
}
// At this point, send back the results for the BisectFix job also.
done = &dashapi.JobDoneReq{
ID: resp.ID,
Build: *build,
Log: []byte("bisectfix log 4"),
CrashTitle: "bisectfix crash title 4",
CrashLog: []byte("bisectfix crash log 4"),
CrashReport: []byte("bisectfix crash report 4"),
Commits: []dashapi.Commit{
{
Hash: "46e65cb4a0448942ec316b24d60446bbd5cc7827",
Title: "kernel: add a fix",
Author: "[email protected]",
AuthorName: "Author Kernelov",
CC: []string{
"[email protected]", "\"Reviewer2\" <[email protected]>",
// These must be filtered out:
"\"syzbot\" <[email protected]>",
},
Date: time.Date(2000, 2, 9, 4, 5, 6, 7, time.UTC),
},
},
}
c.expectOK(c.client2.JobDone(done))
// No reporting should come in at this point. If there is reporting, c.Close()
// will fail.
}
// Test that fix bisections are listed on the bug page if the bug.BisectFix
// is not BisectYes.
func TestFixBisectionsListed(t *testing.T) {
c := NewCtx(t)
defer c.Close()
// Upload a crash report.
build := testBuild(1)
c.client2.UploadBuild(build)
crash := testCrashWithRepro(build, 1)
c.client2.ReportCrash(crash)
c.client2.pollEmailBug()
// Receive the JobBisectCause.
resp := c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectCause)
done := &dashapi.JobDoneReq{
ID: resp.ID,
Error: []byte("testBisectFixRetry:JobBisectCause"),
}
c.client2.expectOK(c.client2.JobDone(done))
// At this point, no fix bisections should be listed out.
var bugs []*Bug
keys, err := db.NewQuery("Bug").GetAll(c.ctx, &bugs)
c.expectEQ(err, nil)
c.expectEQ(len(bugs), 1)
url := fmt.Sprintf("/bug?id=%v", keys[0].StringID())
content, err := c.GET(url)
c.expectEQ(err, nil)
c.expectTrue(!bytes.Contains(content, []byte("All fix bisections")))
// Advance time by 30 days and read out any notification emails.
{
c.advanceTime(30 * 24 * time.Hour)
msg := c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "title1")
c.expectTrue(strings.Contains(msg.Body, "Sending this report upstream."))
msg = c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "[syzbot] title1")
c.expectTrue(strings.Contains(msg.Body, "syzbot found the following issue"))
}
// Ensure that we get a JobBisectFix. We send back a crashlog, no error,
// no commits.
resp = c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectFix)
done = &dashapi.JobDoneReq{
Build: dashapi.Build{
ID: "build1",
},
ID: resp.ID,
CrashTitle: "this is a crashtitle",
CrashLog: []byte("this is a crashlog"),
CrashReport: []byte("this is a crashreport"),
Log: []byte("this is a log"),
}
c.client2.expectOK(c.client2.JobDone(done))
// Check the bug page and ensure that a bisection is listed out.
content, err = c.GET(url)
c.expectEQ(err, nil)
c.expectTrue(bytes.Contains(content, []byte("Fix bisection attempts")))
// Advance time by 30 days. No notification emails.
{
c.advanceTime(30 * 24 * time.Hour)
}
// Ensure that we get a JobBisectFix retry.
resp = c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectFix)
done = &dashapi.JobDoneReq{
ID: resp.ID,
Error: []byte("testBisectFixRetry:JobBisectFix"),
}
c.client2.expectOK(c.client2.JobDone(done))
// Check the bug page and ensure that no bisections are listed out.
content, err = c.GET(url)
c.expectEQ(err, nil)
c.expectTrue(!bytes.Contains(content, []byte("All fix bisections")))
}
// Test that fix bisections do not occur if Repo has NoFixBisections set.
func TestFixBisectionsDisabled(t *testing.T) {
c := NewCtx(t)
defer c.Close()
// Upload a crash report.
build := testBuild(1)
build.Manager = noFixBisectionManager
c.client2.UploadBuild(build)
crash := testCrashWithRepro(build, 20)
c.client2.ReportCrash(crash)
c.client2.pollEmailBug()
// Receive the JobBisectCause.
resp := c.client2.pollJobs(build.Manager)
c.client2.expectNE(resp.ID, "")
c.client2.expectEQ(resp.Type, dashapi.JobBisectCause)
done := &dashapi.JobDoneReq{
ID: resp.ID,
Error: []byte("testBisectFixRetry:JobBisectCause"),
}
c.client2.expectOK(c.client2.JobDone(done))
// Advance time by 30 days and read out any notification emails.
{
c.advanceTime(30 * 24 * time.Hour)
msg := c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "title20")
c.expectTrue(strings.Contains(msg.Body, "Sending this report upstream."))
msg = c.client2.pollEmailBug()
c.expectEQ(msg.Subject, "[syzbot] title20")
c.expectTrue(strings.Contains(msg.Body, "syzbot found the following issue"))
}
// Ensure that we do not get a JobBisectFix.
resp = c.client2.pollJobs(build.Manager)
c.client2.expectEQ(resp.ID, "")
}