1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/internal/test/daemon/daemon_unix.go
Vincent Demeester cb8db44395
Make testing helpers as such…
That way, those lines won't be reported in the failure.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-04-20 10:38:43 +02:00

39 lines
1 KiB
Go

// +build !windows
package daemon // import "github.com/docker/docker/internal/test/daemon"
import (
"os"
"path/filepath"
"github.com/docker/docker/internal/test"
"golang.org/x/sys/unix"
)
func cleanupNetworkNamespace(t testingT, execRoot string) {
if ht, ok := t.(test.HelperT); ok {
ht.Helper()
}
// Cleanup network namespaces in the exec root of this
// daemon because this exec root is specific to this
// daemon instance and has no chance of getting
// cleaned up when a new daemon is instantiated with a
// new exec root.
netnsPath := filepath.Join(execRoot, "netns")
filepath.Walk(netnsPath, func(path string, info os.FileInfo, err error) error {
if err := unix.Unmount(path, unix.MNT_FORCE); err != nil {
t.Logf("unmount of %s failed: %v", path, err)
}
os.Remove(path)
return nil
})
}
// SignalDaemonDump sends a signal to the daemon to write a dump file
func SignalDaemonDump(pid int) {
unix.Kill(pid, unix.SIGQUIT)
}
func signalDaemonReload(pid int) error {
return unix.Kill(pid, unix.SIGHUP)
}