1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin dragonfly freebsd openbsd
15 "golang.org/x/sys/unix"
18 func TestGetfsstat(t *testing.T) {
19 n, err := unix.Getfsstat(nil, unix.MNT_NOWAIT)
24 data := make([]unix.Statfs_t, n)
25 n2, err := unix.Getfsstat(data, unix.MNT_NOWAIT)
30 t.Errorf("Getfsstat(nil) = %d, but subsequent Getfsstat(slice) = %d", n, n2)
32 for i, stat := range data {
33 if stat == (unix.Statfs_t{}) {
34 t.Errorf("index %v is an empty Statfs_t struct", i)
38 for i, stat := range data[:n2] {
39 t.Logf("data[%v] = %+v", i, stat)
41 mount, err := exec.Command("mount").CombinedOutput()
43 t.Logf("mount: %v\n%s", err, mount)
45 t.Logf("mount: %s", mount)
50 func TestSysctlRaw(t *testing.T) {
51 if runtime.GOOS == "openbsd" {
52 t.Skip("kern.proc.pid does not exist on OpenBSD")
55 _, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid())
61 func TestSysctlUint32(t *testing.T) {
62 maxproc, err := unix.SysctlUint32("kern.maxproc")
66 t.Logf("kern.maxproc: %v", maxproc)
69 func TestSysctlClockinfo(t *testing.T) {
70 ci, err := unix.SysctlClockinfo("kern.clockrate")
74 t.Logf("tick = %v, hz = %v, profhz = %v, stathz = %v",
75 ci.Tick, ci.Hz, ci.Profhz, ci.Stathz)
78 func TestSysctlTimeval(t *testing.T) {
79 tv, err := unix.SysctlTimeval("kern.boottime")
83 t.Logf("boottime = %v", time.Unix(tv.Unix()))