How to use LoadBug method of dashapi Package

Best Syzkaller code snippet using dashapi.LoadBug

fix_test.go

Source:fix_test.go Github

copy

Full Screen

1// Copyright 2017 syzkaller project authors. All rights reserved.2// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.3package main4import (5 "testing"6 "time"7 "github.com/google/syzkaller/dashboard/dashapi"8)9// Basic scenario of marking a bug as fixed by a particular commit,10// discovering this commit on builder and marking the bug as ultimately fixed.11func TestFixBasic(t *testing.T) {12 c := NewCtx(t)13 defer c.Close()14 build1 := testBuild(1)15 c.client.UploadBuild(build1)16 crash1 := testCrash(build1, 1)17 c.client.ReportCrash(crash1)18 builderPollResp, _ := c.client.BuilderPoll(build1.Manager)19 c.expectEQ(len(builderPollResp.PendingCommits), 0)20 needRepro, _ := c.client.NeedRepro(testCrashID(crash1))21 c.expectEQ(needRepro, true)22 rep := c.client.pollBug()23 // Specify fixing commit for the bug.24 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{25 ID: rep.ID,26 Status: dashapi.BugStatusOpen,27 FixCommits: []string{"foo: fix the crash"},28 })29 c.expectEQ(reply.OK, true)30 // Don't need repro once there are fixing commits.31 needRepro, _ = c.client.NeedRepro(testCrashID(crash1))32 c.expectEQ(needRepro, false)33 // Check that the commit is now passed to builders.34 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)35 c.expectEQ(len(builderPollResp.PendingCommits), 1)36 c.expectEQ(builderPollResp.PendingCommits[0], "foo: fix the crash")37 // Patches must not be reset on other actions.38 c.client.updateBug(rep.ID, dashapi.BugStatusOpen, "")39 // Upstream commands must fail if patches are already present.40 // Right course of action is unclear in this situation,41 // so this test merely documents the current behavior.42 reply, _ = c.client.ReportingUpdate(&dashapi.BugUpdate{43 ID: rep.ID,44 Status: dashapi.BugStatusUpstream,45 })46 c.expectEQ(reply.OK, false)47 c.client.ReportCrash(crash1)48 c.client.pollBugs(0)49 // Upload another build with the commit present.50 build2 := testBuild(2)51 build2.Manager = build1.Manager52 build2.Commits = []string{"foo: fix the crash"}53 c.client.UploadBuild(build2)54 // Check that the commit is now not passed to this builder.55 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)56 c.expectEQ(len(builderPollResp.PendingCommits), 0)57 // Ensure that a new crash creates a new bug (the old one must be marked as fixed).58 c.client.ReportCrash(crash1)59 rep2 := c.client.pollBug()60 c.expectEQ(rep2.Title, "title1 (2)")61 // Regression test: previously upstreamming failed because the new bug had fixing commits.62 c.client.ReportCrash(crash1)63 c.client.updateBug(rep2.ID, dashapi.BugStatusUpstream, "")64 c.client.pollBug()65}66// Test bug that is fixed by 2 commits.67func TestFixedByTwoCommits(t *testing.T) {68 c := NewCtx(t)69 defer c.Close()70 build1 := testBuild(1)71 c.client.UploadBuild(build1)72 crash1 := testCrash(build1, 1)73 c.client.ReportCrash(crash1)74 builderPollResp, _ := c.client.BuilderPoll(build1.Manager)75 c.expectEQ(len(builderPollResp.PendingCommits), 0)76 rep := c.client.pollBug()77 // Specify fixing commit for the bug.78 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{79 ID: rep.ID,80 Status: dashapi.BugStatusOpen,81 FixCommits: []string{"bar: prepare for fixing", "\"foo: fix the crash\""},82 })83 c.expectEQ(reply.OK, true)84 // Check that the commit is now passed to builders.85 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)86 c.expectEQ(len(builderPollResp.PendingCommits), 2)87 c.expectEQ(builderPollResp.PendingCommits[0], "bar: prepare for fixing")88 c.expectEQ(builderPollResp.PendingCommits[1], "foo: fix the crash")89 // Upload another build with only one of the commits.90 build2 := testBuild(2)91 build2.Manager = build1.Manager92 build2.Commits = []string{"bar: prepare for fixing"}93 c.client.UploadBuild(build2)94 // Check that it has not fixed the bug.95 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)96 c.expectEQ(len(builderPollResp.PendingCommits), 2)97 c.expectEQ(builderPollResp.PendingCommits[0], "bar: prepare for fixing")98 c.expectEQ(builderPollResp.PendingCommits[1], "foo: fix the crash")99 c.client.ReportCrash(crash1)100 c.client.pollBugs(0)101 // Now upload build with both commits.102 build3 := testBuild(3)103 build3.Manager = build1.Manager104 build3.Commits = []string{"foo: fix the crash", "bar: prepare for fixing"}105 c.client.UploadBuild(build3)106 // Check that the commit is now not passed to this builder.107 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)108 c.expectEQ(len(builderPollResp.PendingCommits), 0)109 // Ensure that a new crash creates a new bug (the old one must be marked as fixed).110 c.client.ReportCrash(crash1)111 rep2 := c.client.pollBug()112 c.expectEQ(rep2.Title, "title1 (2)")113}114// A bug is marked as fixed by one commit and then remarked as fixed by another.115func TestReFixed(t *testing.T) {116 c := NewCtx(t)117 defer c.Close()118 build1 := testBuild(1)119 c.client.UploadBuild(build1)120 crash1 := testCrash(build1, 1)121 c.client.ReportCrash(crash1)122 builderPollResp, _ := c.client.BuilderPoll(build1.Manager)123 c.expectEQ(len(builderPollResp.PendingCommits), 0)124 c.advanceTime(time.Hour)125 rep := c.client.pollBug()126 bug, _, _ := c.loadBug(rep.ID)127 c.expectEQ(bug.LastActivity, c.mockedTime)128 c.expectEQ(bug.FixTime, time.Time{})129 // Specify fixing commit for the bug.130 c.advanceTime(time.Hour)131 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{132 ID: rep.ID,133 Status: dashapi.BugStatusOpen,134 FixCommits: []string{"a wrong one"},135 })136 c.expectEQ(reply.OK, true)137 bug, _, _ = c.loadBug(rep.ID)138 c.expectEQ(bug.LastActivity, c.mockedTime)139 c.expectEQ(bug.FixTime, c.mockedTime)140 c.advanceTime(time.Hour)141 reply, _ = c.client.ReportingUpdate(&dashapi.BugUpdate{142 ID: rep.ID,143 Status: dashapi.BugStatusOpen,144 FixCommits: []string{"the right one"},145 })146 c.expectEQ(reply.OK, true)147 bug, _, _ = c.loadBug(rep.ID)148 c.expectEQ(bug.LastActivity, c.mockedTime)149 c.expectEQ(bug.FixTime, c.mockedTime)150 // No updates, just check that LastActivity time is updated, FixTime preserved.151 fixTime := c.mockedTime152 c.advanceTime(time.Hour)153 reply, _ = c.client.ReportingUpdate(&dashapi.BugUpdate{154 ID: rep.ID,155 Status: dashapi.BugStatusOpen,156 })157 c.expectEQ(reply.OK, true)158 bug, _, _ = c.loadBug(rep.ID)159 c.expectEQ(bug.LastActivity, c.mockedTime)160 c.expectEQ(bug.FixTime, fixTime)161 // Send the same fixing commit, check that LastActivity time is updated, FixTime preserved.162 c.advanceTime(time.Hour)163 reply, _ = c.client.ReportingUpdate(&dashapi.BugUpdate{164 ID: rep.ID,165 Status: dashapi.BugStatusOpen,166 FixCommits: []string{"the right one"},167 })168 c.expectEQ(reply.OK, true)169 bug, _, _ = c.loadBug(rep.ID)170 c.expectEQ(bug.LastActivity, c.mockedTime)171 c.expectEQ(bug.FixTime, fixTime)172 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)173 c.expectEQ(len(builderPollResp.PendingCommits), 1)174 c.expectEQ(builderPollResp.PendingCommits[0], "the right one")175 // Upload another build with the wrong commit.176 build2 := testBuild(2)177 build2.Manager = build1.Manager178 build2.Commits = []string{"a wrong one"}179 c.client.UploadBuild(build2)180 // Check that it has not fixed the bug.181 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)182 c.expectEQ(len(builderPollResp.PendingCommits), 1)183 c.expectEQ(builderPollResp.PendingCommits[0], "the right one")184 c.client.ReportCrash(crash1)185 c.client.pollBugs(0)186 // Now upload build with the right commit.187 build3 := testBuild(3)188 build3.Manager = build1.Manager189 build3.Commits = []string{"the right one"}190 c.client.UploadBuild(build3)191 // Check that the commit is now not passed to this builder.192 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)193 c.expectEQ(len(builderPollResp.PendingCommits), 0)194}195// Fixing commit is present on one manager, but missing on another.196func TestFixTwoManagers(t *testing.T) {197 c := NewCtx(t)198 defer c.Close()199 build1 := testBuild(1)200 c.client.UploadBuild(build1)201 crash1 := testCrash(build1, 1)202 c.client.ReportCrash(crash1)203 builderPollResp, _ := c.client.BuilderPoll(build1.Manager)204 c.expectEQ(len(builderPollResp.PendingCommits), 0)205 rep := c.client.pollBug()206 // Specify fixing commit for the bug.207 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{208 ID: rep.ID,209 Status: dashapi.BugStatusOpen,210 FixCommits: []string{"foo: fix the crash"},211 })212 c.expectEQ(reply.OK, true)213 // Now the second manager appears.214 build2 := testBuild(2)215 c.client.UploadBuild(build2)216 // Check that the commit is now passed to builders.217 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)218 c.expectEQ(len(builderPollResp.PendingCommits), 1)219 c.expectEQ(builderPollResp.PendingCommits[0], "foo: fix the crash")220 builderPollResp, _ = c.client.BuilderPoll(build2.Manager)221 c.expectEQ(len(builderPollResp.PendingCommits), 1)222 c.expectEQ(builderPollResp.PendingCommits[0], "foo: fix the crash")223 // Now first manager picks up the commit.224 build3 := testBuild(3)225 build3.Manager = build1.Manager226 build3.Commits = []string{"foo: fix the crash"}227 c.client.UploadBuild(build3)228 // Check that the commit is now not passed to this builder.229 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)230 c.expectEQ(len(builderPollResp.PendingCommits), 0)231 // But still passed to another.232 builderPollResp, _ = c.client.BuilderPoll(build2.Manager)233 c.expectEQ(len(builderPollResp.PendingCommits), 1)234 c.expectEQ(builderPollResp.PendingCommits[0], "foo: fix the crash")235 // Check that the bug is still open.236 c.client.ReportCrash(crash1)237 c.client.pollBugs(0)238 // Now the second manager picks up the commit.239 build4 := testBuild(4)240 build4.Manager = build2.Manager241 build4.Commits = []string{"foo: fix the crash"}242 c.client.UploadBuild(build4)243 // Now the bug must be fixed.244 builderPollResp, _ = c.client.BuilderPoll(build2.Manager)245 c.expectEQ(len(builderPollResp.PendingCommits), 0)246 c.client.ReportCrash(crash1)247 rep2 := c.client.pollBug()248 c.expectEQ(rep2.Title, "title1 (2)")249}250func TestReFixedTwoManagers(t *testing.T) {251 c := NewCtx(t)252 defer c.Close()253 build1 := testBuild(1)254 c.client.UploadBuild(build1)255 crash1 := testCrash(build1, 1)256 c.client.ReportCrash(crash1)257 builderPollResp, _ := c.client.BuilderPoll(build1.Manager)258 c.expectEQ(len(builderPollResp.PendingCommits), 0)259 rep := c.client.pollBug()260 // Specify fixing commit for the bug.261 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{262 ID: rep.ID,263 Status: dashapi.BugStatusOpen,264 FixCommits: []string{"foo: fix the crash"},265 })266 c.expectEQ(reply.OK, true)267 // Now the second manager appears.268 build2 := testBuild(2)269 c.client.UploadBuild(build2)270 // Now first manager picks up the commit.271 build3 := testBuild(3)272 build3.Manager = build1.Manager273 build3.Commits = []string{"foo: fix the crash"}274 c.client.UploadBuild(build3)275 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)276 c.expectEQ(len(builderPollResp.PendingCommits), 0)277 // Now we change the fixing commit.278 reply, _ = c.client.ReportingUpdate(&dashapi.BugUpdate{279 ID: rep.ID,280 Status: dashapi.BugStatusOpen,281 FixCommits: []string{"the right one"},282 })283 c.expectEQ(reply.OK, true)284 // Now it must again appear on both managers.285 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)286 c.expectEQ(len(builderPollResp.PendingCommits), 1)287 c.expectEQ(builderPollResp.PendingCommits[0], "the right one")288 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)289 c.expectEQ(len(builderPollResp.PendingCommits), 1)290 c.expectEQ(builderPollResp.PendingCommits[0], "the right one")291 // Now the second manager picks up the second commit.292 build4 := testBuild(4)293 build4.Manager = build2.Manager294 build4.Commits = []string{"the right one"}295 c.client.UploadBuild(build4)296 // The bug must be still open.297 c.client.ReportCrash(crash1)298 c.client.pollBugs(0)299 // Specify fixing commit again, but it's the same one as before, so nothing changed.300 reply, _ = c.client.ReportingUpdate(&dashapi.BugUpdate{301 ID: rep.ID,302 Status: dashapi.BugStatusOpen,303 FixCommits: []string{"the right one"},304 })305 c.expectEQ(reply.OK, true)306 // Now the first manager picks up the second commit.307 build5 := testBuild(5)308 build5.Manager = build1.Manager309 build5.Commits = []string{"the right one"}310 c.client.UploadBuild(build5)311 // Now the bug must be fixed.312 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)313 c.expectEQ(len(builderPollResp.PendingCommits), 0)314 c.client.ReportCrash(crash1)315 rep2 := c.client.pollBug()316 c.expectEQ(rep2.Title, "title1 (2)")317}318// TestFixedWithCommitTags tests fixing of bugs with Reported-by commit tags.319func TestFixedWithCommitTags(t *testing.T) {320 c := NewCtx(t)321 defer c.Close()322 build1 := testBuild(1)323 c.client.UploadBuild(build1)324 build2 := testBuild(2)325 c.client.UploadBuild(build2)326 crash1 := testCrash(build1, 1)327 c.client.ReportCrash(crash1)328 rep := c.client.pollBug()329 // Upload build with 2 fixing commits for this bug.330 build1.FixCommits = []dashapi.Commit{331 {Title: "fix commit 1", BugIDs: []string{rep.ID}},332 {Title: "fix commit 2", BugIDs: []string{rep.ID}},333 }334 c.client.UploadBuild(build1)335 // Now the commits must be associated with the bug and the second336 // manager must get them as pending.337 builderPollResp, _ := c.client.BuilderPoll(build2.Manager)338 c.expectEQ(len(builderPollResp.PendingCommits), 2)339 c.expectEQ(builderPollResp.PendingCommits[0], "fix commit 1")340 c.expectEQ(builderPollResp.PendingCommits[1], "fix commit 2")341 // The first manager must not get them.342 builderPollResp, _ = c.client.BuilderPoll(build1.Manager)343 c.expectEQ(len(builderPollResp.PendingCommits), 0)344 // The bug is still not fixed.345 c.client.ReportCrash(crash1)346 c.client.pollBugs(0)347 // Now the second manager reports the same commits.348 // This must close the bug.349 build2.FixCommits = build1.FixCommits350 c.client.UploadBuild(build2)351 // Commits must not be passed to managers.352 builderPollResp, _ = c.client.BuilderPoll(build2.Manager)353 c.expectEQ(len(builderPollResp.PendingCommits), 0)354 // Ensure that a new crash creates a new bug.355 c.client.ReportCrash(crash1)356 rep2 := c.client.pollBug()357 c.expectEQ(rep2.Title, "title1 (2)")358}359// TestFixedDup tests Reported-by commit tag that comes for a dup.360// In such case we need to associate it with the canonical bugs.361func TestFixedDup(t *testing.T) {362 c := NewCtx(t)363 defer c.Close()364 build := testBuild(1)365 c.client.UploadBuild(build)366 crash1 := testCrash(build, 1)367 c.client.ReportCrash(crash1)368 rep1 := c.client.pollBug()369 crash2 := testCrash(build, 2)370 c.client.ReportCrash(crash2)371 rep2 := c.client.pollBug()372 // rep2 is a dup of rep1.373 c.client.updateBug(rep2.ID, dashapi.BugStatusDup, rep1.ID)374 // Upload build that fixes rep2.375 build.FixCommits = []dashapi.Commit{376 {Title: "fix commit 1", BugIDs: []string{rep2.ID}},377 }378 c.client.UploadBuild(build)379 // This must fix rep1.380 c.client.ReportCrash(crash1)381 rep3 := c.client.pollBug()382 c.expectEQ(rep3.Title, rep1.Title+" (2)")383}384// TestFixedDup2 tests Reported-by commit tag that comes for a dup.385// Ensure that non-canonical bug gets fixing commit too.386func TestFixedDup2(t *testing.T) {387 c := NewCtx(t)388 defer c.Close()389 build1 := testBuild(1)390 c.client.UploadBuild(build1)391 build2 := testBuild(2)392 c.client.UploadBuild(build2)393 crash1 := testCrash(build1, 1)394 c.client.ReportCrash(crash1)395 rep1 := c.client.pollBug()396 crash2 := testCrash(build1, 2)397 c.client.ReportCrash(crash2)398 rep2 := c.client.pollBug()399 // rep2 is a dup of rep1.400 c.client.updateBug(rep2.ID, dashapi.BugStatusDup, rep1.ID)401 // Upload build that fixes rep2.402 build1.FixCommits = []dashapi.Commit{403 {Title: "fix commit 1", BugIDs: []string{rep2.ID}},404 }405 c.client.UploadBuild(build1)406 // Now undup the bugs. They are still unfixed as only 1 manager uploaded the commit.407 c.client.updateBug(rep2.ID, dashapi.BugStatusOpen, "")408 // Now the second manager reports the same commits. This must close both bugs.409 build2.FixCommits = build1.FixCommits410 c.client.UploadBuild(build2)411 c.client.pollBugs(0)412 c.advanceTime(24 * time.Hour)413 c.client.ReportCrash(crash1)414 rep3 := c.client.pollBug()415 c.expectEQ(rep3.Title, rep1.Title+" (2)")416 c.client.ReportCrash(crash2)417 rep4 := c.client.pollBug()418 c.expectEQ(rep4.Title, rep2.Title+" (2)")419}420// TestFixedDup3 tests Reported-by commit tag that comes for both dup and canonical bug.421func TestFixedDup3(t *testing.T) {422 c := NewCtx(t)423 defer c.Close()424 build1 := testBuild(1)425 c.client.UploadBuild(build1)426 build2 := testBuild(2)427 c.client.UploadBuild(build2)428 crash1 := testCrash(build1, 1)429 c.client.ReportCrash(crash1)430 rep1 := c.client.pollBug()431 crash2 := testCrash(build1, 2)432 c.client.ReportCrash(crash2)433 rep2 := c.client.pollBug()434 // rep2 is a dup of rep1.435 c.client.updateBug(rep2.ID, dashapi.BugStatusDup, rep1.ID)436 // Upload builds that fix rep1 and rep2 with different commits.437 // This must fix rep1 eventually and we must not livelock in such scenario.438 build1.FixCommits = []dashapi.Commit{439 {Title: "fix commit 1", BugIDs: []string{rep1.ID}},440 {Title: "fix commit 2", BugIDs: []string{rep2.ID}},441 }442 build2.FixCommits = build1.FixCommits443 c.client.UploadBuild(build1)444 c.client.UploadBuild(build2)445 c.client.UploadBuild(build1)446 c.client.UploadBuild(build2)447 c.client.ReportCrash(crash1)448 rep3 := c.client.pollBug()449 c.expectEQ(rep3.Title, rep1.Title+" (2)")450}...

