diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-08-10 19:46:48 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-08-16 00:17:21 +0000 |
| commit | 66da885594b6dbf61d93b627f5f2d5cd34cf9023 (patch) | |
| tree | 742099f2b1090d3bf1ca222cac229c5f05e1acde /src/syscall | |
| parent | 664c4a1f87fb48d7af6880fd9e4b504049c37b9b (diff) | |
| download | go-66da885594b6dbf61d93b627f5f2d5cd34cf9023.tar.xz | |
syscall: test Gettimeofday everywhere, not just on Darwin
The Darwin-only restriction was because we were late in the Go 1.7
cycle when the test was added.
In the process, I noticed Gettimeofday wasn't in the "unimplemented
midden heap" section of syscall_nacl.go, despite this line in the
original go1.txt:
pkg syscall, func Gettimeofday(*Timeval) error
So, add it, returning ENOSYS like the others.
Change-Id: Id7e02e857b753f8d079bee335c22368734e92254
Reviewed-on: https://go-review.googlesource.com/26772
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
Diffstat (limited to 'src/syscall')
| -rw-r--r-- | src/syscall/syscall_darwin_test.go | 23 | ||||
| -rw-r--r-- | src/syscall/syscall_nacl.go | 1 | ||||
| -rw-r--r-- | src/syscall/syscall_test.go | 14 |
3 files changed, 15 insertions, 23 deletions
diff --git a/src/syscall/syscall_darwin_test.go b/src/syscall/syscall_darwin_test.go deleted file mode 100644 index cea5636d07..0000000000 --- a/src/syscall/syscall_darwin_test.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin -// +build amd64 386 arm arm64 - -package syscall_test - -import ( - "syscall" - "testing" -) - -func TestDarwinGettimeofday(t *testing.T) { - tv := &syscall.Timeval{} - if err := syscall.Gettimeofday(tv); err != nil { - t.Fatal(err) - } - if tv.Sec == 0 && tv.Usec == 0 { - t.Fatal("Sec and Usec both zero") - } -} diff --git a/src/syscall/syscall_nacl.go b/src/syscall/syscall_nacl.go index ba6eafed1c..d22d0c7536 100644 --- a/src/syscall/syscall_nacl.go +++ b/src/syscall/syscall_nacl.go @@ -295,6 +295,7 @@ func Getgroups() ([]int, error) { return []int{1}, nil } func Getpagesize() int { return 65536 } func Getppid() int { return 2 } func Getpid() int { return 3 } +func Gettimeofday(tv *Timeval) error { return ENOSYS } func Getuid() int { return 1 } func Kill(pid int, signum Signal) error { return ENOSYS } func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { diff --git a/src/syscall/syscall_test.go b/src/syscall/syscall_test.go index 0a0b8b7a26..c3fffda2df 100644 --- a/src/syscall/syscall_test.go +++ b/src/syscall/syscall_test.go @@ -8,6 +8,7 @@ import ( "fmt" "internal/testenv" "os" + "runtime" "syscall" "testing" ) @@ -59,3 +60,16 @@ func TestExecErrPermutedFds(t *testing.T) { t.Fatalf("StartProcess of invalid program returned err = nil") } } + +func TestGettimeofday(t *testing.T) { + if runtime.GOOS == "nacl" { + t.Skip("not implemented on nacl") + } + tv := &syscall.Timeval{} + if err := syscall.Gettimeofday(tv); err != nil { + t.Fatal(err) + } + if tv.Sec == 0 && tv.Usec == 0 { + t.Fatal("Sec and Usec both zero") + } +} |
