Skip to content

Commit 08d04ba

Browse files
committed
log/syslog: disable unix/unixgram tests on android
unix/unixgram is not available to standard Android programs. For #10807 Change-Id: I6062c3a25cffb86e58cbbd12a07dc90ffbf57185 Reviewed-on: https://go-review.googlesource.com/16114 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 5174df9 commit 08d04ba

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

src/log/syslog/syslog_test.go

+27-16
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ func runPktSyslog(c net.PacketConn, done chan<- string) {
4747

4848
var crashy = false
4949

50+
func testableNetwork(network string) bool {
51+
switch network {
52+
case "unix", "unixgram":
53+
switch runtime.GOOS {
54+
case "darwin":
55+
switch runtime.GOARCH {
56+
case "arm", "arm64":
57+
return false
58+
}
59+
case "android":
60+
return false
61+
}
62+
}
63+
return true
64+
}
65+
5066
func runStreamSyslog(l net.Listener, done chan<- string, wg *sync.WaitGroup) {
5167
for {
5268
var c net.Conn
@@ -119,12 +135,10 @@ func startServer(n, la string, done chan<- string) (addr string, sock io.Closer,
119135

120136
func TestWithSimulated(t *testing.T) {
121137
msg := "Test 123"
122-
transport := []string{"unix", "unixgram", "udp", "tcp"}
123-
124-
if runtime.GOOS == "darwin" {
125-
switch runtime.GOARCH {
126-
case "arm", "arm64":
127-
transport = []string{"udp", "tcp"}
138+
var transport []string
139+
for _, n := range []string{"unix", "unixgram", "udp", "tcp"} {
140+
if testableNetwork(n) {
141+
transport = append(transport, n)
128142
}
129143
}
130144

@@ -150,14 +164,11 @@ func TestWithSimulated(t *testing.T) {
150164
}
151165

152166
func TestFlap(t *testing.T) {
153-
if runtime.GOOS == "darwin" {
154-
switch runtime.GOARCH {
155-
case "arm", "arm64":
156-
t.Skipf("skipping on %s/%s", runtime.GOOS, runtime.GOARCH)
157-
}
167+
net := "unix"
168+
if !testableNetwork(net) {
169+
t.Skipf("skipping on %s/%s; 'unix' is not supported", runtime.GOOS, runtime.GOARCH)
158170
}
159171

160-
net := "unix"
161172
done := make(chan string)
162173
addr, sock, srvWG := startServer(net, "", done)
163174
defer srvWG.Wait()
@@ -321,10 +332,10 @@ func TestConcurrentReconnect(t *testing.T) {
321332
const N = 10
322333
const M = 100
323334
net := "unix"
324-
if runtime.GOOS == "darwin" {
325-
switch runtime.GOARCH {
326-
case "arm", "arm64":
327-
net = "tcp"
335+
if !testableNetwork(net) {
336+
net = "tcp"
337+
if !testableNetwork(net) {
338+
t.Skipf("skipping on %s/%s; neither 'unix' or 'tcp' is supported", runtime.GOOS, runtime.GOARCH)
328339
}
329340
}
330341
done := make(chan string, N*M)

0 commit comments

Comments
 (0)