Full Screen

Full Screen

reporting_test.go

Source:reporting_test.go Github

copy

Full Screen

1// Copyright 2017 syzkaller project authors. All rights reserved.2// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.3// +build aetest4package dash5import (6 "testing"7 "time"8 "github.com/google/syzkaller/dashboard/dashapi"9)10func TestReportBug(t *testing.T) {11 c := NewCtx(t)12 defer c.Close()13 build := testBuild(1)14 c.client.UploadBuild(build)15 crash1 := &dashapi.Crash{16 BuildID: "build1",17 Title: "title1",18 Maintainers: []string{`"Foo Bar" <foo@bar.com>`, `bar@foo.com`},19 Log: []byte("log1"),20 Report: []byte("report1"),21 }22 c.client.ReportCrash(crash1)23 // Must get no reports for "unknown" type.24 resp, _ := c.client.ReportingPollBugs("unknown")25 c.expectEQ(len(resp.Reports), 0)26 // Must get a proper report for "test" type.27 resp, _ = c.client.ReportingPollBugs("test")28 c.expectEQ(len(resp.Reports), 1)29 rep := resp.Reports[0]30 if rep.ID == "" {31 t.Fatalf("empty report ID")32 }33 _, dbCrash, dbBuild := c.loadBug(rep.ID)34 want := &dashapi.BugReport{35 Namespace: "test1",36 Config: []byte(`{"Index":1}`),37 ID: rep.ID,38 First: true,39 Title: "title1",40 Maintainers: []string{"bar@foo.com", "foo@bar.com"},41 CompilerID: "compiler1",42 KernelRepo: "repo1",43 KernelRepoAlias: "repo1/branch1",44 KernelBranch: "branch1",45 KernelCommit: "1111111111111111111111111111111111111111",46 KernelCommitTitle: build.KernelCommitTitle,47 KernelCommitDate: buildCommitDate,48 KernelConfig: []byte("config1"),49 KernelConfigLink: externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig),50 Log: []byte("log1"),51 LogLink: externalLink(c.ctx, textCrashLog, dbCrash.Log),52 Report: []byte("report1"),53 ReportLink: externalLink(c.ctx, textCrashReport, dbCrash.Report),54 CrashID: rep.CrashID,55 NumCrashes: 1,56 HappenedOn: []string{"repo1/branch1"},57 }58 c.expectEQ(rep, want)59 // Since we did not update bug status yet, should get the same report again.60 c.expectEQ(c.client.pollBug(), want)61 // Now add syz repro and check that we get another bug report.62 crash1.ReproOpts = []byte("some opts")63 crash1.ReproSyz = []byte("getpid()")64 want.First = false65 want.ReproSyz = []byte(syzReproPrefix + "#some opts\ngetpid()")66 c.client.ReportCrash(crash1)67 rep1 := c.client.pollBug()68 if want.CrashID == rep1.CrashID {69 t.Fatal("get the same CrashID for new crash")70 }71 _, dbCrash, _ = c.loadBug(rep.ID)72 want.CrashID = rep1.CrashID73 want.NumCrashes = 274 want.ReproSyzLink = externalLink(c.ctx, textReproSyz, dbCrash.ReproSyz)75 want.LogLink = externalLink(c.ctx, textCrashLog, dbCrash.Log)76 want.ReportLink = externalLink(c.ctx, textCrashReport, dbCrash.Report)77 c.expectEQ(rep1, want)78 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{79 ID: rep.ID,80 Status: dashapi.BugStatusOpen,81 ReproLevel: dashapi.ReproLevelSyz,82 })83 c.expectEQ(reply.OK, true)84 // After bug update should not get the report again.85 c.client.pollBugs(0)86 // Now close the bug in the first reporting.87 c.client.updateBug(rep.ID, dashapi.BugStatusUpstream, "")88 // Check that bug updates for the first reporting fail now.89 reply, _ = c.client.ReportingUpdate(&dashapi.BugUpdate{ID: rep.ID, Status: dashapi.BugStatusOpen})90 c.expectEQ(reply.OK, false)91 // Report another crash with syz repro for this bug,92 // ensure that we still report the original crash in the next reporting.93 // That's what we've upstreammed, it's bad to switch crashes without reason.94 crash1.Report = []byte("report2")95 c.client.ReportCrash(crash1)96 // Check that we get the report in the second reporting.97 rep2 := c.client.pollBug()98 if rep2.ID == "" || rep2.ID == rep.ID {99 t.Fatalf("bad report ID: %q", rep2.ID)100 }101 want.ID = rep2.ID102 want.First = true103 want.Config = []byte(`{"Index":2}`)104 want.NumCrashes = 3105 c.expectEQ(rep2, want)106 // Check that that we can't upstream the bug in the final reporting.107 reply, _ = c.client.ReportingUpdate(&dashapi.BugUpdate{108 ID: rep2.ID,109 Status: dashapi.BugStatusUpstream,110 })111 c.expectEQ(reply.OK, false)112}113func TestInvalidBug(t *testing.T) {114 c := NewCtx(t)115 defer c.Close()116 build := testBuild(1)117 c.client.UploadBuild(build)118 crash1 := testCrashWithRepro(build, 1)119 c.client.ReportCrash(crash1)120 rep := c.client.pollBug()121 c.expectEQ(rep.Title, "title1")122 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{123 ID: rep.ID,124 Status: dashapi.BugStatusOpen,125 ReproLevel: dashapi.ReproLevelC,126 })127 c.expectEQ(reply.OK, true)128 {129 closed, _ := c.client.ReportingPollClosed([]string{rep.ID, "foobar"})130 c.expectEQ(len(closed), 0)131 }132 // Mark the bug as invalid.133 c.client.updateBug(rep.ID, dashapi.BugStatusInvalid, "")134 {135 closed, _ := c.client.ReportingPollClosed([]string{rep.ID, "foobar"})136 c.expectEQ(len(closed), 1)137 c.expectEQ(closed[0], rep.ID)138 }139 // Now it should not be reported in either reporting.140 c.client.pollBugs(0)141 // Now a similar crash happens again.142 crash2 := &dashapi.Crash{143 BuildID: "build1",144 Title: "title1",145 Log: []byte("log2"),146 Report: []byte("report2"),147 ReproC: []byte("int main() { return 1; }"),148 }149 c.client.ReportCrash(crash2)150 // Now it should be reported again.151 rep = c.client.pollBug()152 if rep.ID == "" {153 t.Fatalf("empty report ID")154 }155 _, dbCrash, dbBuild := c.loadBug(rep.ID)156 want := &dashapi.BugReport{157 Namespace: "test1",158 Config: []byte(`{"Index":1}`),159 ID: rep.ID,160 First: true,161 Title: "title1 (2)",162 CompilerID: "compiler1",163 KernelRepo: "repo1",164 KernelRepoAlias: "repo1/branch1",165 KernelBranch: "branch1",166 KernelCommit: "1111111111111111111111111111111111111111",167 KernelCommitTitle: build.KernelCommitTitle,168 KernelCommitDate: buildCommitDate,169 KernelConfig: []byte("config1"),170 KernelConfigLink: externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig),171 Log: []byte("log2"),172 LogLink: externalLink(c.ctx, textCrashLog, dbCrash.Log),173 Report: []byte("report2"),174 ReportLink: externalLink(c.ctx, textCrashReport, dbCrash.Report),175 ReproC: []byte("int main() { return 1; }"),176 ReproCLink: externalLink(c.ctx, textReproC, dbCrash.ReproC),177 CrashID: rep.CrashID,178 NumCrashes: 1,179 HappenedOn: []string{"repo1/branch1"},180 }181 c.expectEQ(rep, want)182 c.client.ReportFailedRepro(testCrashID(crash1))183}184func TestReportingQuota(t *testing.T) {185 c := NewCtx(t)186 defer c.Close()187 build := testBuild(1)188 c.client.UploadBuild(build)189 const numReports = 8 // quota is 3 per day190 for i := 0; i < numReports; i++ {191 c.client.ReportCrash(testCrash(build, i))192 }193 for _, reports := range []int{3, 3, 2, 0, 0} {194 c.advanceTime(24 * time.Hour)195 c.client.pollBugs(reports)196 // Out of quota for today, so must get 0 reports.197 c.client.pollBugs(0)198 }199}200// Basic dup scenario: mark one bug as dup of another.201func TestReportingDup(t *testing.T) {202 c := NewCtx(t)203 defer c.Close()204 build := testBuild(1)205 c.client.UploadBuild(build)206 crash1 := testCrash(build, 1)207 c.client.ReportCrash(crash1)208 crash2 := testCrash(build, 2)209 c.client.ReportCrash(crash2)210 reports := c.client.pollBugs(2)211 rep1 := reports[0]212 rep2 := reports[1]213 // Dup.214 c.client.updateBug(rep2.ID, dashapi.BugStatusDup, rep1.ID)215 {216 // Both must be reported as open.217 closed, _ := c.client.ReportingPollClosed([]string{rep1.ID, rep2.ID})218 c.expectEQ(len(closed), 0)219 }220 // Undup.221 c.client.updateBug(rep2.ID, dashapi.BugStatusOpen, "")222 // Dup again.223 c.client.updateBug(rep2.ID, dashapi.BugStatusDup, rep1.ID)224 // Dup crash happens again, new bug must not be created.225 c.client.ReportCrash(crash2)226 c.client.pollBugs(0)227 // Now close the original bug, and check that new bugs for dup are now created.228 c.client.updateBug(rep1.ID, dashapi.BugStatusInvalid, "")229 {230 // Now both must be reported as closed.231 closed, _ := c.client.ReportingPollClosed([]string{rep1.ID, rep2.ID})232 c.expectEQ(len(closed), 2)233 c.expectEQ(closed[0], rep1.ID)234 c.expectEQ(closed[1], rep2.ID)235 }236 c.client.ReportCrash(crash2)237 rep3 := c.client.pollBug()238 c.expectEQ(rep3.Title, crash2.Title+" (2)")239 // Unduping after the canonical bugs was closed must not work240 // (we already created new bug for this report).241 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{242 ID: rep2.ID,243 Status: dashapi.BugStatusOpen,244 })245 c.expectEQ(reply.OK, false)246}247// Dup bug onto a closed bug.248// A new crash report must create a new bug.249func TestReportingDupToClosed(t *testing.T) {250 c := NewCtx(t)251 defer c.Close()252 build := testBuild(1)253 c.client.UploadBuild(build)254 crash1 := testCrash(build, 1)255 c.client.ReportCrash(crash1)256 crash2 := testCrash(build, 2)257 c.client.ReportCrash(crash2)258 reports := c.client.pollBugs(2)259 c.client.updateBug(reports[0].ID, dashapi.BugStatusInvalid, "")260 c.client.updateBug(reports[1].ID, dashapi.BugStatusDup, reports[0].ID)261 c.client.ReportCrash(crash2)262 rep2 := c.client.pollBug()263 c.expectEQ(rep2.Title, crash2.Title+" (2)")264}265// Test that marking dups across reporting levels is not permitted.266func TestReportingDupCrossReporting(t *testing.T) {267 c := NewCtx(t)268 defer c.Close()269 build := testBuild(1)270 c.client.UploadBuild(build)271 crash1 := testCrash(build, 1)272 c.client.ReportCrash(crash1)273 crash2 := testCrash(build, 2)274 c.client.ReportCrash(crash2)275 reports := c.client.pollBugs(2)276 rep1 := reports[0]277 rep2 := reports[1]278 // Upstream second bug.279 c.client.updateBug(rep2.ID, dashapi.BugStatusUpstream, "")280 rep3 := c.client.pollBug()281 {282 closed, _ := c.client.ReportingPollClosed([]string{rep1.ID, rep2.ID, rep3.ID})283 c.expectEQ(len(closed), 1)284 c.expectEQ(closed[0], rep2.ID)285 }286 // Duping must fail all ways.287 cmds := []*dashapi.BugUpdate{288 {ID: rep1.ID, DupOf: rep1.ID},289 {ID: rep1.ID, DupOf: rep2.ID},290 {ID: rep1.ID, DupOf: rep3.ID},291 {ID: rep2.ID, DupOf: rep1.ID},292 {ID: rep2.ID, DupOf: rep2.ID},293 {ID: rep2.ID, DupOf: rep3.ID},294 {ID: rep3.ID, DupOf: rep1.ID},295 {ID: rep3.ID, DupOf: rep2.ID},296 {ID: rep3.ID, DupOf: rep3.ID},297 }298 for _, cmd := range cmds {299 t.Logf("duping %v -> %v", cmd.ID, cmd.DupOf)300 cmd.Status = dashapi.BugStatusDup301 reply, _ := c.client.ReportingUpdate(cmd)302 c.expectEQ(reply.OK, false)303 }304}305func TestReportingFilter(t *testing.T) {306 c := NewCtx(t)307 defer c.Close()308 build := testBuild(1)309 c.client.UploadBuild(build)310 crash1 := testCrash(build, 1)311 crash1.Title = "skip without repro 1"312 c.client.ReportCrash(crash1)313 // This does not skip first reporting, because it does not have repro.314 rep1 := c.client.pollBug()315 c.expectEQ(string(rep1.Config), `{"Index":1}`)316 crash1.ReproSyz = []byte("getpid()")317 c.client.ReportCrash(crash1)318 // This has repro but was already reported to first reporting,319 // so repro must go to the first reporting as well.320 rep2 := c.client.pollBug()321 c.expectEQ(string(rep2.Config), `{"Index":1}`)322 // Now upstream it and it must go to the second reporting.323 c.client.updateBug(rep1.ID, dashapi.BugStatusUpstream, "")324 rep3 := c.client.pollBug()325 c.expectEQ(string(rep3.Config), `{"Index":2}`)326 // Now report a bug that must go to the second reporting right away.327 crash2 := testCrash(build, 2)328 crash2.Title = "skip without repro 2"329 crash2.ReproSyz = []byte("getpid()")330 c.client.ReportCrash(crash2)331 rep4 := c.client.pollBug()332 c.expectEQ(string(rep4.Config), `{"Index":2}`)333}...

