1
0
mirror of https://github.com/golang/go synced 2024-11-19 15:34:47 -07:00

runtime: make TestWindowsStackMemory build even with CGO_ENABLED=0 set

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>
This commit is contained in:
Alex Brainman 2017-11-14 12:51:58 +11:00 committed by Brad Fitzpatrick
parent b29bb78a7e
commit cea92e8d13
2 changed files with 15 additions and 10 deletions

View 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"))
}

View 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