github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/sys/unix/syscall_bsd_test.go (about)

     1  // Copyright 2014 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  // +build darwin dragonfly freebsd openbsd
     6  
     7  package unix_test
     8  
     9  import (
    10  	"testing"
    11  
    12  	"golang.org/x/sys/unix"
    13  )
    14  
    15  const MNT_WAIT = 1
    16  
    17  func TestGetfsstat(t *testing.T) {
    18  	n, err := unix.Getfsstat(nil, MNT_WAIT)
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  
    23  	data := make([]unix.Statfs_t, n)
    24  	n, err = unix.Getfsstat(data, MNT_WAIT)
    25  	if err != nil {
    26  		t.Fatal(err)
    27  	}
    28  
    29  	empty := unix.Statfs_t{}
    30  	for _, stat := range data {
    31  		if stat == empty {
    32  			t.Fatal("an empty Statfs_t struct was returned")
    33  		}
    34  	}
    35  }
    36  
    37  func TestSysctlRaw(t *testing.T) {
    38  	_, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid())
    39  	if err != nil {
    40  		t.Fatal(err)
    41  	}
    42  }