summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/sys/unix/syscall_linux_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/unix/syscall_linux_test.go')
-rw-r--r--vendor/golang.org/x/sys/unix/syscall_linux_test.go92
1 files changed, 44 insertions, 48 deletions
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_test.go b/vendor/golang.org/x/sys/unix/syscall_linux_test.go
index c0ab2db9e..84c69d268 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux_test.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux_test.go
@@ -56,34 +56,6 @@ func TestIoctlGetInt(t *testing.T) {
t.Logf("%d bits of entropy available", v)
}
-func TestPoll(t *testing.T) {
- f, cleanup := mktmpfifo(t)
- defer cleanup()
-
- const timeout = 100
-
- ok := make(chan bool, 1)
- go func() {
- select {
- case <-time.After(10 * timeout * time.Millisecond):
- t.Errorf("Poll: failed to timeout after %d milliseconds", 10*timeout)
- case <-ok:
- }
- }()
-
- fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}}
- n, err := unix.Poll(fds, timeout)
- ok <- true
- if err != nil {
- t.Errorf("Poll: unexpected error: %v", err)
- return
- }
- if n != 0 {
- t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0)
- return
- }
-}
-
func TestPpoll(t *testing.T) {
f, cleanup := mktmpfifo(t)
defer cleanup()
@@ -113,25 +85,6 @@ func TestPpoll(t *testing.T) {
}
}
-// mktmpfifo creates a temporary FIFO and provides a cleanup function.
-func mktmpfifo(t *testing.T) (*os.File, func()) {
- err := unix.Mkfifo("fifo", 0666)
- if err != nil {
- t.Fatalf("mktmpfifo: failed to create FIFO: %v", err)
- }
-
- f, err := os.OpenFile("fifo", os.O_RDWR, 0666)
- if err != nil {
- os.Remove("fifo")
- t.Fatalf("mktmpfifo: failed to open FIFO: %v", err)
- }
-
- return f, func() {
- f.Close()
- os.Remove("fifo")
- }
-}
-
func TestTime(t *testing.T) {
var ut unix.Time_t
ut2, err := unix.Time(&ut)
@@ -184,6 +137,38 @@ func TestUtime(t *testing.T) {
}
}
+func TestUtimesNanoAt(t *testing.T) {
+ defer chtmpdir(t)()
+
+ symlink := "symlink1"
+ os.Remove(symlink)
+ err := os.Symlink("nonexisting", symlink)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ts := []unix.Timespec{
+ {Sec: 1111, Nsec: 2222},
+ {Sec: 3333, Nsec: 4444},
+ }
+ err = unix.UtimesNanoAt(unix.AT_FDCWD, symlink, ts, unix.AT_SYMLINK_NOFOLLOW)
+ if err != nil {
+ t.Fatalf("UtimesNanoAt: %v", err)
+ }
+
+ var st unix.Stat_t
+ err = unix.Lstat(symlink, &st)
+ if err != nil {
+ t.Fatalf("Lstat: %v", err)
+ }
+ if st.Atim != ts[0] {
+ t.Errorf("UtimesNanoAt: wrong atime: %v", st.Atim)
+ }
+ if st.Mtim != ts[1] {
+ t.Errorf("UtimesNanoAt: wrong mtime: %v", st.Mtim)
+ }
+}
+
func TestGetrlimit(t *testing.T) {
var rlim unix.Rlimit
err := unix.Getrlimit(unix.RLIMIT_AS, &rlim)
@@ -193,12 +178,23 @@ func TestGetrlimit(t *testing.T) {
}
func TestSelect(t *testing.T) {
- _, err := unix.Select(0, nil, nil, nil, &unix.Timeval{0, 0})
+ _, err := unix.Select(0, nil, nil, nil, &unix.Timeval{Sec: 0, Usec: 0})
if err != nil {
t.Fatalf("Select: %v", err)
}
}
+func TestUname(t *testing.T) {
+ var utsname unix.Utsname
+ err := unix.Uname(&utsname)
+ if err != nil {
+ t.Fatalf("Uname: %v", err)
+ }
+
+ // conversion from []byte to string, golang.org/issue/20753
+ t.Logf("OS: %s/%s %s", string(utsname.Sysname[:]), string(utsname.Machine[:]), string(utsname.Release[:]))
+}
+
// utilities taken from os/os_test.go
func touch(t *testing.T, name string) {