User-facing API for use within an assignment test case for: Interacting with or querying data for the student's assembled binary Test result collection (requirements, pass/fail cases) Performing any other esoteric test-related action.
More...
#include <test_context.hpp>
|
| | TestContext (TestBase &test, Program program, std::function< void(const RequirementResult &)> on_requirement=common::noop) noexcept |
| |
| bool | require (bool condition, const std::string &msg, RequirementResult::DebugInfo debug_info=RequirementResult::DebugInfo{}) |
| |
| bool | require (bool condition, RequirementResult::DebugInfo debug_info=RequirementResult::DebugInfo{}) |
| |
| template<exprs::Operator Op> |
| bool | require (const Requirement< Op > &req, RequirementResult::DebugInfo debug_info=RequirementResult::DebugInfo{}) |
| |
| TestResult | finalize () |
| | Obtain the final test results Run after the test is complete. Note: has no ill effects if run before test is complete.
|
| |
| std::string_view | get_name () const |
| | Test name getter.
|
| |
| void | restart_program () |
| | Restarts the entire program.
|
| |
| Result< SyscallRecord > | exec_syscall (u64 sys_nr, std::array< std::uint64_t, 6 > args) |
| |
| std::string | get_stdout () |
| | Get any new stdout from the program since the last call to this function.
|
| |
| std::string | get_full_stdout () |
| | Get all stdout from since the beginning of the test invokation.
|
| |
| std::size_t | flush_stdin () |
| | Flushes any reamaining unread data in the stdin buffer Returns: number of bytes flushed, or error kind if failure occured.
|
| |
| const std::vector< SyscallRecord > & | get_syscall_records () const |
| | Obtain a list of the syscalls that have been executed so far.
|
| |
| RegistersState | get_registers () const |
| | Get the current register state of the program.
|
| |
| void | send_stdin (const std::string &input) |
| | Get any new stdout from the program since the last call to this function.
|
| |
| template<typename T > |
| AsmSymbol< T > | find_symbol (std::string_view name) |
| | Find a named symbol in the associated program.
|
| |
| template<std::size_t NumBytes> |
| AsmBuffer< NumBytes > | create_buffer () |
| | Create a buffer of NumBytes
|
| |
| template<typename Func > |
| AsmFunction< Func > | find_function (std::string name) |
| | Find a named function in the associated program.
|
| |
| RunResult | run () |
| | Run the program normally from _start, stopping at the first exit(2) or exit_group(2) syscall invocation.
|
| |
User-facing API for use within an assignment test case for: Interacting with or querying data for the student's assembled binary Test result collection (requirements, pass/fail cases) Performing any other esoteric test-related action.
◆ TestContext()
◆ create_buffer()
template<std::size_t NumBytes>
| AsmBuffer< NumBytes > asmgrader::TestContext::create_buffer |
( |
| ) |
|
Create a buffer of NumBytes
◆ exec_syscall()
| Result< SyscallRecord > asmgrader::TestContext::exec_syscall |
( |
u64 | sys_nr, |
|
|
std::array< std::uint64_t, 6 > | args ) |
◆ finalize()
Obtain the final test results Run after the test is complete. Note: has no ill effects if run before test is complete.
◆ find_function()
template<typename Func >
| AsmFunction< Func > asmgrader::TestContext::find_function |
( |
std::string | name | ) |
|
Find a named function in the associated program.
◆ find_symbol()
template<typename T >
| AsmSymbol< T > asmgrader::TestContext::find_symbol |
( |
std::string_view | name | ) |
|
Find a named symbol in the associated program.
- Template Parameters
-
| T | type of data that the symbol refers to |
◆ flush_stdin()
| std::size_t asmgrader::TestContext::flush_stdin |
( |
| ) |
|
Flushes any reamaining unread data in the stdin buffer Returns: number of bytes flushed, or error kind if failure occured.
◆ get_full_stdout()
| std::string asmgrader::TestContext::get_full_stdout |
( |
| ) |
|
Get all stdout from since the beginning of the test invokation.
◆ get_name()
| std::string_view asmgrader::TestContext::get_name |
( |
| ) |
const |
◆ get_registers()
Get the current register state of the program.
◆ get_stdout()
| std::string asmgrader::TestContext::get_stdout |
( |
| ) |
|
Get any new stdout from the program since the last call to this function.
◆ get_syscall_records()
| const std::vector< SyscallRecord > & asmgrader::TestContext::get_syscall_records |
( |
| ) |
const |
Obtain a list of the syscalls that have been executed so far.
◆ require() [1/3]
◆ require() [2/3]
◆ require() [3/3]
template<exprs::Operator Op>
◆ restart_program()
| void asmgrader::TestContext::restart_program |
( |
| ) |
|
Restarts the entire program.
Note: if the asm executable has changed, this will launch with the NEW executable Important: this has the almost certain effect of invalidating all buffers or other addressable references to said program, as the address space WILL change
◆ run()
Run the program normally from _start, stopping at the first exit(2) or exit_group(2) syscall invocation.
◆ send_stdin()
| void asmgrader::TestContext::send_stdin |
( |
const std::string & | input | ) |
|
Get any new stdout from the program since the last call to this function.
The documentation for this class was generated from the following files: