summaryrefslogtreecommitdiffhomepage
path: root/test/runner
diff options
context:
space:
mode:
Diffstat (limited to 'test/runner')
-rw-r--r--test/runner/BUILD3
-rw-r--r--test/runner/defs.bzl28
-rw-r--r--test/runner/runner.go112
3 files changed, 11 insertions, 132 deletions
diff --git a/test/runner/BUILD b/test/runner/BUILD
index 049c26081..582d2946d 100644
--- a/test/runner/BUILD
+++ b/test/runner/BUILD
@@ -11,14 +11,11 @@ go_binary(
],
visibility = ["//:sandbox"],
deps = [
- "//pkg/context",
"//pkg/log",
- "//pkg/test/dockerutil",
"//pkg/test/testutil",
"//runsc/specutils",
"//test/runner/gtest",
"//test/uds",
- "@com_github_docker_docker//api/types/mount:go_default_library",
"@com_github_opencontainers_runtime_spec//specs-go:go_default_library",
"@com_github_syndtr_gocapability//capability:go_default_library",
"@org_golang_x_sys//unix:go_default_library",
diff --git a/test/runner/defs.bzl b/test/runner/defs.bzl
index 9dc955c77..032ebd04e 100644
--- a/test/runner/defs.bzl
+++ b/test/runner/defs.bzl
@@ -57,8 +57,6 @@ def _syscall_test(
platform,
use_tmpfs,
tags,
- use_image = "",
- setup_command = "",
network = "none",
file_access = "exclusive",
overlay = False,
@@ -81,8 +79,6 @@ def _syscall_test(
name += "_fuse"
if network != "none":
name += "_" + network + "net"
- if use_image != "":
- name += "_container"
# Apply all tags.
if tags == None:
@@ -111,8 +107,6 @@ def _syscall_test(
"--platform=" + platform,
"--network=" + network,
"--use-tmpfs=" + str(use_tmpfs),
- "--use-image=" + use_image,
- "--setup-command=" + setup_command,
"--file-access=" + file_access,
"--overlay=" + str(overlay),
"--add-uds-tree=" + str(add_uds_tree),
@@ -138,8 +132,6 @@ def syscall_test(
shard_count = 5,
size = "small",
use_tmpfs = False,
- use_image = "",
- setup_command = "",
add_overlay = False,
add_uds_tree = False,
add_hostinet = False,
@@ -154,8 +146,6 @@ def syscall_test(
shard_count: shards for defined tests.
size: the defined test size.
use_tmpfs: use tmpfs in the defined tests.
- use_image: use specified docker image in the defined tests.
- setup_command: command to set up the docker container. Should be used when ise_image is.
add_overlay: add an overlay test.
add_uds_tree: add a UDS test.
add_hostinet: add a hostinet test.
@@ -188,26 +178,8 @@ def syscall_test(
vfs2 = True,
fuse = fuse,
)
-
- if use_image != "":
- # Run the test in the container specified.
- _syscall_test(
- test = test,
- shard_count = shard_count,
- size = size,
- platform = default_platform,
- use_tmpfs = use_tmpfs,
- use_image = use_image,
- setup_command = setup_command,
- add_uds_tree = add_uds_tree,
- tags = platforms[default_platform] + vfs2_tags,
- vfs2 = True,
- fuse = True,
- )
-
if fuse:
# Only generate *_vfs2_fuse target if fuse parameter is enabled.
- # The rest of the targets don't support FUSE as of yet.
return
_syscall_test(
diff --git a/test/runner/runner.go b/test/runner/runner.go
index fe501c4c7..22d535f8d 100644
--- a/test/runner/runner.go
+++ b/test/runner/runner.go
@@ -23,20 +23,16 @@ import (
"os"
"os/exec"
"os/signal"
- "path"
"path/filepath"
"strings"
"syscall"
"testing"
"time"
- "github.com/docker/docker/api/types/mount"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/syndtr/gocapability/capability"
"golang.org/x/sys/unix"
- "gvisor.dev/gvisor/pkg/context"
"gvisor.dev/gvisor/pkg/log"
- "gvisor.dev/gvisor/pkg/test/dockerutil"
"gvisor.dev/gvisor/pkg/test/testutil"
"gvisor.dev/gvisor/runsc/specutils"
"gvisor.dev/gvisor/test/runner/gtest"
@@ -44,19 +40,17 @@ import (
)
var (
- debug = flag.Bool("debug", false, "enable debug logs")
- strace = flag.Bool("strace", false, "enable strace logs")
- platform = flag.String("platform", "ptrace", "platform to run on")
- network = flag.String("network", "none", "network stack to run on (sandbox, host, none)")
- useTmpfs = flag.Bool("use-tmpfs", false, "mounts tmpfs for /tmp")
- useImage = flag.String("use-image", "", "container image to use for test. Path relative to //images")
- setupCommand = flag.String("setup-command", "", "command to run before running the test to set up container environment")
- fileAccess = flag.String("file-access", "exclusive", "mounts root in exclusive or shared mode")
- overlay = flag.Bool("overlay", false, "wrap filesystem mounts with writable tmpfs overlay")
- vfs2 = flag.Bool("vfs2", false, "enable VFS2")
- fuse = flag.Bool("fuse", false, "enable FUSE")
- parallel = flag.Bool("parallel", false, "run tests in parallel")
- runscPath = flag.String("runsc", "", "path to runsc binary")
+ debug = flag.Bool("debug", false, "enable debug logs")
+ strace = flag.Bool("strace", false, "enable strace logs")
+ platform = flag.String("platform", "ptrace", "platform to run on")
+ network = flag.String("network", "none", "network stack to run on (sandbox, host, none)")
+ useTmpfs = flag.Bool("use-tmpfs", false, "mounts tmpfs for /tmp")
+ fileAccess = flag.String("file-access", "exclusive", "mounts root in exclusive or shared mode")
+ overlay = flag.Bool("overlay", false, "wrap filesystem mounts with writable tmpfs overlay")
+ vfs2 = flag.Bool("vfs2", false, "enable VFS2")
+ fuse = flag.Bool("fuse", false, "enable FUSE")
+ parallel = flag.Bool("parallel", false, "run tests in parallel")
+ runscPath = flag.String("runsc", "", "path to runsc binary")
addUDSTree = flag.Bool("add-uds-tree", false, "expose a tree of UDS utilities for use in tests")
)
@@ -319,92 +313,8 @@ func setupUDSTree(spec *specs.Spec) (cleanup func(), err error) {
return cleanup, nil
}
-func runTestCaseInContainer(testBin string, tc gtest.TestCase, image string, t *testing.T) {
- if usingFUSE, err := dockerutil.UsingFUSE(); err != nil {
- t.Fatalf("failed to read config for runtime %s: %v", dockerutil.Runtime(), err)
- } else if !usingFUSE {
- t.Skip("FUSE not being used.")
- }
-
- ctx := context.Background()
- d := dockerutil.MakeContainer(ctx, t)
- defer d.CleanUp(ctx)
-
- // Run the basic container.
- tmpDir := "/tmpDir"
- testBinDir := "/testDir"
- opts := dockerutil.RunOpts{
- Image: image,
- Privileged: true,
- CapAdd: []string{"CAP_SYS_ADMIN"},
-
- // Mount a tmpfs directory to use when benchmarking.
- Mounts: []mount.Mount{
- {
- Type: mount.TypeTmpfs,
- Target: tmpDir,
- ReadOnly: false,
- },
- },
- Env: []string{
- fmt.Sprintf("TEST_TMPDIR=%s", tmpDir),
- fmt.Sprintf("TEST_FUSEPRE=%s", "/fus/mountpoint"),
- },
- }
- wd, err := os.Getwd()
- if err != nil {
- t.Fatalf("Getwd run failed: %v", err)
- }
-
- wdPathToTestBin := strings.TrimPrefix(testBin, wd)
- containerTestBin := path.Join(testBinDir, path.Base(wdPathToTestBin))
- d.CopyFiles(&opts, testBinDir, wdPathToTestBin)
- if err := d.CopyErr(); err != nil {
- t.Fatalf("Copy failed %v", err)
- }
-
- err = d.Spawn(ctx, opts, "sleep", "1000")
- if err != nil {
- t.Fatalf("docker run failed: %v", err)
- }
-
- // Run the server setup command.
- if *setupCommand != "" {
- out, err := d.Exec(ctx, dockerutil.ExecOpts{
- Privileged: true,
- }, "/bin/sh", "-c", *setupCommand)
- if err != nil {
- t.Fatalf("docker exec failed: %v with output %v", err, out)
- }
- }
-
- cmd := "chmod +x " + containerTestBin
- out, err := d.Exec(ctx, dockerutil.ExecOpts{
- Privileged: true,
- }, "/bin/sh", "-c", cmd)
- if err != nil {
- t.Fatalf("docker exec failed: %v with output %v", err, out)
- }
-
- cmd = containerTestBin + " " + strings.Join(tc.Args(), " ")
- out, err = d.Exec(ctx, dockerutil.ExecOpts{
- Privileged: true,
- }, "/bin/sh", "-c", cmd)
- if err != nil {
- t.Fatalf("docker exec failed: %v with output %v", err, out)
- }
-
- fmt.Print(out)
- return
-}
-
// runsTestCaseRunsc runs the test case in runsc.
func runTestCaseRunsc(testBin string, tc gtest.TestCase, t *testing.T) {
- if *useImage != "" {
- runTestCaseInContainer(testBin, tc, *useImage, t)
- return
- }
-
// Run a new container with the test executable and filter for the
// given test suite and name.
spec := testutil.NewSpecWithArgs(append([]string{testBin}, tc.Args()...)...)