testutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MachineX86_64 is the ELF e_machine value for AMD64.
	MachineX86_64 = 62
	// MachineAArch64 is the ELF e_machine value for AArch64.
	MachineAArch64 = 183
)

Variables

This section is empty.

Functions

func VerifyExpectations

func VerifyExpectations(t *testing.T, lines []DisasmLine, expect []Expectation)

VerifyExpectations walks the objdump output and ensures each expectation is satisfied in order. Extra instructions after all expectations are ignored so padding emitted for alignment does not fail the test.

Types

type DisasmLine

type DisasmLine struct {
	Text       string
	Normalized string
	Mnemonic   string
}

DisasmLine represents a single instruction line emitted by objdump.

func DisassembleWithObjdump

func DisassembleWithObjdump(t *testing.T, code []byte, machine uint16, extraArgs ...string) []DisasmLine

DisassembleWithObjdump wraps the provided code bytes into a minimal ELF for the supplied machine type and runs GNU objdump -d --no-show-raw-insn.

func DisassembleWithTool

func DisassembleWithTool(t *testing.T, tool string, code []byte, machine uint16, args ...string) []DisasmLine

DisassembleWithTool wraps the provided code bytes into a minimal ELF for the supplied machine type and invokes the requested disassembler.

func (DisasmLine) Contains

func (l DisasmLine) Contains(substr string) bool

Contains reports whether the normalized instruction text contains the provided substring.

type Expectation

type Expectation struct {
	Name     string
	Mnemonic string
	Contains []string
}

Expectation describes a single instruction that should appear in the disassembly output.

Jump to

Keyboard shortcuts

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