From 67788723c99cda8b41e5a488b988e2a72732d684 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 19 Sep 2013 19:20:05 +0200 Subject: [PATCH] runtime test: Ensure all containers are unmounted at nuke() Otherwise we may leave around e.g. devmapper mounts --- container.go | 9 +++++++++ runtime_test.go | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/container.go b/container.go index 35cd11080..f5f7d0ef8 100644 --- a/container.go +++ b/container.go @@ -1180,6 +1180,15 @@ func (container *Container) EnsureMounted() error { return container.Mount() } +func (container *Container) EnsureUnmounted() error { + if mounted, err := container.Mounted(); err != nil { + return err + } else if !mounted { + return nil + } + return container.Unmount() +} + func (container *Container) Mount() error { image, err := container.GetImage() if err != nil { diff --git a/runtime_test.go b/runtime_test.go index ccdf4d956..684ca005c 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -44,6 +44,10 @@ func nuke(runtime *Runtime) error { }(container) } wg.Wait() + + for _, container := range runtime.List() { + container.EnsureUnmounted() + } return os.RemoveAll(runtime.root) }