Documentation ¶
Index ¶
- Variables
- func AllowRecording(t testing.TB)
- func DefaultTestBackend(testBackend *string)
- func FindFixturesDir() string
- func MustHaveCgo(t *testing.T)
- func MustHaveRecordingAllowed(t testing.TB)
- func MustSupportFunctionCalls(t *testing.T, testBackend string)
- func RegabiSupported() bool
- func RunTestsWithFixtures(m *testing.M) int
- func SafeRemoveAll(dir string)
- func TempFile(name string) string
- type BuildFlags
- type Fixture
Constants ¶
This section is empty.
Variables ¶
var EnableRace = flag.Bool("racetarget", false, "Enables race detector on inferior process")
EnableRace allows to configure whether the race detector is enabled on target process.
var PathsToRemove []string
PathsToRemove is a list of files and directories to remove after running all the tests
Functions ¶
func AllowRecording ¶ added in v1.0.0
AllowRecording allows the calling test to be used with a recording of the fixture.
func DefaultTestBackend ¶ added in v1.22.2
func DefaultTestBackend(testBackend *string)
DefaultTestBackend changes the value of testBackend to be the default test backend for the OS, if testBackend isn't already set.
func FindFixturesDir ¶
func FindFixturesDir() string
FindFixturesDir will search for the directory holding all test fixtures beginning with the current directory and searching up 10 directories.
func MustHaveCgo ¶ added in v1.22.2
func MustHaveRecordingAllowed ¶ added in v1.0.0
MustHaveRecordingAllowed skips this test if recording is not allowed
Not all the tests can be run with a recording:
- some fixtures never terminate independently (loopprog, testnextnethttp) and can not be recorded
- some tests assume they can interact with the target process (for example TestIssue419, or anything changing the value of a variable), which we can't do on with a recording
- some tests assume that the Pid returned by the process is valid, but it won't be at replay time
- some tests will start the fixture but not never execute a single instruction, for some reason rr doesn't like this and will print an error if it happens
- many tests will assume that we can return from a runtime.Breakpoint, with a recording this is not possible because when the fixture ran it wasn't attached to a debugger and in those circumstances a runtime.Breakpoint leads directly to a crash
Some of the tests using runtime.Breakpoint (anything involving variable evaluation and TestWorkDir) have been adapted to work with a recording.
func MustSupportFunctionCalls ¶ added in v1.1.0
MustSupportFunctionCalls skips this test if function calls are unsupported on this backend/architecture pair.
func RegabiSupported ¶ added in v1.22.2
func RegabiSupported() bool
func RunTestsWithFixtures ¶
RunTestsWithFixtures will pre-compile test fixtures before running test methods. Test binaries are deleted before exiting.
func SafeRemoveAll ¶ added in v1.0.0
func SafeRemoveAll(dir string)
SafeRemoveAll removes dir and its contents but only as long as dir does not contain directories.
Types ¶
type BuildFlags ¶ added in v1.0.0
type BuildFlags uint32
BuildFlags used to build fixture.
const ( // LinkStrip enables '-ldflags="-s"'. LinkStrip BuildFlags = 1 << iota // EnableCGOOptimization will build CGO code with optimizations. EnableCGOOptimization // EnableInlining will build a binary with inline optimizations turned on. EnableInlining // EnableOptimization will build a binary with default optimizations. EnableOptimization // EnableDWZCompression will enable DWZ compression of DWARF sections. EnableDWZCompression BuildModePIE BuildModePlugin BuildModeExternalLinker AllNonOptimized // LinkDisableDWARF enables '-ldflags="-w"'. LinkDisableDWARF )
type Fixture ¶
type Fixture struct { // Name is the short name of the fixture. Name string // Path is the absolute path to the test binary. Path string // Source is the absolute path of the test binary source. Source string // BuildDir is the directory where the build command was run. BuildDir string }
Fixture is a test binary.
func BuildFixture ¶
func BuildFixture(name string, flags BuildFlags) Fixture
BuildFixture will compile the fixture 'name' using the provided build flags.
func WithPlugins ¶ added in v1.22.2
func WithPlugins(t *testing.T, flags BuildFlags, plugins ...string) []Fixture
WithPlugins builds the fixtures in plugins as plugins and returns them. The test calling WithPlugins will be skipped if the current combination of OS, architecture and version of GO doesn't support plugins or debugging plugins.