diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-02-11 16:36:38 +0000 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-02-11 19:09:50 +0000 |
commit | 70418eb819eb1d02c2c56a13159d95baab85d3a8 (patch) | |
tree | b2be36726c972edd20699b710574de20ce20c300 | |
parent | 53b66616736480152969fe1749f62e3da07644f7 (diff) | |
download | go-70418eb819eb1d02c2c56a13159d95baab85d3a8.tar.gz go-70418eb819eb1d02c2c56a13159d95baab85d3a8.zip |
runtime: add test for mincore's return value sign on Linux
Updates #14297
Change-Id: I6b5f5020af5efaaa71280bdeb2ff99785ee9b959
Reviewed-on: https://go-review.googlesource.com/19457
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/runtime/export_test.go | 2 | ||||
-rw-r--r-- | src/runtime/runtime_linux_test.go | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index 5400c1d14e..b09022b53c 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -28,6 +28,8 @@ var Exitsyscall = exitsyscall var LockedOSThread = lockedOSThread var Xadduintptr = atomic.Xadduintptr +var Mincore = mincore + var FuncPC = funcPC var Fastlog2 = fastlog2 diff --git a/src/runtime/runtime_linux_test.go b/src/runtime/runtime_linux_test.go index 5344ed2051..58c797f1dd 100644 --- a/src/runtime/runtime_linux_test.go +++ b/src/runtime/runtime_linux_test.go @@ -8,6 +8,7 @@ import ( . "runtime" "syscall" "testing" + "unsafe" ) var pid, tid int @@ -27,3 +28,15 @@ func TestLockOSThread(t *testing.T) { t.Fatalf("pid=%d but tid=%d", pid, tid) } } + +// Test that error values are negative. Use address 1 (a misaligned +// pointer) to get -EINVAL. +func TestMincoreErrorSign(t *testing.T) { + var dst byte + v := Mincore(unsafe.Pointer(uintptr(1)), 1, &dst) + + const EINVAL = 0x16 + if v != -EINVAL { + t.Errorf("mincore = %v, want %v", v, -EINVAL) + } +} |