diff --git a/emper/Context.hpp b/emper/Context.hpp index ae068e5c111dc149e74f54510f11b16b5ca64f92..e3117ee688b73bd0ac61809fcd81267379a1faf8 100644 --- a/emper/Context.hpp +++ b/emper/Context.hpp @@ -6,7 +6,7 @@ #include <cstdint> // for uintptr_t #include <functional> // for function #include <iosfwd> // for ostream -#include <type_traits> // for remove_reference<>::type +#include <type_traits> // for remove_reference<>::type // IWYU pragma: keep #include <utility> #include "Common.hpp" // for func_t, DIE, ALIGN_TO_CACHE_LINE diff --git a/emper/Debug.hpp b/emper/Debug.hpp index a4d99c28fcb2a8b1d7895a9c523ad770201d5a19..ff0cc2a4fe6d87c05564aeb31e7eb4108db11b97 100644 --- a/emper/Debug.hpp +++ b/emper/Debug.hpp @@ -3,7 +3,6 @@ #pragma once #include <iostream> // IWYU pragma: keep -#include <map> // for allocator, map #include <sstream> // IWYU pragma: keep #include <string> // for string, operator<< @@ -77,16 +76,33 @@ enum LogLevel { void worker_log(const std::string& prefix, const std::string& message); -static const std::map<LogSubsystem, LogLevel> LOG_CONFIG = { - {LogSubsystem::PS, ALL}, {LogSubsystem::F, ALL}, {LogSubsystem::C, ALL}, - {LogSubsystem::CM, ALL}, {LogSubsystem::DISP, ALL}, {LogSubsystem::SCHED, ALL}, - {LogSubsystem::RUNTI, ALL}, {LogSubsystem::U_B_MPSC_Q, ALL}, -}; - template <LogSubsystem logSubsystem> class Logger { private: - static constexpr auto getTagFor(LogSubsystem system) -> char const* { + static constexpr LogLevel getLevelFor(LogSubsystem system) { + switch (system) { + case LogSubsystem::PS: + return ALL; + case LogSubsystem::F: + return ALL; + case LogSubsystem::C: + return ALL; + case LogSubsystem::CM: + return ALL; + case LogSubsystem::DISP: + return ALL; + case LogSubsystem::SCHED: + return ALL; + case LogSubsystem::RUNTI: + return ALL; + case LogSubsystem::U_B_MPSC_Q: + return ALL; + default: + return ALL; + } + } + + static constexpr char const* getTagFor(LogSubsystem system) { switch (system) { case LogSubsystem::PS: return "PS "; @@ -125,7 +141,7 @@ class Logger { // Do not log any debug messages if NDEBUG is defined. if (level >= Debug) return; #endif - if (level > LOG_CONFIG.at(logSubsystem)) return; + if (level > getLevelFor(logSubsystem)) return; std::string subSystemTag = getTagFor(logSubsystem); ; diff --git a/emper/meson.build b/emper/meson.build index ec79201a227800ebff0466ccb5f8e6e9dbbf9b58..eeee83e0fcdc45d4072b09519c49684b85ddba25 100644 --- a/emper/meson.build +++ b/emper/meson.build @@ -29,6 +29,7 @@ emper_cpp_sources = [ emper_generated_files = [] +emper_include = [] subdir('include') emper_library_include = [] diff --git a/tests/SimpleActorTest.cpp b/tests/SimpleActorTest.cpp index 1aa84dbbc4750bcf604d42b4dffe957dd3ee199b..cf7e49d04449ed7a25980369990909608279f9d4 100644 --- a/tests/SimpleActorTest.cpp +++ b/tests/SimpleActorTest.cpp @@ -28,6 +28,8 @@ class SumActor : public Actor<uint64_t> { std::atomic_thread_fence(std::memory_order::memory_order_acquire); return sum; } + + void stop() { Actor::stop(); } }; static void mainFiber(void* runtime_ptr) { @@ -62,6 +64,8 @@ static void mainFiber(void* runtime_ptr) { exit(EXIT_FAILURE); } + sumActor.stop(); + if (sumActor.getSum() != EXPECTED_SUM) { std::cerr << "FAILURE: Actor sum " << sumActor.getSum() << " is not equal to expected sum " << EXPECTED_SUM << std::endl; diff --git a/tests/meson.build b/tests/meson.build index a02648e48cb86b766daef4986b5769dc68b4228d..60b881dddb5e10cbbad2e2a456bbe71e3654a830 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -20,11 +20,10 @@ tests = { 'description': 'Test EMPER\'s C++ API', }, - # 'SimpleActorTest.cpp': - # { - # 'description': 'Simple Actor Test', - # 'test_suite': 'broken', - # }, + 'SimpleActorTest.cpp': + { + 'description': 'Simple Actor Test', + }, 'SimpleLawsTest.cpp': { @@ -34,6 +33,14 @@ tests = { undef_ndebug = '-UNDEBUG' test_dep = [thread_dep] +test_env = environment( + { + # Set glibc's MALLOC_PERTURB to 1. This means that newly allocated + # memory will be initialized with 0x01, and that free'ed memory + # will be set to 0xFE (I think). + 'MALLOC_PERTURB_': '1', + } +) foreach source, test_dict : tests # TODO: Use meson fs (filesystem) module once meson >= 0.53 is in @@ -55,6 +62,7 @@ foreach source, test_dict : tests test_exe, is_parallel: test_dict.get('is_parallel', true), suite: test_dict.get('test_suite', 'all'), - timeout: 60 + timeout: 60, + env: test_env, ) endforeach