Commit 70418eb8 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

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: default avatarIan Lance Taylor <iant@golang.org>
parent 53b66616
......@@ -28,6 +28,8 @@ var Exitsyscall = exitsyscall
var LockedOSThread = lockedOSThread
var Xadduintptr = atomic.Xadduintptr
var Mincore = mincore
var FuncPC = funcPC
var Fastlog2 = fastlog2
......
......@@ -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)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment