github.com/gogf/gkafka@v1.0.1-0.20190702070843-033a14468069/third/golang.org/x/sys/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  	"github.com/gogf/gkafka/third/golang.org/x/sys/unix"
    12  )
    13  
    14  func TestPpoll(t *testing.T) {
    15  	f, cleanup := mktmpfifo(t)
    16  	defer cleanup()
    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  }