From e70eafc9e5bb5b1ffd6fb7001c2c0d77a5368486 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Tue, 6 Aug 2019 23:25:28 -0700 Subject: Make loading container in a sandbox more robust PiperOrigin-RevId: 262071646 --- runsc/test/testutil/testutil.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'runsc/test/testutil/testutil.go') diff --git a/runsc/test/testutil/testutil.go b/runsc/test/testutil/testutil.go index 406f6d08a..e288c7758 100644 --- a/runsc/test/testutil/testutil.go +++ b/runsc/test/testutil/testutil.go @@ -189,11 +189,14 @@ func SetupRootDir() (string, error) { // SetupContainer creates a bundle and root dir for the container, generates a // test config, and writes the spec to config.json in the bundle dir. func SetupContainer(spec *specs.Spec, conf *boot.Config) (rootDir, bundleDir string, err error) { - rootDir, err = SetupRootDir() - if err != nil { - return "", "", err + // Setup root dir if one hasn't been provided. + if len(conf.RootDir) == 0 { + rootDir, err = SetupRootDir() + if err != nil { + return "", "", err + } + conf.RootDir = rootDir } - conf.RootDir = rootDir bundleDir, err = SetupBundleDir(spec) return rootDir, bundleDir, err } -- cgit v1.2.3