aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-testbed
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-10-03 17:43:17 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-10-11 11:58:06 +0000
commitd041766f6c33a373e0064b832cc4e7a4401b3659 (patch)
treeba008da309760c5e88859ada245225d01769c15c /tools/syz-testbed
parent5e7b4bcaa61e8bb9b1d1fbca21684fe490f69133 (diff)
pkg/manager: factor out the crash storage functionality
It reduces the size of the syz-manager/ code and makes it testable. Use it in syz-testbed.
Diffstat (limited to 'tools/syz-testbed')
-rw-r--r--tools/syz-testbed/stats.go32
1 files changed, 7 insertions, 25 deletions
diff --git a/tools/syz-testbed/stats.go b/tools/syz-testbed/stats.go
index 185156a5d..6044bfe3d 100644
--- a/tools/syz-testbed/stats.go
+++ b/tools/syz-testbed/stats.go
@@ -8,10 +8,9 @@ import (
"fmt"
"os"
"path/filepath"
- "strings"
"time"
- "github.com/google/syzkaller/pkg/osutil"
+ "github.com/google/syzkaller/pkg/manager"
"github.com/google/syzkaller/pkg/stat/sample"
)
@@ -51,33 +50,16 @@ type StatView struct {
Groups []RunResultGroup
}
-// TODO: we're implementing this functionaity at least the 3rd time (see syz-manager/html
-// and tools/reporter). Create a more generic implementation and put it into a globally
-// visible package.
func collectBugs(workdir string) ([]BugInfo, error) {
- crashdir := filepath.Join(workdir, "crashes")
- dirs, err := osutil.ListDir(crashdir)
+ list, err := manager.ReadCrashStore(workdir).BugList()
if err != nil {
return nil, err
}
- bugs := []BugInfo{}
- for _, dir := range dirs {
- bugFolder := filepath.Join(crashdir, dir)
- titleBytes, err := os.ReadFile(filepath.Join(bugFolder, "description"))
- if err != nil {
- return nil, err
- }
- bug := BugInfo{
- Title: strings.TrimSpace(string(titleBytes)),
- }
- files, err := os.ReadDir(bugFolder)
- if err != nil {
- return nil, err
- }
- for _, f := range files {
- if strings.HasPrefix(f.Name(), "log") {
- bug.Logs = append(bug.Logs, filepath.Join(bugFolder, f.Name()))
- }
+ var bugs []BugInfo
+ for _, info := range list {
+ bug := BugInfo{Title: info.Title}
+ for _, crash := range info.Crashes {
+ bug.Logs = append(bug.Logs, filepath.Join(workdir, crash.Log))
}
bugs = append(bugs, bug)
}