Fix errcheck errors in probe

This commit is contained in:
Peter Bourgon
2015-05-26 16:49:47 +02:00
parent 957d5253a1
commit 8f6b9895ac
2 changed files with 10 additions and 4 deletions

View File

@@ -53,7 +53,7 @@ func main() {
log.Printf("exposing Prometheus endpoint at %s%s", *httpListen, *prometheusEndpoint)
http.Handle(*prometheusEndpoint, makePrometheusHandler())
}
go http.ListenAndServe(*httpListen, nil)
go func(err error) { log.Print(err) }(http.ListenAndServe(*httpListen, nil))
}
if *spyProcs && os.Getegid() != 0 {

View File

@@ -17,7 +17,7 @@ func TestCgroupMapper(t *testing.T) {
"/netscape/notify_on_release": "0\n",
"/weirdfile": "",
})
defer os.RemoveAll(tmp)
defer removeAll(t, tmp)
m := newCgroupMapper(tmp, 1*time.Second)
for pid, want := range map[uint]string{
@@ -44,14 +44,20 @@ func setupTmpFS(t *testing.T, fs map[string]string) string {
for file, content := range fs {
dir := path.Dir(file)
if err := os.MkdirAll(filepath.Join(tmp, dir), 0777); err != nil {
os.RemoveAll(tmp)
removeAll(t, tmp)
t.Fatalf("MkdirAll: %v", err)
}
if err := ioutil.WriteFile(filepath.Join(tmp, file), []byte(content), 0655); err != nil {
os.RemoveAll(tmp)
removeAll(t, tmp)
t.Fatalf("WriteFile: %v", err)
}
}
return tmp
}
func removeAll(t *testing.T, path string) {
if err := os.RemoveAll(path); err != nil {
t.Error(err)
}
}