Skip to content

Commit 70418eb

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 53b6661 commit 70418eb

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/runtime/export_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var Exitsyscall = exitsyscall
2828
var LockedOSThread = lockedOSThread
2929
var Xadduintptr = atomic.Xadduintptr
3030

31+
var Mincore = mincore
32+
3133
var FuncPC = funcPC
3234

3335
var Fastlog2 = fastlog2

src/runtime/runtime_linux_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
. "runtime"
99
"syscall"
1010
"testing"
11+
"unsafe"
1112
)
1213

1314
var pid, tid int
@@ -27,3 +28,15 @@ func TestLockOSThread(t *testing.T) {
2728
t.Fatalf("pid=%d but tid=%d", pid, tid)
2829
}
2930
}
31+
32+
// Test that error values are negative. Use address 1 (a misaligned
33+
// pointer) to get -EINVAL.
34+
func TestMincoreErrorSign(t *testing.T) {
35+
var dst byte
36+
v := Mincore(unsafe.Pointer(uintptr(1)), 1, &dst)
37+
38+
const EINVAL = 0x16
39+
if v != -EINVAL {
40+
t.Errorf("mincore = %v, want %v", v, -EINVAL)
41+
}
42+
}

0 commit comments

Comments
 (0)