18#include <fmt/format.h>
45 bool require(
bool condition, std::string msg,
93 template <std::
size_t NumBytes>
97 template <
typename Func>
116template <std::
size_t NumBytes>
125 static_assert(
MemoryReadSupported<T>,
"Specified type does not have supported memory read operation! See docs.");
130 LOG_DEBUG(
"Could not resolve symbol {:?}", name);
131 return {prog_, std::string{name}, ErrorKind::UnresolvedSymbol};
134 return {prog_, std::string{name}, symbol->address};
137template <
typename Func>
142 return {prog_, std::move(name), ErrorKind::UnresolvedSymbol};
145 return {prog_, std::move(name), loc->address};
Definition asm_buffer.hpp:23
Definition asm_function.hpp:18
Definition asm_symbol.hpp:21
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
Definition program.hpp:31
SymbolTable & get_symtab()
Definition program.cpp:75
Definition run_result.hpp:6
std::optional< Symbol > find(std::string_view name) const
Definition symbol_table.cpp:21
Base class primarily for a user-written test.
Definition test_base.hpp:17
User-facing API for use within an assignment test case for: Interacting with or querying data for the...
Definition test_context.hpp:40
TestResult finalize()
Obtain the final test results Run after the test is complete. Note: has no ill effects if run before ...
Definition test_context.cpp:52
TestContext(TestBase &test, Program program, std::function< void(const RequirementResult &)> on_requirement=common::noop) noexcept
Definition test_context.cpp:41
std::string get_full_stdout()
Get all stdout from since the beginning of the test invokation.
Definition test_context.cpp:89
RegistersState get_registers() const
Get the current register state of the program.
Definition test_context.cpp:176
std::string get_stdout()
Get any new stdout from the program since the last call to this function.
Definition test_context.cpp:85
AsmSymbol< T > find_symbol(std::string_view name)
Find a named symbol in the associated program.
Definition test_context.hpp:124
void send_stdin(const std::string &input)
Get any new stdout from the program since the last call to this function.
Definition test_context.cpp:93
AsmFunction< Func > find_function(std::string name)
Find a named function in the associated program.
Definition test_context.hpp:138
Result< SyscallRecord > exec_syscall(u64 sys_nr, std::array< std::uint64_t, 6 > args)
Definition test_context.cpp:105
void restart_program()
Restarts the entire program.
Definition test_context.cpp:101
AsmBuffer< NumBytes > create_buffer()
Create a buffer of NumBytes
Definition test_context.hpp:117
std::size_t flush_stdin()
Flushes any reamaining unread data in the stdin buffer Returns: number of bytes flushed,...
Definition test_context.cpp:113
std::string_view get_name() const
Test name getter.
Definition test_context.cpp:81
const std::vector< SyscallRecord > & get_syscall_records() const
Obtain a list of the syscalls that have been executed so far.
Definition test_context.cpp:109
RunResult run()
Run the program normally from _start
Definition test_context.cpp:97
bool require(bool condition, std::string msg, RequirementResult::DebugInfo debug_info=RequirementResult::DebugInfo{})
Definition test_context.cpp:72
Definition concepts.hpp:23
Defines data classes to store result data for the current run session.
#define LOG_DEBUG(...)
Definition logging.hpp:44
constexpr auto noop
Usefule as the default argument to function callbacks.
Definition functional.hpp:6
Definition asm_buffer.hpp:19
All header-only as this is relatively low level and we want operations to be fast (inlinable)
Definition grading_session.hpp:77
Definition grading_session.hpp:72
Definition grading_session.hpp:93