syscall_bsd_test.go 783 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. "testing"
  8. "golang.org/x/sys/unix"
  9. )
  10. const MNT_WAIT = 1
  11. func TestGetfsstat(t *testing.T) {
  12. n, err := unix.Getfsstat(nil, MNT_WAIT)
  13. if err != nil {
  14. t.Fatal(err)
  15. }
  16. data := make([]unix.Statfs_t, n)
  17. n, err = unix.Getfsstat(data, MNT_WAIT)
  18. if err != nil {
  19. t.Fatal(err)
  20. }
  21. empty := unix.Statfs_t{}
  22. for _, stat := range data {
  23. if stat == empty {
  24. t.Fatal("an empty Statfs_t struct was returned")
  25. }
  26. }
  27. }
  28. func TestSysctlRaw(t *testing.T) {
  29. _, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid())
  30. if err != nil {
  31. t.Fatal(err)
  32. }
  33. }