diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-09-01 12:11:42 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2023-09-06 10:29:02 +0000 |
| commit | 8c6013de89e4280c27344f6180db06ae27b7749f (patch) | |
| tree | 237fca72b2999e8b8917bbbeb4de8c3c8f76703e /pkg/email | |
| parent | 736a3c37c74cb6da919ca7d68f3c1e2a2d2b62a7 (diff) | |
dashboard: auto-guess kernel and repo for #syz test
We used to support this only for external reportings, but let's
auto-guess these parameters for all incoming patch testing commands.
Diffstat (limited to 'pkg/email')
| -rw-r--r-- | pkg/email/parser.go | 23 | ||||
| -rw-r--r-- | pkg/email/parser_test.go | 15 |
2 files changed, 29 insertions, 9 deletions
diff --git a/pkg/email/parser.go b/pkg/email/parser.go index 2ed9495fd..efc63391b 100644 --- a/pkg/email/parser.go +++ b/pkg/email/parser.go @@ -296,13 +296,21 @@ func extractCommand(body string) (*SingleCommand, int) { // For "fix:"/"dup:" we need a whole non-empty line of text. switch cmd { case CmdTest: - args = extractArgsTokens(body[cmdPos+cmdEnd:], 2) + if strings.HasSuffix(str, ":") { + // For "#syz test:", we do want to query 2 arguments. + args = extractArgsTokens(body[cmdPos+cmdEnd:], 2) + } else { + // For "#syz test", it's likely there won't be anything else, so let's only parse + // the first line. + fmt.Printf("line: %s", body[cmdPos+cmdEnd:]) + args = extractArgsLine(body[cmdPos+cmdEnd:], false) + } case CmdSet, CmdUnset: - args = extractArgsLine(body[cmdPos+cmdEnd:]) + args = extractArgsLine(body[cmdPos+cmdEnd:], true) case cmdTest5: args = extractArgsTokens(body[cmdPos+cmdEnd:], 5) case CmdFix, CmdDup: - args = extractArgsLine(body[cmdPos+cmdEnd:]) + args = extractArgsLine(body[cmdPos+cmdEnd:], true) } return &SingleCommand{ Command: cmd, @@ -365,11 +373,12 @@ func extractArgsTokens(body string, num int) string { return strings.TrimSpace(strings.Join(args, " ")) } -func extractArgsLine(body string) string { +func extractArgsLine(body string, skipWs bool) string { pos := 0 - for pos < len(body) && (body[pos] == ' ' || body[pos] == '\t' || - body[pos] == '\n' || body[pos] == '\r') { - pos++ + if skipWs { + for pos < len(body) && unicode.IsSpace(rune(body[pos])) { + pos++ + } } lineEnd := strings.IndexByte(body[pos:], '\n') if lineEnd == -1 { diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go index 0d3c54c87..239b795a3 100644 --- a/pkg/email/parser_test.go +++ b/pkg/email/parser_test.go @@ -217,7 +217,8 @@ git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core cmd: &SingleCommand{ Command: CmdTest, Str: "test", - Args: "git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core", + // We only look for arguments if there's ":" after "#syz test". + Args: "", }, }, { @@ -250,6 +251,16 @@ locking/core }, }, { + body: `#syz test +patch-begins +`, + cmd: &SingleCommand{ + Command: CmdTest, + Str: "test", + Args: "", + }, + }, + { body: ` #syz test_5_arg_cmd arg1 @@ -696,7 +707,7 @@ index 3d85747bd86e..a257b872a53d 100644 { Command: CmdTest, Str: "test", - Args: "commit 59372bbf3abd5b24a7f6f676a3968685c280f955", + Args: "", }, }, }}, |
