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