Skip to content

Commit

Permalink
Test relative mount points for the helper, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsa committed Jan 4, 2016
1 parent 1a2acca commit db0c0e2
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions tools/integration_tests/mount_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ func (t *MountHelperTest) TearDown() {
AssertEq(nil, err)
}

func (t *MountHelperTest) mount(args []string) (err error) {
cmd := exec.Command(t.helperPath)
func (t *MountHelperTest) mountHelperCommand(args []string) (cmd *exec.Cmd) {
cmd = exec.Command(t.helperPath)
cmd.Args = append(cmd.Args, args...)
cmd.Env = []string{
fmt.Sprintf("PATH=%s", path.Join(gBuildDir, "bin")),
}

return
}

func (t *MountHelperTest) mount(args []string) (err error) {
cmd := t.mountHelperCommand(args)

output, err := cmd.CombinedOutput()
if err != nil {
err = fmt.Errorf("CombinedOutput: %v\nOutput:\n%s", err, output)
Expand Down Expand Up @@ -120,11 +126,7 @@ func (t *MountHelperTest) BadUsage() {

// Run each test case.
for i, tc := range testCases {
cmd := exec.Command(t.helperPath)
cmd.Args = append(cmd.Args, tc.args...)
cmd.Env = []string{
fmt.Sprintf("PATH=%s", path.Join(gBuildDir, "bin")),
}
cmd := t.mountHelperCommand(tc.args)

output, err := cmd.CombinedOutput()
ExpectThat(err, Error(HasSubstr("exit status")), "case %d", i)
Expand All @@ -150,6 +152,30 @@ func (t *MountHelperTest) SuccessfulMount() {
ExpectEq(len(canned.TopLevelFile_Contents), fi.Size())
}

func (t *MountHelperTest) RelativeMountPoint() {
var err error
var fi os.FileInfo

// Mount with a relative mount point.
cmd := t.mountHelperCommand([]string{
canned.FakeBucketName,
path.Base(t.dir),
})

cmd.Dir = path.Dir(t.dir)

output, err := cmd.CombinedOutput()
AssertEq(nil, err, "output:\n%s", output)

defer unmount(t.dir)

// The file system should be available.
fi, err = os.Lstat(path.Join(t.dir, canned.TopLevelFile))
AssertEq(nil, err)
ExpectEq(os.FileMode(0644), fi.Mode())
ExpectEq(len(canned.TopLevelFile_Contents), fi.Size())
}

func (t *MountHelperTest) ReadOnlyMode() {
var err error

Expand Down

0 comments on commit db0c0e2

Please sign in to comment.