Remove shelling out to mount

Also remove the target from the Mount struct because it should not be
used at all.  The target can be variable and set by a caller, not by the
snapshot drivers.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-01-17 13:26:56 -08:00
parent c0fdda03cc
commit a7a6270f2a
9 changed files with 28 additions and 101 deletions

View file

@ -4,7 +4,6 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/docker/containerd"
@ -48,18 +47,10 @@ func TestSnapshotManagerBasic(t *testing.T) {
t.Fatal("expected mounts to have entries")
}
for _, mount := range mounts {
if !strings.HasPrefix(mount.Target, preparing) {
t.Fatalf("expected mount target to be prefixed with tmpDir: %q does not startwith %q", mount.Target, preparing)
}
t.Log(containerd.MountCommand(mount))
}
if err := containerd.MountAll(mounts...); err != nil {
if err := containerd.MountAll(mounts, preparing); err != nil {
t.Fatal(err)
}
defer testutil.UnmountAll(t, mounts)
defer testutil.Unmount(t, preparing)
if err := ioutil.WriteFile(filepath.Join(preparing, "foo"), []byte("foo\n"), 0777); err != nil {
t.Fatal(err)
@ -86,18 +77,10 @@ func TestSnapshotManagerBasic(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if err := containerd.MountAll(mounts...); err != nil {
if err := containerd.MountAll(mounts, next); err != nil {
t.Fatal(err)
}
defer testutil.UnmountAll(t, mounts)
for _, mount := range mounts {
if !strings.HasPrefix(mount.Target, next) {
t.Fatalf("expected mount target to be prefixed with tmpDir: %q does not startwith %q", mount.Target, next)
}
t.Log(containerd.MountCommand(mount))
}
defer testutil.Unmount(t, next)
if err := ioutil.WriteFile(filepath.Join(next, "bar"), []byte("bar\n"), 0777); err != nil {
t.Fatal(err)