diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9061fb8d4698c681d3cdd38986b081f6b47df5aa..10fb65efd052c1d9d7d7fdd5f50bdec0f93cb5a5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,73 +1,27 @@ -set(HEADERS - ../src/cell.hpp - ../src/cell_tree.hpp - ../src/math.hpp - ../src/point.hpp - ../src/segment.hpp - ../src/swcio.hpp - ../src/tree.hpp -) # google test framework -add_library(gtest gtest-all.cpp gtest.h) +add_library(gtest gtest-all.cpp) +# tests look for gtest.h here +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -set(TEST_SOURCES - # unit tests - test_algorithms.cpp - test_cell.cpp - test_compartments.cpp - test_event_queue.cpp - test_fvm.cpp - test_cell_group.cpp - test_matrix.cpp - test_mechanisms.cpp - test_optional.cpp - test_parameters.cpp - test_point.cpp - test_probe.cpp - test_segment.cpp - test_spikes.cpp - test_stimulus.cpp - test_swcio.cpp - test_synapses.cpp - test_tree.cpp - test_uninitialized.cpp - # unit test driver - test.cpp -) +# Unit tests +add_subdirectory(unit) -set(VALIDATION_SOURCES - # unit tests - validate_ball_and_stick.cpp - validate_soma.cpp - #validate_synapses.cpp +# Test validating models, possebly needing other software installed +add_subdirectory(validation) - # unit test driver - validate.cpp -) +# Test for the internode communication (eg. mpi) +add_subdirectory(global_communication) -add_definitions("-DDATADIR=\"${CMAKE_SOURCE_DIR}/data\"") -add_executable(test.exe ${TEST_SOURCES} ${HEADERS}) -add_executable(validate.exe ${VALIDATION_SOURCES} ${HEADERS}) -set(TARGETS test.exe validate.exe) +# Proposed additional test types: -foreach(target ${TARGETS}) - target_link_libraries(${target} LINK_PUBLIC cellalgo gtest) +# Large test, employing the full simulator. validated using deltas on output data - if(WITH_TBB) - target_link_libraries(${target} LINK_PUBLIC ${TBB_LIBRARIES}) - endif() +# Test to check integration between components - if(WITH_MPI) - target_link_libraries(${target} LINK_PUBLIC ${MPI_C_LIBRARIES}) - set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS "${MPI_C_LINK_FLAGS}") - endif() +# Tests for performance: This could include stand alone tests. These do not necessarily be run automatically - set_target_properties(${target} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests" - ) -endforeach() +# Numbered tests based on bugs in the tracker diff --git a/tests/global_communication/CMakeLists.txt b/tests/global_communication/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f7d000157e4cfd130399d1f718b67fbc5eb2f86d --- /dev/null +++ b/tests/global_communication/CMakeLists.txt @@ -0,0 +1 @@ +# Nothing to be done yet diff --git a/tests/util.hpp b/tests/test_util.hpp similarity index 100% rename from tests/util.hpp rename to tests/test_util.hpp diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a3a2d55333f6316b133bff3982ec58e1b03d525d --- /dev/null +++ b/tests/unit/CMakeLists.txt @@ -0,0 +1,59 @@ +set(HEADERS + ${PROJECT_SOURCE_DIR}/src/cell.hpp + ${PROJECT_SOURCE_DIR}/src/cell_tree.hpp + ${PROJECT_SOURCE_DIR}/src/math.hpp + ${PROJECT_SOURCE_DIR}/src/point.hpp + ${PROJECT_SOURCE_DIR}/src/segment.hpp + ${PROJECT_SOURCE_DIR}/src/swcio.hpp + ${PROJECT_SOURCE_DIR}/src/tree.hpp +) + +set(TEST_SOURCES + # unit tests + test_algorithms.cpp + test_cell.cpp + test_compartments.cpp + test_event_queue.cpp + test_fvm.cpp + test_cell_group.cpp + test_matrix.cpp + test_mechanisms.cpp + test_optional.cpp + test_parameters.cpp + test_point.cpp + test_probe.cpp + test_segment.cpp + test_spikes.cpp + test_stimulus.cpp + test_swcio.cpp + test_synapses.cpp + test_tree.cpp + test_uninitialized.cpp + + # unit test driver + test.cpp +) + +add_definitions("-DDATADIR=\"${CMAKE_SOURCE_DIR}/data\"") +add_executable(test.exe ${TEST_SOURCES} ${HEADERS}) + +set(TARGETS test.exe) + +foreach(target ${TARGETS}) + target_link_libraries(${target} LINK_PUBLIC cellalgo gtest) + + if(WITH_TBB) + target_link_libraries(${target} LINK_PUBLIC ${TBB_LIBRARIES}) + endif() + + if(WITH_MPI) + target_link_libraries(${target} LINK_PUBLIC ${MPI_C_LIBRARIES}) + set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS "${MPI_C_LINK_FLAGS}") + endif() + + set_target_properties(${target} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests" + ) +endforeach() + diff --git a/tests/test.cpp b/tests/unit/test.cpp similarity index 100% rename from tests/test.cpp rename to tests/unit/test.cpp diff --git a/tests/test_algorithms.cpp b/tests/unit/test_algorithms.cpp similarity index 99% rename from tests/test_algorithms.cpp rename to tests/unit/test_algorithms.cpp index d1ffdf11811f44266df10215026a11d907172459..badaabffb605986578cbc15b9ed40b597a0e95ff 100644 --- a/tests/test_algorithms.cpp +++ b/tests/unit/test_algorithms.cpp @@ -3,7 +3,7 @@ #include "gtest.h" #include "algorithms.hpp" -#include "util.hpp" +#include "../test_util.hpp" #include "util/debug.hpp" diff --git a/tests/test_cell.cpp b/tests/unit/test_cell.cpp similarity index 100% rename from tests/test_cell.cpp rename to tests/unit/test_cell.cpp diff --git a/tests/test_cell_group.cpp b/tests/unit/test_cell_group.cpp similarity index 100% rename from tests/test_cell_group.cpp rename to tests/unit/test_cell_group.cpp diff --git a/tests/test_compartments.cpp b/tests/unit/test_compartments.cpp similarity index 100% rename from tests/test_compartments.cpp rename to tests/unit/test_compartments.cpp diff --git a/tests/test_event_queue.cpp b/tests/unit/test_event_queue.cpp similarity index 100% rename from tests/test_event_queue.cpp rename to tests/unit/test_event_queue.cpp diff --git a/tests/test_fvm.cpp b/tests/unit/test_fvm.cpp similarity index 99% rename from tests/test_fvm.cpp rename to tests/unit/test_fvm.cpp index bc7374cbd0ea8f16b2b8adb02c4d27382aa83c61..1383167aafec9b0c0ae36f2bd6ab8661803d2fe5 100644 --- a/tests/test_fvm.cpp +++ b/tests/unit/test_fvm.cpp @@ -1,7 +1,7 @@ #include <fstream> #include "gtest.h" -#include "util.hpp" +#include "../test_util.hpp" #include <cell.hpp> #include <fvm_cell.hpp> diff --git a/tests/test_matrix.cpp b/tests/unit/test_matrix.cpp similarity index 100% rename from tests/test_matrix.cpp rename to tests/unit/test_matrix.cpp diff --git a/tests/test_mechanisms.cpp b/tests/unit/test_mechanisms.cpp similarity index 100% rename from tests/test_mechanisms.cpp rename to tests/unit/test_mechanisms.cpp diff --git a/tests/test_optional.cpp b/tests/unit/test_optional.cpp similarity index 100% rename from tests/test_optional.cpp rename to tests/unit/test_optional.cpp diff --git a/tests/test_parameters.cpp b/tests/unit/test_parameters.cpp similarity index 97% rename from tests/test_parameters.cpp rename to tests/unit/test_parameters.cpp index 8a4b0d200785036d727fda4cae698a7950fbf040..0781640489725a100b3e4ede3be40dfe168b1cef 100644 --- a/tests/test_parameters.cpp +++ b/tests/unit/test_parameters.cpp @@ -1,7 +1,7 @@ #include <fstream> #include "gtest.h" -#include "util.hpp" +#include "../test_util.hpp" #include "../src/parameter_list.hpp" diff --git a/tests/test_point.cpp b/tests/unit/test_point.cpp similarity index 100% rename from tests/test_point.cpp rename to tests/unit/test_point.cpp diff --git a/tests/test_probe.cpp b/tests/unit/test_probe.cpp similarity index 100% rename from tests/test_probe.cpp rename to tests/unit/test_probe.cpp diff --git a/tests/test_segment.cpp b/tests/unit/test_segment.cpp similarity index 100% rename from tests/test_segment.cpp rename to tests/unit/test_segment.cpp diff --git a/tests/test_spikes.cpp b/tests/unit/test_spikes.cpp similarity index 100% rename from tests/test_spikes.cpp rename to tests/unit/test_spikes.cpp diff --git a/tests/test_stimulus.cpp b/tests/unit/test_stimulus.cpp similarity index 100% rename from tests/test_stimulus.cpp rename to tests/unit/test_stimulus.cpp diff --git a/tests/test_swcio.cpp b/tests/unit/test_swcio.cpp similarity index 100% rename from tests/test_swcio.cpp rename to tests/unit/test_swcio.cpp diff --git a/tests/test_synapses.cpp b/tests/unit/test_synapses.cpp similarity index 98% rename from tests/test_synapses.cpp rename to tests/unit/test_synapses.cpp index 87ac3aeca2e828035dea39c7cab4bf156a4e04bf..ff79c1e6488a2534a03303aa30f05403bd4acdf9 100644 --- a/tests/test_synapses.cpp +++ b/tests/unit/test_synapses.cpp @@ -1,5 +1,5 @@ #include "gtest.h" -#include "util.hpp" +#include "../test_util.hpp" #include <cell.hpp> #include <fvm_cell.hpp> diff --git a/tests/test_tree.cpp b/tests/unit/test_tree.cpp similarity index 100% rename from tests/test_tree.cpp rename to tests/unit/test_tree.cpp diff --git a/tests/test_uninitialized.cpp b/tests/unit/test_uninitialized.cpp similarity index 100% rename from tests/test_uninitialized.cpp rename to tests/unit/test_uninitialized.cpp diff --git a/tests/validation/CMakeLists.txt b/tests/validation/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..31477528d45b62aef700fbbdff3e3ea686a66ee4 --- /dev/null +++ b/tests/validation/CMakeLists.txt @@ -0,0 +1,49 @@ +set(HEADERS + ${PROJECT_SOURCE_DIR}/src/cell.hpp + ${PROJECT_SOURCE_DIR}/src/cell_tree.hpp + ${PROJECT_SOURCE_DIR}/src/math.hpp + ${PROJECT_SOURCE_DIR}/src/point.hpp + ${PROJECT_SOURCE_DIR}/src/segment.hpp + ${PROJECT_SOURCE_DIR}/src/swcio.hpp + ${PROJECT_SOURCE_DIR}/src/tree.hpp +) + +set(TEST_SOURCES + # unit test driver + test.cpp +) + +set(VALIDATION_SOURCES + # unit tests + validate_ball_and_stick.cpp + validate_soma.cpp + #validate_synapses.cpp + + # unit test driver + validate.cpp +) + +add_definitions("-DDATADIR=\"${CMAKE_SOURCE_DIR}/data\"") + +add_executable(validate.exe ${VALIDATION_SOURCES} ${HEADERS}) + +set(TARGETS validate.exe) + +foreach(target ${TARGETS}) + target_link_libraries(${target} LINK_PUBLIC cellalgo gtest) + + if(WITH_TBB) + target_link_libraries(${target} LINK_PUBLIC ${TBB_LIBRARIES}) + endif() + + if(WITH_MPI) + target_link_libraries(${target} LINK_PUBLIC ${MPI_C_LIBRARIES}) + set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS "${MPI_C_LINK_FLAGS}") + endif() + + set_target_properties(${target} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests" + ) +endforeach() + diff --git a/tests/make_image.sh b/tests/validation/make_image.sh old mode 100755 new mode 100644 similarity index 100% rename from tests/make_image.sh rename to tests/validation/make_image.sh diff --git a/tests/plot.py b/tests/validation/plot.py similarity index 100% rename from tests/plot.py rename to tests/validation/plot.py diff --git a/tests/validation/test.cpp b/tests/validation/test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2eab0931a0b4b2a5b17ed12ba6c2f3d1d09d27c --- /dev/null +++ b/tests/validation/test.cpp @@ -0,0 +1,11 @@ +#include <iostream> +#include <fstream> +#include <numeric> +#include <vector> + +#include "gtest.h" + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tests/validate.cpp b/tests/validation/validate.cpp similarity index 100% rename from tests/validate.cpp rename to tests/validation/validate.cpp diff --git a/tests/validate_ball_and_stick.cpp b/tests/validation/validate_ball_and_stick.cpp similarity index 99% rename from tests/validate_ball_and_stick.cpp rename to tests/validation/validate_ball_and_stick.cpp index 5b509525b053fe389908b150b87333a27f5241ec..803550641694fb1226bf90c42877634aa9a4fd34 100644 --- a/tests/validate_ball_and_stick.cpp +++ b/tests/validation/validate_ball_and_stick.cpp @@ -2,7 +2,7 @@ #include <json/src/json.hpp> #include "gtest.h" -#include "util.hpp" +#include "../test_util.hpp" #include <cell.hpp> #include <fvm_cell.hpp> diff --git a/tests/validate_soma.cpp b/tests/validation/validate_soma.cpp similarity index 99% rename from tests/validate_soma.cpp rename to tests/validation/validate_soma.cpp index 2353cb483967fb74757dab81ffcf96c68f3c649a..dac3ca0fd7604a307b46ed25441334d5641b1ca7 100644 --- a/tests/validate_soma.cpp +++ b/tests/validation/validate_soma.cpp @@ -2,7 +2,7 @@ #include <json/src/json.hpp> #include "gtest.h" -#include "util.hpp" +#include "../test_util.hpp" #include <cell.hpp> #include <fvm_cell.hpp> diff --git a/tests/validate_synapses.cpp b/tests/validation/validate_synapses.cpp similarity index 99% rename from tests/validate_synapses.cpp rename to tests/validation/validate_synapses.cpp index 2ccde863cb4cbf16efbe75dd509e9c7c2095ddbe..3b53b3c1ab48f8d2fc234550c9d27a6ac4644910 100644 --- a/tests/validate_synapses.cpp +++ b/tests/validation/validate_synapses.cpp @@ -1,7 +1,7 @@ #include <fstream> #include "gtest.h" -#include "util.hpp" +#include "../test_util.hpp" #include <cell.hpp> #include <fvm_cell.hpp>