Module testing

Module testing 

Source

Structs§

AutoReleasableTask
PanickingFile
An implementation of FileOps that panics on any read, write, or ioctl operation.
PanickingFsNode
An FsNodeOps implementation that panics if you try to open it. Useful as a stand-in for testing APIs that require a FsNodeOps implementation but don’t actually use it.
UserMemoryWriter
Helper to write out data to a task’s memory sequentially.

Functions§

anon_test_file
Returns a new anonymous test file with the specified ops and flags.
check_page_eq
Checks that the page in current_task’s address space starting at addr is readable. Panics if the read failed, or the page was not filled with the ASCII character data.
check_page_ne
Checks that the page in current_task’s address space starting at addr is readable. Panics if the read failed, or the page was filled with the ASCII character data.
check_unmapped
Checks that the page in current_task’s address space starting at addr is unmapped. Panics if the read succeeds, or if an error other than EFAULT occurs.
create_fs_node_for_testing
create_kernel_task_and_unlockedDeprecated
create_namespace_node_for_testing
create_task
An old way of creating a task for testing
create_testfs
create_testfs_with_root
fill_page
Fills one page in the current_task’s address space starting at addr with the ASCII character data. Panics if the write failed.
map_memory
Maps length at address with PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE.
map_memory_anywhere
Maps a region of mery at least len bytes long with PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, returning the mapped address.
map_memory_with_flags
Maps length at address with PROT_READ | PROT_WRITE and the specified flags.
map_object_anywhere
Maps a region of memory large enough for the object with PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE and writes the object to it, returning the mapped address.
remap_memory
Convenience wrapper around sys_mremap which extracts the returned UserAddress from the generic SyscallResult.
spawn_kernel_and_run
Create a Kernel object and run the given callback in the init process for that kernel.
spawn_kernel_and_run_sync
Create a Kernel object and run the given synchronous callback in the init process for that kernel.
spawn_kernel_and_run_with_pkgfs
Create a Kernel object and run the given callback in the init process for that kernel. The task is rooted in a pkgfs instance.
spawn_kernel_with_selinux_and_run
Variant of spawn_kernel_and_run() that configures the kernel with SELinux enabled. The supplied callback is invoked with an additional argument providing test access to the SELinux security-server.