bootloadertest

package
v0.0.0-...-c7fba9c Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UTF16Bytes

func UTF16Bytes(s string) []byte

UTF16Bytes converts the given string into its UTF16 encoding. Convenient for use together with efi.MockVars.

Types

type ExtractedRecoveryKernelCall

type ExtractedRecoveryKernelCall struct {
	RecoverySystemDir string
	S                 snap.PlaceInfo
}

type MockBootloader

type MockBootloader struct {
	MockedPresent bool
	PresentErr    error

	BootVars         map[string]string
	SetBootVarsCalls int
	SetErr           error
	SetErrFunc       func() error
	GetErr           error

	ExtractKernelAssetsCalls []snap.PlaceInfo
	RemoveKernelAssetsCalls  []snap.PlaceInfo

	InstallBootConfigCalled []string
	InstallBootConfigErr    error
	// contains filtered or unexported fields
}

MockBootloader mocks the bootloader interface and records all set/get calls.

func Mock

func Mock(name, bootdir string) *MockBootloader

func (*MockBootloader) ExtractKernelAssets

func (b *MockBootloader) ExtractKernelAssets(s snap.PlaceInfo, snapf snap.Container) error

func (*MockBootloader) ExtractedRecoveryKernelImage

func (b *MockBootloader) ExtractedRecoveryKernelImage() *MockExtractedRecoveryKernelImageBootloader

ExtractedRecoveryKernelImage derives a MockRecoveryAwareBootloader from a base MockBootloader.

func (*MockBootloader) GetBootVars

func (b *MockBootloader) GetBootVars(keys ...string) (map[string]string, error)

func (*MockBootloader) InstallBootConfig

func (b *MockBootloader) InstallBootConfig(gadgetDir string, opts *bootloader.Options) error

InstallBootConfig installs the boot config in the gadget directory to the mock bootloader's root directory.

func (*MockBootloader) Name

func (b *MockBootloader) Name() string

func (*MockBootloader) Present

func (b *MockBootloader) Present() (bool, error)

func (*MockBootloader) RecoveryAware

func (b *MockBootloader) RecoveryAware() *MockRecoveryAwareBootloader

RecoveryAware derives a MockRecoveryAwareBootloader from a base MockBootloader.

func (*MockBootloader) RemoveKernelAssets

func (b *MockBootloader) RemoveKernelAssets(s snap.PlaceInfo) error

func (*MockBootloader) SetBootVars

func (b *MockBootloader) SetBootVars(values map[string]string) error

func (*MockBootloader) SetEnabledKernel

func (b *MockBootloader) SetEnabledKernel(s snap.PlaceInfo) (restore func())

func (*MockBootloader) SetEnabledTryKernel

func (b *MockBootloader) SetEnabledTryKernel(s snap.PlaceInfo) (restore func())

func (*MockBootloader) SetMockToPanic

func (b *MockBootloader) SetMockToPanic(f string) (restore func())

SetMockToPanic allows setting any method in the Bootloader interface or derived interface to panic instead of returning. This allows one to test what would happen if the system was rebooted during execution of a particular function. Specifically, the panic will be done immediately entering the function so setting SetBootVars to panic will emulate a reboot before any boot vars are set persistently

func (*MockBootloader) WithExtractedRunKernelImage

func (b *MockBootloader) WithExtractedRunKernelImage() *MockExtractedRunKernelImageBootloader

WithExtractedRunKernelImage derives a MockExtractedRunKernelImageBootloader from a base MockBootloader.

func (*MockBootloader) WithRecoveryAwareTrustedAssets

func (b *MockBootloader) WithRecoveryAwareTrustedAssets() *MockRecoveryAwareTrustedAssetsBootloader

func (*MockBootloader) WithTrustedAssets

func (b *MockBootloader) WithTrustedAssets() *MockTrustedAssetsBootloader

type MockExtractedRecoveryKernelImageBootloader

