author | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-05-28 21:26:28 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-05-28 23:21:04 UTC |
parent | c26a65e81ff02d0c9d426395d9cce01b3d46e06c |
systemd_test.go | +20 | -0 |
diff --git a/systemd_test.go b/systemd_test.go index 6686795..e005b67 100644 --- a/systemd_test.go +++ b/systemd_test.go @@ -105,6 +105,26 @@ func TestNoFDs(t *testing.T) { if ls, err := Files(); len(ls) != 0 || err != nil { t.Errorf("Got a non-empty result: %v // %v", ls, err) } + if l, err := OneListener("nothing"); l != nil || err != nil { + t.Errorf("Unexpected result: %v // %v", l, err) + } + if l, err := Listen("tcp", "¬hing"); l != nil || err == nil { + t.Errorf("Unexpected result: %v // %v", l, err) + } +} + +func TestBadFDs(t *testing.T) { + f, err := os.Open(os.DevNull) + if err != nil { + t.Fatalf("Failed to open /dev/null: %v", err) + } + defer f.Close() + + setenv(strconv.Itoa(os.Getpid()), "1") + firstFD = int(f.Fd()) + if ls, err := Listeners(); len(ls) != 1 || err == nil { + t.Errorf("Got a non-empty result: %v // %v", ls, err) + } } // newListener creates a TCP listener.