aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-02-17 22:09:35 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-02-17 22:22:01 +0100
commit19d8bc6235424c4b1734ded2f3cf723639bc2608 (patch)
tree9f3f32ce310132cdcec13440b9c515af070e4f84 /tools
parentd8f047b7fb21efcf610167cd6c72f0942a4f852d (diff)
syz-dash: first version of dashboard app
syz-dash is an appengine app that aggregates crashes from multiple managers. Very early version, still flashing out required functionality.
Diffstat (limited to 'tools')
-rw-r--r--tools/syz-dashtool/dashtool.go121
1 files changed, 121 insertions, 0 deletions
diff --git a/tools/syz-dashtool/dashtool.go b/tools/syz-dashtool/dashtool.go
new file mode 100644
index 000000000..d3d37c7b6
--- /dev/null
+++ b/tools/syz-dashtool/dashtool.go
@@ -0,0 +1,121 @@
+// Copyright 2017 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+// syz-dashtool allow to upload a single crash or all crashes in workdir
+// to a dashboard for testing.
+package main
+
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+
+ "github.com/google/syzkaller/dashboard"
+)
+
+var (
+ flagAddr = flag.String("addr", "", "dashboard address")
+ flagClient = flag.String("client", "", "dashboard client")
+ flagKey = flag.String("key", "", "dashboard key")
+)
+
+func main() {
+ flag.Parse()
+ if *flagAddr == "" || *flagClient == "" || *flagKey == "" {
+ fmt.Fprintf(os.Stderr, "addr/client/key flags are mandatory\n")
+ flag.PrintDefaults()
+ os.Exit(1)
+ }
+ dash := &dashboard.Dashboard{
+ Addr: *flagAddr,
+ Client: *flagClient,
+ Key: *flagKey,
+ }
+ if len(flag.Args()) == 0 {
+ fmt.Fprintf(os.Stderr, "specify command: report, report-all\n")
+ os.Exit(1)
+ }
+ switch flag.Args()[0] {
+ case "report":
+ if len(flag.Args()) != 2 {
+ fmt.Fprintf(os.Stderr, "usage: report logN\n")
+ os.Exit(1)
+ }
+ report(dash, flag.Args()[1])
+ case "report-all":
+ if len(flag.Args()) != 2 {
+ fmt.Fprintf(os.Stderr, "usage: report-all workdir/crashes\n")
+ os.Exit(1)
+ }
+ reportAll(dash, flag.Args()[1])
+ default:
+ fmt.Fprintf(os.Stderr, "unknown command: %v\n", flag.Args()[0])
+ os.Exit(1)
+ }
+}
+
+func report(dash *dashboard.Dashboard, logfile string) {
+ n := -1
+ for i := range logfile {
+ x, err := strconv.Atoi(logfile[i:])
+ if err == nil {
+ n = x
+ break
+ }
+ }
+ if n == -1 {
+ fmt.Fprintf(os.Stderr, "bad log file name\n")
+ os.Exit(1)
+ }
+ dir := filepath.Dir(logfile)
+
+ log, err := ioutil.ReadFile(logfile)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to read log file: %v\n", err)
+ os.Exit(1)
+ }
+ desc, err := ioutil.ReadFile(filepath.Join(dir, "description"))
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to description file: %v\n", err)
+ os.Exit(1)
+ }
+ tag, _ := ioutil.ReadFile(filepath.Join(dir, fmt.Sprintf("tag%v", n)))
+ report, _ := ioutil.ReadFile(filepath.Join(dir, fmt.Sprintf("report%v", n)))
+
+ crash := &dashboard.Crash{
+ Tag: string(tag),
+ Desc: string(desc),
+ Log: log,
+ Report: report,
+ }
+
+ if err := dash.ReportCrash(crash); err != nil {
+ fmt.Fprintf(os.Stderr, "failed: %v\n", err)
+ os.Exit(1)
+ }
+}
+
+func reportAll(dash *dashboard.Dashboard, crashes string) {
+ dirs, err := ioutil.ReadDir(crashes)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to read crashes dir: %v\n", err)
+ os.Exit(1)
+ }
+ for _, dir := range dirs {
+ files, err := ioutil.ReadDir(filepath.Join(crashes, dir.Name()))
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "failed to read crashes dir: %v\n", err)
+ os.Exit(1)
+ }
+ for _, file := range files {
+ if !strings.HasPrefix(file.Name(), "log") {
+ continue
+ }
+ report(dash, filepath.Join(crashes, dir.Name(), file.Name()))
+ }
+ }
+}