tests: fixed TestLookupPidInProc

We expect to find at least one process that its inode 1 points to
/dev/null. The returned pid shouldn't be -1.
This commit is contained in:
Gustavo Iñiguez Goia 2021-02-06 15:29:24 +01:00
parent 95e4afac8e
commit 1e45a4c98b

View file

@ -22,16 +22,10 @@ func TestLookupPidDescriptors(t *testing.T) {
}
func TestLookupPidInProc(t *testing.T) {
pidsFd := lookupPidDescriptors(fmt.Sprint("/proc/", myPid, "/fd/"))
if len(pidsFd) == 0 {
t.Error("lookupPidInProc() pids length should not be 0", pidsFd)
}
// we expect that the inode 1 points to /dev/null
expect := "/dev/null"
foundPid := lookupPidInProc("/proc/", expect, "", 1)
if foundPid != myPid {
t.Error("lookupPidInProc() found PID (x) should be (y)", foundPid, myPid)
if foundPid == -1 {
t.Error("lookupPidInProc() should not return -1")
}
}