diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 675725ee75695e475e751a717bc2520f02d10522..87b24637f2c3aa17c9fb72ab63134a7446143c1f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,6 +78,13 @@ variables: extends: - .clang - .default-library-static + variables: + # Clang's sanitizers require undefined symbols to be allowed when + # linking. See also: + # - https://github.com/mesonbuild/meson/issues/764 + # - https://mesonbuild.com/Builtin-options.html + EMPER_B_LUNDEF: 'false' + .clang-sanitizer-undefined: extends: diff --git a/tests/SignalPrivateSemaphoreFromAnywhereTest.cpp b/tests/SignalPrivateSemaphoreFromAnywhereTest.cpp index d4fd5858023e19a279f4f1a223dec95a6124cbad..e5f871390fd38bd2ad72a1a0ab7fcb45206d8214 100644 --- a/tests/SignalPrivateSemaphoreFromAnywhereTest.cpp +++ b/tests/SignalPrivateSemaphoreFromAnywhereTest.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright © 2020 Florian Schmaus -#include <cstdlib> // for exit, EXIT_FAILURE, EXIT_SUCCESS #include <thread> #include "BinaryPrivateSemaphore.hpp" #include "Fiber.hpp" -#include "Runtime.hpp" // for Runtime -#include "emper-common.h" #include "emper.hpp" -static void testSignalPrivateSemaphoreFromAnywhere() { +void emperTest() { BinaryPrivateSemaphore bpsTest; BinaryPrivateSemaphore bpsSignalledFromAnywhere; @@ -28,18 +25,4 @@ static void testSignalPrivateSemaphoreFromAnywhere() { // TODO: Remove this once we use std::jthread when EMPER uses C++20. signallingThread.join(); - - exit(EXIT_SUCCESS); -} - -auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int { - Runtime runtime; - - Fiber* alphaFiber = Fiber::from(&testSignalPrivateSemaphoreFromAnywhere); - - runtime.scheduleFromAnywhere(*alphaFiber); - - runtime.waitUntilFinished(); - - return EXIT_FAILURE; } diff --git a/tests/TellActorFromAnywhereTest.cpp b/tests/TellActorFromAnywhereTest.cpp index 4f535657e29a7a152cd2efa9152c1f1308983a4e..bedfbd6d83a16d5e03e593eaa1642ecd7c07f2db 100644 --- a/tests/TellActorFromAnywhereTest.cpp +++ b/tests/TellActorFromAnywhereTest.cpp @@ -1,13 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright © 2020 Florian Schmaus -#include <cstdlib> // for exit, EXIT_FAILURE, EXIT_SUCCESS #include <functional> // for bind #include <thread> #include "Actor.hpp" #include "BinaryPrivateSemaphore.hpp" -#include "Fiber.hpp" -#include "Runtime.hpp" // for Runtime #include "emper-common.h" class SignallingActor : public Actor<unsigned int> { @@ -21,7 +18,7 @@ class SignallingActor : public Actor<unsigned int> { SignallingActor(BinaryPrivateSemaphore& bps) : bps(bps){}; }; -static void testTellActorFromAnywhere() { +void emperTest() { BinaryPrivateSemaphore bps; SignallingActor signallingActor(bps); signallingActor.start(); @@ -33,18 +30,4 @@ static void testTellActorFromAnywhere() { // TODO: Remove this once we use std::jthread when EMPER uses C++20. signallingThread.join(); - - exit(EXIT_SUCCESS); -} - -auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int { - Runtime runtime; - - Fiber* alphaFiber = Fiber::from(&testTellActorFromAnywhere); - - runtime.scheduleFromAnywhere(*alphaFiber); - - runtime.waitUntilFinished(); - - return EXIT_FAILURE; } diff --git a/tests/meson.build b/tests/meson.build index 32e83633e66a58f4c0d7e430b7d71c688f561983..a4ba8ce841f6ca9fb25687de3f83563f6ec46912 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -54,12 +54,14 @@ tests = { 'description': 'Simple test for PrivateSemaphore:signalFromAnywhere()', 'test_suite': 'smoke', 'is_parallel': true, + 'emper_test_runner': true, }, 'TellActorFromAnywhereTest.cpp': { 'description': 'Simple test for Actor:tellFromAnywhere()', 'test_suite': 'smoke', 'is_parallel': true, + 'emper_test_runner': true, }, } @@ -74,6 +76,8 @@ test_env = environment( } ) +subdir('test-runner') + foreach source, test_dict : tests # TODO: Use meson fs (filesystem) module once meson >= 0.53 is in # buster-backports, instead of split('.')[0] @@ -86,6 +90,10 @@ foreach source, test_dict : tests test_deps += test_dict['dependencies'] endif + if test_dict.get('emper_test_runner', false) + test_deps += emper_test_runner_dep + endif + test_exe = executable(test_name, source, include_directories: emper_all_include, diff --git a/tests/test-runner/emper-test-runner.cpp b/tests/test-runner/emper-test-runner.cpp new file mode 100644 index 0000000000000000000000000000000000000000..711e757ff931b0d931905de52e15f6e5050cbf8a --- /dev/null +++ b/tests/test-runner/emper-test-runner.cpp @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2020 Florian Schmaus +#include <cstdlib> +#include <iostream> + +#include "Fiber.hpp" +#include "Runtime.hpp" +#include "emper-common.h" + +void emperTest() __attribute__((weak)); + +static void invokeTest() { + emperTest(); + + exit(EXIT_SUCCESS); +} + +auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int { + if (!&emperTest) { + std::cerr << "ERROR: The emperTest() method is not defined."; + return EXIT_FAILURE; + } + + Runtime runtime; + + Fiber* alphaFiber = Fiber::from(&invokeTest); + + runtime.scheduleFromAnywhere(*alphaFiber); + + runtime.waitUntilFinished(); + + return EXIT_FAILURE; +} diff --git a/tests/test-runner/meson.build b/tests/test-runner/meson.build new file mode 100644 index 0000000000000000000000000000000000000000..151b2cab19e3e5e86fc15a1b67ffb173660ddcd8 --- /dev/null +++ b/tests/test-runner/meson.build @@ -0,0 +1,8 @@ +emper_test_runner_lib = library('emper-test-runner', + 'emper-test-runner.cpp', + dependencies: emper_dep + ) + +emper_test_runner_dep = declare_dependency( + link_with : emper_test_runner_lib +)