Documentation ¶
Index ¶
- func UTF16Bytes(s string) []byte
- type ExtractedRecoveryKernelCall
- type MockBootloader
- func (b *MockBootloader) ExtractKernelAssets(s snap.PlaceInfo, snapf snap.Container) error
- func (b *MockBootloader) ExtractedRecoveryKernelImage() *MockExtractedRecoveryKernelImageBootloader
- func (b *MockBootloader) GetBootVars(keys ...string) (map[string]string, error)
- func (b *MockBootloader) InstallBootConfig(gadgetDir string, opts *bootloader.Options) error
- func (b *MockBootloader) Name() string
- func (b *MockBootloader) Present() (bool, error)
- func (b *MockBootloader) RecoveryAware() *MockRecoveryAwareBootloader
- func (b *MockBootloader) RemoveKernelAssets(s snap.PlaceInfo) error
- func (b *MockBootloader) SetBootVars(values map[string]string) error
- func (b *MockBootloader) SetEnabledKernel(s snap.PlaceInfo) (restore func())
- func (b *MockBootloader) SetEnabledTryKernel(s snap.PlaceInfo) (restore func())
- func (b *MockBootloader) SetMockToPanic(f string) (restore func())
- func (b *MockBootloader) WithExtractedRunKernelImage() *MockExtractedRunKernelImageBootloader
- func (b *MockBootloader) WithNotScriptable() *MockNotScriptableBootloader
- func (b *MockBootloader) WithRebootBootloader() *MockRebootBootloader
- func (b *MockBootloader) WithRecoveryAwareTrustedAssets() *MockRecoveryAwareTrustedAssetsBootloader
- func (b *MockBootloader) WithTrustedAssets() *MockTrustedAssetsBootloader
- func (b *MockBootloader) WithTrustedAssetsAndEfi() *MockTrustedAssetsBootloaderWithEfi
- type MockEfiLoadOptionMixin
- type MockExtractedRecoveryKernelImageBootloader
- type MockExtractedRecoveryKernelNotScriptableBootloader
- type MockExtractedRunKernelImageBootloader
- type MockExtractedRunKernelImageMixin
- func (b *MockExtractedRunKernelImageMixin) DisableTryKernel() error
- func (b *MockExtractedRunKernelImageMixin) EnableKernel(s snap.PlaceInfo) error
- func (b *MockExtractedRunKernelImageMixin) EnableTryKernel(s snap.PlaceInfo) error
- func (b *MockExtractedRunKernelImageMixin) GetRunKernelImageFunctionSnapCalls(f string) ([]snap.PlaceInfo, int)
- func (b *MockExtractedRunKernelImageMixin) Kernel() (snap.PlaceInfo, error)
- func (b *MockExtractedRunKernelImageMixin) SetEnabledKernel(kernel snap.PlaceInfo) (restore func())
- func (b *MockExtractedRunKernelImageMixin) SetEnabledTryKernel(kernel snap.PlaceInfo) (restore func())
- func (b *MockExtractedRunKernelImageMixin) SetRunKernelImageFunctionError(f string, err error) (restore func())
- func (b *MockExtractedRunKernelImageMixin) TryKernel() (snap.PlaceInfo, error)
- type MockNotScriptableBootloader
- type MockRebootBootloader
- type MockRebootBootloaderMixin
- type MockRecoveryAwareBootloader
- type MockRecoveryAwareMixin
- type MockRecoveryAwareTrustedAssetsBootloader
- type MockTrustedAssetsBootloader
- type MockTrustedAssetsBootloaderWithEfi
- type MockTrustedAssetsMixin
- func (b *MockTrustedAssetsMixin) BootChains(runBl bootloader.Bootloader, kernelPath string) ([][]bootloader.BootFile, error)
- func (b *MockTrustedAssetsMixin) CandidateCommandLine(pieces bootloader.CommandLineComponents) (string, error)
- func (b *MockTrustedAssetsMixin) CommandLine(pieces bootloader.CommandLineComponents) (string, error)
- func (b *MockTrustedAssetsMixin) DefaultCommandLine(candidate bool) (string, error)
- func (b *MockTrustedAssetsMixin) ManagedAssets() []string
- func (b *MockTrustedAssetsMixin) RecoveryBootChains(kernelPath string) ([][]bootloader.BootFile, error)
- func (b *MockTrustedAssetsMixin) TrustedAssets() (map[string]string, error)
- func (b *MockTrustedAssetsMixin) UpdateBootConfig() (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UTF16Bytes ¶
UTF16Bytes converts the given string into its UTF16 encoding. Convenient for use together with efi.MockVars.
Types ¶
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 (*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) WithNotScriptable ¶
func (b *MockBootloader) WithNotScriptable() *MockNotScriptableBootloader
func (*MockBootloader) WithRebootBootloader ¶
func (b *MockBootloader) WithRebootBootloader() *MockRebootBootloader
func (*MockBootloader) WithRecoveryAwareTrustedAssets ¶
func (b *MockBootloader) WithRecoveryAwareTrustedAssets() *MockRecoveryAwareTrustedAssetsBootloader
func (*MockBootloader) WithTrustedAssets ¶
func (b *MockBootloader) WithTrustedAssets() *MockTrustedAssetsBootloader
func (*MockBootloader) WithTrustedAssetsAndEfi ¶
func (b *MockBootloader) WithTrustedAssetsAndEfi() *MockTrustedAssetsBootloaderWithEfi
type MockEfiLoadOptionMixin ¶
type MockEfiLoadOptionMixin struct { EfiLoadOptionErr error EfiLoadOptionDesc string EfiLoadOptionPath string EfiLoadOptionData []byte SeenUpdatedAssets [][]string }
func (*MockEfiLoadOptionMixin) ParametersForEfiLoadOption ¶
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 MockExtractedRecoveryKernelNotScriptableBootloader ¶
type MockExtractedRecoveryKernelNotScriptableBootloader struct { *MockNotScriptableBootloader ExtractRecoveryKernelAssetsCalls []ExtractedRecoveryKernelCall }
MockExtractedRecoveryKernelNotScriptableBootloader implements the bootloader.ExtractedRecoveryKernelImageBootloader interface and includes MockNotScriptableBootloader
func (*MockExtractedRecoveryKernelNotScriptableBootloader) ExtractRecoveryKernelAssets ¶
func (b *MockExtractedRecoveryKernelNotScriptableBootloader) 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 ¶
func (b *MockExtractedRunKernelImageMixin) EnableKernel(s snap.PlaceInfo) error
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 ¶
func (b *MockExtractedRunKernelImageMixin) Kernel() (snap.PlaceInfo, error)
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.
type MockNotScriptableBootloader ¶
type MockNotScriptableBootloader struct {
*MockBootloader
}
MockNotScriptableBootloader implements the bootloader.NotScriptableBootloader interface.
func (*MockNotScriptableBootloader) SetBootVarsFromInitramfs ¶
func (b *MockNotScriptableBootloader) SetBootVarsFromInitramfs(values map[string]string) error
func (*MockNotScriptableBootloader) WithExtractedRecoveryKernel ¶
func (b *MockNotScriptableBootloader) WithExtractedRecoveryKernel() *MockExtractedRecoveryKernelNotScriptableBootloader
type MockRebootBootloader ¶
type MockRebootBootloader struct { *MockBootloader MockRebootBootloaderMixin }
MockRebootBootloader mocks a bootloader implementing the bootloader.RebootBootloader interface.
type MockRebootBootloaderMixin ¶
type MockRebootBootloaderMixin struct {
RebootArgs string
}
MockRebootBootloaderMixin implements the bootloader.RebootBootloader interface.
func (*MockRebootBootloaderMixin) GetRebootArguments ¶
func (b *MockRebootBootloaderMixin) GetRebootArguments() (string, error)
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 MockTrustedAssetsBootloaderWithEfi ¶
type MockTrustedAssetsBootloaderWithEfi struct { *MockBootloader MockTrustedAssetsMixin MockEfiLoadOptionMixin }
type MockTrustedAssetsMixin ¶
type MockTrustedAssetsMixin struct { TrustedAssetsMap map[string]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) BootChains ¶
func (b *MockTrustedAssetsMixin) BootChains(runBl bootloader.Bootloader, kernelPath string) ([][]bootloader.BootFile, error)
func (*MockTrustedAssetsMixin) CandidateCommandLine ¶
func (b *MockTrustedAssetsMixin) CandidateCommandLine(pieces bootloader.CommandLineComponents) (string, error)
func (*MockTrustedAssetsMixin) CommandLine ¶
func (b *MockTrustedAssetsMixin) CommandLine(pieces bootloader.CommandLineComponents) (string, error)
func (*MockTrustedAssetsMixin) DefaultCommandLine ¶
func (b *MockTrustedAssetsMixin) DefaultCommandLine(candidate bool) (string, error)
func (*MockTrustedAssetsMixin) ManagedAssets ¶
func (b *MockTrustedAssetsMixin) ManagedAssets() []string
func (*MockTrustedAssetsMixin) RecoveryBootChains ¶
func (b *MockTrustedAssetsMixin) RecoveryBootChains(kernelPath string) ([][]bootloader.BootFile, error)
func (*MockTrustedAssetsMixin) TrustedAssets ¶
func (b *MockTrustedAssetsMixin) TrustedAssets() (map[string]string, error)
func (*MockTrustedAssetsMixin) UpdateBootConfig ¶
func (b *MockTrustedAssetsMixin) UpdateBootConfig() (bool, error)