How to use Len method of dashapi Package

Best Syzkaller code snippet using dashapi.Len

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.3// +build aetest4package dash5import (6 "testing"7 "github.com/google/syzkaller/dashboard/dashapi"8)9func reportAllBugs(c *Ctx, expect int) []*dashapi.BugReport {10 pr := &dashapi.PollRequest{11 Type: "test",12 }13 resp := new(dashapi.PollResponse)14 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))15 if len(resp.Reports) != expect {16 c.t.Fatalf("\n%v: want %v reports, got %v", caller(0), expect, len(resp.Reports))17 }18 for _, rep := range resp.Reports {19 reproLevel := dashapi.ReproLevelNone20 if len(rep.ReproC) != 0 {21 reproLevel = dashapi.ReproLevelC22 } else if len(rep.ReproSyz) != 0 {23 reproLevel = dashapi.ReproLevelSyz24 }25 cmd := &dashapi.BugUpdate{26 ID: rep.ID,27 Status: dashapi.BugStatusOpen,28 ReproLevel: reproLevel,29 }30 reply := new(dashapi.BugUpdateReply)31 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))32 c.expectEQ(reply.Error, false)33 c.expectEQ(reply.OK, true)34 }35 return resp.Reports36}37// Basic scenario of marking a bug as fixed by a particular commit,38// discovering this commit on builder and marking the bug as ultimately fixed.39func TestFixBasic(t *testing.T) {40 c := NewCtx(t)41 defer c.Close()42 build1 := testBuild(1)43 c.expectOK(c.API(client1, key1, "upload_build", build1, nil))44 crash1 := testCrash(build1, 1)45 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))46 builderPollReq := &dashapi.BuilderPollReq{build1.Manager}47 builderPollResp := new(dashapi.BuilderPollResp)48 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))49 c.expectEQ(len(builderPollResp.PendingCommits), 0)50 cid := testCrashID(crash1)51 needReproResp := new(dashapi.NeedReproResp)52 c.expectOK(c.API(client1, key1, "need_repro", cid, needReproResp))53 c.expectEQ(needReproResp.NeedRepro, true)54 reports := reportAllBugs(c, 1)55 rep := reports[0]56 // Specify fixing commit for the bug.57 cmd := &dashapi.BugUpdate{58 ID: rep.ID,59 Status: dashapi.BugStatusOpen,60 FixCommits: []string{"foo: fix the crash"},61 }62 reply := new(dashapi.BugUpdateReply)63 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))64 c.expectEQ(reply.OK, true)65 // Don't need repro once there are fixing commits.66 c.expectOK(c.API(client1, key1, "need_repro", cid, needReproResp))67 c.expectEQ(needReproResp.NeedRepro, false)68 // Check that the commit is now passed to builders.69 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))70 c.expectEQ(len(builderPollResp.PendingCommits), 1)71 c.expectEQ(builderPollResp.PendingCommits[0], "foo: fix the crash")72 // Patches must not be reset on other actions.73 cmd = &dashapi.BugUpdate{74 ID: rep.ID,75 Status: dashapi.BugStatusOpen,76 }77 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))78 c.expectEQ(reply.OK, true)79 // Upstream commands must fail if patches are already present.80 // Right course of action is unclear in this situation,81 // so this test merely documents the current behavior.82 cmd = &dashapi.BugUpdate{83 ID: rep.ID,84 Status: dashapi.BugStatusUpstream,85 }86 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))87 c.expectEQ(reply.OK, false)88 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))89 reportAllBugs(c, 0)90 // Upload another build with the commit present.91 build2 := testBuild(2)92 build2.Manager = build1.Manager93 build2.Commits = []string{"foo: fix the crash"}94 c.expectOK(c.API(client1, key1, "upload_build", build2, nil))95 // Check that the commit is now not passed to this builder.96 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))97 c.expectEQ(len(builderPollResp.PendingCommits), 0)98 // Ensure that a new crash creates a new bug (the old one must be marked as fixed).99 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))100 reports = reportAllBugs(c, 1)101 c.expectEQ(reports[0].Title, "title1 (2)")102 // Regression test: previously upstreamming failed because the new bug had fixing commits.103 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))104 cmd = &dashapi.BugUpdate{105 ID: reports[0].ID,106 Status: dashapi.BugStatusUpstream,107 }108 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))109 c.expectEQ(reply.OK, true)110}111// Test bug that is fixed by 2 commits.112func TestFixedByTwoCommits(t *testing.T) {113 c := NewCtx(t)114 defer c.Close()115 build1 := testBuild(1)116 c.expectOK(c.API(client1, key1, "upload_build", build1, nil))117 crash1 := testCrash(build1, 1)118 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))119 builderPollReq := &dashapi.BuilderPollReq{build1.Manager}120 builderPollResp := new(dashapi.BuilderPollResp)121 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))122 c.expectEQ(len(builderPollResp.PendingCommits), 0)123 reports := reportAllBugs(c, 1)124 rep := reports[0]125 // Specify fixing commit for the bug.126 cmd := &dashapi.BugUpdate{127 ID: rep.ID,128 Status: dashapi.BugStatusOpen,129 FixCommits: []string{"bar: prepare for fixing", "\"foo: fix the crash\""},130 }131 reply := new(dashapi.BugUpdateReply)132 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))133 c.expectEQ(reply.OK, true)134 // Check that the commit is now passed to builders.135 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))136 c.expectEQ(len(builderPollResp.PendingCommits), 2)137 c.expectEQ(builderPollResp.PendingCommits[0], "bar: prepare for fixing")138 c.expectEQ(builderPollResp.PendingCommits[1], "foo: fix the crash")139 // Upload another build with only one of the commits.140 build2 := testBuild(2)141 build2.Manager = build1.Manager142 build2.Commits = []string{"bar: prepare for fixing"}143 c.expectOK(c.API(client1, key1, "upload_build", build2, nil))144 // Check that it has not fixed the bug.145 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))146 c.expectEQ(len(builderPollResp.PendingCommits), 2)147 c.expectEQ(builderPollResp.PendingCommits[0], "bar: prepare for fixing")148 c.expectEQ(builderPollResp.PendingCommits[1], "foo: fix the crash")149 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))150 reportAllBugs(c, 0)151 // Now upload build with both commits.152 build3 := testBuild(3)153 build3.Manager = build1.Manager154 build3.Commits = []string{"foo: fix the crash", "bar: prepare for fixing"}155 c.expectOK(c.API(client1, key1, "upload_build", build3, nil))156 // Check that the commit is now not passed to this builder.157 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))158 c.expectEQ(len(builderPollResp.PendingCommits), 0)159 // Ensure that a new crash creates a new bug (the old one must be marked as fixed).160 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))161 reports = reportAllBugs(c, 1)162 c.expectEQ(reports[0].Title, "title1 (2)")163}164// A bug is marked as fixed by one commit and then remarked as fixed by another.165func TestReFixed(t *testing.T) {166 c := NewCtx(t)167 defer c.Close()168 build1 := testBuild(1)169 c.expectOK(c.API(client1, key1, "upload_build", build1, nil))170 crash1 := testCrash(build1, 1)171 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))172 builderPollReq := &dashapi.BuilderPollReq{build1.Manager}173 builderPollResp := new(dashapi.BuilderPollResp)174 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))175 c.expectEQ(len(builderPollResp.PendingCommits), 0)176 reports := reportAllBugs(c, 1)177 rep := reports[0]178 // Specify fixing commit for the bug.179 cmd := &dashapi.BugUpdate{180 ID: rep.ID,181 Status: dashapi.BugStatusOpen,182 FixCommits: []string{"a wrong one"},183 }184 reply := new(dashapi.BugUpdateReply)185 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))186 c.expectEQ(reply.OK, true)187 cmd = &dashapi.BugUpdate{188 ID: rep.ID,189 Status: dashapi.BugStatusOpen,190 FixCommits: []string{"the right one"},191 }192 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))193 c.expectEQ(reply.OK, true)194 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))195 c.expectEQ(len(builderPollResp.PendingCommits), 1)196 c.expectEQ(builderPollResp.PendingCommits[0], "the right one")197 // Upload another build with the wrong commit.198 build2 := testBuild(2)199 build2.Manager = build1.Manager200 build2.Commits = []string{"a wrong one"}201 c.expectOK(c.API(client1, key1, "upload_build", build2, nil))202 // Check that it has not fixed the bug.203 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))204 c.expectEQ(len(builderPollResp.PendingCommits), 1)205 c.expectEQ(builderPollResp.PendingCommits[0], "the right one")206 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))207 reportAllBugs(c, 0)208 // Now upload build with the right commit.209 build3 := testBuild(3)210 build3.Manager = build1.Manager211 build3.Commits = []string{"the right one"}212 c.expectOK(c.API(client1, key1, "upload_build", build3, nil))213 // Check that the commit is now not passed to this builder.214 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))215 c.expectEQ(len(builderPollResp.PendingCommits), 0)216}217// Fixing commit is present on one manager, but missing on another.218func TestFixTwoManagers(t *testing.T) {219 c := NewCtx(t)220 defer c.Close()221 build1 := testBuild(1)222 c.expectOK(c.API(client1, key1, "upload_build", build1, nil))223 crash1 := testCrash(build1, 1)224 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))225 builderPollReq := &dashapi.BuilderPollReq{build1.Manager}226 builderPollResp := new(dashapi.BuilderPollResp)227 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))228 c.expectEQ(len(builderPollResp.PendingCommits), 0)229 reports := reportAllBugs(c, 1)230 rep := reports[0]231 // Specify fixing commit for the bug.232 cmd := &dashapi.BugUpdate{233 ID: rep.ID,234 Status: dashapi.BugStatusOpen,235 FixCommits: []string{"foo: fix the crash"},236 }237 reply := new(dashapi.BugUpdateReply)238 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))239 c.expectEQ(reply.OK, true)240 // Now the second manager appears.241 build2 := testBuild(2)242 c.expectOK(c.API(client1, key1, "upload_build", build2, nil))243 // Check that the commit is now passed to builders.244 builderPollReq = &dashapi.BuilderPollReq{build1.Manager}245 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))246 c.expectEQ(len(builderPollResp.PendingCommits), 1)247 c.expectEQ(builderPollResp.PendingCommits[0], "foo: fix the crash")248 builderPollReq = &dashapi.BuilderPollReq{build2.Manager}249 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))250 c.expectEQ(len(builderPollResp.PendingCommits), 1)251 c.expectEQ(builderPollResp.PendingCommits[0], "foo: fix the crash")252 // Now first manager picks up the commit.253 build3 := testBuild(3)254 build3.Manager = build1.Manager255 build3.Commits = []string{"foo: fix the crash"}256 c.expectOK(c.API(client1, key1, "upload_build", build3, nil))257 // Check that the commit is now not passed to this builder.258 builderPollReq = &dashapi.BuilderPollReq{build1.Manager}259 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))260 c.expectEQ(len(builderPollResp.PendingCommits), 0)261 // But still passed to another.262 builderPollReq = &dashapi.BuilderPollReq{build2.Manager}263 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))264 c.expectEQ(len(builderPollResp.PendingCommits), 1)265 c.expectEQ(builderPollResp.PendingCommits[0], "foo: fix the crash")266 // Check that the bug is still open.267 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))268 reportAllBugs(c, 0)269 // Now the second manager picks up the commit.270 build4 := testBuild(4)271 build4.Manager = build2.Manager272 build4.Commits = []string{"foo: fix the crash"}273 c.expectOK(c.API(client1, key1, "upload_build", build4, nil))274 // Now the bug must be fixed.275 builderPollReq = &dashapi.BuilderPollReq{build2.Manager}276 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))277 c.expectEQ(len(builderPollResp.PendingCommits), 0)278 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))279 reports = reportAllBugs(c, 1)280 c.expectEQ(reports[0].Title, "title1 (2)")281}282func TestReFixedTwoManagers(t *testing.T) {283 c := NewCtx(t)284 defer c.Close()285 build1 := testBuild(1)286 c.expectOK(c.API(client1, key1, "upload_build", build1, nil))287 crash1 := testCrash(build1, 1)288 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))289 builderPollReq := &dashapi.BuilderPollReq{build1.Manager}290 builderPollResp := new(dashapi.BuilderPollResp)291 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))292 c.expectEQ(len(builderPollResp.PendingCommits), 0)293 reports := reportAllBugs(c, 1)294 rep := reports[0]295 // Specify fixing commit for the bug.296 cmd := &dashapi.BugUpdate{297 ID: rep.ID,298 Status: dashapi.BugStatusOpen,299 FixCommits: []string{"foo: fix the crash"},300 }301 reply := new(dashapi.BugUpdateReply)302 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))303 c.expectEQ(reply.OK, true)304 // Now the second manager appears.305 build2 := testBuild(2)306 c.expectOK(c.API(client1, key1, "upload_build", build2, nil))307 // Now first manager picks up the commit.308 build3 := testBuild(3)309 build3.Manager = build1.Manager310 build3.Commits = []string{"foo: fix the crash"}311 c.expectOK(c.API(client1, key1, "upload_build", build3, nil))312 builderPollReq = &dashapi.BuilderPollReq{build1.Manager}313 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))314 c.expectEQ(len(builderPollResp.PendingCommits), 0)315 // Now we change the fixing commit.316 cmd = &dashapi.BugUpdate{317 ID: rep.ID,318 Status: dashapi.BugStatusOpen,319 FixCommits: []string{"the right one"},320 }321 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))322 c.expectEQ(reply.OK, true)323 // Now it must again appear on both managers.324 builderPollReq = &dashapi.BuilderPollReq{build1.Manager}325 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))326 c.expectEQ(len(builderPollResp.PendingCommits), 1)327 c.expectEQ(builderPollResp.PendingCommits[0], "the right one")328 builderPollReq = &dashapi.BuilderPollReq{build2.Manager}329 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))330 c.expectEQ(len(builderPollResp.PendingCommits), 1)331 c.expectEQ(builderPollResp.PendingCommits[0], "the right one")332 // Now the second manager picks up the second commit.333 build4 := testBuild(4)334 build4.Manager = build2.Manager335 build4.Commits = []string{"the right one"}336 c.expectOK(c.API(client1, key1, "upload_build", build4, nil))337 // The bug must be still open.338 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))339 reportAllBugs(c, 0)340 // Specify fixing commit again, but it's the same one as before, so nothing changed.341 cmd = &dashapi.BugUpdate{342 ID: rep.ID,343 Status: dashapi.BugStatusOpen,344 FixCommits: []string{"the right one"},345 }346 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))347 c.expectEQ(reply.OK, true)348 // Now the first manager picks up the second commit.349 build5 := testBuild(5)350 build5.Manager = build1.Manager351 build5.Commits = []string{"the right one"}352 c.expectOK(c.API(client1, key1, "upload_build", build5, nil))353 // Now the bug must be fixed.354 builderPollReq = &dashapi.BuilderPollReq{build1.Manager}355 c.expectOK(c.API(client1, key1, "builder_poll", builderPollReq, builderPollResp))356 c.expectEQ(len(builderPollResp.PendingCommits), 0)357 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))358 reports = reportAllBugs(c, 1)359 c.expectEQ(reports[0].Title, "title1 (2)")360}...

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 "fmt"7 "testing"8 "time"9 "github.com/google/syzkaller/dashboard/dashapi"10)11func TestReportBug(t *testing.T) {12 c := NewCtx(t)13 defer c.Close()14 build := testBuild(1)15 c.expectOK(c.API(client1, key1, "upload_build", build, nil))16 crash1 := &dashapi.Crash{17 BuildID: "build1",18 Title: "title1",19 Maintainers: []string{`"Foo Bar" <foo@bar.com>`, `bar@foo.com`},20 Log: []byte("log1"),21 Report: []byte("report1"),22 }23 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))24 // Must get no reports for "unknown" type.25 pr := &dashapi.PollRequest{26 Type: "unknown",27 }28 resp := new(dashapi.PollResponse)29 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))30 c.expectEQ(len(resp.Reports), 0)31 // Must get a proper report for "test" type.32 pr.Type = "test"33 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))34 c.expectEQ(len(resp.Reports), 1)35 rep := resp.Reports[0]36 if rep.ID == "" {37 t.Fatalf("empty report ID")38 }39 want := &dashapi.BugReport{40 Config: []byte(`{"Index":1}`),41 ID: rep.ID,42 First: true,43 Title: "title1",44 Maintainers: []string{"bar@foo.com", "foo@bar.com"},45 CompilerID: "compiler1",46 KernelRepo: "repo1",47 KernelBranch: "branch1",48 KernelCommit: "kernel_commit1",49 KernelConfig: []byte("config1"),50 Log: []byte("log1"),51 Report: []byte("report1"),52 }53 c.expectEQ(rep, want)54 // Since we did not update bug status yet, should get the same report again.55 reports := reportAllBugs(c, 1)56 c.expectEQ(reports[0], want)57 // Now add syz repro and check that we get another bug report.58 crash1.ReproOpts = []byte("some opts")59 crash1.ReproSyz = []byte("getpid()")60 want.First = false61 want.ReproSyz = []byte("#some opts\ngetpid()")62 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))63 reports = reportAllBugs(c, 1)64 c.expectEQ(reports[0], want)65 cmd := &dashapi.BugUpdate{66 ID: rep.ID,67 Status: dashapi.BugStatusOpen,68 ReproLevel: dashapi.ReproLevelSyz,69 }70 reply := new(dashapi.BugUpdateReply)71 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))72 c.expectEQ(reply.OK, true)73 // After bug update should not get the report again.74 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))75 c.expectEQ(len(resp.Reports), 0)76 // Now close the bug in the first reporting.77 cmd = &dashapi.BugUpdate{78 ID: rep.ID,79 Status: dashapi.BugStatusUpstream,80 }81 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))82 c.expectEQ(reply.OK, true)83 // Check that bug updates for the first reporting fail now.84 cmd = &dashapi.BugUpdate{85 ID: rep.ID,86 Status: dashapi.BugStatusOpen,87 }88 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))89 c.expectEQ(reply.OK, false)90 // Check that we get the report in the second reporting.91 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))92 c.expectEQ(len(resp.Reports), 1)93 rep2 := resp.Reports[0]94 if rep2.ID == "" || rep2.ID == rep.ID {95 t.Fatalf("bad report ID: %q", rep2.ID)96 }97 want.ID = rep2.ID98 want.First = true99 want.Config = []byte(`{"Index":2}`)100 c.expectEQ(rep2, want)101 // Check that that we can't upstream the bug in the final reporting.102 cmd = &dashapi.BugUpdate{103 ID: rep2.ID,104 Status: dashapi.BugStatusUpstream,105 }106 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))107 c.expectEQ(reply.OK, false)108}109func TestInvalidBug(t *testing.T) {110 c := NewCtx(t)111 defer c.Close()112 build := testBuild(1)113 c.expectOK(c.API(client1, key1, "upload_build", build, nil))114 crash1 := testCrash(build, 1)115 crash1.ReproC = []byte("int main() {}")116 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))117 pr := &dashapi.PollRequest{118 Type: "test",119 }120 resp := new(dashapi.PollResponse)121 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))122 c.expectEQ(len(resp.Reports), 1)123 rep := resp.Reports[0]124 c.expectEQ(rep.Title, "title1")125 cmd := &dashapi.BugUpdate{126 ID: rep.ID,127 Status: dashapi.BugStatusOpen,128 ReproLevel: dashapi.ReproLevelC,129 }130 reply := new(dashapi.BugUpdateReply)131 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))132 c.expectEQ(reply.OK, true)133 // Mark the bug as invalid.134 cmd = &dashapi.BugUpdate{135 ID: rep.ID,136 Status: dashapi.BugStatusInvalid,137 }138 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))139 c.expectEQ(reply.OK, true)140 // Now it should not be reported in either reporting.141 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))142 c.expectEQ(len(resp.Reports), 0)143 // Now a similar crash happens again.144 crash2 := &dashapi.Crash{145 BuildID: "build1",146 Title: "title1",147 Log: []byte("log2"),148 Report: []byte("report2"),149 ReproC: []byte("int main() { return 1; }"),150 }151 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))152 // Now it should be reported again.153 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))154 c.expectEQ(len(resp.Reports), 1)155 rep = resp.Reports[0]156 if rep.ID == "" {157 t.Fatalf("empty report ID")158 }159 want := &dashapi.BugReport{160 Config: []byte(`{"Index":1}`),161 ID: rep.ID,162 First: true,163 Title: "title1 (2)",164 CompilerID: "compiler1",165 KernelRepo: "repo1",166 KernelBranch: "branch1",167 KernelCommit: "kernel_commit1",168 KernelConfig: []byte("config1"),169 Log: []byte("log2"),170 Report: []byte("report2"),171 ReproC: []byte("int main() { return 1; }"),172 }173 c.expectEQ(rep, want)174 cid := &dashapi.CrashID{175 BuildID: build.ID,176 Title: crash1.Title,177 }178 c.expectOK(c.API(client1, key1, "report_failed_repro", cid, nil))179}180func TestReportingQuota(t *testing.T) {181 c := NewCtx(t)182 defer c.Close()183 build := testBuild(1)184 c.expectOK(c.API(client1, key1, "upload_build", build, nil))185 const numReports = 8 // quota is 3 per day186 for i := 0; i < numReports; i++ {187 crash := &dashapi.Crash{188 BuildID: "build1",189 Title: fmt.Sprintf("title%v", i),190 Log: []byte(fmt.Sprintf("log%v", i)),191 Report: []byte(fmt.Sprintf("report%v", i)),192 }193 c.expectOK(c.API(client1, key1, "report_crash", crash, nil))194 }195 for _, reports := range []int{3, 3, 2, 0, 0} {196 c.advanceTime(24 * time.Hour)197 pr := &dashapi.PollRequest{198 Type: "test",199 }200 resp := new(dashapi.PollResponse)201 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))202 c.expectEQ(len(resp.Reports), reports)203 for _, rep := range resp.Reports {204 cmd := &dashapi.BugUpdate{205 ID: rep.ID,206 Status: dashapi.BugStatusOpen,207 }208 reply := new(dashapi.BugUpdateReply)209 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))210 c.expectEQ(reply.OK, true)211 }212 // Out of quota for today, so must get 0 reports.213 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))214 c.expectEQ(len(resp.Reports), 0)215 }216}217// Basic dup scenario: mark one bug as dup of another.218func TestReportingDup(t *testing.T) {219 c := NewCtx(t)220 defer c.Close()221 build := testBuild(1)222 c.expectOK(c.API(client1, key1, "upload_build", build, nil))223 crash1 := testCrash(build, 1)224 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))225 crash2 := testCrash(build, 2)226 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))227 pr := &dashapi.PollRequest{228 Type: "test",229 }230 resp := new(dashapi.PollResponse)231 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))232 c.expectEQ(len(resp.Reports), 2)233 rep1 := resp.Reports[0]234 cmd := &dashapi.BugUpdate{235 ID: rep1.ID,236 Status: dashapi.BugStatusOpen,237 }238 reply := new(dashapi.BugUpdateReply)239 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))240 c.expectEQ(reply.OK, true)241 rep2 := resp.Reports[1]242 cmd = &dashapi.BugUpdate{243 ID: rep2.ID,244 Status: dashapi.BugStatusOpen,245 }246 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))247 c.expectEQ(reply.OK, true)248 // Dup.249 cmd = &dashapi.BugUpdate{250 ID: rep2.ID,251 Status: dashapi.BugStatusDup,252 DupOf: rep1.ID,253 }254 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))255 c.expectEQ(reply.OK, true)256 // Undup.257 cmd = &dashapi.BugUpdate{258 ID: rep2.ID,259 Status: dashapi.BugStatusOpen,260 }261 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))262 c.expectEQ(reply.OK, true)263 // Dup again.264 cmd = &dashapi.BugUpdate{265 ID: rep2.ID,266 Status: dashapi.BugStatusDup,267 DupOf: rep1.ID,268 }269 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))270 c.expectEQ(reply.OK, true)271 // Dup crash happens again, new bug must not be created.272 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))273 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))274 c.expectEQ(len(resp.Reports), 0)275 // Now close the original bug, and check that new bugs for dup are now created.276 cmd = &dashapi.BugUpdate{277 ID: rep1.ID,278 Status: dashapi.BugStatusInvalid,279 }280 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))281 c.expectEQ(reply.OK, true)282 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))283 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))284 c.expectEQ(len(resp.Reports), 1)285 c.expectEQ(resp.Reports[0].Title, crash2.Title+" (2)")286}287// Test that marking dups across reporting levels is not permitted.288func TestReportingDupCrossReporting(t *testing.T) {289 c := NewCtx(t)290 defer c.Close()291 build := testBuild(1)292 c.expectOK(c.API(client1, key1, "upload_build", build, nil))293 crash1 := testCrash(build, 1)294 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))295 crash2 := testCrash(build, 2)296 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))297 pr := &dashapi.PollRequest{298 Type: "test",299 }300 resp := new(dashapi.PollResponse)301 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))302 c.expectEQ(len(resp.Reports), 2)303 rep1 := resp.Reports[0]304 cmd := &dashapi.BugUpdate{305 ID: rep1.ID,306 Status: dashapi.BugStatusOpen,307 }308 reply := new(dashapi.BugUpdateReply)309 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))310 c.expectEQ(reply.OK, true)311 rep2 := resp.Reports[1]312 cmd = &dashapi.BugUpdate{313 ID: rep2.ID,314 Status: dashapi.BugStatusOpen,315 }316 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))317 c.expectEQ(reply.OK, true)318 // Upstream second bug.319 cmd = &dashapi.BugUpdate{320 ID: rep2.ID,321 Status: dashapi.BugStatusUpstream,322 }323 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))324 c.expectEQ(reply.OK, true)325 c.expectOK(c.API(client1, key1, "reporting_poll", pr, resp))326 c.expectEQ(len(resp.Reports), 1)327 rep3 := resp.Reports[0]328 // Duping must fail all ways.329 cmds := []*dashapi.BugUpdate{330 &dashapi.BugUpdate{ID: rep1.ID, DupOf: rep1.ID},331 &dashapi.BugUpdate{ID: rep1.ID, DupOf: rep2.ID},332 &dashapi.BugUpdate{ID: rep1.ID, DupOf: rep3.ID},333 &dashapi.BugUpdate{ID: rep2.ID, DupOf: rep1.ID},334 &dashapi.BugUpdate{ID: rep2.ID, DupOf: rep2.ID},335 &dashapi.BugUpdate{ID: rep2.ID, DupOf: rep3.ID},336 &dashapi.BugUpdate{ID: rep3.ID, DupOf: rep1.ID},337 &dashapi.BugUpdate{ID: rep3.ID, DupOf: rep2.ID},338 &dashapi.BugUpdate{ID: rep3.ID, DupOf: rep3.ID},339 }340 for _, cmd := range cmds {341 t.Logf("duping %v -> %v", cmd.ID, cmd.DupOf)342 cmd.Status = dashapi.BugStatusDup343 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))344 c.expectEQ(reply.OK, false)345 }346}...

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/golang/example/stringutil"3func main() {4 fmt.Println(stringutil.Reverse("!oG ,olleH"))5 fmt.Println(stringutil.Len("Hello"))6}7import "fmt"8import "github.com/golang/example/stringutil"9func main() {10 fmt.Println(stringutil.Reverse("!oG ,olleH"))11}12import "fmt"13import "github.com/golang/example/stringutil"14func main() {15 fmt.Println(stringutil.Reverse("!oG ,olleH"))16 fmt.Println(stringutil.Len("Hello"))17}18import "fmt"19import "github.com/golang/example/stringutil"20func main() {21 fmt.Println(stringutil.Reverse("!oG ,olleH"))22 fmt.Println(stringutil.Len("Hello"))23}24import "fmt"25import "github.com/golang/example/stringutil"26func main() {27 fmt.Println(stringutil.Reverse("!oG ,olleH"))28 fmt.Println(stringutil.Len("Hello"))29}30import "fmt"31import "github.com/golang/example/stringutil"32func main() {33 fmt.Println(stringutil.Reverse("!oG ,olleH"))34 fmt.Println(stringutil.Len("Hello"))35}36import "fmt"37import "github.com/golang/example/stringutil"38func main() {39 fmt.Println(stringutil.Reverse("!oG ,olleH"))40 fmt.Println(stringutil.Len("Hello"))41}42import "fmt"43import "github.com/golang/example/stringutil"44func main() {45 fmt.Println(stringutil.Reverse("!oG ,olleH"))46 fmt.Println(stringutil.Len("Hello"))47}

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/robertkrimen/otto"3func main() {4 vm := otto.New()5 vm.Run(`6 var dashapi = {7 Len: function (s) {8 return s.length;9 }10 };11 value, _ := vm.Run("dashapi.Len('Hello, World!')")12 result, _ := value.ToInteger()13 fmt.Println(result)14}15import "fmt"16import "github.com/robertkrimen/otto"17func main() {18 vm := otto.New()19 vm.Run(`20 var dashapi = {21 Len: function (s) {22 return s.length;23 }24 };25 value, _ := vm.Call("dashapi.Len", nil, "Hello, World!")26 result, _ := value.ToInteger()27 fmt.Println(result)28}29import "fmt"30import "github.com/robertkrimen/otto"31func main() {32 vm := otto.New()33 vm.Set("dashapi", map[string]interface{}{34 "Len": func(call otto.FunctionCall) otto.Value {35 s, _ := call.Argument(0).ToString()36 result, _ := otto.ToValue(len(s))37 },38 })39 value, _ := vm.Run("dashapi.Len('Hello, World!')")40 result, _ := value.ToInteger()41 fmt.Println(result)42}

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(dashapi.Len("test"))4}5import (6func main() {7 fmt.Println(dashapi.Len("test"))8}9import (10func main() {11 fmt.Println(dashapi.Len("test"))12}13import (14func main() {15 fmt.Println(dashapi.Len("test"))16}17import (18func main() {19 fmt.Println(dashapi.Len("test"))20}21import (22func main() {23 fmt.Println(dashapi.Len("test"))24}25import (26func main() {27 fmt.Println(dashapi.Len("test"))28}29import (30func main() {31 fmt.Println(dashapi.Len("test"))32}33import (34func main() {35 fmt.Println(dashapi.Len("test"))36}

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 dashapi := dashapi.Dashapi{}4 dashapi.SetLen(10)5 fmt.Println(dashapi.Len())6}

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1func main() {2 var dashapi = dashapi.New(10)3 fmt.Println(dashapi.Len())4}5import (6func main() {7 var dashapi = dashapi.New(10)8 fmt.Println(dashapi.Len())9}

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 x = dashapi.Dash{1, 2, 3, 4, 5}4 fmt.Println(x.Len())5}6The method Len() is a method

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "github.com/udhos/dashapi"3func main() {4 fmt.Println("DashAPI 2.go")5 var api = dashapi.NewDashAPI()6 var length = api.Len()7 fmt.Println("length is", length)8}9import "fmt"10import "github.com/udhos/dashapi"11func main() {12 fmt.Println("DashAPI 3.go")13 var api = dashapi.NewDashAPI()14 var length = api.Len()15 fmt.Println("length is", length)16}17import "fmt"18import "github.com/udhos/dashapi"19func main() {20 fmt.Println("DashAPI 4.go")21 var api = dashapi.NewDashAPI()22 var length = api.Len()23 fmt.Println("length is", length)24}25import "fmt"26import "github.com/udhos/dashapi"27func main() {28 fmt.Println("DashAPI 5.go")29 var api = dashapi.NewDashAPI()30 var length = api.Len()31 fmt.Println("length is", length)32}33import "fmt"34import "github.com/udhos/dashapi"35func main() {36 fmt.Println("DashAPI 6.go")37 var api = dashapi.NewDashAPI()38 var length = api.Len()39 fmt.Println("length is", length)40}41import "fmt"42import "github.com/udhos/dashapi"43func main() {44 fmt.Println("DashAPI 7.go")45 var api = dashapi.NewDashAPI()46 var length = api.Len()47 fmt.Println("length is", length)48}49import "fmt"50import "github.com/udhos/dashapi"51func main() {52 fmt.Println("DashAPI 8.go")

Full Screen

Full Screen

Len

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(s.Len())4}5import (6func main() {7 fmt.Println(s.Len())8}9import (10func main() {11 fmt.Println(s.Len())12}13import (14func main() {15 fmt.Println(s.Len())16}17import (

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