integration

package
v5.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: BSD-3-Clause Imports: 19 Imported by: 0

README

Integration Tests

This tests core use cases for u-root such as:

  • retrieving and kexec'ing a Linux kernel,
  • uinit (user init), and
  • running unit tests requiring root privileges.

Usage

Run the tests with:

go test

When the QEMU arch is not amd64, set the UROOT_TESTARCH variable. For example:

UROOT_TESTARCH=arm go test

Currently, only amd64 and arm are supported.

Requirements

  • QEMU
    • Path and arguments must be set with UROOT_QEMU.
    • Example: export UROOT_QEMU="$HOME/bin/qemu-system-x86_64 -L ."
  • Linux kernel
    • Path and arguments must be set with UROOT_KERNEL.
    • Example: export UROOT_KERNEL="$HOME/linux/arch/x86_64/boot/bzImage"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QEMU

func QEMU(o *Options) (*qemu.Options, error)

func QEMUTest

func QEMUTest(t *testing.T, o *Options) (*qemu.VM, func())

func SkipWithoutQEMU added in v0.4.0

func SkipWithoutQEMU(t *testing.T)

SkipWithoutQEMU skips the test when the QEMU environment variables are not set. This is already called by QEMUTest(), so use if some expensive operations are performed before calling QEMUTest().

func TestArch added in v0.4.0

func TestArch() string

TestArch returns the architecture under test. Pass this as GOARCH when building Go programs to be run in the QEMU environment.

Types

type Options

type Options struct {
	// Env is the Go environment to use to build u-root.
	Env *golang.Environ

	// Name is the test's name.
	//
	// If name is left empty, the calling function's function name will be
	// used as determined by runtime.Caller
	Name string

	// Go commands to include in the initramfs for the VM.
	//
	// If left empty, all u-root commands will be included.
	Cmds []string

	// Uinit are commands to execute after init.
	//
	// If populated, a uinit.go will be generated from these.
	Uinit []string

	// Files are files to include in the VMs initramfs.
	Files []string

	// TmpDir is a temporary directory for build artifacts.
	TmpDir string

	// LogFile is a file to log serial output to.
	//
	// The default is serial/$Name.log
	LogFile string

	// Logger logs build statements.
	Logger logger.Logger

	// Timeout is the timeout for expect statements.
	Timeout time.Duration

	// Network is the VM's network.
	Network *qemu.Network

	// Extra environment variables to set when building (used by u-bmc)
	ExtraBuildEnv []string

	// Serial Output
	SerialOutput io.WriteCloser
}

Options are integration test options.

type TestLineWriter added in v0.5.0

type TestLineWriter struct {
	TB     testing.TB
	Prefix string
	// contains filtered or unexported fields
}

TestLineWriter is an io.Writer that waits for a full line of prints before logging to TB.

func (*TestLineWriter) Close added in v0.5.0

func (tsw *TestLineWriter) Close() error

func (*TestLineWriter) Write added in v0.5.0

func (tsw *TestLineWriter) Write(p []byte) (int, error)

Directories

Path Synopsis
testcmd

Jump to

Keyboard shortcuts

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