mirror of
https://github.com/golang/go
synced 2024-11-21 22:14:41 -07:00
misc/cgo/test: add test for issue 3871: cgo setgid hang on GNU/Linux
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/6445049
This commit is contained in:
parent
a1f340fa1a
commit
c49af2ccaf
@ -11,6 +11,7 @@ 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)
|
||||
@ -57,6 +58,7 @@ import "C"
|
||||
import (
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@ -124,6 +126,20 @@ 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
|
||||
|
@ -27,5 +27,6 @@ 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) }
|
||||
|
Loading…
Reference in New Issue
Block a user