mirror of
https://github.com/golang/go
synced 2024-11-19 04:34:39 -07:00
runtime: make TestCgoExternalThreadPanic run on windows
LGTM=rsc R=golang-codereviews, bradfitz, rsc CC=golang-codereviews https://golang.org/cl/163540043
This commit is contained in:
parent
bfe459adc9
commit
f9c4c16dce
@ -36,10 +36,14 @@ func TestCgoTraceback(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCgoExternalThreadPanic(t *testing.T) {
|
func TestCgoExternalThreadPanic(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
|
if runtime.GOOS == "plan9" {
|
||||||
t.Skipf("no pthreads on %s", runtime.GOOS)
|
t.Skipf("no pthreads on %s", runtime.GOOS)
|
||||||
}
|
}
|
||||||
got := executeTest(t, cgoExternalThreadPanicSource, nil, "main.c", cgoExternalThreadPanicC)
|
csrc := cgoExternalThreadPanicC
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
csrc = cgoExternalThreadPanicC_windows
|
||||||
|
}
|
||||||
|
got := executeTest(t, cgoExternalThreadPanicSource, nil, "main.c", csrc)
|
||||||
want := "panic: BOOM"
|
want := "panic: BOOM"
|
||||||
if !strings.Contains(got, want) {
|
if !strings.Contains(got, want) {
|
||||||
t.Fatalf("want failure containing %q. output:\n%s\n", want, got)
|
t.Fatalf("want failure containing %q. output:\n%s\n", want, got)
|
||||||
@ -169,3 +173,24 @@ start(void)
|
|||||||
printf("pthread_create failed\n");
|
printf("pthread_create failed\n");
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const cgoExternalThreadPanicC_windows = `
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void gopanic(void);
|
||||||
|
|
||||||
|
static void*
|
||||||
|
die(void* x)
|
||||||
|
{
|
||||||
|
gopanic();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
start(void)
|
||||||
|
{
|
||||||
|
if(_beginthreadex(0, 0, die, 0, 0, 0) != 0)
|
||||||
|
printf("_beginthreadex failed\n");
|
||||||
|
}
|
||||||
|
`
|
||||||
|
Loading…
Reference in New Issue
Block a user