From cbd0445ec3b0b184db66966d8a47e6b37d13692e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 25 Nov 2020 09:17:50 +0100 Subject: all: make timeouts configurable Add sys/targets.Timeouts struct that parametrizes timeouts throughout the system. The struct allows to control syscall/program/no output timeouts for OS/arch/VM/etc. See comment on the struct for more details. --- pkg/csource/csource.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pkg/csource/csource.go') diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index b53b3b97f..a01141567 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -29,6 +29,7 @@ import ( "regexp" "sort" "strings" + "time" "github.com/google/syzkaller/prog" "github.com/google/syzkaller/sys/targets" @@ -93,11 +94,12 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) { replacements["SANDBOX_FUNC"] = replacements["SYSCALLS"] replacements["SYSCALLS"] = "unused" } - replacements["PROGRAM_TIMEOUT_MS"] = "5000" - timeoutExpr := "45" + timeouts := ctx.sysTarget.Timeouts(opts.Slowdown) + replacements["PROGRAM_TIMEOUT_MS"] = fmt.Sprint(int(timeouts.Program / time.Millisecond)) + timeoutExpr := fmt.Sprint(int(timeouts.Syscall / time.Millisecond)) for i, call := range p.Calls { if timeout := call.Meta.Attrs.Timeout; timeout != 0 { - timeoutExpr += fmt.Sprintf(" + (call == %d ? %d : 0)", i, timeout) + timeoutExpr += fmt.Sprintf(" + (call == %v ? %v : 0)", i, timeout*uint64(timeouts.Scale)) } } replacements["CALL_TIMEOUT_MS"] = timeoutExpr -- cgit mrf-deployment