peercredtest

package
v0.3.18 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 9 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 peercredtest gives a test a socket peer that is another process, with a pid and a lifetime of its own: what telling a peer from the test itself, or outliving it, needs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(run func() int) int

Main is Run for a TestMain with work of its own around the tests, such as testhome's isolation:

func TestMain(m *testing.M) {
	os.Exit(testhome.Main(func() int { return peercredtest.Main(m.Run) }))
}

It calls run and returns its code, except in the process Start runs, where it is the peer: it connects to the test's socket, stays until its standard input closes, and returns the peer's exit code.

func Run

func Run(m *testing.M)

Run is the TestMain of a package whose tests call Start:

func TestMain(m *testing.M) { peercredtest.Run(m) }

It runs the tests and exits with their code, except in the process Start runs, where it is the peer. See Main.

Types

type Peer

type Peer struct {
	// Conn is the test's end of the connection the peer made.
	Conn *net.UnixConn
	// PID is the peer's process id.
	PID int
	// contains filtered or unexported fields
}

Peer is a process of its own connected to the test.

func Start

func Start(t testing.TB) *Peer

Start runs the test binary again as a peer (Main) and returns once it has connected. The peer ends, and is reaped, with the test at the latest.

func (*Peer) End

func (p *Peer) End()

End tells the peer to exit and returns at once: until Reap the peer is running or, once it has exited, a zombie whose pid is still its own.

func (*Peer) Reap

func (p *Peer) Reap(t testing.TB)

Reap ends the peer and waits for it, after which its pid is free for another process. Reaping again does nothing.

Jump to

Keyboard shortcuts

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