Commit cea92e8d authored by Alex Brainman's avatar Alex Brainman Committed by Brad Fitzpatrick

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/77430Reviewed-by: default avatarChris Hines <chris.cs.guy@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent b29bb78a
......@@ -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"))
}
......@@ -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
......
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