syscall_netbsd_test.go 930 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2018 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.
  4. package unix_test
  5. import (
  6. "testing"
  7. "golang.org/x/sys/unix"
  8. )
  9. // stringsFromByteSlice converts a sequence of attributes to a []string.
  10. // On NetBSD, each entry consists of a single byte containing the length
  11. // of the attribute name, followed by the attribute name.
  12. // The name is _not_ NULL-terminated.
  13. func stringsFromByteSlice(buf []byte) []string {
  14. var result []string
  15. i := 0
  16. for i < len(buf) {
  17. next := i + 1 + int(buf[i])
  18. result = append(result, string(buf[i+1:next]))
  19. i = next
  20. }
  21. return result
  22. }
  23. func TestSysctlClockinfo(t *testing.T) {
  24. ci, err := unix.SysctlClockinfo("kern.clockrate")
  25. if err != nil {
  26. t.Fatal(err)
  27. }
  28. t.Logf("tick = %v, tickadj = %v, hz = %v, profhz = %v, stathz = %v",
  29. ci.Tick, ci.Tickadj, ci.Hz, ci.Profhz, ci.Stathz)
  30. }