files

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package files contains the utilities for testing file based storage. It is primarily used to test cryptohomed and user's home directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFile

func AppendFile(ctx context.Context, runner hwsec.CmdRunner, path, key string, length int) error

AppendFile appends to the the file at path, for a size of length bytes. The data written is generated with AES. length should always be multples of 32 bytes. Note that key and path should not contain single quote ('). Note that a block size of 32 is used so that we can test partial pages/sector, while having acceptable performance. (bs=1 can be slow.)

func CalcSHA256

func CalcSHA256(ctx context.Context, runner hwsec.CmdRunner, path string) (string, error)

CalcSHA256 calculates the SHA256 sum of a file on the DUT.

func DeriveOpenSSLAESKeyIV

func DeriveOpenSSLAESKeyIV(key string) ([]byte, []byte)

DeriveOpenSSLAESKeyIV derives the key and IV that was used by OpenSSL when it wrote the test data to the test file.

func ResetFile

func ResetFile(ctx context.Context, runner hwsec.CmdRunner, path string) error

ResetFile ensures that the given file exists on the DUT and is of length 0.

func UpdateHashForIteration

func UpdateHashForIteration(h *hash.Hash, key string, length int) error

UpdateHashForIteration updates the given sha256 hash object to reflect the contents written to the test file during the iteration/round. This function mirrors what AppendFile() does. length is the length of the data, it should be in multiples of 32 bytes.

Types

type FileInfo

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

FileInfo stores the information related to a file under test that is stored in the DUT. With the information

func NewFileInfo

func NewFileInfo(ctx context.Context, path string, runner hwsec.CmdRunner) (*FileInfo, error)

NewFileInfo create a new FileInfo for testing a file. Note that calling this method only initializes the data structures and doesn't touch anything on disk. To reset the on disk state, call Clear().

func (*FileInfo) Clear

func (f *FileInfo) Clear(ctx context.Context) error

Clear resets the file and the state in data structure back to an empty file.

func (*FileInfo) Iteration

func (f *FileInfo) Iteration() int

Iteration return the current iteration.

func (*FileInfo) Path

func (f *FileInfo) Path() string

Path returns the path for the file info.

func (*FileInfo) Step

func (f *FileInfo) Step(ctx context.Context) error

Step append to the test file.

func (*FileInfo) StepOverridePath

func (f *FileInfo) StepOverridePath(ctx context.Context, path string) error

StepOverridePath append to the test file, but assuming the file is located at the given path. This is used to test bind mount.

func (*FileInfo) Verify

func (f *FileInfo) Verify(ctx context.Context) error

Verify tests the file on disk is correct.

func (*FileInfo) VerifyOverridePath

func (f *FileInfo) VerifyOverridePath(ctx context.Context, path string) error

VerifyOverridePath tests the file on disk is correct, assuming the file is located at the given path. This is used to test bind mount.

type HomedirFiles

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

HomedirFiles stores the test file related to a user's home directory.

func NewHomedirFiles

func NewHomedirFiles(ctx context.Context, util *hwsec.CryptohomeClient, runner hwsec.CmdRunner, username string) (*HomedirFiles, error)

NewHomedirFiles creates a new HomedirFiles for testing the files in the given user's home directory. Note that calling this method only initializes the data structures and doesn't touch anything on disk. To reset the on disk state, call Clear(). Thus, this can be called before the home is mounted.

func (*HomedirFiles) Clear

func (h *HomedirFiles) Clear(ctx context.Context) error

Clear resets the files and their corresponding states in data structure.

func (*HomedirFiles) Step

func (h *HomedirFiles) Step(ctx context.Context) error

Step appends data to all test files in the home directory. It'll only use the first path for each file.

func (*HomedirFiles) StepAll

func (h *HomedirFiles) StepAll(ctx context.Context) error

StepAll appends to data to all test files in the home directory. However, unlike Step(), it'll use all available paths to the same file and Step once for each available paths.

func (*HomedirFiles) Verify

func (h *HomedirFiles) Verify(ctx context.Context) error

Verify verifies all test files in the user's home directory. It'll only verify through the first path for each file.

func (*HomedirFiles) VerifyAll

func (h *HomedirFiles) VerifyAll(ctx context.Context) error

VerifyAll verifies all test files in the user's home directory. Unlike Verify(), it'll use all available paths to the same file and verifies all of them are correct.

Jump to

Keyboard shortcuts

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