From 88f59346334b1ec60ea3cc78af174856aee31866 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 24 Dec 2018 09:41:43 +0100 Subject: vm: allow fine-grained control over program exit conditions Currently we only support canExit flag. However there are actually 3 separate conditions: - program can exit normally - program can timeout (e.g. fuzzer test or runtest can't) - program can exit with error (e.g. C test can) Allow to specify these 3 conditions separately. --- pkg/instance/instance.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pkg/instance') diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 1d35efa75..64d135429 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -265,11 +265,11 @@ func (inst *inst) testInstance() error { cmd := FuzzerCmd(fuzzerBin, executorBin, "test", inst.cfg.TargetOS, inst.cfg.TargetArch, fwdAddr, inst.cfg.Sandbox, 0, 0, false, false, true, false) - outc, errc, err := inst.vm.Run(5*time.Minute, nil, cmd) + outc, errc, err := inst.vm.Run(10*time.Minute, nil, cmd) if err != nil { return fmt.Errorf("failed to run binary in VM: %v", err) } - rep := inst.vm.MonitorExecution(outc, errc, inst.reporter, true) + rep := inst.vm.MonitorExecution(outc, errc, inst.reporter, vm.ExitNormal) if rep != nil { if err := inst.reporter.Symbolize(rep); err != nil { // TODO(dvyukov): send such errors to dashboard. @@ -350,7 +350,8 @@ func (inst *inst) testProgram(command string, testTime time.Duration) error { if err != nil { return fmt.Errorf("failed to run binary in VM: %v", err) } - rep := inst.vm.MonitorExecution(outc, errc, inst.reporter, true) + rep := inst.vm.MonitorExecution(outc, errc, inst.reporter, + vm.ExitTimeout|vm.ExitNormal|vm.ExitError) if rep == nil { return nil } -- cgit mrf-deployment