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) WithExtractedRunKernelImage() *MockExtractedRunKernelImageBootloader
- func (b *MockBootloader) WithTrustedAssets() *MockTrustedAssetsBootloader
- type MockExtractedRecoveryKernelImageBootloader
- type MockExtractedRunKernelImageBootloader
- func (b *MockExtractedRunKernelImageBootloader) DisableTryKernel() error
- func (b *MockExtractedRunKernelImageBootloader) EnableKernel(s snap.PlaceInfo) error
- func (b *MockExtractedRunKernelImageBootloader) EnableTryKernel(s snap.PlaceInfo) error
- func (b *MockExtractedRunKernelImageBootloader) GetRunKernelImageFunctionSnapCalls(f string) ([]snap.PlaceInfo, int)
- func (b *MockExtractedRunKernelImageBootloader) Kernel() (snap.PlaceInfo, error)
- func (b *MockExtractedRunKernelImageBootloader) SetEnabledKernel(kernel snap.PlaceInfo) (restore func())
- func (b *MockExtractedRunKernelImageBootloader) SetEnabledTryKernel(kernel snap.PlaceInfo) (restore func())
- func (b *MockExtractedRunKernelImageBootloader) SetRunKernelImageFunctionError(f string, err error) (restore func())
- func (b *MockExtractedRunKernelImageBootloader) SetRunKernelImagePanic(f string) (restore func())
- func (b *MockExtractedRunKernelImageBootloader) TryKernel() (snap.PlaceInfo, error)
- type MockRecoveryAwareBootloader
- type MockTrustedAssetsBootloader
- func (b *MockTrustedAssetsBootloader) BootChain(runBl bootloader.Bootloader, kernelPath string) ([]bootloader.BootFile, error)
- func (b *MockTrustedAssetsBootloader) CandidateCommandLine(modeArg, systemArg, extraArgs string) (string, error)
- func (b *MockTrustedAssetsBootloader) CommandLine(modeArg, systemArg, extraArgs string) (string, error)
- func (b *MockTrustedAssetsBootloader) ManagedAssets() []string
- func (b *MockTrustedAssetsBootloader) RecoveryBootChain(kernelPath string) ([]bootloader.BootFile, error)
- func (b *MockTrustedAssetsBootloader) TrustedAssets() ([]string, error)
- func (b *MockTrustedAssetsBootloader) 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 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) WithExtractedRunKernelImage ¶
func (b *MockBootloader) WithExtractedRunKernelImage() *MockExtractedRunKernelImageBootloader
WithExtractedRunKernelImage derives a MockExtractedRunKernelImageBootloader from a base MockBootloader.
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 // contains filtered or unexported fields }
MockExtractedRunKernelImageBootloader mocks a bootloader implementing the ExtractedRunKernelImageBootloader interface.
func (*MockExtractedRunKernelImageBootloader) DisableTryKernel ¶
func (b *MockExtractedRunKernelImageBootloader) DisableTryKernel() error
DisableTryKernel removes the current try-kernel "symlink" set in the bootloader; part of ExtractedRunKernelImageBootloader.
func (*MockExtractedRunKernelImageBootloader) EnableKernel ¶
func (b *MockExtractedRunKernelImageBootloader) EnableKernel(s snap.PlaceInfo) error
EnableKernel enables the kernel; part of ExtractedRunKernelImageBootloader.
func (*MockExtractedRunKernelImageBootloader) EnableTryKernel ¶
func (b *MockExtractedRunKernelImageBootloader) EnableTryKernel(s snap.PlaceInfo) error
EnableTryKernel enables a try-kernel; part of ExtractedRunKernelImageBootloader.
func (*MockExtractedRunKernelImageBootloader) GetRunKernelImageFunctionSnapCalls ¶
func (b *MockExtractedRunKernelImageBootloader) 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 (*MockExtractedRunKernelImageBootloader) Kernel ¶
func (b *MockExtractedRunKernelImageBootloader) Kernel() (snap.PlaceInfo, error)
Kernel returns the current kernel set in the bootloader; part of ExtractedRunKernelImageBootloader.
func (*MockExtractedRunKernelImageBootloader) SetEnabledKernel ¶
func (b *MockExtractedRunKernelImageBootloader) 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 (*MockExtractedRunKernelImageBootloader) SetEnabledTryKernel ¶
func (b *MockExtractedRunKernelImageBootloader) 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 (*MockExtractedRunKernelImageBootloader) SetRunKernelImageFunctionError ¶
func (b *MockExtractedRunKernelImageBootloader) 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 (*MockExtractedRunKernelImageBootloader) SetRunKernelImagePanic ¶
func (b *MockExtractedRunKernelImageBootloader) SetRunKernelImagePanic(f string) (restore func())
SetRunKernelImagePanic allows setting any method in the ExtractedRunKernelImageBootloader interface on MockExtractedRunKernelImageBootloader 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
type MockRecoveryAwareBootloader ¶
type MockRecoveryAwareBootloader struct { *MockBootloader RecoverySystemDir string RecoverySystemBootVars map[string]string }
MockRecoveryAwareBootloader mocks a bootloader implementing the RecoveryAware interface.
func (*MockRecoveryAwareBootloader) GetRecoverySystemEnv ¶
func (b *MockRecoveryAwareBootloader) GetRecoverySystemEnv(recoverySystemDir, key string) (string, error)
GetRecoverySystemEnv gets the recovery system environment bootloader variables; part of RecoveryAwareBootloader.
func (*MockRecoveryAwareBootloader) SetRecoverySystemEnv ¶
func (b *MockRecoveryAwareBootloader) SetRecoverySystemEnv(recoverySystemDir string, blVars map[string]string) error
SetRecoverySystemEnv sets the recovery system environment bootloader variables; part of RecoveryAwareBootloader.
type MockTrustedAssetsBootloader ¶
type MockTrustedAssetsBootloader struct { *MockBootloader 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 }
MockTrustedAssetsBootloader mocks a bootloader implementing the bootloader.TrustedAssetsBootloader interface.
func (*MockTrustedAssetsBootloader) BootChain ¶
func (b *MockTrustedAssetsBootloader) BootChain(runBl bootloader.Bootloader, kernelPath string) ([]bootloader.BootFile, error)
func (*MockTrustedAssetsBootloader) CandidateCommandLine ¶
func (b *MockTrustedAssetsBootloader) CandidateCommandLine(modeArg, systemArg, extraArgs string) (string, error)
func (*MockTrustedAssetsBootloader) CommandLine ¶
func (b *MockTrustedAssetsBootloader) CommandLine(modeArg, systemArg, extraArgs string) (string, error)
func (*MockTrustedAssetsBootloader) ManagedAssets ¶
func (b *MockTrustedAssetsBootloader) ManagedAssets() []string
func (*MockTrustedAssetsBootloader) RecoveryBootChain ¶
func (b *MockTrustedAssetsBootloader) RecoveryBootChain(kernelPath string) ([]bootloader.BootFile, error)
func (*MockTrustedAssetsBootloader) TrustedAssets ¶
func (b *MockTrustedAssetsBootloader) TrustedAssets() ([]string, error)
func (*MockTrustedAssetsBootloader) UpdateBootConfig ¶
func (b *MockTrustedAssetsBootloader) UpdateBootConfig() (bool, error)