Best Syzkaller code snippet using main.expectEQ
reporting_test.go
Source:reporting_test.go
...26 Type: "unknown",27 }28 resp := new(dashapi.PollBugsResponse)29 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", 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_bugs", 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 _, dbCrash, dbBuild := c.loadBug(rep.ID)40 want := &dashapi.BugReport{41 Namespace: "test1",42 Config: []byte(`{"Index":1}`),43 ID: rep.ID,44 First: true,45 Title: "title1",46 Maintainers: []string{"bar@foo.com", "foo@bar.com"},47 CompilerID: "compiler1",48 KernelRepo: "repo1",49 KernelRepoAlias: "repo1/branch1",50 KernelBranch: "branch1",51 KernelCommit: "1111111111111111111111111111111111111111",52 KernelCommitTitle: build.KernelCommitTitle,53 KernelCommitDate: buildCommitDate,54 KernelConfig: []byte("config1"),55 KernelConfigLink: externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig),56 Log: []byte("log1"),57 LogLink: externalLink(c.ctx, textCrashLog, dbCrash.Log),58 Report: []byte("report1"),59 ReportLink: externalLink(c.ctx, textCrashReport, dbCrash.Report),60 CrashID: rep.CrashID,61 NumCrashes: 1,62 HappenedOn: []string{"repo1/branch1"},63 }64 c.expectEQ(rep, want)65 // Since we did not update bug status yet, should get the same report again.66 reports := reportAllBugs(c, 1)67 c.expectEQ(reports[0], want)68 // Now add syz repro and check that we get another bug report.69 crash1.ReproOpts = []byte("some opts")70 crash1.ReproSyz = []byte("getpid()")71 want.First = false72 want.ReproSyz = []byte(syzReproPrefix + "#some opts\ngetpid()")73 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))74 reports = reportAllBugs(c, 1)75 if want.CrashID == reports[0].CrashID {76 t.Fatal("get the same CrashID for new crash")77 }78 _, dbCrash, _ = c.loadBug(rep.ID)79 want.CrashID = reports[0].CrashID80 want.NumCrashes = 281 want.ReproSyzLink = externalLink(c.ctx, textReproSyz, dbCrash.ReproSyz)82 want.LogLink = externalLink(c.ctx, textCrashLog, dbCrash.Log)83 want.ReportLink = externalLink(c.ctx, textCrashReport, dbCrash.Report)84 c.expectEQ(reports[0], want)85 cmd := &dashapi.BugUpdate{86 ID: rep.ID,87 Status: dashapi.BugStatusOpen,88 ReproLevel: dashapi.ReproLevelSyz,89 }90 reply := new(dashapi.BugUpdateReply)91 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))92 c.expectEQ(reply.OK, true)93 // After bug update should not get the report again.94 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))95 c.expectEQ(len(resp.Reports), 0)96 // Now close the bug in the first reporting.97 cmd = &dashapi.BugUpdate{98 ID: rep.ID,99 Status: dashapi.BugStatusUpstream,100 }101 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))102 c.expectEQ(reply.OK, true)103 // Check that bug updates for the first reporting fail now.104 cmd = &dashapi.BugUpdate{105 ID: rep.ID,106 Status: dashapi.BugStatusOpen,107 }108 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))109 c.expectEQ(reply.OK, false)110 // Report another crash with syz repro for this bug,111 // ensure that we still report the original crash in the next reporting.112 // That's what we've upstreammed, it's bad to switch crashes without reason.113 crash1.Report = []byte("report2")114 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))115 // Check that we get the report in the second reporting.116 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))117 c.expectEQ(len(resp.Reports), 1)118 rep2 := resp.Reports[0]119 if rep2.ID == "" || rep2.ID == rep.ID {120 t.Fatalf("bad report ID: %q", rep2.ID)121 }122 want.ID = rep2.ID123 want.First = true124 want.Config = []byte(`{"Index":2}`)125 want.NumCrashes = 3126 c.expectEQ(rep2, want)127 // Check that that we can't upstream the bug in the final reporting.128 cmd = &dashapi.BugUpdate{129 ID: rep2.ID,130 Status: dashapi.BugStatusUpstream,131 }132 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))133 c.expectEQ(reply.OK, false)134}135func TestInvalidBug(t *testing.T) {136 c := NewCtx(t)137 defer c.Close()138 build := testBuild(1)139 c.expectOK(c.API(client1, key1, "upload_build", build, nil))140 crash1 := testCrash(build, 1)141 crash1.ReproC = []byte("int main() {}")142 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))143 pr := &dashapi.PollBugsRequest{144 Type: "test",145 }146 resp := new(dashapi.PollBugsResponse)147 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))148 c.expectEQ(len(resp.Reports), 1)149 rep := resp.Reports[0]150 c.expectEQ(rep.Title, "title1")151 cmd := &dashapi.BugUpdate{152 ID: rep.ID,153 Status: dashapi.BugStatusOpen,154 ReproLevel: dashapi.ReproLevelC,155 }156 reply := new(dashapi.BugUpdateReply)157 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))158 c.expectEQ(reply.OK, true)159 {160 req := &dashapi.PollClosedRequest{161 IDs: []string{rep.ID, "foobar"},162 }163 resp := new(dashapi.PollClosedResponse)164 c.expectOK(c.API(client1, key1, "reporting_poll_closed", req, resp))165 c.expectEQ(len(resp.IDs), 0)166 }167 // Mark the bug as invalid.168 cmd = &dashapi.BugUpdate{169 ID: rep.ID,170 Status: dashapi.BugStatusInvalid,171 }172 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))173 c.expectEQ(reply.OK, true)174 {175 req := &dashapi.PollClosedRequest{176 IDs: []string{rep.ID, "foobar"},177 }178 resp := new(dashapi.PollClosedResponse)179 c.expectOK(c.API(client1, key1, "reporting_poll_closed", req, resp))180 c.expectEQ(len(resp.IDs), 1)181 c.expectEQ(resp.IDs[0], rep.ID)182 }183 // Now it should not be reported in either reporting.184 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))185 c.expectEQ(len(resp.Reports), 0)186 // Now a similar crash happens again.187 crash2 := &dashapi.Crash{188 BuildID: "build1",189 Title: "title1",190 Log: []byte("log2"),191 Report: []byte("report2"),192 ReproC: []byte("int main() { return 1; }"),193 }194 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))195 // Now it should be reported again.196 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))197 c.expectEQ(len(resp.Reports), 1)198 rep = resp.Reports[0]199 if rep.ID == "" {200 t.Fatalf("empty report ID")201 }202 _, dbCrash, dbBuild := c.loadBug(rep.ID)203 want := &dashapi.BugReport{204 Namespace: "test1",205 Config: []byte(`{"Index":1}`),206 ID: rep.ID,207 First: true,208 Title: "title1 (2)",209 CompilerID: "compiler1",210 KernelRepo: "repo1",211 KernelRepoAlias: "repo1/branch1",212 KernelBranch: "branch1",213 KernelCommit: "1111111111111111111111111111111111111111",214 KernelCommitTitle: build.KernelCommitTitle,215 KernelCommitDate: buildCommitDate,216 KernelConfig: []byte("config1"),217 KernelConfigLink: externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig),218 Log: []byte("log2"),219 LogLink: externalLink(c.ctx, textCrashLog, dbCrash.Log),220 Report: []byte("report2"),221 ReportLink: externalLink(c.ctx, textCrashReport, dbCrash.Report),222 ReproC: []byte("int main() { return 1; }"),223 ReproCLink: externalLink(c.ctx, textReproC, dbCrash.ReproC),224 CrashID: rep.CrashID,225 NumCrashes: 1,226 HappenedOn: []string{"repo1/branch1"},227 }228 c.expectEQ(rep, want)229 cid := &dashapi.CrashID{230 BuildID: build.ID,231 Title: crash1.Title,232 }233 c.expectOK(c.API(client1, key1, "report_failed_repro", cid, nil))234}235func TestReportingQuota(t *testing.T) {236 c := NewCtx(t)237 defer c.Close()238 build := testBuild(1)239 c.expectOK(c.API(client1, key1, "upload_build", build, nil))240 const numReports = 8 // quota is 3 per day241 for i := 0; i < numReports; i++ {242 crash := &dashapi.Crash{243 BuildID: "build1",244 Title: fmt.Sprintf("title%v", i),245 Log: []byte(fmt.Sprintf("log%v", i)),246 Report: []byte(fmt.Sprintf("report%v", i)),247 }248 c.expectOK(c.API(client1, key1, "report_crash", crash, nil))249 }250 for _, reports := range []int{3, 3, 2, 0, 0} {251 c.advanceTime(24 * time.Hour)252 pr := &dashapi.PollBugsRequest{253 Type: "test",254 }255 resp := new(dashapi.PollBugsResponse)256 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))257 c.expectEQ(len(resp.Reports), reports)258 for _, rep := range resp.Reports {259 cmd := &dashapi.BugUpdate{260 ID: rep.ID,261 Status: dashapi.BugStatusOpen,262 }263 reply := new(dashapi.BugUpdateReply)264 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))265 c.expectEQ(reply.OK, true)266 }267 // Out of quota for today, so must get 0 reports.268 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))269 c.expectEQ(len(resp.Reports), 0)270 }271}272// Basic dup scenario: mark one bug as dup of another.273func TestReportingDup(t *testing.T) {274 c := NewCtx(t)275 defer c.Close()276 build := testBuild(1)277 c.expectOK(c.API(client1, key1, "upload_build", build, nil))278 crash1 := testCrash(build, 1)279 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))280 crash2 := testCrash(build, 2)281 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))282 pr := &dashapi.PollBugsRequest{283 Type: "test",284 }285 resp := new(dashapi.PollBugsResponse)286 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))287 c.expectEQ(len(resp.Reports), 2)288 rep1 := resp.Reports[0]289 cmd := &dashapi.BugUpdate{290 ID: rep1.ID,291 Status: dashapi.BugStatusOpen,292 }293 reply := new(dashapi.BugUpdateReply)294 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))295 c.expectEQ(reply.OK, true)296 rep2 := resp.Reports[1]297 cmd = &dashapi.BugUpdate{298 ID: rep2.ID,299 Status: dashapi.BugStatusOpen,300 }301 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))302 c.expectEQ(reply.OK, true)303 // Dup.304 cmd = &dashapi.BugUpdate{305 ID: rep2.ID,306 Status: dashapi.BugStatusDup,307 DupOf: rep1.ID,308 }309 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))310 c.expectEQ(reply.OK, true)311 {312 // Both must be reported as open.313 req := &dashapi.PollClosedRequest{314 IDs: []string{rep1.ID, rep2.ID},315 }316 resp := new(dashapi.PollClosedResponse)317 c.expectOK(c.API(client1, key1, "reporting_poll_closed", req, resp))318 c.expectEQ(len(resp.IDs), 0)319 }320 // Undup.321 cmd = &dashapi.BugUpdate{322 ID: rep2.ID,323 Status: dashapi.BugStatusOpen,324 }325 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))326 c.expectEQ(reply.OK, true)327 // Dup again.328 cmd = &dashapi.BugUpdate{329 ID: rep2.ID,330 Status: dashapi.BugStatusDup,331 DupOf: rep1.ID,332 }333 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))334 c.expectEQ(reply.OK, true)335 // Dup crash happens again, new bug must not be created.336 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))337 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))338 c.expectEQ(len(resp.Reports), 0)339 // Now close the original bug, and check that new bugs for dup are now created.340 cmd = &dashapi.BugUpdate{341 ID: rep1.ID,342 Status: dashapi.BugStatusInvalid,343 }344 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))345 c.expectEQ(reply.OK, true)346 {347 // Now both must be reported as closed.348 req := &dashapi.PollClosedRequest{349 IDs: []string{rep1.ID, rep2.ID},350 }351 resp := new(dashapi.PollClosedResponse)352 c.expectOK(c.API(client1, key1, "reporting_poll_closed", req, resp))353 c.expectEQ(len(resp.IDs), 2)354 c.expectEQ(resp.IDs[0], rep1.ID)355 c.expectEQ(resp.IDs[1], rep2.ID)356 }357 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))358 c.expectOK(c.API(client1, key1, "reporting_poll_bugs", pr, resp))359 c.expectEQ(len(resp.Reports), 1)360 c.expectEQ(resp.Reports[0].Title, crash2.Title+" (2)")361 // Unduping after the canonical bugs was closed must not work362 // (we already created new bug for this report).363 cmd = &dashapi.BugUpdate{364 ID: rep2.ID,365 Status: dashapi.BugStatusOpen,366 }367 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))368 c.expectEQ(reply.OK, false)369}370// Dup bug onto a closed bug.371// A new crash report must create a new bug.372func TestReportingDupToClosed(t *testing.T) {373 c := NewCtx(t)374 defer c.Close()375 build := testBuild(1)376 c.expectOK(c.API(client1, key1, "upload_build", build, nil))377 crash1 := testCrash(build, 1)378 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))379 crash2 := testCrash(build, 2)380 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))381 reports := reportAllBugs(c, 2)382 cmd := &dashapi.BugUpdate{383 ID: reports[0].ID,384 Status: dashapi.BugStatusInvalid,385 }386 reply := new(dashapi.BugUpdateReply)387 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))388 c.expectEQ(reply.OK, true)389 cmd = &dashapi.BugUpdate{390 ID: reports[1].ID,391 Status: dashapi.BugStatusDup,392 DupOf: reports[0].ID,393 }394 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))395 c.expectEQ(reply.OK, true)396 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))397 reports2 := reportAllBugs(c, 1)398 c.expectEQ(reports2[0].Title, crash2.Title+" (2)")399}400// Test that marking dups across reporting levels is not permitted.401func TestReportingDupCrossReporting(t *testing.T) {402 c := NewCtx(t)403 defer c.Close()404 build := testBuild(1)405 c.expectOK(c.API(client1, key1, "upload_build", build, nil))406 crash1 := testCrash(build, 1)407 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))408 crash2 := testCrash(build, 2)409 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))410 reports := reportAllBugs(c, 2)411 rep1 := reports[0]412 rep2 := reports[1]413 // Upstream second bug.414 cmd := &dashapi.BugUpdate{415 ID: rep2.ID,416 Status: dashapi.BugStatusUpstream,417 }418 reply := new(dashapi.BugUpdateReply)419 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))420 c.expectEQ(reply.OK, true)421 reports = reportAllBugs(c, 1)422 rep3 := reports[0]423 {424 req := &dashapi.PollClosedRequest{425 IDs: []string{rep1.ID, rep2.ID, rep3.ID},426 }427 resp := new(dashapi.PollClosedResponse)428 c.expectOK(c.API(client1, key1, "reporting_poll_closed", req, resp))429 c.expectEQ(len(resp.IDs), 1)430 c.expectEQ(resp.IDs[0], rep2.ID)431 }432 // Duping must fail all ways.433 cmds := []*dashapi.BugUpdate{434 &dashapi.BugUpdate{ID: rep1.ID, DupOf: rep1.ID},435 &dashapi.BugUpdate{ID: rep1.ID, DupOf: rep2.ID},436 &dashapi.BugUpdate{ID: rep1.ID, DupOf: rep3.ID},437 &dashapi.BugUpdate{ID: rep2.ID, DupOf: rep1.ID},438 &dashapi.BugUpdate{ID: rep2.ID, DupOf: rep2.ID},439 &dashapi.BugUpdate{ID: rep2.ID, DupOf: rep3.ID},440 &dashapi.BugUpdate{ID: rep3.ID, DupOf: rep1.ID},441 &dashapi.BugUpdate{ID: rep3.ID, DupOf: rep2.ID},442 &dashapi.BugUpdate{ID: rep3.ID, DupOf: rep3.ID},443 }444 for _, cmd := range cmds {445 t.Logf("duping %v -> %v", cmd.ID, cmd.DupOf)446 cmd.Status = dashapi.BugStatusDup447 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))448 c.expectEQ(reply.OK, false)449 }450}451func TestReportingFilter(t *testing.T) {452 c := NewCtx(t)453 defer c.Close()454 build := testBuild(1)455 c.expectOK(c.API(client1, key1, "upload_build", build, nil))456 crash1 := testCrash(build, 1)457 crash1.Title = "skip without repro 1"458 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))459 // This does not skip first reporting, because it does not have repro.460 rep1 := reportAllBugs(c, 1)[0]461 c.expectEQ(string(rep1.Config), `{"Index":1}`)462 crash1.ReproSyz = []byte("getpid()")463 c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))464 // This has repro but was already reported to first reporting,465 // so repro must go to the first reporting as well.466 rep2 := reportAllBugs(c, 1)[0]467 c.expectEQ(string(rep2.Config), `{"Index":1}`)468 // Now upstream it and it must go to the second reporting.469 cmd := &dashapi.BugUpdate{470 ID: rep1.ID,471 Status: dashapi.BugStatusUpstream,472 }473 reply := new(dashapi.BugUpdateReply)474 c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))475 c.expectEQ(reply.OK, true)476 rep3 := reportAllBugs(c, 1)[0]477 c.expectEQ(string(rep3.Config), `{"Index":2}`)478 // Now report a bug that must go to the second reporting right away.479 crash2 := testCrash(build, 2)480 crash2.Title = "skip without repro 2"481 crash2.ReproSyz = []byte("getpid()")482 c.expectOK(c.API(client1, key1, "report_crash", crash2, nil))483 rep4 := reportAllBugs(c, 1)[0]484 c.expectEQ(string(rep4.Config), `{"Index":2}`)485}...
commit_poll_test.go
Source:commit_poll_test.go
...19 rep2 := c.client.pollBug()20 // No commits in commit poll.21 commitPollResp, err := c.client.CommitPoll()22 c.expectOK(err)23 c.expectEQ(len(commitPollResp.Repos), 2)24 c.expectEQ(commitPollResp.Repos[0].URL, testConfig.Namespaces["test1"].Repos[0].URL)25 c.expectEQ(commitPollResp.Repos[0].Branch, testConfig.Namespaces["test1"].Repos[0].Branch)26 c.expectEQ(commitPollResp.Repos[1].URL, testConfig.Namespaces["test1"].Repos[1].URL)27 c.expectEQ(commitPollResp.Repos[1].Branch, testConfig.Namespaces["test1"].Repos[1].Branch)28 c.expectEQ(len(commitPollResp.Commits), 0)29 // Specify fixing commit for the bug.30 reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{31 ID: rep1.ID,32 Status: dashapi.BugStatusOpen,33 FixCommits: []string{"foo: fix1", "foo: fix2"},34 })35 c.expectEQ(reply.OK, true)36 // The commit should appear in commit poll.37 for i := 0; i < 2; i++ {38 commitPollResp, err = c.client.CommitPoll()39 c.expectOK(err)40 c.expectEQ(len(commitPollResp.Commits), 2)41 sort.Strings(commitPollResp.Commits)42 c.expectEQ(commitPollResp.Commits[0], "foo: fix1")43 c.expectEQ(commitPollResp.Commits[1], "foo: fix2")44 }45 // Upload hash for the first commit and fixing commit for the second bug.46 c.expectOK(c.client.UploadCommits([]dashapi.Commit{47 {Hash: "hash1", Title: "foo: fix1"},48 {Hash: "hash2", Title: "bar: fix3", BugIDs: []string{rep2.ID}},49 {Hash: "hash3", Title: "some unrelated commit", BugIDs: []string{"does not exist"}},50 {Hash: "hash4", Title: "another unrelated commit"},51 }))52 commitPollResp, err = c.client.CommitPoll()53 c.expectOK(err)54 c.expectEQ(len(commitPollResp.Commits), 2)55 sort.Strings(commitPollResp.Commits)56 c.expectEQ(commitPollResp.Commits[0], "foo: fix1")57 c.expectEQ(commitPollResp.Commits[1], "foo: fix2")58 // Upload hash for the second commit and a new fixing commit for the second bug.59 c.expectOK(c.client.UploadCommits([]dashapi.Commit{60 {Hash: "hash5", Title: "foo: fix2"},61 {Title: "bar: fix4", BugIDs: []string{rep2.ID}},62 }))63 commitPollResp, err = c.client.CommitPoll()64 c.expectOK(err)65 c.expectEQ(len(commitPollResp.Commits), 1)66 c.expectEQ(commitPollResp.Commits[0], "bar: fix4")67 // Upload hash for the second commit and a new fixing commit for the second bug.68 c.expectOK(c.client.UploadCommits([]dashapi.Commit{69 {Hash: "hash1", Title: "foo: fix1"},70 {Hash: "hash5", Title: "foo: fix2"},71 {Hash: "hash6", Title: "bar: fix4"},72 }))73 commitPollResp, err = c.client.CommitPoll()74 c.expectOK(err)75 c.expectEQ(len(commitPollResp.Commits), 0)76}...
instruction_test.go
Source:instruction_test.go
1package asm2import (3 "testing"4 "github.com/sxarp/c_compiler_go/src/h"5)6func TestIns(t *testing.T) {7 h.ExpectEq(t, " ret", I().Ret().Str())8 h.ExpectEq(t, " mov rax, 42", I().Mov().Rax().Val(42).Str())9 h.ExpectEq(t, " mov rax, rax", I().Mov().Rax().Rax().Str())10 h.ExpectEq(t, " add rax, 42", I().Add().Rax().Val(42).Str())11 h.ExpectEq(t, " sub rax, 42", I().Sub().Rax().Val(42).Str())12 h.ExpectEq(t, " pop 42", I().Pop().Val(42).Str())13 h.ExpectEq(t, " push 42", I().Push().Val(42).Str())14 h.ExpectEq(t, " push rax", I().Push().Rax().Str())15 h.ExpectEq(t, " push rdi", I().Push().Rdi().Str())16 h.ExpectEq(t, " pop rax", I().Pop().Rax().Str())17 h.ExpectEq(t, " pop rdi", I().Pop().Rdi().Str())18 h.ExpectEq(t, " mul rdi", I().Mul().Rdi().Str())19 h.ExpectEq(t, " div rdi", I().Div().Rdi().Str())20 h.ExpectEq(t, " mov rdx, 0", I().Mov().Rdx().Val(0).Str())21 h.ExpectEq(t, " mov rbp, rsp", I().Mov().Rbp().Rsp().Str())22 h.ExpectEq(t, " mov rsp, rbp", I().Mov().Rsp().Rbp().Str())23 h.ExpectEq(t, " mov [rsp], rbp", I().Mov().Rsp().P().Rbp().Str())24 h.ExpectEq(t, " mov rsp, [rbp]", I().Mov().Rsp().Rbp().P().Str())25 h.ExpectEq(t, " mov [rdi], rax", I().Mov().Rdi().P().Rax().Str())26 h.ExpectEq(t, " cmp rdi, rax", I().Cmp().Rdi().Rax().Str())27 h.ExpectEq(t, " sete al", I().Sete().Al().Str())28 h.ExpectEq(t, " setne al", I().Setne().Al().Str())29 h.ExpectEq(t, " movzb rax, al", I().Movzb().Rax().Al().Str())30 h.ExpectEq(t, " call foo", I().Call("foo").Str())31 h.ExpectEq(t, " mov rsi, rcx", I().Mov().Rsi().Rcx().Str())32 h.ExpectEq(t, " mov rcx, rsi", I().Mov().Rcx().Rsi().Str())33 h.ExpectEq(t, " mov r8, r9", I().Mov().R8().R9().Str())34 h.ExpectEq(t, " mov r9, r8", I().Mov().R9().R8().Str())35 h.ExpectEq(t, " mov r10, r10", I().Mov().R10().R10().Str())36 h.ExpectEq(t, "main:", I().Label("main").Str())37 h.ExpectEq(t, " je .Lend", I().Je(".Lend").Str())38 h.ExpectEq(t, " jl .Lend", I().Jl(".Lend").Str())39 h.ExpectEq(t, " jmp .Lend", I().Jmp(".Lend").Str())40 h.ExpectEq(t, " syscall", I().Sys().Str())41}42func TestFinEq(t *testing.T) {43 for _, comp := range []struct {44 lhs Fin45 rhs Fin46 expect bool47 }{48 {I().Sub().Rax().Val(42), I().Sub().Rax().Val(42), true},49 {I().Sub().Rax().Val(42), I().Sub().Rax().Val(43), false},50 {I().Push().Rax(), I().Push().Rax(), true},51 {I().Push().Rax(), I().Push().Rdi(), false},52 } {53 h.ExpectEq(t, comp.expect, comp.lhs.Eq((&comp.rhs)))54 }55}...
expectEQ
Using AI Code Generation
1import (2func TestExpectEQ(t *testing.T) {3 main := Main{}4 main.ExpectEQ(1, 1)5}6import (7func TestExpectEQ(t *testing.T) {8 main := Main{}9 main.ExpectEQ(1, 1)10}11import (12func TestExpectEQ(t *testing.T) {13 main := Main{}14 main.ExpectEQ(1, 1)15}16import (17func TestExpectEQ(t *testing.T) {18 main := Main{}19 main.ExpectEQ(1, 1)20}21import (22func TestExpectEQ(t *testing.T) {23 main := Main{}24 main.ExpectEQ(1, 1)25}26import (27func TestExpectEQ(t *testing.T) {28 main := Main{}29 main.ExpectEQ(1, 1)30}31import (32func TestExpectEQ(t *testing.T) {33 main := Main{}34 main.ExpectEQ(1, 1)35}36import (37func TestExpectEQ(t *testing.T) {38 main := Main{}39 main.ExpectEQ(1, 1)40}41import (42func TestExpectEQ(t *testing.T) {43 main := Main{}44 main.ExpectEQ(1, 1)45}46import (47func TestExpectEQ(t *testing.T) {48 main := Main{}49 main.ExpectEQ(1, 1)50}
expectEQ
Using AI Code Generation
1import (2func TestExpectEQ(t *testing.T) {3 fmt.Println("TestExpectEQ")4 main := Main{}5 main.ExpectEQ(1, 1)6 main.ExpectEQ(1, 2)7 main.ExpectEQ("abc", "abc")8 main.ExpectEQ("abc", "def")9}10import (11func TestExpectEQ(t *testing.T) {12 fmt.Println("TestExpectEQ")13 main := Main{}14 main.ExpectEQ(1, 1)15 main.ExpectEQ(1, 2)16 main.ExpectEQ("abc", "abc")17 main.ExpectEQ("abc", "def")18}19import (20func TestExpectEQ(t *testing.T) {21 fmt.Println("TestExpectEQ")22 main := Main{}23 main.ExpectEQ(1, 1)24 main.ExpectEQ(1, 2)25 main.ExpectEQ("abc", "abc")26 main.ExpectEQ("abc", "def")27}28import (29func TestExpectEQ(t *testing.T) {30 fmt.Println("TestExpectEQ")31 main := Main{}32 main.ExpectEQ(1, 1)33 main.ExpectEQ(1, 2)34 main.ExpectEQ("abc", "abc")35 main.ExpectEQ("abc", "def")36}37import (38type Main struct {39}40func (m *Main) ExpectEQ(a interface{}, b interface{}) {41 if a == b {42 fmt.Println("Passed")43 } else {44 fmt.Println("Failed")45 }46}47func main() {48 main := Main{}49 for i := 1; i <= 5; i++ {50 fileName := strconv.Itoa(i) + ".go"51 fmt.Println("File Name: " + fileName)
expectEQ
Using AI Code Generation
1import (2func TestAdd(t *testing.T) {3 fmt.Println("TestAdd")4 expectEQ(t, 1, 1)5 expectEQ(t, 2, 2)6 expectEQ(t, 3, 3)7}8func expectEQ(t *testing.T, a, b int) {9 if a != b {10 t.Errorf("Expected %d, got %d", a, b)11 }12}13import (14func main() {15 testing.Main(func(pat, str string) (bool, error) {16 }, []testing.InternalTest{17 {18 },19 }, []testing.InternalBenchmark{}, []testing.InternalExample{})20}21--- FAIL: TestAdd (0.00s)22In the above code, we have a main class that runs the tests using the testing.Main() method. The testing.Main() method takes the following arguments:
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!