Documentation ¶
Index ¶
- func CreateDefaultCache(bytesPerBlock, totalBlocks uint, writable bool, backingData []byte, ...) *blockcache.BlockCache
- func CreateRandomImage(bytesPerBlock, totalBlocks uint, t *testing.T) []byte
- func LoadDiskImage(t *testing.T, compressedImageBytes []byte, sectorSize, totalSectors uint) io.ReadWriteSeeker
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 ¶
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.