syscall_bsd_test.go 882 B

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