]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make TestWindowsStackMemory build even with CGO_ENABLED=0 set
authorAlex Brainman <alex.brainman@gmail.com>
Tue, 14 Nov 2017 01:51:58 +0000 (12:51 +1100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 14 Nov 2017 03:53:15 +0000 (03:53 +0000)
Just copy some code to make TestWindowsStackMemory build
when CGO_ENABLED is set to 0.

Fixes #22680

Change-Id: I63f9b409a3a97b7718f5d37837ab706d8ed92e81
Reviewed-on: https://go-review.googlesource.com/77430
Reviewed-by: Chris Hines <chris.cs.guy@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/crash_cgo_test.go
src/runtime/syscall_windows_test.go

index a4f4dd606d3fb4891b57887dbc3543bc5ab05fc1..25ff34397f72cdf6af00334168c289a97c653c18 100644 (file)
@@ -454,7 +454,12 @@ func TestCgoLockOSThreadExit(t *testing.T) {
        testLockOSThreadExit(t, "testprogcgo")
 }
 
-func testWindowsStackMemory(t *testing.T, o string) {
+func TestWindowsStackMemoryCgo(t *testing.T) {
+       if runtime.GOOS != "windows" {
+               t.Skip("skipping windows specific test")
+       }
+       testenv.SkipFlaky(t, 22575)
+       o := runTestProg(t, "testprogcgo", "StackMemory")
        stackUsage, err := strconv.Atoi(o)
        if err != nil {
                t.Fatalf("Failed to read stack usage: %v", err)
@@ -463,11 +468,3 @@ func testWindowsStackMemory(t *testing.T, o string) {
                t.Fatalf("expected < %d bytes of memory per thread, got %d", expected, got)
        }
 }
-
-func TestWindowsStackMemoryCgo(t *testing.T) {
-       if runtime.GOOS != "windows" {
-               t.Skip("skipping windows specific test")
-       }
-       testenv.SkipFlaky(t, 22575)
-       testWindowsStackMemory(t, runTestProg(t, "testprogcgo", "StackMemory"))
-}
index 20acf1b626c709bbb8aeb55d40630b10a44ab436..dfde12a211c939159c73481ee69eb9488762a233 100644 (file)
@@ -15,6 +15,7 @@ import (
        "os/exec"
        "path/filepath"
        "runtime"
+       "strconv"
        "strings"
        "syscall"
        "testing"
@@ -538,7 +539,14 @@ func TestWERDialogue(t *testing.T) {
 }
 
 func TestWindowsStackMemory(t *testing.T) {
-       testWindowsStackMemory(t, runTestProg(t, "testprog", "StackMemory"))
+       o := runTestProg(t, "testprog", "StackMemory")
+       stackUsage, err := strconv.Atoi(o)
+       if err != nil {
+               t.Fatalf("Failed to read stack usage: %v", err)
+       }
+       if expected, got := 100<<10, stackUsage; got > expected {
+               t.Fatalf("expected < %d bytes of memory per thread, got %d", expected, got)
+       }
 }
 
 var used byte