diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:04 +0000 |
commit | b09c6d56832eb1718c07d74abf3bc6ae3fe4e030 (patch) | |
tree | d2caec2610d4ea887803ec9e9c3cd77136c448ba /dependencies/pkg/mod/golang.org/x/sys@v0.1.0/unix/syscall_bsd_test.go | |
parent | Initial commit. (diff) | |
download | icingadb-b09c6d56832eb1718c07d74abf3bc6ae3fe4e030.tar.xz icingadb-b09c6d56832eb1718c07d74abf3bc6ae3fe4e030.zip |
Adding upstream version 1.1.0.upstream/1.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dependencies/pkg/mod/golang.org/x/sys@v0.1.0/unix/syscall_bsd_test.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/dependencies/pkg/mod/golang.org/x/sys@v0.1.0/unix/syscall_bsd_test.go b/dependencies/pkg/mod/golang.org/x/sys@v0.1.0/unix/syscall_bsd_test.go new file mode 100644 index 0000000..9646c56 --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/sys@v0.1.0/unix/syscall_bsd_test.go @@ -0,0 +1,61 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build darwin || dragonfly || freebsd || netbsd || openbsd +// +build darwin dragonfly freebsd netbsd openbsd + +package unix_test + +import ( + "runtime" + "testing" + "time" + + "golang.org/x/sys/unix" +) + +func TestSysctlRaw(t *testing.T) { + switch runtime.GOOS { + case "netbsd", "openbsd": + t.Skipf("kern.proc.pid does not exist on %s", runtime.GOOS) + } + + _, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid()) + if err != nil { + t.Fatal(err) + } +} + +func TestSysctlUint32(t *testing.T) { + maxproc, err := unix.SysctlUint32("kern.maxproc") + if err != nil { + t.Fatal(err) + } + t.Logf("kern.maxproc: %v", maxproc) +} + +func TestSysctlClockinfo(t *testing.T) { + ci, err := unix.SysctlClockinfo("kern.clockrate") + if err != nil { + if runtime.GOOS == "openbsd" && (err == unix.ENOMEM || err == unix.EIO) { + if osrev, _ := unix.SysctlUint32("kern.osrevision"); osrev <= 202010 { + // SysctlClockinfo should fail gracefully due to a struct size + // mismatch on OpenBSD 6.8 and earlier, see + // https://golang.org/issue/47629 + return + } + } + t.Fatal(err) + } + t.Logf("tick = %v, hz = %v, profhz = %v, stathz = %v", + ci.Tick, ci.Hz, ci.Profhz, ci.Stathz) +} + +func TestSysctlTimeval(t *testing.T) { + tv, err := unix.SysctlTimeval("kern.boottime") + if err != nil { + t.Fatal(err) + } + t.Logf("boottime = %v", time.Unix(tv.Unix())) +} |