Full Screen

Full Screen

LoadBug

Using AI Code Generation

copy

Full Screen

1import (2const (3type BugzillaBug struct {4}5type DashAPI struct {6}7func (d *DashAPI) LoadBug(bugID int) error {8 u, err := url.Parse(BaseQuery)9 if err != nil {10 }11 q := u.Query()12 q.Set("id", strconv.Itoa(bugID))13 u.RawQuery = q.Encode()14 resp, err := http.Get(u.String())15 if err != nil {16 }17 defer resp.Body.Close()18 if err := DecodeJSON(resp.Body, &bugs); err != nil {19 }20 if len(bugs) == 0 {21 return fmt.Errorf("No bug with ID %d found", bugID)22 }23}24func (d *DashAPI) LoadAge() error {

Full Screen

Full Screen

LoadBug

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 d := dashapi.DashAPI{}4 bug := d.LoadBug(123456)5 fmt.Println(bug.Summary)6}7import (8func main() {9 d := dashapi.DashAPI{}10 bug := d.LoadBug(123456)11 fmt.Println(bug.Summary)12}13import (14func main() {15 d := dashapi.DashAPI{}16 bug := d.LoadBug(123456)17 fmt.Println(bug.Summary)18}19import (20func main() {21 d := dashapi.DashAPI{}22 bug := d.LoadBug(123456)23 fmt.Println(bug.Summary)24}25import (26func main() {27 d := dashapi.DashAPI{}28 bug := d.LoadBug(123456)29 fmt.Println(bug.Summary)30}31import (32func main() {

Full Screen

Full Screen

LoadBug

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(bug)4}5import (6func main() {7 fmt.Println(bug)8}9import (10func main() {11 fmt.Println(bug)12}13import (14func main() {15 fmt.Println(bug)16}17import (18func main() {19 fmt.Println(bug)20}21import (22func main() {23 fmt.Println(bug)24}

Full Screen

Full Screen

LoadBug

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "bugzilla.mozilla.org/dashapi"3func main() {4 dash := dashapi.New()5 bug, err := dash.LoadBug(12345)6 if err != nil {7 fmt.Println("Error loading bug: ", err)8 } else {9 fmt.Println("Bug Summary: ", bug.Summary)10 }11}

Full Screen

Full Screen

LoadBug

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/abhishekkr/gol/golapi"3func main() {4 fmt.Println("Hello, world.")5 golapi.LoadBug("2.go")6}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful