vmtest

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChooseTestInitramfs

func ChooseTestInitramfs(dontSetEnv bool, o uroot.Opts, uinit, outputFile string) error

ChooseTestInitramfs chooses which initramfs will be used for a given test and places it at the location given by outputFile. Default to the override initramfs if one is specified in the UROOT_INITRAMFS environment variable. Else, build an initramfs with the given parameters. If no uinit was provided, the generic one is used.

func CreateTestInitramfs

func CreateTestInitramfs(dontSetEnv bool, o uroot.Opts, uinit, outputFile string) (string, error)

CreateTestInitramfs creates an initramfs with the given build options and uinit, and writes it to the given output file. If no output file is provided, one will be created. The output file name is returned. It is the caller's responsibility to remove the initramfs file after use.

func GolangTest

func GolangTest(t *testing.T, pkgs []string, o *Options)

GolangTest compiles the unit tests found in pkgs and runs them in a QEMU VM.

func JSONLessTestLineWriter

func JSONLessTestLineWriter(tb testing.TB, prefix string) io.WriteCloser

func QEMU

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

QEMU builds the u-root environment and prepares QEMU options given the test options and environment variables.

QEMU will augment o.BuildOpts and o.QEMUOpts with configuration that the caller either requested (through the Options.Uinit field, for example) or that the caller did not set.

QEMU returns the QEMU launch options or an error.

func QEMUTest

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

func SkipWithoutQEMU

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

func TestArch() string

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

func TestLineWriter

func TestLineWriter(tb testing.TB, prefix string) io.WriteCloser

TestLineWriter is an io.Writer that logs full lines of serial to tb.

Types

type Options

type Options struct {
	// BuildOpts are u-root initramfs options.
	//
	// They are used if the test needs to generate an initramfs.
	// Fields that are not set are populated by QEMU and QEMUTest as
	// possible.
	BuildOpts uroot.Opts

	// QEMUOpts are QEMU VM options for the test.
	//
	// Fields that are not set are populated by QEMU and QEMUTest as
	// possible.
	QEMUOpts qemu.Options

	// DontSetEnv doesn't set the BuildOpts.Env and uses the user-supplied one.
	//
	// TODO: make uroot.Opts.Env a pointer?
	DontSetEnv bool

	// 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

	// Uinit is the uinit that should be added to a generated initramfs.
	//
	// If none is specified, the generic uinit will be used, which searches for
	// and runs the script generated from TestCmds.
	Uinit string

	// TestCmds are commands to execute after init.
	//
	// QEMUTest generates an Elvish script with these commands. The script is
	// shared with the VM, and is run from the generic uinit.
	TestCmds []string

	// TmpDir is the temporary directory exposed to the QEMU VM.
	TmpDir string

	// Logger logs build statements.
	Logger ulog.Logger

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

	// Use virtual vfat rather than 9pfs
	UseVVFAT bool

	// By default, if your kernel has CONFIG_DEBUG_FS=y and
	// CONFIG_GCOV_KERNEL=y enabled, the kernel's coverage will be
	// collected and saved to:
	//   u-root/integration/coverage/{{testname}}/{{instance}}/kernel_coverage.tar
	NoKernelCoverage bool
}

Options are integration test options.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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