diff options
| author | Mara Mihali <maramihali@google.com> | 2021-06-23 16:23:53 +0000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-06-30 09:35:14 +0200 |
| commit | bf86d29b9edb7e1346978c74ea837b5ec3683b2d (patch) | |
| tree | 3b2421a7eeea0adf572e467cef1d0430ed200cd4 /pkg/instance/instance_test.go | |
| parent | 090883682f4b0031511214e359fb7b4355e71364 (diff) | |
pkg/instance: add RunnerCmd
This function creates the command for starting a runner with the provided command line arguments.
Diffstat (limited to 'pkg/instance/instance_test.go')
| -rw-r--r-- | pkg/instance/instance_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pkg/instance/instance_test.go b/pkg/instance/instance_test.go index d95b6623e..c5d8cd1d1 100644 --- a/pkg/instance/instance_test.go +++ b/pkg/instance/instance_test.go @@ -141,3 +141,38 @@ func TestExecprogCmd(t *testing.T) { t.Errorf("bad slowdown: %v, want: %v", *flagSlowdown, 10) } } + +func TestRunnerCmd(t *testing.T) { + flags := flag.NewFlagSet("", flag.ContinueOnError) + flagFwdAddr := flags.String("addr", "", "verifier rpc address") + flagOS := flags.String("os", "", "target OS") + 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") + + cmdLine := RunnerCmd(os.Args[0], "localhost:1234", targets.Linux, targets.AMD64, 0, 0) + args := strings.Split(cmdLine, " ")[1:] + if err := flags.Parse(args); err != nil { + t.Fatalf("error parsing flags: %v, want: nil", err) + } + + if got, want := *flagFwdAddr, "localhost:1234"; got != want { + t.Errorf("bad addr: %q, want: %q", got, want) + } + + if got, want := *flagOS, targets.Linux; got != want { + t.Errorf("bad os: %q, want %q", got, want) + } + + if got, want := *flagArch, targets.AMD64; got != want { + t.Errorf("bad arch: %q, want: %q", got, want) + } + + if got, want := *flagPool, 0; got != want { + t.Errorf("bad pool index: %d, want: %d", got, want) + } + + if got, want := *flagVM, 0; got != want { + t.Errorf("bad vm index: %d, want: %d", got, want) + } +} |
