From 6cc47f10ed3b9abb237c00688751acd26465af7c Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 24 Mar 2015 11:04:15 +1100 Subject: [PATCH] Unlink mount points on tear-down. --- samples/in_process.go | 7 +++++++ samples/subprocess.go | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/samples/in_process.go b/samples/in_process.go index e4f2caf..c0fb1da 100644 --- a/samples/in_process.go +++ b/samples/in_process.go @@ -18,6 +18,7 @@ import ( "fmt" "io" "io/ioutil" + "os" "time" "github.com/googlecloudplatform/gcsfuse/timeutil" @@ -129,5 +130,11 @@ func (t *SampleTest) destroy() (err error) { return } + // Unlink the mount point. + if err = os.Remove(t.Dir); err != nil { + err = fmt.Errorf("Unlinking mount point: %v", err) + return + } + return } diff --git a/samples/subprocess.go b/samples/subprocess.go index 288e185..b8464df 100644 --- a/samples/subprocess.go +++ b/samples/subprocess.go @@ -286,6 +286,7 @@ func (t *SubprocessTest) destroy() (err error) { // Make sure we wait for the unmount, even if we've already returned early in // error. Return its error if we haven't seen any other error. defer func() { + // Wait. unmountErr := <-unmountErrChan if unmountErr != nil { if err != nil { @@ -294,7 +295,11 @@ func (t *SubprocessTest) destroy() (err error) { } err = fmt.Errorf("unmount: %v", unmountErr) + return } + + // Attempt to unlink the mount point. + os.Remove(t.Dir) }() // Wait for the subprocess.