aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2024-07-10 18:07:37 +0200
committerTaras Madan <tarasmadan@google.com>2024-07-15 20:31:23 +0000
commit626375c87b8c76fa305742f4dceefccde55245b2 (patch)
treef75b0c3210c7f9d3390bebbdfffd66c8058652d5 /tools
parent4178f02a1cc67951c9573229e920860d86049d57 (diff)
all: add the coverage map visualization to syz-cover
Diffstat (limited to 'tools')
-rw-r--r--tools/syz-cover/syz-cover.go49
1 files changed, 39 insertions, 10 deletions
diff --git a/tools/syz-cover/syz-cover.go b/tools/syz-cover/syz-cover.go
index def54d549..bf1c02ae4 100644
--- a/tools/syz-cover/syz-cover.go
+++ b/tools/syz-cover/syz-cover.go
@@ -29,7 +29,9 @@ import (
"os/exec"
"strconv"
"strings"
+ "time"
+ "cloud.google.com/go/civil"
"github.com/google/syzkaller/pkg/cover"
"github.com/google/syzkaller/pkg/mgrconfig"
"github.com/google/syzkaller/pkg/osutil"
@@ -37,18 +39,45 @@ import (
"github.com/google/syzkaller/pkg/vminfo"
)
+var (
+ flagConfig = flag.String("config", "", "configuration file")
+ flagModules = flag.String("modules", "",
+ "modules JSON info obtained from /modules (optional)")
+ flagExportCSV = flag.String("csv", "", "export coverage data in csv format (optional)")
+ flagExportLineJSON = flag.String("json", "", "export coverage data with source line info in json format (optional)")
+ flagExportJSONL = flag.String("jsonl", "", "export jsonl coverage data (optional)")
+ flagExportHTML = flag.String("html", "", "save coverage HTML report to file (optional)")
+ flagNsHeatmap = flag.String("heatmap", "", "generate namespace heatmap")
+ flagDateFrom = flag.String("from",
+ civil.DateOf(time.Now().Add(-14*24*time.Hour)).String(), "heatmap date from(optional)")
+ flagDateTo = flag.String("to",
+ civil.DateOf(time.Now()).String(), "heatmap date to(optional)")
+)
+
+func toolBuildNsHeatmap() {
+ buf := new(bytes.Buffer)
+ var dateFrom, dateTo civil.Date
+ var err error
+ if dateFrom, err = civil.ParseDate(*flagDateFrom); err != nil {
+ tool.Failf("failed to parse date from: %v", err.Error())
+ }
+ if dateTo, err = civil.ParseDate(*flagDateTo); err != nil {
+ tool.Failf("failed to parse date to: %v", err.Error())
+ }
+ if err = cover.DoHeatMap(buf, *flagNsHeatmap, dateFrom, dateTo); err != nil {
+ tool.Fail(err)
+ }
+ if err = osutil.WriteFile(*flagNsHeatmap+".html", buf.Bytes()); err != nil {
+ tool.Fail(err)
+ }
+}
+
func main() {
- var (
- flagConfig = flag.String("config", "", "configuration file")
- flagModules = flag.String("modules", "",
- "modules JSON info obtained from /modules (optional)")
- flagExportCSV = flag.String("csv", "", "export coverage data in csv format (optional)")
- flagExportLineJSON = flag.String("json", "", "export coverage data with source line info in json format (optional)")
- flagExportJSONL = flag.String("jsonl", "", "export jsonl coverage data (optional)")
- flagExportHTML = flag.String("html", "", "save coverage HTML report to file (optional)")
- )
defer tool.Init()()
-
+ if *flagNsHeatmap != "" {
+ toolBuildNsHeatmap()
+ return
+ }
cfg, err := mgrconfig.LoadFile(*flagConfig)
if err != nil {
tool.Fail(err)