From a34c7eefe83809e36dbb0420eb513504b11fe898 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 29 Jan 2022 00:42:38 +0100 Subject: [PATCH] Make the Catch2-SimGrid integration available to more tests --- MANIFEST.in | 4 +-- .../include/catch_simgrid.hpp | 7 +++-- ...tivity-lifecycle.cpp => catch_simgrid.cpp} | 4 +-- teshsuite/s4u/CMakeLists.txt | 28 +++++++++++++------ .../s4u/activity-lifecycle/testing_comm.cpp | 2 +- .../testing_comm_direct.cpp | 2 +- .../s4u/activity-lifecycle/testing_exec.cpp | 2 +- .../s4u/activity-lifecycle/testing_sleep.cpp | 2 +- .../activity-lifecycle/testing_test-wait.cpp | 2 +- 9 files changed, 33 insertions(+), 20 deletions(-) rename teshsuite/s4u/activity-lifecycle/activity-lifecycle.hpp => src/include/catch_simgrid.hpp (83%) rename teshsuite/{s4u/activity-lifecycle/activity-lifecycle.cpp => catch_simgrid.cpp} (97%) diff --git a/MANIFEST.in b/MANIFEST.in index 7ba1b9a2ee..15d6b34bc9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -672,6 +672,7 @@ include examples/smpi/trace_call_location/trace_call_location.c include examples/smpi/trace_call_location/trace_call_location.tesh include examples/smpi/trace_simple/trace_simple.c include examples/smpi/trace_simple/trace_simple.tesh +include src/include/catch_simgrid.hpp include teshsuite/java/semaphoregc/SemaphoreGC.java include teshsuite/java/semaphoregc/semaphoregc.tesh include teshsuite/java/sleephostoff/SleepHostOff.java @@ -750,8 +751,7 @@ include teshsuite/python/corrupt-stack/corrupt-stack.tesh include teshsuite/python/corrupt-stack/corrupt-stack_d.xml include teshsuite/python/platform-mix/platform-mix.py include teshsuite/python/platform-mix/platform-mix.tesh -include teshsuite/s4u/activity-lifecycle/activity-lifecycle.cpp -include teshsuite/s4u/activity-lifecycle/activity-lifecycle.hpp +include teshsuite/s4u/../catch_simgrid.cpp include teshsuite/s4u/activity-lifecycle/activity-lifecycle.tesh include teshsuite/s4u/activity-lifecycle/testing_comm.cpp include teshsuite/s4u/activity-lifecycle/testing_comm_direct.cpp diff --git a/teshsuite/s4u/activity-lifecycle/activity-lifecycle.hpp b/src/include/catch_simgrid.hpp similarity index 83% rename from teshsuite/s4u/activity-lifecycle/activity-lifecycle.hpp rename to src/include/catch_simgrid.hpp index 33dc50040a..ada84da9e3 100644 --- a/teshsuite/s4u/activity-lifecycle/activity-lifecycle.hpp +++ b/src/include/catch_simgrid.hpp @@ -24,8 +24,11 @@ extern void assert_exit(bool exp_success, double duration); extern void assert_cleanup(); /* We need an extra actor here, so that it can sleep until the end of each test */ -#define BEGIN_SECTION(descr) SECTION(descr) { simgrid::s4u::Actor::create(descr, all_hosts[0], []() -#define END_SECTION }) +#define BEGIN_SECTION(descr) \ + SECTION(descr) \ + { simgrid::s4u::Actor::create(descr, all_hosts[0], []() +#define END_SECTION \ + }) #define RUN_SECTION(descr, ...) SECTION(descr) simgrid::s4u::Actor::create(descr, all_hosts[0], __VA_ARGS__) diff --git a/teshsuite/s4u/activity-lifecycle/activity-lifecycle.cpp b/teshsuite/catch_simgrid.cpp similarity index 97% rename from teshsuite/s4u/activity-lifecycle/activity-lifecycle.cpp rename to teshsuite/catch_simgrid.cpp index 5427b09c8b..e0723ee281 100644 --- a/teshsuite/s4u/activity-lifecycle/activity-lifecycle.cpp +++ b/teshsuite/catch_simgrid.cpp @@ -5,7 +5,7 @@ #define CATCH_CONFIG_RUNNER // we supply our own main() -#include "activity-lifecycle.hpp" +#include "catch_simgrid.hpp" #include @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) e.load_platform(platf); int status = 42; - all_hosts = e.get_all_hosts(); + all_hosts = e.get_all_hosts(); simgrid::s4u::Actor::create("main_dispatcher", all_hosts[0], [&argc, &argv, &status]() { status = Catch::Session().run(argc, argv); }); diff --git a/teshsuite/s4u/CMakeLists.txt b/teshsuite/s4u/CMakeLists.txt index 6c750547a8..bf142a31e2 100644 --- a/teshsuite/s4u/CMakeLists.txt +++ b/teshsuite/s4u/CMakeLists.txt @@ -1,3 +1,9 @@ +# Specify the source files of multi-files tests +set(activity-lifecycle_sources ../catch_simgrid.cpp) +foreach(x sleep exec comm comm_direct test-wait) + set(activity-lifecycle_sources ${activity-lifecycle_sources} activity-lifecycle/testing_${x}.cpp) +endforeach() + foreach(x actor actor-autorestart actor-suspend activity-lifecycle comm-get-sender comm-pt2pt wait-all-for wait-any-for @@ -10,20 +16,24 @@ foreach(x actor actor-autorestart actor-suspend trace-integration seal-platform vm-live-migration vm-suicide issue71) - add_executable (${x} EXCLUDE_FROM_ALL ${x}/${x}.cpp) + + if(NOT DEFINED ${x}_sources) + set(${x}_sources ${x}/${x}.cpp) + endif() + + add_executable (${x} EXCLUDE_FROM_ALL ${${x}_sources}) target_link_libraries(${x} simgrid) set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) add_dependencies(tests ${x}) - set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp) -endforeach() + foreach(file ${${x}_sources}) + set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + endforeach() -# Fix build rules for activity-lifecycle (multi-file) -foreach(x sleep exec comm comm_direct test-wait) - target_sources(activity-lifecycle PRIVATE activity-lifecycle/testing_${x}.cpp) - set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/activity-lifecycle/testing_${x}.cpp) + unset(${x}_sources) endforeach() -set_property(TARGET activity-lifecycle APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}") # for +set_property(TARGET activity-lifecycle APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}") # for and catch_simgrid + ## Add the tests. ## Some need to be run with all factories, some don't need tesh to run @@ -78,7 +88,7 @@ ADD_TEST(tesh-parser-full-links01 ${CMAKE_BINARY_DIR}/teshsuite/s4u/basic-par ADD_TEST(tesh-parser-full-links02 ${CMAKE_BINARY_DIR}/teshsuite/s4u/basic-parsing-test/basic-parsing-test ${CMAKE_HOME_DIRECTORY}/teshsuite/platforms/two_clusters_one_name.xml FULL_LINK) ADD_TEST(tesh-parser-one-link-g5k ${CMAKE_BINARY_DIR}/teshsuite/s4u/basic-parsing-test/basic-parsing-test ${CMAKE_HOME_DIRECTORY}/examples/platforms/g5k.xml ONE_LINK) -set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/activity-lifecycle/activity-lifecycle.hpp PARENT_SCOPE) +set(teshsuite_src ${teshsuite_src} ${CMAKE_SOURCE_DIR}/src/include/catch_simgrid.hpp PARENT_SCOPE) set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/basic-parsing-test/basic-parsing-test-sym-full.tesh ${CMAKE_CURRENT_SOURCE_DIR}/basic-parsing-test/basic-parsing-test-bypass.tesh PARENT_SCOPE) set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/activity-lifecycle/testing_platform.xml diff --git a/teshsuite/s4u/activity-lifecycle/testing_comm.cpp b/teshsuite/s4u/activity-lifecycle/testing_comm.cpp index 0973987031..44b49007c0 100644 --- a/teshsuite/s4u/activity-lifecycle/testing_comm.cpp +++ b/teshsuite/s4u/activity-lifecycle/testing_comm.cpp @@ -3,7 +3,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "activity-lifecycle.hpp" +#include "catch_simgrid.hpp" #include static void test_link_off_helper(double delay) diff --git a/teshsuite/s4u/activity-lifecycle/testing_comm_direct.cpp b/teshsuite/s4u/activity-lifecycle/testing_comm_direct.cpp index b6a19e3d85..c75054f347 100644 --- a/teshsuite/s4u/activity-lifecycle/testing_comm_direct.cpp +++ b/teshsuite/s4u/activity-lifecycle/testing_comm_direct.cpp @@ -3,7 +3,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "activity-lifecycle.hpp" +#include "catch_simgrid.hpp" TEST_CASE("Activity lifecycle: direct communication activities") { diff --git a/teshsuite/s4u/activity-lifecycle/testing_exec.cpp b/teshsuite/s4u/activity-lifecycle/testing_exec.cpp index d7712c4a78..07d5a728f1 100644 --- a/teshsuite/s4u/activity-lifecycle/testing_exec.cpp +++ b/teshsuite/s4u/activity-lifecycle/testing_exec.cpp @@ -3,7 +3,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "activity-lifecycle.hpp" +#include "catch_simgrid.hpp" TEST_CASE("Activity lifecycle: exec activities") { diff --git a/teshsuite/s4u/activity-lifecycle/testing_sleep.cpp b/teshsuite/s4u/activity-lifecycle/testing_sleep.cpp index 8920685a7f..8dc8d3a848 100644 --- a/teshsuite/s4u/activity-lifecycle/testing_sleep.cpp +++ b/teshsuite/s4u/activity-lifecycle/testing_sleep.cpp @@ -3,7 +3,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "activity-lifecycle.hpp" +#include "catch_simgrid.hpp" TEST_CASE("Activity lifecycle: sleep activities") { diff --git a/teshsuite/s4u/activity-lifecycle/testing_test-wait.cpp b/teshsuite/s4u/activity-lifecycle/testing_test-wait.cpp index 39a9e76fc8..e2a3ab4252 100644 --- a/teshsuite/s4u/activity-lifecycle/testing_test-wait.cpp +++ b/teshsuite/s4u/activity-lifecycle/testing_test-wait.cpp @@ -3,7 +3,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "activity-lifecycle.hpp" +#include "catch_simgrid.hpp" //========== Creators: create an async activity -- 2.20.1