type MockExtractedRecoveryKernelImageBootloader struct {
	*MockBootloader

	ExtractRecoveryKernelAssetsCalls []ExtractedRecoveryKernelCall
}

MockExtractedRecoveryKernelImageBootloader mocks a bootloader implementing the ExtractedRecoveryKernelImage interface.

func (*MockExtractedRecoveryKernelImageBootloader) ExtractRecoveryKernelAssets

func (b *MockExtractedRecoveryKernelImageBootloader) ExtractRecoveryKernelAssets(recoverySystemDir string, s snap.PlaceInfo, snapf snap.Container) error

ExtractRecoveryKernelAssets extracts the kernel assets for the provided kernel snap into the specified recovery system dir; part of RecoveryAwareBootloader.

type MockExtractedRunKernelImageBootloader

type MockExtractedRunKernelImageBootloader struct {
	*MockBootloader

	MockExtractedRunKernelImageMixin
}

MockExtractedRunKernelImageBootloader mocks a bootloader implementing the ExtractedRunKernelImageBootloader interface.

func (*MockExtractedRunKernelImageBootloader) SetEnabledKernel

func (b *MockExtractedRunKernelImageBootloader) SetEnabledKernel(kernel snap.PlaceInfo) (restore func())

func (*MockExtractedRunKernelImageBootloader) SetEnabledTryKernel

func (b *MockExtractedRunKernelImageBootloader) SetEnabledTryKernel(kernel snap.PlaceInfo) (restore func())

type MockExtractedRunKernelImageMixin

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

MockExtractedRunKernelImageMixin implements the ExtractedRunKernelImageBootloader interface.

func (*MockExtractedRunKernelImageMixin) DisableTryKernel

func (b *MockExtractedRunKernelImageMixin) DisableTryKernel() error

DisableTryKernel removes the current try-kernel "symlink" set in the bootloader; part of ExtractedRunKernelImageBootloader.

func (*MockExtractedRunKernelImageMixin) EnableKernel

EnableKernel enables the kernel; part of ExtractedRunKernelImageBootloader.

func (*MockExtractedRunKernelImageMixin) EnableTryKernel

func (b *MockExtractedRunKernelImageMixin) EnableTryKernel(s snap.PlaceInfo) error

EnableTryKernel enables a try-kernel; part of ExtractedRunKernelImageBootloader.

func (*MockExtractedRunKernelImageMixin) GetRunKernelImageFunctionSnapCalls

func (b *MockExtractedRunKernelImageMixin) GetRunKernelImageFunctionSnapCalls(f string) ([]snap.PlaceInfo, int)

GetRunKernelImageFunctionSnapCalls returns which snaps were specified during execution, in order of calls, as well as the number of calls for methods that don't take a snap to set.

func (*MockExtractedRunKernelImageMixin) Kernel

Kernel returns the current kernel set in the bootloader; part of ExtractedRunKernelImageBootloader.

func (*MockExtractedRunKernelImageMixin) SetEnabledKernel

func (b *MockExtractedRunKernelImageMixin) SetEnabledKernel(kernel snap.PlaceInfo) (restore func())

SetEnabledKernel sets the current kernel "symlink" as returned by Kernel(); returns' a restore function to set it back to what it was before.

func (*MockExtractedRunKernelImageMixin) SetEnabledTryKernel

func (b *MockExtractedRunKernelImageMixin) SetEnabledTryKernel(kernel snap.PlaceInfo) (restore func())

SetEnabledTryKernel sets the current try-kernel "symlink" as returned by TryKernel(). If set to nil, TryKernel()'s second return value will be false; returns' a restore function to set it back to what it was before.

func (*MockExtractedRunKernelImageMixin) SetRunKernelImageFunctionError

func (b *MockExtractedRunKernelImageMixin) SetRunKernelImageFunctionError(f string, err error) (restore func())

SetRunKernelImageFunctionError allows setting an error to be returned for the specified function; it returns a restore function to set it back to what it was before.

