8f1b2a0fd3
testutil/daemon uses a generic unix implementation that assumes that the host OS supports cgroups & network namespaces, which is not the case for FreeBSD. This change adds a FreeBSD-specific implementation for `testutil/daemon`, namely for `cleanupNetworkNamespace` and `CgroupNamespace` functions. Signed-off-by: Artem Khramov <akhramov@pm.me>
38 lines
846 B
Go
38 lines
846 B
Go
//go:build !windows
|
|
// +build !windows
|
|
|
|
package daemon // import "github.com/docker/docker/testutil/daemon"
|
|
|
|
import (
|
|
"os/exec"
|
|
"syscall"
|
|
"testing"
|
|
|
|
"github.com/moby/sys/mount"
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// cleanupMount unmounts the daemon root directory, or logs a message if
|
|
// unmounting failed.
|
|
func cleanupMount(t testing.TB, d *Daemon) {
|
|
t.Helper()
|
|
if err := mount.Unmount(d.Root); err != nil {
|
|
d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
|
|
}
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
func setsid(cmd *exec.Cmd) {
|
|
if cmd.SysProcAttr == nil {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
|
}
|
|
cmd.SysProcAttr.Setsid = true
|
|
}
|