diff --git a/TactilityKernel/Source/module.cpp b/TactilityKernel/Source/module.cpp index 6ae1e312..1105d971 100644 --- a/TactilityKernel/Source/module.cpp +++ b/TactilityKernel/Source/module.cpp @@ -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; } diff --git a/Tests/TactilityKernel/Source/ModuleTest.cpp b/Tests/TactilityKernel/Source/ModuleTest.cpp index 57517dff..24d60fb7 100644 --- a/Tests/TactilityKernel/Source/ModuleTest.cpp +++ b/Tests/TactilityKernel/Source/ModuleTest.cpp @@ -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); }