Files
sys/unix/syscall_bsd_test.go
Dmitri Shuralyov 1bfbee0e20 all: update go directive to 1.18
Done with:

go get go@1.18
go mod tidy
go fix ./...

Using go1.21.3.

Also update code generators to use only the new go:build lines,
not the old +build ones.

For golang/go#60268.

Change-Id: I6aabc42efb6ab3329981100e1db2263aac5e92a6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/534222
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-11 21:54:30 +00:00

61 lines
1.4 KiB
Go

// 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
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()))
}