github.com/etecs-ru/go-sys-wineventlog@v0.0.0-20210227233244-4c3abb794018/unix/syscall_openbsd_test.go (about) 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 5 package unix_test 6 7 import ( 8 "testing" 9 "time" 10 11 "golang.org/x/sys/unix" 12 ) 13 14 func TestPpoll(t *testing.T) { 15 defer chtmpdir(t)() 16 f, cleanup := mktmpfifo(t) 17 defer cleanup() 18 19 const timeout = 100 * time.Millisecond 20 21 ok := make(chan bool, 1) 22 go func() { 23 select { 24 case <-time.After(10 * timeout): 25 t.Errorf("Ppoll: failed to timeout after %d", 10*timeout) 26 case <-ok: 27 } 28 }() 29 30 fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}} 31 timeoutTs := unix.NsecToTimespec(int64(timeout)) 32 n, err := unix.Ppoll(fds, &timeoutTs, nil) 33 ok <- true 34 if err != nil { 35 t.Errorf("Ppoll: unexpected error: %v", err) 36 return 37 } 38 if n != 0 { 39 t.Errorf("Ppoll: wrong number of events: got %v, expected %v", n, 0) 40 return 41 } 42 } 43 44 func TestSysctlUvmexp(t *testing.T) { 45 uvm, err := unix.SysctlUvmexp("vm.uvmexp") 46 if err != nil { 47 t.Fatal(err) 48 } 49 t.Logf("free = %v", uvm.Free) 50 }