diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-06-30 14:52:58 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-06-30 15:09:57 +0200 |
| commit | c2028e38d2d92ebad25b9d41b3bc8eb50f2718ab (patch) | |
| tree | 15fb6d85754033b1ed6dc8ad8e897832a0e34ba7 /pkg | |
| parent | 909ccbe28fb62774ef7cb0f035ab9cf41927c06a (diff) | |
pkg/report: change arg of ExtractGuiltyFile to []byte
We usually store reports as []byte, not as string. They can be large.
So change arg type to []byte.
Also rename it from log to report. In our terminology log is
not symblized/processed crash output. What this function wants
is called report in manager.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/report/guilty.go | 11 | ||||
| -rw-r--r-- | pkg/report/guilty_test.go | 8 |
2 files changed, 10 insertions, 9 deletions
diff --git a/pkg/report/guilty.go b/pkg/report/guilty.go index 272f63063..41dc65cbd 100644 --- a/pkg/report/guilty.go +++ b/pkg/report/guilty.go @@ -4,6 +4,7 @@ package report import ( + "bytes" "net/mail" "regexp" "strings" @@ -34,17 +35,17 @@ var ( } ) -func extractFiles(log string) []string { - matches := filename.FindAllString(log, -1) +func extractFiles(report []byte) []string { + matches := filename.FindAll(report, -1) var files []string for _, match := range matches { - files = append(files, strings.Split(match, ":")[0]) + files = append(files, string(bytes.Split(match, []byte{':'})[0])) } return files } -func ExtractGuiltyFile(log string) string { - files := extractFiles(log) +func ExtractGuiltyFile(report []byte) string { + files := extractFiles(report) nextFile: for _, file := range files { for _, re := range blacklist { diff --git a/pkg/report/guilty_test.go b/pkg/report/guilty_test.go index 2f4b9c244..1138f7a6c 100644 --- a/pkg/report/guilty_test.go +++ b/pkg/report/guilty_test.go @@ -703,10 +703,10 @@ Call Trace: [<ffffffff827436ac>] nf_sockopt net/netfilter/nf_sockopt.c:105 [inline] `: `net/netfilter/x_tables.c`, } - for log, guilty0 := range tests { - if guilty := ExtractGuiltyFile(log); guilty != guilty0 { - t.Logf("log:\n%s", log) - t.Logf("extracted files:\n%s", extractFiles(log)) + for report, guilty0 := range tests { + if guilty := ExtractGuiltyFile([]byte(report)); guilty != guilty0 { + t.Logf("log:\n%s", report) + t.Logf("extracted files:\n%s", extractFiles([]byte(report))) t.Logf("want guilty:\n%s", guilty0) t.Logf("got guilty:\n%s", guilty) t.Fatalf("couldn't extract guilty file") |
