abistub

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 8 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 abistub builds C libraries that stand in for a vendor library in native ABI tests of the generated bindings.

A stub starts with Prelude and records each argument it receives with its macros. A test loads the stub through the package's own Load, calls a wrapper, and compares Recorder.Recorded with the arguments it passed, bit for bit. The stub returns the value set by Recorder.Reset, so the same call also checks error conversion.

Index

Constants

View Source
const Prelude = `` /* 439-byte string literal not displayed */

Prelude declares the record a stub keeps and the macros that fill it. Each function starts with BEGIN and returns RET:

R(x)    records an unsigned integer, pointer or handle, zero-extended
S(x)    records a signed integer, sign-extended
F32(x)  records a float's bit pattern
F64(x)  records a double's bit pattern

Variables

This section is empty.

Functions

func Build

func Build(tb testing.TB, csrc string, flags ...string) string

Build compiles csrc, with flags, as a shared library and returns its path. It skips tb when there is no C compiler.

func CUDAInclude

func CUDAInclude(header string) string

CUDAInclude returns the CUDA toolkit include directory holding header, or "" if there is none. It looks in $CUDA_HOME, $CUDA_PATH and /usr/local/cuda, then in /usr, where distribution packages such as NCCL's install their headers. A stub built against the real header with -DSTUB_REAL_HEADER has its prototypes and layouts checked by the compiler.

func Child

func Child(t *testing.T, test, env, lib string)

Child runs the top-level test named test in a child process of the test binary, with the environment variable env set to lib, and fails t if the child fails. A test that loads a stub runs there, so the stub never becomes another test's library.

Types

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

A Recorder reads the record of a loaded stub.

func NewRecorder

func NewRecorder(lookup func(string) (uintptr, error)) (*Recorder, error)

NewRecorder returns a Recorder for the stub whose data symbols lookup resolves.

func (*Recorder) Recorded

func (r *Recorder) Recorded() []uint64

Recorded returns the words the last stub call recorded.

func (*Recorder) Reset

func (r *Recorder) Reset(ret int32)

Reset clears the record and sets the value each stub function returns.

func (*Recorder) Uint64s

func (r *Recorder) Uint64s(name string, n int) ([]uint64, error)

Uint64s returns the first n elements of the stub's uint64_t array name.

Jump to

Keyboard shortcuts

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