mirror of
https://github.com/rwinkhart/peercred-mini.git
synced 2026-08-28 04:46:43 -04:00
Update test to check for full FreeBSD support
This commit is contained in:
+2
-2
@@ -16,8 +16,8 @@ type Creds struct {
|
|||||||
uid string
|
uid string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Creds) PID() (pid int, ok bool) {
|
func (c *Creds) PID() (pid int) {
|
||||||
return c.pid, c.pid != 0
|
return c.pid
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserID returns the userid (or Windows SID) that owns the other side
|
// UserID returns the userid (or Windows SID) that owns the other side
|
||||||
|
|||||||
+8
-14
@@ -11,7 +11,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,23 +51,18 @@ func TestUnixSock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uid := creds.UserID()
|
uid := creds.UserID()
|
||||||
if !ok {
|
if uid == "" {
|
||||||
t.Errorf("no UID")
|
t.Errorf("no UID")
|
||||||
}
|
}
|
||||||
if got, want := uid, fmt.Sprint(os.Getuid()); got != want {
|
if got, want := uid, fmt.Sprint(os.Getuid()); got != want {
|
||||||
t.Errorf("UID = %q; want %q", got, want)
|
t.Errorf("UID = %q; want %q", got, want)
|
||||||
}
|
}
|
||||||
pid, ok := creds.PID()
|
|
||||||
if runtime.GOOS == "freebsd" {
|
pid := creds.PID()
|
||||||
if ok {
|
if pid == 0 {
|
||||||
t.Error("PID ok; want !ok. Thank you for fixing FreeBSD, please update the test.")
|
t.Errorf("no PID")
|
||||||
}
|
}
|
||||||
} else {
|
if got, want := pid, os.Getpid(); got != want {
|
||||||
if !ok {
|
t.Errorf("PID = %v; want %v", got, want)
|
||||||
t.Errorf("no PID")
|
|
||||||
}
|
|
||||||
if got, want := pid, os.Getpid(); got != want {
|
|
||||||
t.Errorf("PID = %v; want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user