]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add test for mincore's return value sign on Linux
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 11 Feb 2016 16:36:38 +0000 (16:36 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 11 Feb 2016 19:09:50 +0000 (19:09 +0000)
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>
src/runtime/export_test.go
src/runtime/runtime_linux_test.go

index 5400c1d14eaae2d0fe30396357a616aa36572bff..b09022b53cc01f1536c46c27a11396048db699be 100644 (file)
@@ -28,6 +28,8 @@ var Exitsyscall = exitsyscall
 var LockedOSThread = lockedOSThread
 var Xadduintptr = atomic.Xadduintptr
 
+var Mincore = mincore
+
 var FuncPC = funcPC
 
 var Fastlog2 = fastlog2
index 5344ed2051a7cf09bc3cd564b3fbe4bdb62834aa..58c797f1dd6d2d0f0531667d480bc059bae1cf59 100644 (file)
@@ -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)
+       }
+}