fdtest

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Beyond

func Beyond(held, baseline []string) []string

Beyond lists what held has more of than baseline, both in order.

func Held

func Held(t testing.TB, pid int) []string

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

func HoldSilent(t testing.TB, fd uintptr)

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 Own

func Own(t testing.TB) []string

Own is Held for the test's own process.

func RawPipe

func RawPipe(t testing.TB) (r *os.File, w uintptr)

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

func Receive(t testing.TB, send func(w uintptr)) []byte

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

func RequireNoneBeyond(t testing.TB, baseline []string, after string)

RequireNoneBeyond fails the test when its own process holds anything beyond baseline, naming what it holds and after what.

func Stream

func Stream(t testing.TB, fd uintptr, payload []byte) (wait func() error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL