diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-06-14 10:18:10 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-06-14 10:18:10 +0200 |
| commit | 54e36636a1909c1b0efdf11d80e168afdc045d9d (patch) | |
| tree | b30d2f58c88199d26a5a25750096c8e450993fab | |
| parent | b41e96b421acda1761e9ba2ee17da16efad436cd (diff) | |
syz-dash: move patch parsing to pkg/kernel
Patch parsing is not dashboard-specific and can
be reused by other programs.
| -rw-r--r-- | pkg/kernel/patch.go (renamed from syz-dash/patch.go) | 4 | ||||
| -rw-r--r-- | pkg/kernel/patch_test.go (renamed from syz-dash/patch_test.go) | 4 | ||||
| -rw-r--r-- | syz-dash/handler.go | 3 |
3 files changed, 6 insertions, 5 deletions
diff --git a/syz-dash/patch.go b/pkg/kernel/patch.go index fe713b063..b8e30dbec 100644 --- a/syz-dash/patch.go +++ b/pkg/kernel/patch.go @@ -1,7 +1,7 @@ // 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. -package dash +package kernel import ( "bufio" @@ -9,7 +9,7 @@ import ( "strings" ) -func parsePatch(text string) (title string, diff string, err error) { +func ParsePatch(text string) (title string, diff string, err error) { s := bufio.NewScanner(strings.NewReader(text)) parsingDiff := false diffStarted := false diff --git a/syz-dash/patch_test.go b/pkg/kernel/patch_test.go index e36d068d5..360583693 100644 --- a/syz-dash/patch_test.go +++ b/pkg/kernel/patch_test.go @@ -1,7 +1,7 @@ // 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. -package dash +package kernel import ( "testing" @@ -10,7 +10,7 @@ import ( func TestParsePatch(t *testing.T) { for _, test := range tests { t.Run(test.title, func(t *testing.T) { - title, diff, err := parsePatch(test.text) + title, diff, err := ParsePatch(test.text) if err != nil { t.Fatalf("failed to parse patch: %v", err) } diff --git a/syz-dash/handler.go b/syz-dash/handler.go index 3d0d9a6a7..e0dd2a807 100644 --- a/syz-dash/handler.go +++ b/syz-dash/handler.go @@ -16,6 +16,7 @@ import ( "strings" "time" + "github.com/google/syzkaller/pkg/kernel" "appengine" ds "appengine/datastore" "appengine/user" @@ -412,7 +413,7 @@ func handleBug(c appengine.Context, w http.ResponseWriter, r *http.Request) erro } dropCached(c) case "Add patch": - title, diff, err := parsePatch(r.FormValue("patch")) + title, diff, err := kernel.ParsePatch(r.FormValue("patch")) if err != nil { return fmt.Errorf("failed to parse patch: %v", err) } |
