How to use extJobID method of main Package

Best Syzkaller code snippet using main.extJobID

jobs.go

Source:jobs.go Github

copy

Full Screen

...352 }353 return job, jobKey, nil354}355func createJobResp(c context.Context, job *Job, jobKey *db.Key) (*dashapi.JobPollResp, bool, error) {356 jobID := extJobID(jobKey)357 patch, _, err := getText(c, textPatch, job.Patch)358 if err != nil {359 return nil, false, err360 }361 bugKey := jobKey.Parent()362 crashKey := db.NewKey(c, "Crash", "", job.CrashID, bugKey)363 crash := new(Crash)364 if err := db.Get(c, crashKey, crash); err != nil {365 return nil, false, fmt.Errorf("job %v: failed to get crash: %v", jobID, err)366 }367 build, err := loadBuild(c, job.Namespace, crash.BuildID)368 if err != nil {369 return nil, false, err370 }371 kernelConfig, _, err := getText(c, textKernelConfig, build.KernelConfig)372 if err != nil {373 return nil, false, err374 }375 reproC, _, err := getText(c, textReproC, crash.ReproC)376 if err != nil {377 return nil, false, err378 }379 reproSyz, err := loadReproSyz(c, crash)380 if err != nil {381 return nil, false, err382 }383 now := timeNow(c)384 stale := false385 tx := func(c context.Context) error {386 stale = false387 job = new(Job)388 if err := db.Get(c, jobKey, job); err != nil {389 return fmt.Errorf("job %v: failed to get in tx: %v", jobID, err)390 }391 if !job.Finished.IsZero() {392 // This happens sometimes due to inconsistent db.393 stale = true394 return nil395 }396 job.Attempts++397 job.Started = now398 if _, err := db.Put(c, jobKey, job); err != nil {399 return fmt.Errorf("job %v: failed to put: %v", jobID, err)400 }401 return nil402 }403 if err := db.RunInTransaction(c, tx, nil); err != nil {404 return nil, false, err405 }406 if stale {407 return nil, true, nil408 }409 resp := &dashapi.JobPollResp{410 ID: jobID,411 Manager: job.Manager,412 KernelRepo: job.KernelRepo,413 KernelBranch: job.KernelBranch,414 KernelCommit: build.KernelCommit,415 KernelCommitTitle: build.KernelCommitTitle,416 KernelCommitDate: build.KernelCommitDate,417 KernelConfig: kernelConfig,418 SyzkallerCommit: build.SyzkallerCommit,419 Patch: patch,420 ReproOpts: crash.ReproOpts,421 ReproSyz: reproSyz,422 ReproC: reproC,423 }424 switch job.Type {425 case JobTestPatch:426 resp.Type = dashapi.JobTestPatch427 case JobBisectCause:428 resp.Type = dashapi.JobBisectCause429 case JobBisectFix:430 resp.Type = dashapi.JobBisectFix431 default:432 return nil, false, fmt.Errorf("bad job type %v", job.Type)433 }434 return resp, false, nil435}436// doneJob is called by syz-ci to mark completion of a job.437func doneJob(c context.Context, req *dashapi.JobDoneReq) error {438 jobID := req.ID439 jobKey, err := jobID2Key(c, req.ID)440 if err != nil {441 return err442 }443 now := timeNow(c)444 tx := func(c context.Context) error {445 job := new(Job)446 if err := db.Get(c, jobKey, job); err != nil {447 return fmt.Errorf("job %v: failed to get job: %v", jobID, err)448 }449 if !job.Finished.IsZero() {450 return fmt.Errorf("job %v: already finished", jobID)451 }452 ns := job.Namespace453 if req.Build.ID != "" {454 if _, isNewBuild, err := uploadBuild(c, now, ns, &req.Build, BuildJob); err != nil {455 return err456 } else if !isNewBuild {457 log.Errorf(c, "job %v: duplicate build %v", jobID, req.Build.ID)458 }459 }460 if job.Log, err = putText(c, ns, textLog, req.Log, false); err != nil {461 return err462 }463 if job.Error, err = putText(c, ns, textError, req.Error, false); err != nil {464 return err465 }466 if job.CrashLog, err = putText(c, ns, textCrashLog, req.CrashLog, false); err != nil {467 return err468 }469 if job.CrashReport, err = putText(c, ns, textCrashReport, req.CrashReport, false); err != nil {470 return err471 }472 for _, com := range req.Commits {473 cc := email.MergeEmailLists(com.CC,474 GetEmails(com.Recipients, dashapi.To),475 GetEmails(com.Recipients, dashapi.Cc))476 job.Commits = append(job.Commits, Commit{477 Hash: com.Hash,478 Title: com.Title,479 Author: com.Author,480 AuthorName: com.AuthorName,481 CC: strings.Join(sanitizeCC(c, cc), "|"),482 Date: com.Date,483 })484 }485 job.BuildID = req.Build.ID486 job.CrashTitle = req.CrashTitle487 job.Finished = now488 job.Flags = JobFlags(req.Flags)489 if job.Type == JobBisectCause || job.Type == JobBisectFix {490 // Update bug.BisectCause/Fix status and also remember current bug reporting to send results.491 if err := updateBugBisection(c, job, jobKey, req, now); err != nil {492 return err493 }494 }495 if _, err := db.Put(c, jobKey, job); err != nil {496 return fmt.Errorf("failed to put job: %v", err)497 }498 log.Infof(c, "DONE JOB %v: reported=%v reporting=%v", jobID, job.Reported, job.Reporting)499 return nil500 }501 return db.RunInTransaction(c, tx, &db.TransactionOptions{XG: true, Attempts: 30})502}503func updateBugBisection(c context.Context, job *Job, jobKey *db.Key, req *dashapi.JobDoneReq, now time.Time) error {504 bug := new(Bug)505 bugKey := jobKey.Parent()506 if err := db.Get(c, bugKey, bug); err != nil {507 return fmt.Errorf("job %v: failed to get bug: %v", req.ID, err)508 }509 result := BisectYes510 if len(req.Error) != 0 {511 result = BisectError512 } else if len(req.Commits) > 1 {513 result = BisectInconclusive514 } else if len(req.Commits) == 0 {515 result = BisectHorizont516 } else if job.isUnreliableBisect() {517 result = BisectUnreliable518 }519 if job.Type == JobBisectCause {520 bug.BisectCause = result521 } else {522 bug.BisectFix = result523 }524 // If the crash still occurs on HEAD, update the bug's LastTime so that it will be525 // retried after 30 days.526 if job.Type == JobBisectFix && req.Error == nil && len(req.Commits) == 0 && len(req.CrashLog) != 0 {527 bug.BisectFix = BisectNot528 bug.LastTime = now529 }530 if _, err := db.Put(c, bugKey, bug); err != nil {531 return fmt.Errorf("failed to put bug: %v", err)532 }533 _, bugReporting, _, _, _ := currentReporting(c, bug)534 // The bug is either already closed or not yet reported in the current reporting,535 // either way we don't need to report it. If it wasn't reported, it will be reported536 // with the bisection results.537 if bugReporting == nil || bugReporting.Reported.IsZero() ||538 // Don't report errors for non-user-initiated jobs.539 job.Error != 0 ||540 // Don't report unreliable/wrong bisections.541 job.isUnreliableBisect() {542 job.Reported = true543 } else {544 job.Reporting = bugReporting.Name545 }546 return nil547}548// TODO: this is temporal for gradual bisection rollout.549// Notify only about successful cause bisection for now.550// For now we only enable this in tests.551var notifyAboutUnsuccessfulBisections = false552func pollCompletedJobs(c context.Context, typ string) ([]*dashapi.BugReport, error) {553 var jobs []*Job554 keys, err := db.NewQuery("Job").555 Filter("Finished>", time.Time{}).556 Filter("Reported=", false).557 GetAll(c, &jobs)558 if err != nil {559 return nil, fmt.Errorf("failed to query jobs: %v", err)560 }561 var reports []*dashapi.BugReport562 for i, job := range jobs {563 if job.Reporting == "" {564 log.Criticalf(c, "no reporting for job %v", extJobID(keys[i]))565 continue566 }567 reporting := config.Namespaces[job.Namespace].ReportingByName(job.Reporting)568 if reporting.Config.Type() != typ {569 continue570 }571 if job.Type == JobBisectCause && !notifyAboutUnsuccessfulBisections && len(job.Commits) != 1 {572 continue573 }574 // If BisectFix results in a crash on HEAD, no notification is sent out.575 if job.Type == JobBisectFix && len(job.Commits) != 1 {576 continue577 }578 // If the bug is already known to be fixed, invalid or duplicate, do not report the bisection results.579 if job.Type == JobBisectCause || job.Type == JobBisectFix {580 bug := new(Bug)581 bugKey := keys[i].Parent()582 if err := db.Get(c, bugKey, bug); err != nil {583 return nil, fmt.Errorf("job %v: failed to get bug: %v", extJobID(keys[i]), err)584 }585 if len(bug.Commits) != 0 || bug.Status != BugStatusOpen {586 jobReported(c, extJobID(keys[i]))587 continue588 }589 }590 rep, err := createBugReportForJob(c, job, keys[i], reporting.Config)591 if err != nil {592 log.Errorf(c, "failed to create report for job: %v", err)593 continue594 }595 reports = append(reports, rep)596 }597 return reports, nil598}599func createBugReportForJob(c context.Context, job *Job, jobKey *db.Key, config interface{}) (600 *dashapi.BugReport, error) {601 reportingConfig, err := json.Marshal(config)602 if err != nil {603 return nil, err604 }605 crashLog, _, err := getText(c, textCrashLog, job.CrashLog)606 if err != nil {607 return nil, err608 }609 report, _, err := getText(c, textCrashReport, job.CrashReport)610 if err != nil {611 return nil, err612 }613 if len(report) > maxMailReportLen {614 report = report[:maxMailReportLen]615 }616 jobError, _, err := getText(c, textError, job.Error)617 if err != nil {618 return nil, err619 }620 build, err := loadBuild(c, job.Namespace, job.BuildID)621 if err != nil {622 return nil, err623 }624 bugKey := jobKey.Parent()625 crashKey := db.NewKey(c, "Crash", "", job.CrashID, bugKey)626 crash := new(Crash)627 if err := db.Get(c, crashKey, crash); err != nil {628 return nil, fmt.Errorf("failed to get crash: %v", err)629 }630 bug := new(Bug)631 if err := db.Get(c, bugKey, bug); err != nil {632 return nil, fmt.Errorf("failed to load job parent bug: %v", err)633 }634 bugReporting := bugReportingByName(bug, job.Reporting)635 if bugReporting == nil {636 return nil, fmt.Errorf("job bug has no reporting %q", job.Reporting)637 }638 kernelRepo := kernelRepoInfo(build)639 rep := &dashapi.BugReport{640 Type: job.Type.toDashapiReportType(),641 Config: reportingConfig,642 JobID: extJobID(jobKey),643 ExtID: job.ExtID,644 CC: append(job.CC, kernelRepo.CC.Always...),645 Log: crashLog,646 LogLink: externalLink(c, textCrashLog, job.CrashLog),647 Report: report,648 ReportLink: externalLink(c, textCrashReport, job.CrashReport),649 ReproCLink: externalLink(c, textReproC, crash.ReproC),650 ReproSyzLink: externalLink(c, textReproSyz, crash.ReproSyz),651 ReproOpts: crash.ReproOpts,652 MachineInfoLink: externalLink(c, textMachineInfo, crash.MachineInfo),653 CrashTitle: job.CrashTitle,654 Error: jobError,655 ErrorLink: externalLink(c, textError, job.Error),656 PatchLink: externalLink(c, textPatch, job.Patch),657 }658 if job.Type == JobBisectCause || job.Type == JobBisectFix {659 rep.Maintainers = append(crash.Maintainers, kernelRepo.CC.Maintainers...)660 rep.ExtID = bugReporting.ExtID661 if bugReporting.CC != "" {662 rep.CC = strings.Split(bugReporting.CC, "|")663 }664 switch job.Type {665 case JobBisectCause:666 rep.BisectCause = bisectFromJob(c, rep, job)667 case JobBisectFix:668 rep.BisectFix = bisectFromJob(c, rep, job)669 }670 }671 if mgr := bug.managerConfig(); mgr != nil {672 rep.CC = append(rep.CC, mgr.CC.Always...)673 if job.Type == JobBisectCause || job.Type == JobBisectFix {674 rep.Maintainers = append(rep.Maintainers, mgr.CC.Maintainers...)675 }676 }677 // Build error output and failing VM boot log can be way too long to inline.678 if len(rep.Error) > maxInlineError {679 rep.Error = rep.Error[len(rep.Error)-maxInlineError:]680 rep.ErrorTruncated = true681 }682 if err := fillBugReport(c, rep, bug, bugReporting, build); err != nil {683 return nil, err684 }685 return rep, nil686}687func bisectFromJob(c context.Context, rep *dashapi.BugReport, job *Job) *dashapi.BisectResult {688 bisect := &dashapi.BisectResult{689 LogLink: externalLink(c, textLog, job.Log),690 CrashLogLink: externalLink(c, textCrashLog, job.CrashLog),691 CrashReportLink: externalLink(c, textCrashReport, job.CrashReport),692 Fix: job.Type == JobBisectFix,693 }694 for _, com := range job.Commits {695 bisect.Commits = append(bisect.Commits, &dashapi.Commit{696 Hash: com.Hash,697 Title: com.Title,698 Author: com.Author,699 AuthorName: com.AuthorName,700 Date: com.Date,701 })702 }703 if len(bisect.Commits) == 1 {704 bisect.Commit = bisect.Commits[0]705 bisect.Commits = nil706 com := job.Commits[0]707 rep.Maintainers = append(rep.Maintainers, com.Author)708 rep.Maintainers = append(rep.Maintainers, strings.Split(com.CC, "|")...)709 }710 return bisect711}712func jobReported(c context.Context, jobID string) error {713 jobKey, err := jobID2Key(c, jobID)714 if err != nil {715 return err716 }717 now := timeNow(c)718 tx := func(c context.Context) error {719 job := new(Job)720 if err := db.Get(c, jobKey, job); err != nil {721 return fmt.Errorf("job %v: failed to get job: %v", jobID, err)722 }723 job.Reported = true724 // Auto-mark the bug as fixed by the result of fix bisection,725 // if the setting is enabled for the namespace.726 if job.Type == JobBisectFix &&727 config.Namespaces[job.Namespace].FixBisectionAutoClose &&728 len(job.Commits) == 1 {729 bug := new(Bug)730 bugKey := jobKey.Parent()731 if err := db.Get(c, bugKey, bug); err != nil {732 return fmt.Errorf("failed to get bug: %v", err)733 }734 if bug.Status == BugStatusOpen && len(bug.Commits) == 0 {735 bug.updateCommits([]string{job.Commits[0].Title}, now)736 if _, err := db.Put(c, bugKey, bug); err != nil {737 return fmt.Errorf("failed to put bug: %v", err)738 }739 }740 }741 if _, err := db.Put(c, jobKey, job); err != nil {742 return fmt.Errorf("failed to put job: %v", err)743 }744 return nil745 }746 return db.RunInTransaction(c, tx, nil)747}748func loadPendingJob(c context.Context, managers map[string]dashapi.ManagerJobs) (*Job, *db.Key, error) {749 var jobs []*Job750 keys, err := db.NewQuery("Job").751 Filter("Finished=", time.Time{}).752 Order("Attempts").753 Order("Created").754 GetAll(c, &jobs)755 if err != nil {756 return nil, nil, fmt.Errorf("failed to query jobs: %v", err)757 }758 for i, job := range jobs {759 switch job.Type {760 case JobTestPatch:761 if !managers[job.Manager].TestPatches {762 continue763 }764 case JobBisectCause, JobBisectFix:765 if job.Type == JobBisectCause && !managers[job.Manager].BisectCause ||766 job.Type == JobBisectFix && !managers[job.Manager].BisectFix {767 continue768 }769 // Don't retry bisection jobs too often.770 // This allows to have several syz-ci's doing bisection771 // and protects from bisection job crashing syz-ci.772 const bisectRepeat = 3 * 24 * time.Hour773 if timeSince(c, job.Created) < bisectRepeat ||774 timeSince(c, job.Started) < bisectRepeat {775 continue776 }777 default:778 return nil, nil, fmt.Errorf("bad job type %v", job.Type)779 }780 return job, keys[i], nil781 }782 return nil, nil, nil783}784func extJobID(jobKey *db.Key) string {785 return fmt.Sprintf("%v|%v", jobKey.Parent().StringID(), jobKey.IntID())786}787func jobID2Key(c context.Context, id string) (*db.Key, error) {788 keyStr := strings.Split(id, "|")789 if len(keyStr) != 2 {790 return nil, fmt.Errorf("bad job id %q", id)791 }792 jobKeyID, err := strconv.ParseInt(keyStr[1], 10, 64)793 if err != nil {794 return nil, fmt.Errorf("bad job id %q", id)795 }796 bugKey := db.NewKey(c, "Bug", keyStr[0], 0, nil)797 jobKey := db.NewKey(c, "Job", "", jobKeyID, bugKey)798 return jobKey, nil...

Full Screen

Full Screen

extJobID

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println(extJobID(1))4}5import "fmt"6func extJobID(jobID int) string {7 return fmt.Sprintf("jobID-%d", jobID)8}9func extJobID(jobID int) string {10 return fmt.Sprintf("jobID-%d", jobID)11}12import (13func main() {14 fmt.Println(yourpackage.ExtJobID(1))15}16import "fmt"17func main() {18 fmt.Println(ExtJobID(1))19}20import "fmt"21func main() {22 fmt.Println(extJobID(1))23}24func extJobID(jobID int) string {25 return fmt.Sprintf("jobID-%d", jobID)26}

Full Screen

Full Screen

extJobID

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println(extJobID)4}5import "fmt"6func main() {7 fmt.Println(extJobID())8}9import "fmt"10func main() {11 fmt.Println(extJobID)12}13import "fmt"14func main() {15 fmt.Println(extJobID())16}17import "fmt"18func main() {19 fmt.Println(extJobID)20}21import "fmt"22func main() {23 fmt.Println(extJobID())24}25import "fmt"26func main() {27 fmt.Println(extJobID)28}29import "fmt"30func main() {31 fmt.Println(extJobID())32}33import "fmt"34func main() {35 fmt.Println(extJobID)36}37import "fmt"38func main() {39 fmt.Println(extJobID())40}41import "fmt"42func main() {43 fmt.Println(extJobID)44}45import "fmt"46func main() {47 fmt.Println(extJobID())48}49import "fmt"50func main() {51 fmt.Println(extJobID)52}53import

Full Screen

Full Screen

extJobID

Using AI Code Generation

copy

Full Screen

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

Full Screen

Full Screen

extJobID

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 fmt.Println("from 2.go")5 fmt.Println("extJobID = ", os.Getenv("extJobID"))6}7import (8func main() {9 fmt.Println("Hello, playground")10 fmt.Println("from 3.go")11 fmt.Println("extJobID = ", os.Getenv("extJobID"))12}13import (14func main() {15 fmt.Println("Hello, playground")16 fmt.Println("from 4.go")17 fmt.Println("extJobID = ", os.Getenv("extJobID"))18}19import (20func main() {21 fmt.Println("Hello, playground")22 fmt.Println("from 5.go")23 fmt.Println("extJobID = ", os.Getenv("extJobID"))24}25import (26func main() {27 fmt.Println("Hello, playground")28 fmt.Println("from 6.go")29 fmt.Println("extJobID = ", os.Getenv("extJobID"))30}31import (32func main() {33 fmt.Println("Hello, playground")34 fmt.Println("from 7.go")35 fmt.Println("extJobID = ", os.Getenv("extJobID"))36}37import (38func main() {39 fmt.Println("Hello, playground")40 fmt.Println("from 8.go")41 fmt.Println("extJobID = ", os.Getenv("extJobID"))42}43import (44func main() {45 fmt.Println("Hello, playground")46 fmt.Println("from 9.go")47 fmt.Println("extJob

Full Screen

Full Screen

extJobID

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 a.extJobID()5}6import (7func main() {8 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {9 fmt.Fprintf(w, "Hello, you've requested: %s10 })11 http.ListenAndServe(":8080", nil)12}13I have a package called "http" in my GOPATH/src directory. I want to use it in my application. I have a file called http.go in my package directory. I want to import the package and use it in my application. I have tried the following code:14import (15func main() {16 fmt.Println("Hello, playground")17}18 /usr/local/go/src/http (from $GOROOT)19 /home/username/go/src/http (from $GOPATH)20 /usr/local/go/src/fmt (from $GOROOT)21 /home/username/go/src/fmt (from $GOPATH)22import (23func main() {24 fmt.Println("Hello, playground")25}

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.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful