syscall_openbsd_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. "time"
  8. "golang.org/x/sys/unix"
  9. )
  10. func TestPpoll(t *testing.T) {
  11. f, cleanup := mktmpfifo(t)
  12. defer cleanup()
  13. const timeout = 100 * time.Millisecond
  14. ok := make(chan bool, 1)
  15. go func() {
  16. select {
  17. case <-time.After(10 * timeout):
  18. t.Errorf("Ppoll: failed to timeout after %d", 10*timeout)
  19. case <-ok:
  20. }
  21. }()
  22. fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}}
  23. timeoutTs := unix.NsecToTimespec(int64(timeout))
  24. n, err := unix.Ppoll(fds, &timeoutTs, nil)
  25. ok <- true
  26. if err != nil {
  27. t.Errorf("Ppoll: unexpected error: %v", err)
  28. return
  29. }
  30. if n != 0 {
  31. t.Errorf("Ppoll: wrong number of events: got %v, expected %v", n, 0)
  32. return
  33. }
  34. }
  35. func TestSysctlClockinfo(t *testing.T) {
  36. ci, err := unix.SysctlClockinfo("kern.clockrate")
  37. if err != nil {
  38. t.Fatal(err)
  39. }
  40. t.Logf("tick = %v, tickadj = %v, hz = %v, profhz = %v, stathz = %v",
  41. ci.Tick, ci.Tickadj, ci.Hz, ci.Profhz, ci.Stathz)
  42. }
  43. func TestSysctlUvmexp(t *testing.T) {
  44. uvm, err := unix.SysctlUvmexp("vm.uvmexp")
  45. if err != nil {
  46. t.Fatal(err)
  47. }
  48. t.Logf("free = %v", uvm.Free)
  49. }