diff options
Diffstat (limited to 'src/log/syslog/syslog_test.go')
-rw-r--r-- | src/log/syslog/syslog_test.go | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/log/syslog/syslog_test.go b/src/log/syslog/syslog_test.go index dd2f83e04f..8f472a56b7 100644 --- a/src/log/syslog/syslog_test.go +++ b/src/log/syslog/syslog_test.go @@ -51,12 +51,7 @@ func testableNetwork(network string) bool { switch network { case "unix", "unixgram": switch runtime.GOOS { - case "darwin", "ios": - switch runtime.GOARCH { - case "arm64": - return false - } - case "android": + case "ios", "android": return false } } @@ -159,7 +154,7 @@ func TestWithSimulated(t *testing.T) { if err != nil { t.Fatalf("log failed: %v", err) } - check(t, msg, <-done) + check(t, msg, <-done, tr) s.Close() } } @@ -185,7 +180,7 @@ func TestFlap(t *testing.T) { if err != nil { t.Fatalf("log failed: %v", err) } - check(t, msg, <-done) + check(t, msg, <-done, net) // restart the server _, sock2, srvWG2 := startServer(net, addr, done) @@ -198,7 +193,7 @@ func TestFlap(t *testing.T) { if err != nil { t.Fatalf("log failed: %v", err) } - check(t, msg, <-done) + check(t, msg, <-done, net) s.Close() } @@ -258,16 +253,31 @@ func TestDial(t *testing.T) { l.Close() } -func check(t *testing.T, in, out string) { - tmpl := fmt.Sprintf("<%d>%%s %%s syslog_test[%%d]: %s\n", LOG_USER+LOG_INFO, in) - if hostname, err := os.Hostname(); err != nil { +func check(t *testing.T, in, out, transport string) { + hostname, err := os.Hostname() + if err != nil { t.Error("Error retrieving hostname") - } else { - var parsedHostname, timestamp string + return + } + + if transport == "unixgram" || transport == "unix" { + var month, date, ts string var pid int - if n, err := fmt.Sscanf(out, tmpl, ×tamp, &parsedHostname, &pid); n != 3 || err != nil || hostname != parsedHostname { + tmpl := fmt.Sprintf("<%d>%%s %%s %%s syslog_test[%%d]: %s\n", LOG_USER+LOG_INFO, in) + n, err := fmt.Sscanf(out, tmpl, &month, &date, &ts, &pid) + if n != 4 || err != nil { t.Errorf("Got %q, does not match template %q (%d %s)", out, tmpl, n, err) } + return + } + + // Non-UNIX domain transports. + var parsedHostname, timestamp string + var pid int + tmpl := fmt.Sprintf("<%d>%%s %%s syslog_test[%%d]: %s\n", LOG_USER+LOG_INFO, in) + n, err := fmt.Sscanf(out, tmpl, ×tamp, &parsedHostname, &pid) + if n != 3 || err != nil || hostname != parsedHostname { + t.Errorf("Got %q, does not match template %q (%d %s)", out, tmpl, n, err) } } |