You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
1.1 KiB

  1. // Copyright 2017 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 solaris
  5. package unix_test
  6. import (
  7. "os/exec"
  8. "testing"
  9. "time"
  10. "golang.org/x/sys/unix"
  11. )
  12. func TestSelect(t *testing.T) {
  13. err := unix.Select(0, nil, nil, nil, &unix.Timeval{Sec: 0, Usec: 0})
  14. if err != nil {
  15. t.Fatalf("Select: %v", err)
  16. }
  17. dur := 150 * time.Millisecond
  18. tv := unix.NsecToTimeval(int64(dur))
  19. start := time.Now()
  20. err = unix.Select(0, nil, nil, nil, &tv)
  21. took := time.Since(start)
  22. if err != nil {
  23. t.Fatalf("Select: %v", err)
  24. }
  25. if took < dur {
  26. t.Errorf("Select: timeout should have been at least %v, got %v", dur, took)
  27. }
  28. }
  29. func TestStatvfs(t *testing.T) {
  30. if err := unix.Statvfs("", nil); err == nil {
  31. t.Fatal(`Statvfs("") expected failure`)
  32. }
  33. statvfs := unix.Statvfs_t{}
  34. if err := unix.Statvfs("/", &statvfs); err != nil {
  35. t.Errorf(`Statvfs("/") failed: %v`, err)
  36. }
  37. if t.Failed() {
  38. mount, err := exec.Command("mount").CombinedOutput()
  39. if err != nil {
  40. t.Logf("mount: %v\n%s", err, mount)
  41. } else {
  42. t.Logf("mount: %s", mount)
  43. }
  44. }
  45. }