From 6551ba80b1a47cf56fa9d87de618c87eb751bf54 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Thu, 25 Aug 2022 19:30:44 +0200 Subject: [PATCH] Compute test name from source file --- test/CMakeLists.txt | 2 +- test/{manual => emu}/CMakeLists.txt | 0 test/{manual => emu}/instr.h | 0 test/{manual => emu}/nanos6/CMakeLists.txt | 12 ++++---- .../nanos6/blocking.c} | 0 test/{manual => emu}/nanos6/instr_nanos6.h | 0 .../nanos6/nested-tasks-bad.c} | 0 .../nanos6/nested-tasks.c} | 0 .../nanos6/ss-mismatch.c} | 0 .../nanos6/subsystems.c} | 0 .../nanos6/task-types.c} | 0 test/{manual => emu}/nosv/CMakeLists.txt | 8 +++--- test/{manual => emu}/nosv/instr_nosv.h | 0 .../nosv/nested-tasks-bad.c} | 0 .../nosv/nested-tasks.c} | 0 .../nosv/nosv-pause.c => emu/nosv/pause.c} | 0 .../nosv/task-types.c} | 0 test/{manual => emu}/ovni/CMakeLists.txt | 8 +++--- test/{manual => emu}/ovni/flush-overhead.c | 0 test/{manual => emu}/ovni/flush.c | 0 test/{manual => emu}/ovni/instr_ovni.h | 0 test/{manual => emu}/ovni/mp-rank.c | 0 test/{manual => emu}/ovni/mp-simple.c | 0 test/macros.cmake | 28 +++++++++---------- test/rt/CMakeLists.txt | 2 +- test/rt/nanos6/CMakeLists.txt | 4 +-- 26 files changed, 32 insertions(+), 32 deletions(-) rename test/{manual => emu}/CMakeLists.txt (100%) rename test/{manual => emu}/instr.h (100%) rename test/{manual => emu}/nanos6/CMakeLists.txt (78%) rename test/{manual/nanos6/nanos6-blocking.c => emu/nanos6/blocking.c} (100%) rename test/{manual => emu}/nanos6/instr_nanos6.h (100%) rename test/{manual/nanos6/nanos6-nested-tasks-bad.c => emu/nanos6/nested-tasks-bad.c} (100%) rename test/{manual/nanos6/nanos6-nested-tasks.c => emu/nanos6/nested-tasks.c} (100%) rename test/{manual/nanos6/nanos6-ss-mismatch.c => emu/nanos6/ss-mismatch.c} (100%) rename test/{manual/nanos6/nanos6-subsystems.c => emu/nanos6/subsystems.c} (100%) rename test/{manual/nanos6/nanos6-task-types.c => emu/nanos6/task-types.c} (100%) rename test/{manual => emu}/nosv/CMakeLists.txt (83%) rename test/{manual => emu}/nosv/instr_nosv.h (100%) rename test/{manual/nosv/nosv-nested-tasks-bad.c => emu/nosv/nested-tasks-bad.c} (100%) rename test/{manual/nosv/nosv-nested-tasks.c => emu/nosv/nested-tasks.c} (100%) rename test/{manual/nosv/nosv-pause.c => emu/nosv/pause.c} (100%) rename test/{manual/nosv/nosv-task-types.c => emu/nosv/task-types.c} (100%) rename test/{manual => emu}/ovni/CMakeLists.txt (87%) rename test/{manual => emu}/ovni/flush-overhead.c (100%) rename test/{manual => emu}/ovni/flush.c (100%) rename test/{manual => emu}/ovni/instr_ovni.h (100%) rename test/{manual => emu}/ovni/mp-rank.c (100%) rename test/{manual => emu}/ovni/mp-simple.c (100%) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 457b227..0a25e9d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -19,7 +19,7 @@ set(OVNI_TEST_BUILD_DIR "${CMAKE_BINARY_DIR}/test") include(macros.cmake) -add_subdirectory(manual) +add_subdirectory(emu) if(ENABLE_TEST_RT) add_subdirectory(rt) diff --git a/test/manual/CMakeLists.txt b/test/emu/CMakeLists.txt similarity index 100% rename from test/manual/CMakeLists.txt rename to test/emu/CMakeLists.txt diff --git a/test/manual/instr.h b/test/emu/instr.h similarity index 100% rename from test/manual/instr.h rename to test/emu/instr.h diff --git a/test/manual/nanos6/CMakeLists.txt b/test/emu/nanos6/CMakeLists.txt similarity index 78% rename from test/manual/nanos6/CMakeLists.txt rename to test/emu/nanos6/CMakeLists.txt index 9870642..9ff6535 100644 --- a/test/manual/nanos6/CMakeLists.txt +++ b/test/emu/nanos6/CMakeLists.txt @@ -14,11 +14,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -ovni_test(NAME nanos6-nested-tasks) -ovni_test(NAME nanos6-nested-tasks-bad SHOULD_FAIL +ovni_test(nested-tasks.c) +ovni_test(nested-tasks-bad.c SHOULD_FAIL REGEX "fatal: cannot execute task 1: state is not created") -ovni_test(NAME nanos6-task-types MP) -ovni_test(NAME nanos6-blocking MP) -ovni_test(NAME nanos6-subsystems MP) -ovni_test(NAME nanos6-ss-mismatch SHOULD_FAIL +ovni_test(task-types.c MP) +ovni_test(blocking.c MP) +ovni_test(subsystems.c MP) +ovni_test(ss-mismatch.c SHOULD_FAIL REGEX "thread [0-9]\\+ ended with 1 extra stacked nanos6 subsystems, top=ST_NANOS6_SCHED_HUNGRY") diff --git a/test/manual/nanos6/nanos6-blocking.c b/test/emu/nanos6/blocking.c similarity index 100% rename from test/manual/nanos6/nanos6-blocking.c rename to test/emu/nanos6/blocking.c diff --git a/test/manual/nanos6/instr_nanos6.h b/test/emu/nanos6/instr_nanos6.h similarity index 100% rename from test/manual/nanos6/instr_nanos6.h rename to test/emu/nanos6/instr_nanos6.h diff --git a/test/manual/nanos6/nanos6-nested-tasks-bad.c b/test/emu/nanos6/nested-tasks-bad.c similarity index 100% rename from test/manual/nanos6/nanos6-nested-tasks-bad.c rename to test/emu/nanos6/nested-tasks-bad.c diff --git a/test/manual/nanos6/nanos6-nested-tasks.c b/test/emu/nanos6/nested-tasks.c similarity index 100% rename from test/manual/nanos6/nanos6-nested-tasks.c rename to test/emu/nanos6/nested-tasks.c diff --git a/test/manual/nanos6/nanos6-ss-mismatch.c b/test/emu/nanos6/ss-mismatch.c similarity index 100% rename from test/manual/nanos6/nanos6-ss-mismatch.c rename to test/emu/nanos6/ss-mismatch.c diff --git a/test/manual/nanos6/nanos6-subsystems.c b/test/emu/nanos6/subsystems.c similarity index 100% rename from test/manual/nanos6/nanos6-subsystems.c rename to test/emu/nanos6/subsystems.c diff --git a/test/manual/nanos6/nanos6-task-types.c b/test/emu/nanos6/task-types.c similarity index 100% rename from test/manual/nanos6/nanos6-task-types.c rename to test/emu/nanos6/task-types.c diff --git a/test/manual/nosv/CMakeLists.txt b/test/emu/nosv/CMakeLists.txt similarity index 83% rename from test/manual/nosv/CMakeLists.txt rename to test/emu/nosv/CMakeLists.txt index abbf47d..930b59a 100644 --- a/test/manual/nosv/CMakeLists.txt +++ b/test/emu/nosv/CMakeLists.txt @@ -14,8 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -ovni_test(NAME nosv-nested-tasks) -ovni_test(NAME nosv-nested-tasks-bad SHOULD_FAIL +ovni_test(nested-tasks.c) +ovni_test(nested-tasks-bad.c SHOULD_FAIL REGEX "fatal: cannot execute task 1: state is not created") -ovni_test(NAME nosv-task-types MP) -ovni_test(NAME nosv-pause MP) +ovni_test(task-types.c MP) +ovni_test(pause.c MP) diff --git a/test/manual/nosv/instr_nosv.h b/test/emu/nosv/instr_nosv.h similarity index 100% rename from test/manual/nosv/instr_nosv.h rename to test/emu/nosv/instr_nosv.h diff --git a/test/manual/nosv/nosv-nested-tasks-bad.c b/test/emu/nosv/nested-tasks-bad.c similarity index 100% rename from test/manual/nosv/nosv-nested-tasks-bad.c rename to test/emu/nosv/nested-tasks-bad.c diff --git a/test/manual/nosv/nosv-nested-tasks.c b/test/emu/nosv/nested-tasks.c similarity index 100% rename from test/manual/nosv/nosv-nested-tasks.c rename to test/emu/nosv/nested-tasks.c diff --git a/test/manual/nosv/nosv-pause.c b/test/emu/nosv/pause.c similarity index 100% rename from test/manual/nosv/nosv-pause.c rename to test/emu/nosv/pause.c diff --git a/test/manual/nosv/nosv-task-types.c b/test/emu/nosv/task-types.c similarity index 100% rename from test/manual/nosv/nosv-task-types.c rename to test/emu/nosv/task-types.c diff --git a/test/manual/ovni/CMakeLists.txt b/test/emu/ovni/CMakeLists.txt similarity index 87% rename from test/manual/ovni/CMakeLists.txt rename to test/emu/ovni/CMakeLists.txt index c03c5fb..d819064 100644 --- a/test/manual/ovni/CMakeLists.txt +++ b/test/emu/ovni/CMakeLists.txt @@ -16,9 +16,9 @@ # Only run performance sensitive tests on Release builds if(CMAKE_BUILD_TYPE STREQUAL "Release") - ovni_test(NAME flush-overhead) + ovni_test(flush-overhead.c) endif() -ovni_test(NAME flush) -ovni_test(NAME mp-simple MP) -ovni_test(NAME mp-rank MP) +ovni_test(flush.c) +ovni_test(mp-simple.c MP) +ovni_test(mp-rank.c MP) diff --git a/test/manual/ovni/flush-overhead.c b/test/emu/ovni/flush-overhead.c similarity index 100% rename from test/manual/ovni/flush-overhead.c rename to test/emu/ovni/flush-overhead.c diff --git a/test/manual/ovni/flush.c b/test/emu/ovni/flush.c similarity index 100% rename from test/manual/ovni/flush.c rename to test/emu/ovni/flush.c diff --git a/test/manual/ovni/instr_ovni.h b/test/emu/ovni/instr_ovni.h similarity index 100% rename from test/manual/ovni/instr_ovni.h rename to test/emu/ovni/instr_ovni.h diff --git a/test/manual/ovni/mp-rank.c b/test/emu/ovni/mp-rank.c similarity index 100% rename from test/manual/ovni/mp-rank.c rename to test/emu/ovni/mp-rank.c diff --git a/test/manual/ovni/mp-simple.c b/test/emu/ovni/mp-simple.c similarity index 100% rename from test/manual/ovni/mp-simple.c rename to test/emu/ovni/mp-simple.c diff --git a/test/macros.cmake b/test/macros.cmake index 28ea376..04cc4f5 100644 --- a/test/macros.cmake +++ b/test/macros.cmake @@ -1,24 +1,24 @@ include(CMakeParseArguments) -function(ovni_test) +function(ovni_test source) set(switches MP SHOULD_FAIL) - set(single NPROC NAME REGEX) - set(multi SOURCE ENV) + set(single NPROC REGEX) + set(multi ENV) + + # Compute the test name from the source and path + cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR + BASE_DIRECTORY "${OVNI_TEST_SOURCE_DIR}" + OUTPUT_VARIABLE name_prefix) + set(full_path "${name_prefix}/${source}") + string(REGEX REPLACE "\.c$" "" full_path_noext "${full_path}") + string(REPLACE "/" "-" name "${full_path_noext}") cmake_parse_arguments( OVNI_TEST "${switches}" "${single}" "${multi}" ${ARGN}) - if(NOT OVNI_TEST_NAME) - message(FATAL_ERROR "You must provide a test NAME") - endif(NOT OVNI_TEST_NAME) - - set(OVNI_TEST_NAME ${OVNI_TEST_NAME} PARENT_SCOPE) - - # Set default source if not given - if(NOT OVNI_TEST_SOURCE) - set(OVNI_TEST_SOURCE "${OVNI_TEST_NAME}.c") - #message("Setting default source to ${OVNI_TEST_SOURCE}") - endif() + set(OVNI_TEST_NAME ${name} PARENT_SCOPE) + set(OVNI_TEST_NAME ${name}) + set(OVNI_TEST_SOURCE ${source}) if(NOT OVNI_TEST_NPROC) if(NOT OVNI_TEST_MP) diff --git a/test/rt/CMakeLists.txt b/test/rt/CMakeLists.txt index 61af077..538f8b6 100644 --- a/test/rt/CMakeLists.txt +++ b/test/rt/CMakeLists.txt @@ -27,6 +27,6 @@ function(nosv_test) ENVIRONMENT "NOSV_CONFIG=${OVNI_TEST_SOURCE_DIR}/rt/nosv/nosv.toml") endfunction() -nosv_test(NAME nosv-attach SOURCE nosv/attach.c) +nosv_test(nosv/attach.c) add_subdirectory(nanos6) diff --git a/test/rt/nanos6/CMakeLists.txt b/test/rt/nanos6/CMakeLists.txt index 9f4d991..6cae6d8 100644 --- a/test/rt/nanos6/CMakeLists.txt +++ b/test/rt/nanos6/CMakeLists.txt @@ -6,5 +6,5 @@ function(nanos6_rt_test) ENVIRONMENT "NANOS6_CONFIG=${OVNI_TEST_SOURCE_DIR}/rt/nanos6/nanos6.toml") endfunction() -nanos6_rt_test(NAME rt-nanos6-simple-task SOURCE simple-task.c) -nanos6_rt_test(NAME rt-nanos6-nested-task SOURCE nested-task.c) +nanos6_rt_test(simple-task.c) +nanos6_rt_test(nested-task.c)