func check(t *testing.T, in, out, transport string) {
hostname, err := os.Hostname()
if err != nil {
- t.Error("Error retrieving hostname")
+ t.Errorf("Error retrieving hostname: %v", err)
return
}
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 {
+ if n != 3 || err != nil {
t.Errorf("Got %q, does not match template %q (%d %s)", out, tmpl, n, err)
}
+ if hostname != parsedHostname {
+ t.Errorf("Hostname got %q want %q in %q", parsedHostname, hostname, out)
+ }
}
func TestWrite(t *testing.T) {