From b0a9147fd5f0197931b73e18163a12b04ad8e826 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 e9fb4890b7..461004767d 100644 --- a/container.go +++ b/container.go @@ -1181,6 +1181,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 ccdf4d9563..684ca005cd 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) }