From d59ba98314e02be939938f682fd67cd68bbb3b68 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Mon, 26 Sep 2022 09:23:11 +0200 Subject: vm: add the proxyapp support (#3269) * vm: add pool.Close() support * vm: add proxyapp client implementation * vm/proxyapp: autogenerate mocks * vm/proxyapp: add proxyapp tests * pkg/mgrconfig: add proxyapp type tests --- pkg/mgrconfig/mgrconfig_test.go | 3 +++ pkg/mgrconfig/testdata/proxyapp.cfg | 18 ++++++++++++++++++ pkg/osutil/osutil.go | 9 +++++++++ 3 files changed, 30 insertions(+) create mode 100644 pkg/mgrconfig/testdata/proxyapp.cfg (limited to 'pkg') diff --git a/pkg/mgrconfig/mgrconfig_test.go b/pkg/mgrconfig/mgrconfig_test.go index dd3060d5f..d4a37e941 100644 --- a/pkg/mgrconfig/mgrconfig_test.go +++ b/pkg/mgrconfig/mgrconfig_test.go @@ -10,6 +10,7 @@ import ( "github.com/google/syzkaller/pkg/config" . "github.com/google/syzkaller/pkg/mgrconfig" "github.com/google/syzkaller/vm/gce" + "github.com/google/syzkaller/vm/proxyapp" "github.com/google/syzkaller/vm/qemu" ) @@ -30,6 +31,8 @@ func TestCanned(t *testing.T) { vmCfg = new(qemu.Config) case "gce": vmCfg = new(gce.Config) + case "proxyapp": + vmCfg = new(proxyapp.Config) default: t.Fatalf("unknown VM type: %v", cfg.Type) } diff --git a/pkg/mgrconfig/testdata/proxyapp.cfg b/pkg/mgrconfig/testdata/proxyapp.cfg new file mode 100644 index 000000000..4dd83e434 --- /dev/null +++ b/pkg/mgrconfig/testdata/proxyapp.cfg @@ -0,0 +1,18 @@ +{ + "target": "linux/amd64", + "workdir": "./workdir", + "syzkaller": "./testdata/syzkaller", + "http": ":12345", + "type": "proxyapp", + "vm": { + "cmd": "/path/to/proxyapp_binary", + "config": { + "count": 1, + "kernel": "/path/to/LATEST.tar.xz", + "manager_host": "host-for-reverse-connection" + } + }, + "procs": 32, + "disable_syscalls": [ "clock_settime" ], + "reproduce": false +} diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go index 0194a616e..7eb033652 100644 --- a/pkg/osutil/osutil.go +++ b/pkg/osutil/osutil.go @@ -5,6 +5,7 @@ package osutil import ( "bytes" + "context" "fmt" "io/ioutil" "os" @@ -79,6 +80,14 @@ func Run(timeout time.Duration, cmd *exec.Cmd) ([]byte, error) { return output.Bytes(), nil } +// CommandContext is similar to os/exec.CommandContext, but also sets PDEATHSIG to SIGKILL on linux, +// i.e. the child will be killed immediately. +func CommandContext(ctx context.Context, bin string, args ...string) *exec.Cmd { + cmd := exec.CommandContext(ctx, bin, args...) + setPdeathsig(cmd, true) + return cmd +} + // Command is similar to os/exec.Command, but also sets PDEATHSIG to SIGKILL on linux, // i.e. the child will be killed immediately. func Command(bin string, args ...string) *exec.Cmd { -- cgit mrf-deployment