testonly

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package testonly provides support for storage tests.

Index

Constants

View Source
const MemBlockSize = 512

MemBlockSize is the number of bytes in a single memory block.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemDev

type MemDev struct {
	Storage [][MemBlockSize]byte

	// OnBlockWritten is called just after a mem block has been written.
	OnBlockWritten func(lba uint)
}

MemDev is a simple in-memory block device.

func NewMemDev

func NewMemDev(t *testing.T, numBlocks uint) *MemDev

NewMemDev creates a new in-memory block device.

func (MemDev) BlockSize

func (md MemDev) BlockSize() uint

BlockSize returns the block size of the underlying storage system.

func (MemDev) ReadBlocks

func (md MemDev) ReadBlocks(lba uint, b []byte) error

ReadBlocks reads len(b) bytes into b from contiguous storage blocks starting at the given block address. b must be an integer multiple of the device's block size.

func (MemDev) WriteBlocks

func (md MemDev) WriteBlocks(lba uint, b []byte) (uint, error)

WriteBlocks writes len(b) bytes from b to contiguous storage blocks starting at the given block address. b must be an integer multiple of the device's block size.

Returns the number of blocks written, or an error.

Jump to

Keyboard shortcuts

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