diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-01-15 14:12:19 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-01-15 14:13:27 -0800 |
commit | 92cf3764e032740f0c84a1b242c54b99f45a6bf0 (patch) | |
tree | 9e82455ddf0894b177e24cf1d8289b30f9a82e8a /runsc/container/container_test.go | |
parent | 9a01287d23fd4e70067ff82190e7df39a297395c (diff) |
Create working directory if it doesn't yet exist
PiperOrigin-RevId: 229438125
Change-Id: I58eb0d10178d1adfc709d7b859189d1acbcb2f22
Diffstat (limited to 'runsc/container/container_test.go')
-rw-r--r-- | runsc/container/container_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/runsc/container/container_test.go b/runsc/container/container_test.go index affb51fab..bd8655f3e 100644 --- a/runsc/container/container_test.go +++ b/runsc/container/container_test.go @@ -1699,6 +1699,27 @@ func TestDestroyStarting(t *testing.T) { } } +func TestCreateWorkingDir(t *testing.T) { + for _, conf := range configs(overlay) { + t.Logf("Running test with conf: %+v", conf) + + tmpDir, err := ioutil.TempDir(testutil.TmpDir(), "cwd-create") + if err != nil { + t.Fatalf("ioutil.TempDir() failed: %v", err) + } + dir := path.Join(tmpDir, "new/working/dir") + + // touch will fail if the directory doesn't exist. + spec := testutil.NewSpecWithArgs("/bin/touch", path.Join(dir, "file")) + spec.Process.Cwd = dir + spec.Root.Readonly = true + + if err := run(spec, conf); err != nil { + t.Fatalf("Error running container: %v", err) + } + } +} + // executeSync synchronously executes a new process. func (cont *Container) executeSync(args *control.ExecArgs) (syscall.WaitStatus, error) { pid, err := cont.Execute(args) |