mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 10:53:17 +00:00
Fix for tests
This commit is contained in:
parent
fbfdc8f2fb
commit
0e77989bd5
@ -8,7 +8,7 @@
|
||||
#define TAG "module"
|
||||
|
||||
struct ModuleInternal {
|
||||
bool started;
|
||||
bool started = false;
|
||||
};
|
||||
|
||||
struct ModuleLedger {
|
||||
@ -24,7 +24,7 @@ static ModuleLedger ledger;
|
||||
extern "C" {
|
||||
|
||||
error_t module_construct(struct Module* module) {
|
||||
module->internal = new (std::nothrow) ModuleInternal { .started = false };
|
||||
module->internal = new (std::nothrow) ModuleInternal();
|
||||
if (module->internal == nullptr) return ERROR_OUT_OF_MEMORY;
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
@ -64,6 +64,8 @@ TEST_CASE("Module lifecycle") {
|
||||
.internal = nullptr
|
||||
};
|
||||
|
||||
CHECK_EQ(module_construct(&module), ERROR_NONE);
|
||||
|
||||
// 1. Successful start (no parent required anymore)
|
||||
CHECK_EQ(module_start(&module), ERROR_NONE);
|
||||
CHECK_EQ(module_is_started(&module), true);
|
||||
@ -104,6 +106,8 @@ TEST_CASE("Module lifecycle") {
|
||||
// Clean up: fix stop result so we can stop it
|
||||
test_stop_result = ERROR_NONE;
|
||||
CHECK_EQ(module_stop(&module), ERROR_NONE);
|
||||
|
||||
CHECK_EQ(module_destruct(&module), ERROR_NONE);
|
||||
}
|
||||
|
||||
TEST_CASE("Global symbol resolution") {
|
||||
@ -120,6 +124,8 @@ TEST_CASE("Global symbol resolution") {
|
||||
.internal = nullptr
|
||||
};
|
||||
|
||||
REQUIRE_EQ(module_construct(&module), ERROR_NONE);
|
||||
|
||||
uintptr_t addr;
|
||||
// Should fail as it is not added or started
|
||||
CHECK_EQ(module_resolve_symbol_global("symbol_test_function", &addr), false);
|
||||
@ -128,8 +134,8 @@ TEST_CASE("Global symbol resolution") {
|
||||
REQUIRE_EQ(module_start(&module), ERROR_NONE);
|
||||
// Still fails as symbols are null
|
||||
CHECK_EQ(module_resolve_symbol_global("symbol_test_function", &addr), true);
|
||||
|
||||
// Cleanup
|
||||
CHECK_EQ(module_remove(&module), ERROR_NONE);
|
||||
|
||||
CHECK_EQ(module_destruct(&module), ERROR_NONE);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user