19#include <fmt/format.h>
49 [[deprecated(
"Use require(Requirement)")]]
50 bool require(
bool condition,
const std::string& msg,
52 [[deprecated(
"Use require(Requirement)")]]
55 template <exprs::Operator Op>
102 template <std::
size_t NumBytes>
106 template <
typename Func>
113 bool require_impl(
bool condition,
const std::string& description,
114 const std::optional<exprs::ExpressionRepr>& expression_repr,
129template <exprs::Operator Op>
134template <std::
size_t NumBytes>
143 static_assert(
MemoryReadSupported<T>,
"Specified type does not have supported memory read operation! See docs.");
148 LOG_DEBUG(
"Could not resolve symbol {:?}", name);
152 return {prog_, std::string{name}, symbol->address};
155template <
typename Func>
163 return {prog_, std::move(name), loc->address};
Definition asm_buffer.hpp:24
Definition asm_function.hpp:119
Definition asm_symbol.hpp:54
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
Definition program.hpp:32
SymbolTable & get_symtab()
Definition program.cpp:86
Definition requirement.hpp:214
bool get_res() const
Definition requirement.hpp:249
std::string get_description() const
Definition requirement.hpp:247
exprs::ExpressionRepr get_expr_repr() const
Definition requirement.hpp:252
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:44
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:55
TestContext(TestBase &test, Program program, std::function< void(const RequirementResult &)> on_requirement=common::noop) noexcept
Definition test_context.cpp:44
bool require(bool condition, const std::string &msg, RequirementResult::DebugInfo debug_info=RequirementResult::DebugInfo{})
Definition test_context.cpp:75
std::string get_full_stdout()
Get all stdout from since the beginning of the test invokation.
Definition test_context.cpp:87
RegistersState get_registers() const
Get the current register state of the program.
Definition test_context.cpp:193
std::string get_stdout()
Get any new stdout from the program since the last call to this function.
Definition test_context.cpp:83
AsmSymbol< T > find_symbol(std::string_view name)
Find a named symbol in the associated program.
Definition test_context.hpp:142
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:91
AsmFunction< Func > find_function(std::string name)
Find a named function in the associated program.
Definition test_context.hpp:156
Result< SyscallRecord > exec_syscall(u64 sys_nr, std::array< std::uint64_t, 6 > args)
Definition test_context.cpp:122
void restart_program()
Restarts the entire program.
Definition test_context.cpp:118
AsmBuffer< NumBytes > create_buffer()
Create a buffer of NumBytes
Definition test_context.hpp:135
std::size_t flush_stdin()
Flushes any reamaining unread data in the stdin buffer Returns: number of bytes flushed,...
Definition test_context.cpp:130
std::string_view get_name() const
Test name getter.
Definition test_context.cpp:79
const std::vector< SyscallRecord > & get_syscall_records() const
Obtain a list of the syscalls that have been executed so far.
Definition test_context.cpp:126
RunResult run()
Run the program normally from _start, stopping at the first exit(2) or exit_group(2) syscall invocati...
Definition test_context.cpp:95
Definition concepts.hpp:23
Defines data classes to store result data for the current run session.
#define LOG_DEBUG(...)
Definition logging.hpp:41
constexpr auto noop
Usefule as the default argument to function callbacks.
Definition functional.hpp:6
Definition asm_buffer.hpp:20
@ UnresolvedSymbol
Failed to resolve a named symbol in a program.
All header-only as this is relatively low level and we want operations to be fast (inlinable)
Definition grading_session.hpp:83
Definition grading_session.hpp:75
Definition grading_session.hpp:99