func (*MockExtractedRunKernelImageMixin) TryKernel

TryKernel returns the current kernel set in the bootloader; part of ExtractedRunKernelImageBootloader.

type MockRecoveryAwareBootloader

type MockRecoveryAwareBootloader struct {
	*MockBootloader
	MockRecoveryAwareMixin
}

MockRecoveryAwareBootloader mocks a bootloader implementing the RecoveryAware interface.

type MockRecoveryAwareMixin

type MockRecoveryAwareMixin struct {
	RecoverySystemDir      string
	RecoverySystemBootVars map[string]string
}

MockRecoveryAwareMixin implements the RecoveryAware interface.

func (*MockRecoveryAwareMixin) GetRecoverySystemEnv

func (b *MockRecoveryAwareMixin) GetRecoverySystemEnv(recoverySystemDir, key string) (string, error)

GetRecoverySystemEnv gets the recovery system environment bootloader variables; part of RecoveryAwareBootloader.

func (*MockRecoveryAwareMixin) SetRecoverySystemEnv

func (b *MockRecoveryAwareMixin) SetRecoverySystemEnv(recoverySystemDir string, blVars map[string]string) error

SetRecoverySystemEnv sets the recovery system environment bootloader variables; part of RecoveryAwareBootloader.

type MockRecoveryAwareTrustedAssetsBootloader

type MockRecoveryAwareTrustedAssetsBootloader struct {
	*MockBootloader

	MockRecoveryAwareMixin
	MockTrustedAssetsMixin
}

MockRecoveryAwareTrustedAssetsBootloader implements the bootloader.RecoveryAwareBootloader and bootloader.TrustedAssetsBootloader interfaces.

type MockTrustedAssetsBootloader

type MockTrustedAssetsBootloader struct {
	*MockBootloader

	MockTrustedAssetsMixin
}

MockTrustedAssetsBootloader mocks a bootloader implementing the bootloader.TrustedAssetsBootloader interface.

type MockTrustedAssetsMixin

type MockTrustedAssetsMixin struct {
	TrustedAssetsList  []string
	TrustedAssetsErr   error
	TrustedAssetsCalls int

	RecoveryBootChainList []bootloader.BootFile
	RecoveryBootChainErr  error
	BootChainList         []bootloader.BootFile
	BootChainErr          error

	RecoveryBootChainCalls []string
	BootChainRunBl         []bootloader.Bootloader
	BootChainKernelPath    []string

	UpdateErr                  error
	UpdateCalls                int
	Updated                    bool
	ManagedAssetsList          []string
	StaticCommandLine          string
	CandidateStaticCommandLine string
	CommandLineErr             error
}

MockTrustedAssetsMixin implements the bootloader.TrustedAssetsBootloader interface.

func (*MockTrustedAssetsMixin) BootChain

func (b *MockTrustedAssetsMixin) BootChain(runBl bootloader.Bootloader, kernelPath string) ([]bootloader.BootFile, error)

func (*MockTrustedAssetsMixin) CandidateCommandLine

func (b *MockTrustedAssetsMixin) CandidateCommandLine(pieces bootloader.CommandLineComponents) (string, error)

func (*MockTrustedAssetsMixin) CommandLine

func (*MockTrustedAssetsMixin) ManagedAssets

func (b *MockTrustedAssetsMixin) ManagedAssets() []string

func (*MockTrustedAssetsMixin) RecoveryBootChain

func (b *MockTrustedAssetsMixin) RecoveryBootChain(kernelPath string) ([]bootloader.BootFile, error)

func (*MockTrustedAssetsMixin) TrustedAssets

func (b *MockTrustedAssetsMixin) TrustedAssets() ([]string, error)

func (*MockTrustedAssetsMixin) UpdateBootConfig

func (b *MockTrustedAssetsMixin) UpdateBootConfig() (bool, error)

Jump to

Keyboard shortcuts

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