testing

package
v0.0.0-...-429085d Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultCache

func CreateDefaultCache(
	bytesPerBlock,
	totalBlocks uint,
	writable bool,
	backingData []byte,
	t *testing.T,
) *blockcache.BlockCache

Create a cache with default settings, fetch/flush handlers, etc. The image cannot be resized.

Arguments:

  • bytesPerBlock: The number of bytes in a single block.
  • totalBlocks: The number of blocks in the cache.
  • writable: `true` if the image is writable, `false` otherwise. The handler will fail a test if an attempt is made to write to the image if this is false.
  • backingData: Optional. A byte slice of at least `bytesPerBlock * totalBlocks` that is used as the underlying storage the cache sits on top of. You can pass `nil` for this to get completely random data.
  • `t`: The testing fixture.

The fetch and flush handlers generated for the cache check bounds and permissions for you, and fail with an appropriate error message. This means you won't be able to test negative conditions (i.e. ensure methods fail where they should) so you'll have to do that yourself. See CreateRandomImage.

func CreateRandomImage

func CreateRandomImage(bytesPerBlock, totalBlocks uint, t *testing.T) []byte

Create an image with the given number of blocks and bytes per block. It is guaranteed to either return a valid slice or fail the test and abort.

func LoadDiskImage

func LoadDiskImage(
	t *testing.T, compressedImageBytes []byte, sectorSize, totalSectors uint,
) io.ReadWriteSeeker

LoadDiskImage takes a compressed disk image and returns a stream to access the uncompressed data.

  • Writes to the stream do not affect `compressedImageBytes`.
  • While the stream can be written to, its size is fixed to `sectorSize * totalSectors`. Attempting to write past the end of this buffer will trigger an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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