]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/test: only run setgid test on GNU/Linux
authorIan Lance Taylor <iant@golang.org>
Sat, 28 Jul 2012 17:40:51 +0000 (10:40 -0700)
committerIan Lance Taylor <iant@golang.org>
Sat, 28 Jul 2012 17:40:51 +0000 (10:40 -0700)
Fixes #3874.

R=golang-dev, nj, r, minux.ma
CC=golang-dev
https://golang.org/cl/6446060

misc/cgo/test/basic.go
misc/cgo/test/cgo_linux_test.go [new file with mode: 0644]
misc/cgo/test/cgo_test.go
misc/cgo/test/setgid_linux.go [new file with mode: 0644]

index c0f636289a79854d4abd98568e5a845052c01efb..70ec5e43ace398aefd9cf9c923e3bd17adb60702 100644 (file)
@@ -11,7 +11,6 @@ package cgotest
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include <unistd.h>
 
 #define SHIFT(x, y)  ((x)<<(y))
 #define KILO SHIFT(1, 10)
@@ -58,7 +57,6 @@ import "C"
 import (
        "syscall"
        "testing"
-       "time"
        "unsafe"
 )
 
@@ -126,20 +124,6 @@ func testMultipleAssign(t *testing.T) {
        C.free(unsafe.Pointer(p))
 }
 
-func testSetgid(t *testing.T) {
-       // Issue 3871.
-       c := make(chan bool)
-       go func() {
-               C.setgid(0)
-               c <- true
-       }()
-       select {
-       case <-c:
-       case <-time.After(5 * time.Second):
-               t.Error("setgid hung")
-       }
-}
-
 var (
        cuint  = (C.uint)(0)
        culong C.ulong
diff --git a/misc/cgo/test/cgo_linux_test.go b/misc/cgo/test/cgo_linux_test.go
new file mode 100644 (file)
index 0000000..056d67c
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2012 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cgotest
+
+import "testing"
+
+func TestSetgid(t *testing.T) { testSetgid(t) }
index 43d32da58594c25c4f5239f0fca88357b4f91396..34beee69d194d4d387ca738acd6cf041c852fa03 100644 (file)
@@ -27,6 +27,5 @@ func Test1328(t *testing.T)                { test1328(t) }
 func TestParallelSleep(t *testing.T)       { testParallelSleep(t) }
 func TestSetEnv(t *testing.T)              { testSetEnv(t) }
 func TestHelpers(t *testing.T)             { testHelpers(t) }
-func TestSetgid(t *testing.T)              { testSetgid(t) }
 
 func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
diff --git a/misc/cgo/test/setgid_linux.go b/misc/cgo/test/setgid_linux.go
new file mode 100644 (file)
index 0000000..829afce
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright 2012 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test that setgid does not hang on GNU/Linux.
+// See http://code.google.com/p/go/issues/detail?id=3871 for details.
+
+package cgotest
+
+/*
+#include <sys/types.h>
+#include <unistd.h>
+*/
+import "C"
+
+import (
+       "testing"
+       "time"
+)
+
+func testSetgid(t *testing.T) {
+       c := make(chan bool)
+       go func() {
+               C.setgid(0)
+               c <- true
+       }()
+       select {
+       case <-c:
+       case <-time.After(5 * time.Second):
+               t.Error("setgid hung")
+       }
+}