From 23afc60f9d53873eed6f06fcb586bfb7bb4726a0 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Thu, 26 Oct 2023 11:58:05 +0200 Subject: dashboard/app: deduplicate syz test string To unblock #4285. --- dashboard/app/email_test.go | 14 +++++++------- dashboard/app/jobs_test.go | 20 +++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/dashboard/app/email_test.go b/dashboard/app/email_test.go index b79bdcb16..d005bd229 100644 --- a/dashboard/app/email_test.go +++ b/dashboard/app/email_test.go @@ -996,7 +996,7 @@ func TestBugFromSubjectInference(t *testing.T) { // First try to ping some non-existing bug. subject := "Re: unknown-bug" c.incomingEmail("bugs@syzkaller.com", - "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + syzTestGitBranchSamplePatch, EmailOptOrigFrom("test@requester.com"), EmailOptFrom(mailingList), EmailOptSubject(subject), ) @@ -1007,7 +1007,7 @@ func TestBugFromSubjectInference(t *testing.T) { // Now try to test the exiting bug, but with the wrong mailing list. subject = "Re: " + crashTitle c.incomingEmail("bugs@syzkaller.com", - "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + syzTestGitBranchSamplePatch, EmailOptOrigFrom("test@requester.com"), EmailOptFrom(""), EmailOptSubject(subject), ) @@ -1016,7 +1016,7 @@ func TestBugFromSubjectInference(t *testing.T) { // Now try to test the exiting bug with the proper mailing list. c.incomingEmail("bugs@syzkaller.com", - "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + syzTestGitBranchSamplePatch, EmailOptFrom(mailingList), EmailOptOrigFrom("test@requester.com"), EmailOptSubject(subject), ) @@ -1026,7 +1026,7 @@ func TestBugFromSubjectInference(t *testing.T) { // Test that a different type of email headers is also parsed fine. c.incomingEmail("bugs@syzkaller.com", - "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + syzTestGitBranchSamplePatch, EmailOptSender(mailingList), EmailOptFrom("test@requester.com"), EmailOptSubject(subject), ) @@ -1038,7 +1038,7 @@ func TestBugFromSubjectInference(t *testing.T) { // Ensure that the inference fails with the proper title. c.incomingEmail("bugs@syzkaller.com", - "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + syzTestGitBranchSamplePatch, EmailOptSender(mailingList), EmailOptFrom("test@requester.com"), EmailOptSubject(subject), ) @@ -1058,7 +1058,7 @@ func TestBugFromSubjectInference(t *testing.T) { // Make sure syzbot can understand the (2) version. subject = "Re: " + crashTitle + " (2)" c.incomingEmail("bugs@syzkaller.com", - "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + syzTestGitBranchSamplePatch, EmailOptFrom(mailingList), EmailOptOrigFrom(""), EmailOptSubject(subject), ) @@ -1138,7 +1138,7 @@ func TestEmailPatchTestingAccess(t *testing.T) { sender := c.pollEmailBug().Sender c.incomingEmail(sender, - "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + syzTestGitBranchSamplePatch, EmailOptFrom("user@kernel.org"), EmailOptSubject("Re: "+crash.Title), ) diff --git a/dashboard/app/jobs_test.go b/dashboard/app/jobs_test.go index d2e81de75..43e393c77 100644 --- a/dashboard/app/jobs_test.go +++ b/dashboard/app/jobs_test.go @@ -22,6 +22,8 @@ const sampleGitPatch = `--- a/mm/kasan/kasan.c + current->kasan_depth--; ` +const syzTestGitBranchSamplePatch = "#syz test: git://git.git/git.git kernel-branch\n" + sampleGitPatch + // nolint: funlen func TestJob(t *testing.T) { c := NewCtx(t) @@ -45,7 +47,7 @@ func TestJob(t *testing.T) { c.incomingEmail(sender, "bla-bla-bla", EmailOptFrom("maintainer@kernel.org"), EmailOptCC([]string{mailingList, "kernel@mailing.list"})) - c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptFrom("test@requester.com"), EmailOptCC([]string{mailingList})) body := c.pollEmailBug().Body t.Logf("body: %s", body) @@ -78,20 +80,20 @@ func TestJob(t *testing.T) { 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"+sampleGitPatch, + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptFrom("\"foo\" ")) c.expectNoEmail() pollResp := client.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"+sampleGitPatch, + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptMessageID(1), EmailOptFrom("test@requester.com"), EmailOptCC([]string{"somebody@else.com", "test@syzkaller.com"})) 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"+sampleGitPatch, + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptMessageID(1), EmailOptFrom("test@requester.com"), EmailOptCC([]string{"somebody@else.com", "test@syzkaller.com"})) c.expectNoEmail() @@ -157,7 +159,7 @@ patch: %[1]v } // Testing fails with an error. - c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, EmailOptMessageID(2)) + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptMessageID(2)) pollResp = client.pollJobs(build.Manager) c.expectEQ(pollResp.Type, dashapi.JobTestPatch) jobDoneReq = &dashapi.JobDoneReq{ @@ -194,7 +196,7 @@ patch: %[1]v } // 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"+sampleGitPatch, EmailOptMessageID(3)) + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptMessageID(3)) pollResp = client.pollJobs(build.Manager) c.expectEQ(pollResp.Type, dashapi.JobTestPatch) jobDoneReq = &dashapi.JobDoneReq{ @@ -236,7 +238,7 @@ patch: %[3]v c.checkURLContents(kernelConfigLink, build.KernelConfig) } - c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, EmailOptMessageID(4)) + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptMessageID(4)) pollResp = client.pollJobs(build.Manager) c.expectEQ(pollResp.Type, dashapi.JobTestPatch) jobDoneReq = &dashapi.JobDoneReq{ @@ -295,7 +297,7 @@ func TestBootErrorPatch(t *testing.T) { sender = c.pollEmailBug().Sender mailingList := c.config().Namespaces["test2"].Reporting[1].Config.(*EmailConfig).Email - c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptFrom("test@requester.com"), EmailOptCC([]string{mailingList})) c.expectNoEmail() pollResp := c.client2.pollJobs(build.Manager) @@ -320,7 +322,7 @@ func TestTestErrorPatch(t *testing.T) { sender = c.pollEmailBug().Sender mailingList := c.config().Namespaces["test2"].Reporting[1].Config.(*EmailConfig).Email - c.incomingEmail(sender, "#syz test: git://git.git/git.git kernel-branch\n"+sampleGitPatch, + c.incomingEmail(sender, syzTestGitBranchSamplePatch, EmailOptFrom("test@requester.com"), EmailOptCC([]string{mailingList})) c.expectNoEmail() pollResp := c.client2.pollJobs(build.Manager) -- cgit mrf-deployment