...
1
2
3
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 chtmpdir(t)
16 f := mktmpfifo(t)
17
18 const timeout = 100 * time.Millisecond
19
20 ok := make(chan bool, 1)
21 go func() {
22 select {
23 case <-time.After(10 * timeout):
24 t.Errorf("Ppoll: failed to timeout after %d", 10*timeout)
25 case <-ok:
26 }
27 }()
28
29 fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}}
30 timeoutTs := unix.NsecToTimespec(int64(timeout))
31 n, err := unix.Ppoll(fds, &timeoutTs, nil)
32 ok <- true
33 if err != nil {
34 t.Errorf("Ppoll: unexpected error: %v", err)
35 return
36 }
37 if n != 0 {
38 t.Errorf("Ppoll: wrong number of events: got %v, expected %v", n, 0)
39 return
40 }
41 }
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 }
50
View as plain text