diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2022-04-06 11:32:21 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2022-04-06 17:14:35 +0200 |
| commit | 4a7cb474c2f19630d8b1c2609f69ea25f249d535 (patch) | |
| tree | 688e6ea3f8928ce50629506ddcd69cc4303c7de5 /pkg | |
| parent | 86b4b7f81837a5f26db1e1e2cbbefc7c3885fb08 (diff) | |
pkg/instance: explicitly specify optional fuzzer arguments
Otherwise we get problems while testing patches for older syzkaller
versions, which didn't support optional arguments.
Adjust tests so that problems with how OldFuzzerCmd handles such
arguments could be seen.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/instance/instance.go | 29 | ||||
| -rw-r--r-- | pkg/instance/instance_test.go | 2 |
2 files changed, 18 insertions, 13 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index c225f9696..e670a2c64 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -437,6 +437,11 @@ func (inst *inst) testProgram(command string, testTime time.Duration) error { return &CrashError{Report: rep} } +type OptionalFuzzerArgs struct { + Slowdown int + RawCover bool +} + type FuzzerCmdArgs struct { Fuzzer string Executor string @@ -451,8 +456,7 @@ type FuzzerCmdArgs struct { Debug bool Test bool Runtest bool - Slowdown int - RawCover bool + Optional *OptionalFuzzerArgs } func FuzzerCmd(args *FuzzerCmdArgs) string { @@ -471,16 +475,13 @@ func FuzzerCmd(args *FuzzerCmdArgs) string { if args.Verbosity != 0 { verbosityArg = fmt.Sprintf(" -vv=%v", args.Verbosity) } - flags := []tool.Flag{} - if args.Slowdown > 0 { - flags = append(flags, tool.Flag{Name: "slowdown", Value: fmt.Sprint(args.Slowdown)}) - } - if args.RawCover { - flags = append(flags, tool.Flag{Name: "raw_cover", Value: "true"}) - } optionalArg := "" - if len(flags) > 0 { - optionalArg += " " + tool.OptionalFlags(flags) + if args.Optional != nil { + flags := []tool.Flag{ + {Name: "slowdown", Value: fmt.Sprint(args.Optional.Slowdown)}, + {Name: "raw_cover", Value: fmt.Sprint(args.Optional.RawCover)}, + } + optionalArg = " " + tool.OptionalFlags(flags) } return fmt.Sprintf("%v -executor=%v -name=%v -arch=%v%v -manager=%v -sandbox=%v"+ " -procs=%v -cover=%v -debug=%v -test=%v%v%v%v", @@ -490,10 +491,14 @@ func FuzzerCmd(args *FuzzerCmdArgs) string { func OldFuzzerCmd(fuzzer, executor, name, OS, arch, fwdAddr, sandbox string, procs int, cover, test, optionalFlags bool, slowdown int) string { + var optional *OptionalFuzzerArgs + if optionalFlags { + optional = &OptionalFuzzerArgs{Slowdown: slowdown} + } return FuzzerCmd(&FuzzerCmdArgs{Fuzzer: fuzzer, Executor: executor, Name: name, OS: OS, Arch: arch, FwdAddr: fwdAddr, Sandbox: sandbox, Procs: procs, Verbosity: 0, Cover: cover, Debug: false, Test: test, Runtest: false, - Slowdown: slowdown}) + Optional: optional}) } func ExecprogCmd(execprog, executor, OS, arch, sandbox string, repeat, threaded, collide bool, diff --git a/pkg/instance/instance_test.go b/pkg/instance/instance_test.go index 92903512c..2f5c08625 100644 --- a/pkg/instance/instance_test.go +++ b/pkg/instance/instance_test.go @@ -33,7 +33,7 @@ func TestFuzzerCmd(t *testing.T) { flagDebug := flags.Bool("debug", false, "debug output from executor") flagV := flags.Int("v", 0, "verbosity") cmdLine := OldFuzzerCmd(os.Args[0], "/myexecutor", "myname", targets.Linux, targets.I386, "localhost:1234", - "namespace", 3, true, true, false, 0) + "namespace", 3, true, true, false, 5) args := strings.Split(cmdLine, " ")[1:] if err := flags.Parse(args); err != nil { t.Fatal(err) |
