diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-09-24 17:22:33 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-09-25 09:06:08 +0000 |
| commit | 0b45cac3dc627e9b6702daf3d578d970440972e9 (patch) | |
| tree | bdb64625a2b3e3d45bb7b788ea540ed0b485d2c9 /pkg/instance/instance.go | |
| parent | 1763a1862f3468b4b1a5cedef9d61ddd8d0e58e8 (diff) | |
pkg/instance: refactor ExecprogCmd
Reduce the number of arguments by using a csource.Option value directly.
Diffstat (limited to 'pkg/instance/instance.go')
| -rw-r--r-- | pkg/instance/instance.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index ef8860330..e4415a86e 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -442,11 +442,10 @@ func (inst *inst) csourceOptions() (csource.Options, error) { return opts, nil } -func ExecprogCmd(execprog, executor, OS, arch, vmType, sandbox string, sandboxArg int, repeat, - threaded, collide bool, procs, faultCall, faultNth int, optionalFlags bool, slowdown int, - progFile string) string { +func ExecprogCmd(execprog, executor, OS, arch, vmType string, opts csource.Options, + optionalFlags bool, slowdown int, progFile string) string { repeatCount := 1 - if repeat { + if opts.Repeat { repeatCount = 0 } osArg := "" @@ -454,24 +453,21 @@ func ExecprogCmd(execprog, executor, OS, arch, vmType, sandbox string, sandboxAr osArg = " -os=" + OS } optionalArg := "" - - if faultCall >= 0 { + if opts.Fault && opts.FaultCall >= 0 { optionalArg = fmt.Sprintf(" -fault_call=%v -fault_nth=%v", - faultCall, faultNth) + opts.FaultCall, opts.FaultNth) } - if optionalFlags { optionalArg += " " + tool.OptionalFlags([]tool.Flag{ {Name: "slowdown", Value: fmt.Sprint(slowdown)}, - {Name: "sandboxArg", Value: fmt.Sprint(sandboxArg)}, + {Name: "sandboxArg", Value: fmt.Sprint(opts.SandboxArg)}, {Name: "type", Value: fmt.Sprint(vmType)}, }) } - return fmt.Sprintf("%v -executor=%v -arch=%v%v -sandbox=%v"+ " -procs=%v -repeat=%v -threaded=%v -collide=%v -cover=0%v %v", - execprog, executor, arch, osArg, sandbox, - procs, repeatCount, threaded, collide, + execprog, executor, arch, osArg, opts.Sandbox, + opts.Procs, repeatCount, opts.Threaded, opts.Collide, optionalArg, progFile) } |
