summaryrefslogtreecommitdiffhomepage
path: root/runsc/test
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-08-06 23:25:28 -0700
committergVisor bot <gvisor-bot@google.com>2019-08-06 23:26:46 -0700
commite70eafc9e5bb5b1ffd6fb7001c2c0d77a5368486 (patch)
tree783c7707cf32c5ed6d33b0f542368be8879eef25 /runsc/test
parentdfbc0b0a4cabc6468c82a7665ff655fd4a633dd9 (diff)
Make loading container in a sandbox more robust
PiperOrigin-RevId: 262071646
Diffstat (limited to 'runsc/test')
-rw-r--r--runsc/test/testutil/testutil.go11
1 files changed, 7 insertions, 4 deletions
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
}