class TestDevice
Defined at line 76 of file ../../src/security/lib/zxcrypt/tests/test-device.h
|zxcrypt::testing::Utils| is a collection of functions designed to make the zxcrypt
unit test setup and tear down easier.
Public Methods
void TestDevice ()
Defined at line 62 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
void ~TestDevice ()
Defined at line 67 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
void SetupDevmgr ()
Launches an isolated devcoordinator. Must be called before calling
any other methods on TestDevice.
Defined at line 76 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
void TestDevice (const TestDevice & )
Defined at line 80 of file ../../src/security/lib/zxcrypt/tests/test-device.h
void TestDevice (TestDevice && )
Defined at line 80 of file ../../src/security/lib/zxcrypt/tests/test-device.h
TestDevice & operator= (const TestDevice & )
Defined at line 80 of file ../../src/security/lib/zxcrypt/tests/test-device.h
TestDevice & operator= (TestDevice && )
Defined at line 80 of file ../../src/security/lib/zxcrypt/tests/test-device.h
size_t size ()
Returns the size of the zxcrypt volume.
Defined at line 85 of file ../../src/security/lib/zxcrypt/tests/test-device.h
const fbl::unique_fd & devfs_root ()
Defined at line 87 of file ../../src/security/lib/zxcrypt/tests/test-device.h
fidl::UnownedClientEnd<fuchsia_device::Controller> parent_controller ()
Returns a connection to the parent device.
Defined at line 90 of file ../../src/security/lib/zxcrypt/tests/test-device.h
void Create (size_t device_size, size_t block_size, bool fvm, Volume::Version version)
Allocates a new block device of at least |device_size| bytes grouped into blocks of
|block_size| bytes each. If |fvm| is true, it will be formatted as an FVM partition with the
appropriates number of slices of |fvm::kBlockSize| each. A file descriptor for the block
device is returned via |out_fd|.
Defined at line 90 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
fidl::ClientEnd<fuchsia_device::Controller> new_parent_controller ()
Defined at line 94 of file ../../src/security/lib/zxcrypt/tests/test-device.h
fidl::ClientEnd<fuchsia_storage_block::Block> new_parent ()
Defined at line 106 of file ../../src/security/lib/zxcrypt/tests/test-device.h
void Bind (Volume::Version version, bool fvm)
Test helper that generates a key and creates a device according to |version| and |fvm|. It
sets up the device as a zxcrypt volume and binds to it.
Defined at line 114 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
fidl::UnownedClientEnd<fuchsia_storage_block::Block> parent_volume ()
Returns a connection to the parent device.
Defined at line 119 of file ../../src/security/lib/zxcrypt/tests/test-device.h
fidl::UnownedClientEnd<fuchsia_storage_block::Block> zxcrypt_block ()
Returns a connection to the zxcrypt device.
Defined at line 124 of file ../../src/security/lib/zxcrypt/tests/test-device.h
fidl::UnownedClientEnd<fuchsia_storage_block::Block> zxcrypt_volume ()
Returns a connection to the zxcrypt device.
Defined at line 129 of file ../../src/security/lib/zxcrypt/tests/test-device.h
size_t block_size ()
Returns the block size of the zxcrypt device.
Defined at line 134 of file ../../src/security/lib/zxcrypt/tests/test-device.h
void Rebind ()
Test helper that rebinds the ramdisk and its children.
Defined at line 136 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
size_t block_count ()
Returns the block size of the zxcrypt device.
Defined at line 137 of file ../../src/security/lib/zxcrypt/tests/test-device.h
zx::result<size_t> reserved_blocks ()
Returns space reserved for metadata
Defined at line 140 of file ../../src/security/lib/zxcrypt/tests/test-device.h
zx::result<size_t> reserved_slices ()
Defined at line 147 of file ../../src/security/lib/zxcrypt/tests/test-device.h
const crypto::Secret & key ()
Returns a reference to the root key generated for this device.
Defined at line 156 of file ../../src/security/lib/zxcrypt/tests/test-device.h
zx_status_t SingleReadBytes (zx_off_t src_offset, size_t len, size_t dst_offset)
API WRAPPERS
Defined at line 160 of file ../../src/security/lib/zxcrypt/tests/test-device.h
zx_status_t SingleWriteBytes (zx_off_t src_offset, size_t len, size_t dst_offset)
Defined at line 165 of file ../../src/security/lib/zxcrypt/tests/test-device.h
zx_status_t vmo_read (zx_off_t off, size_t len)
These methods mirror the syscall API, except that the VMO and buffers are provided
automatically. |off| and |len| are in bytes.
Defined at line 172 of file ../../src/security/lib/zxcrypt/tests/test-device.h
zx_status_t vmo_write (uint64_t off, uint64_t len)
Defined at line 173 of file ../../src/security/lib/zxcrypt/tests/test-device.h
zx_status_t block_fifo_txn (uint8_t opcode, uint64_t off, uint64_t len)
Sends a request over the block fifo to read or write the blocks given by |off| and |len|,
according to the given |opcode|. The data sent or received can be accessed using |vmo_write|
or |vmo_read|, respectively. |off| and |len| are in blocks.
Defined at line 180 of file ../../src/security/lib/zxcrypt/tests/test-device.h
void SleepUntil (uint64_t num, bool deferred)
Tells the underlying ramdisk to sleep until |num| transactions have been received. If
|deferred| is true, the transactions will be handled on waking; else they will be failed.
Defined at line 181 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
zx_status_t block_fifo_txn (BlockFifoRequest * requests, size_t num)
Sends |num| requests over the block fifo to read or write blocks.
Defined at line 189 of file ../../src/security/lib/zxcrypt/tests/test-device.h
void WakeUp ()
Blocks until the ramdisk is awake.
Defined at line 198 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
void Read (zx_off_t off, size_t len)
Defined at line 234 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
void Write (zx_off_t off, size_t len)
Defined at line 239 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
void ReadVmo (zx_off_t off, size_t len)
Test helpers that perform a |lseek| and a |vmo_read| or |vmo_write| together. |off| and
|len| are in blocks. |ReadVmo| additionally checks that the data read matches what was
written.
Defined at line 241 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
void WriteVmo (zx_off_t off, size_t len)
Defined at line 249 of file ../../src/security/lib/zxcrypt/tests/test-device.cc
void Corrupt (uint64_t blkno, key_slot_t slot)
Test helper that flips a (pseudo)random bit in the key at the given |slot| in the given
|block|. The call to |srand| in main.c guarantees the same bit will be chosen for a given
test iteration.
Defined at line 254 of file ../../src/security/lib/zxcrypt/tests/test-device.cc