Documentation
¶
Overview ¶
Package fdtest reads what a process's file descriptors refer to, for tests that hold a component to closing every descriptor it is handed.
Index ¶
- func Beyond(held, baseline []string) []string
- func Held(t testing.TB, pid int) []string
- func HoldSilent(t testing.TB, fd uintptr)
- func Own(t testing.TB) []string
- func RawPipe(t testing.TB) (r *os.File, w uintptr)
- func Receive(t testing.TB, send func(w uintptr)) []byte
- func RequireNoneBeyond(t testing.TB, baseline []string, after string)
- func Stream(t testing.TB, fd uintptr, payload []byte) (wait func() error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Held ¶
Held is what process pid's open file descriptors refer to, in order: the path each /proc/<pid>/fd entry links to, a socket and a pipe without their inode numbers, so that two readings compare by what is open rather than by which descriptor numbers hold it.
func HoldSilent ¶ added in v0.2.24
HoldSilent dups fd and keeps the dup open and silent until the test ends, so that only a deadline can end a read of the other end.
func RawPipe ¶
RawPipe is a pipe whose write end the Go runtime has never seen, as a compositor hands a source client the write end of a consumer's: w is a plain blocking descriptor, never registered with the poller, and the handler's under test to close. The test reads r, which takes deadlines, and closes it.
func Receive ¶
Receive hands send the write end of a fresh RawPipe and returns what was written to it by the time every write end closed, failing the test when one is still open after receiveLimit.
func RequireNoneBeyond ¶
RequireNoneBeyond fails the test when its own process holds anything beyond baseline, naming what it holds and after what.
func Stream ¶ added in v0.2.24
Stream plays the foreign client at the far end of a transfer: it dups fd, the way the compositor hands one out, writes payload to the dup from its own goroutine and closes it. wait reports the write's error, or that the peer was still blocked on the pipe after receiveLimit; it returns an error rather than failing the test so that it can be called from any goroutine.
Types ¶
This section is empty.