From 08d04ba2a49c1e9556002e36b2146b9467ec77e8 Mon Sep 17 00:00:00 2001 From: Hyang-Ah Hana Kim Date: Tue, 20 Oct 2015 14:48:49 -0400 Subject: [PATCH] log/syslog: disable unix/unixgram tests on android unix/unixgram is not available to standard Android programs. For golang/go#10807 Change-Id: I6062c3a25cffb86e58cbbd12a07dc90ffbf57185 Reviewed-on: https://go-review.googlesource.com/16114 Reviewed-by: Ian Lance Taylor --- src/log/syslog/syslog_test.go | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/log/syslog/syslog_test.go b/src/log/syslog/syslog_test.go index 85aec536abe..52363f9f7c2 100644 --- a/src/log/syslog/syslog_test.go +++ b/src/log/syslog/syslog_test.go @@ -47,6 +47,22 @@ func runPktSyslog(c net.PacketConn, done chan<- string) { var crashy = false +func testableNetwork(network string) bool { + switch network { + case "unix", "unixgram": + switch runtime.GOOS { + case "darwin": + switch runtime.GOARCH { + case "arm", "arm64": + return false + } + case "android": + return false + } + } + return true +} + func runStreamSyslog(l net.Listener, done chan<- string, wg *sync.WaitGroup) { for { var c net.Conn @@ -119,12 +135,10 @@ func startServer(n, la string, done chan<- string) (addr string, sock io.Closer, func TestWithSimulated(t *testing.T) { msg := "Test 123" - transport := []string{"unix", "unixgram", "udp", "tcp"} - - if runtime.GOOS == "darwin" { - switch runtime.GOARCH { - case "arm", "arm64": - transport = []string{"udp", "tcp"} + var transport []string + for _, n := range []string{"unix", "unixgram", "udp", "tcp"} { + if testableNetwork(n) { + transport = append(transport, n) } } @@ -150,14 +164,11 @@ func TestWithSimulated(t *testing.T) { } func TestFlap(t *testing.T) { - if runtime.GOOS == "darwin" { - switch runtime.GOARCH { - case "arm", "arm64": - t.Skipf("skipping on %s/%s", runtime.GOOS, runtime.GOARCH) - } + net := "unix" + if !testableNetwork(net) { + t.Skipf("skipping on %s/%s; 'unix' is not supported", runtime.GOOS, runtime.GOARCH) } - net := "unix" done := make(chan string) addr, sock, srvWG := startServer(net, "", done) defer srvWG.Wait() @@ -321,10 +332,10 @@ func TestConcurrentReconnect(t *testing.T) { const N = 10 const M = 100 net := "unix" - if runtime.GOOS == "darwin" { - switch runtime.GOARCH { - case "arm", "arm64": - net = "tcp" + if !testableNetwork(net) { + net = "tcp" + if !testableNetwork(net) { + t.Skipf("skipping on %s/%s; neither 'unix' or 'tcp' is supported", runtime.GOOS, runtime.GOARCH) } } done := make(chan string, N*M)