From: Brad Fitzpatrick Date: Thu, 11 Feb 2016 16:36:38 +0000 (+0000) Subject: runtime: add test for mincore's return value sign on Linux X-Git-Tag: go1.6~1^2~17 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=70418eb819eb1d02c2c56a13159d95baab85d3a8;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- 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) + } +}