From 1729cf6917b3e2fe4a22101a05e833f717bca8ce Mon Sep 17 00:00:00 2001 From: Mara Mihali Date: Tue, 6 Jul 2021 11:36:45 +0000 Subject: pkg/instance: added threaded and collide flags These can be used to disable threaded execution and collision mode for program's system calls. --- pkg/instance/instance.go | 6 ++++-- pkg/instance/instance_test.go | 12 +++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'pkg/instance') diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 19c71c067..c65d97cce 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -500,6 +500,8 @@ var MakeBin = func() string { return "make" }() -func RunnerCmd(prog, fwdAddr, os, arch string, poolIdx, vmIdx int) string { - return fmt.Sprintf("%s -addr=%s -os=%s -arch=%s -pool=%v -vm=%v", prog, fwdAddr, os, arch, poolIdx, vmIdx) +func RunnerCmd(prog, fwdAddr, os, arch string, poolIdx, vmIdx int, collide, threaded bool) string { + return fmt.Sprintf("%s -addr=%s -os=%s -arch=%s -pool=%d -vm=%d "+ + "-collide=%t -threaded=%t", prog, fwdAddr, os, arch, poolIdx, vmIdx, + collide, threaded) } diff --git a/pkg/instance/instance_test.go b/pkg/instance/instance_test.go index c5d8cd1d1..7d2ce3031 100644 --- a/pkg/instance/instance_test.go +++ b/pkg/instance/instance_test.go @@ -149,8 +149,10 @@ func TestRunnerCmd(t *testing.T) { flagArch := flags.String("arch", "", "target architecture") flagPool := flags.Int("pool", 0, "index of pool that started VM") flagVM := flags.Int("vm", 0, "index of VM that started the Runner") + flagCollide := flags.Bool("collide", true, "collide syscalls to provoke data races") + flagThreaded := flags.Bool("threaded", true, "use threaded mode in executor") - cmdLine := RunnerCmd(os.Args[0], "localhost:1234", targets.Linux, targets.AMD64, 0, 0) + cmdLine := RunnerCmd(os.Args[0], "localhost:1234", targets.Linux, targets.AMD64, 0, 0, false, false) args := strings.Split(cmdLine, " ")[1:] if err := flags.Parse(args); err != nil { t.Fatalf("error parsing flags: %v, want: nil", err) @@ -175,4 +177,12 @@ func TestRunnerCmd(t *testing.T) { if got, want := *flagVM, 0; got != want { t.Errorf("bad vm index: %d, want: %d", got, want) } + + if got, want := *flagCollide, false; got != want { + t.Errorf("bad collide: %t, want: %t", got, want) + } + + if got, want := *flagThreaded, false; got != want { + t.Errorf("bad threaded: %t, want: %t", got, want) + } } -- cgit mrf-deployment