aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-10-26 10:51:06 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-10-26 15:44:28 +0100
commite6e35dba937599d098fc034eff2686e5ddc409e9 (patch)
tree802be708d0bc84dee01b9285639690a53f1f6f94 /dashboard
parentd46bc75207fea1d7671c1277dd660cf1a4d7847b (diff)
sys/targets: add OS/Arch name consts
We use strings to identify OS/Arch. These strings are duplicated throughout the code base massively. golangci-lint points to possiblity of typos and duplication. We already had to define these names in pkg/csource and disable checking for prog package. A future change triggers such warnings in another package. Add OS/Arch name consts to sys/targets so that they can be used to refer to OS/Arch. Use the consts everywhere.
Diffstat (limited to 'dashboard')
-rw-r--r--dashboard/app/api.go3
-rw-r--r--dashboard/app/app_test.go7
-rw-r--r--dashboard/app/email_test.go3
-rw-r--r--dashboard/app/reporting.go5
-rw-r--r--dashboard/app/reporting_test.go13
5 files changed, 18 insertions, 13 deletions
diff --git a/dashboard/app/api.go b/dashboard/app/api.go
index 73a802d61..f802603d8 100644
--- a/dashboard/app/api.go
+++ b/dashboard/app/api.go
@@ -19,6 +19,7 @@ import (
"github.com/google/syzkaller/dashboard/dashapi"
"github.com/google/syzkaller/pkg/email"
"github.com/google/syzkaller/pkg/hash"
+ "github.com/google/syzkaller/sys/targets"
"golang.org/x/net/context"
"google.golang.org/appengine"
db "google.golang.org/appengine/datastore"
@@ -784,7 +785,7 @@ func saveCrash(c context.Context, ns string, req *dashapi.Crash, bugKey *db.Key,
} else if len(req.ReproSyz) != 0 {
prio += 2e12
}
- if build.Arch == "amd64" {
+ if build.Arch == targets.AMD64 {
prio += 1e3
}
crash := &Crash{
diff --git a/dashboard/app/app_test.go b/dashboard/app/app_test.go
index 95b313306..3f80e5a16 100644
--- a/dashboard/app/app_test.go
+++ b/dashboard/app/app_test.go
@@ -13,6 +13,7 @@ import (
"time"
"github.com/google/syzkaller/dashboard/dashapi"
+ "github.com/google/syzkaller/sys/targets"
"google.golang.org/appengine/user"
)
@@ -287,9 +288,9 @@ func testBuild(id int) *dashapi.Build {
return &dashapi.Build{
Manager: fmt.Sprintf("manager%v", id),
ID: fmt.Sprintf("build%v", id),
- OS: "linux",
- Arch: "amd64",
- VMArch: "amd64",
+ OS: targets.Linux,
+ Arch: targets.AMD64,
+ VMArch: targets.AMD64,
SyzkallerCommit: fmt.Sprintf("syzkaller_commit%v", id),
CompilerID: fmt.Sprintf("compiler%v", id),
KernelRepo: fmt.Sprintf("repo%v", id),
diff --git a/dashboard/app/email_test.go b/dashboard/app/email_test.go
index 2e73e61f3..e3eae3944 100644
--- a/dashboard/app/email_test.go
+++ b/dashboard/app/email_test.go
@@ -11,6 +11,7 @@ import (
"github.com/google/syzkaller/dashboard/dashapi"
"github.com/google/syzkaller/pkg/email"
+ "github.com/google/syzkaller/sys/targets"
)
// nolint: funlen
@@ -121,7 +122,7 @@ For more options, visit https://groups.google.com/d/optout.
// Now report syz reproducer and check updated email.
build2 := testBuild(10)
- build2.Arch = "386"
+ build2.Arch = targets.I386
build2.KernelRepo = testConfig.Namespaces["test2"].Repos[0].URL
build2.KernelBranch = testConfig.Namespaces["test2"].Repos[0].Branch
build2.KernelCommitTitle = "a really long title, longer than 80 chars, really long-long-long-long-long-long title"
diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go
index 54ad38cdd..35a050fcb 100644
--- a/dashboard/app/reporting.go
+++ b/dashboard/app/reporting.go
@@ -15,6 +15,7 @@ import (
"github.com/google/syzkaller/dashboard/dashapi"
"github.com/google/syzkaller/pkg/email"
"github.com/google/syzkaller/pkg/html"
+ "github.com/google/syzkaller/sys/targets"
"golang.org/x/net/context"
db "google.golang.org/appengine/datastore"
"google.golang.org/appengine/log"
@@ -1175,9 +1176,9 @@ func (a bugReportSorter) Less(i, j int) bool {
// Currently Linux-specific.
func kernelArch(arch string) string {
switch arch {
- case "386":
+ case targets.I386:
return "i386"
- case "amd64":
+ case targets.AMD64:
return "" // this is kinda the default, so we don't notify about it
default:
return arch
diff --git a/dashboard/app/reporting_test.go b/dashboard/app/reporting_test.go
index 1aa7a4979..7be5e023f 100644
--- a/dashboard/app/reporting_test.go
+++ b/dashboard/app/reporting_test.go
@@ -10,6 +10,7 @@ import (
"time"
"github.com/google/syzkaller/dashboard/dashapi"
+ "github.com/google/syzkaller/sys/targets"
)
func TestReportBug(t *testing.T) {
@@ -45,9 +46,9 @@ func TestReportBug(t *testing.T) {
Namespace: "test1",
Config: []byte(`{"Index":1}`),
ID: rep.ID,
- OS: "linux",
- Arch: "amd64",
- VMArch: "amd64",
+ OS: targets.Linux,
+ Arch: targets.AMD64,
+ VMArch: targets.AMD64,
First: true,
Moderation: true,
Title: "title1",
@@ -208,9 +209,9 @@ func TestInvalidBug(t *testing.T) {
Namespace: "test1",
Config: []byte(`{"Index":1}`),
ID: rep.ID,
- OS: "linux",
- Arch: "amd64",
- VMArch: "amd64",
+ OS: targets.Linux,
+ Arch: targets.AMD64,
+ VMArch: targets.AMD64,
First: true,
Moderation: true,
Title: "title1 (2)",