tests CHANGE move tests from source view to a units view
Focus of the tests is supposed to be on the libyang's parts/mechanisms,
so move the tests structure from source view to a units view.
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 01cb370..631f577 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -15,18 +15,17 @@
set(tests)
set(tests_wraps)
-add_subdirectory(src)
-add_subdirectory(features)
+add_subdirectory(utests)
-foreach(test_name IN LISTS tests)
- message(STATUS ${test_name})
- string(REGEX REPLACE "[a-z]*_(.*)" "\\1" name "${test_name}")
- string(REGEX REPLACE "([a-z]*)_.*" "\\1" prefix "${test_name}")
- add_executable(${test_name} ${prefix}/test_${name}.c $<TARGET_OBJECTS:yangobj>)
-endforeach(test_name)
+foreach(test_id IN LISTS tests)
+ message(STATUS ${test_id})
+ string(REGEX REPLACE "([a-z]*):.*" "\\1" category "${test_id}")
+ string(REGEX REPLACE "[a-z]*:(.*)" "\\1" path "${test_id}")
+ string(REGEX REPLACE "[a-z:/]*test_(.*)" "\\1" name "${test_id}")
+ set(test_name ${category}_${name})
+ add_executable(${test_name} ${category}s/${path}.c $<TARGET_OBJECTS:yangobj>)
-# Set common attributes of all tests
-foreach(test_name IN LISTS tests)
+ # Set common attributes of all tests
target_link_libraries(${test_name} ${CMOCKA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} m)
if (NOT APPLE)
list(GET tests_wraps 0 test_wrap)
@@ -37,20 +36,18 @@
# set_property(TEST ${test_name} PROPERTY ENVIRONMENT "LIBYANG_EXTENSIONS_PLUGINS_DIR=${CMAKE_BINARY_DIR}/src/extensions")
# set_property(TEST ${test_name} APPEND PROPERTY ENVIRONMENT "LIBYANG_USER_TYPES_PLUGINS_DIR=${CMAKE_BINARY_DIR}/src/user_types")
set_property(TEST ${test_name} APPEND PROPERTY ENVIRONMENT "MALLOC_CHECK_=3")
-endforeach(test_name)
-if(ENABLE_VALGRIND_TESTS)
- if(VALGRIND_FOUND)
- foreach(test_name IN LISTS tests)
+ if(ENABLE_VALGRIND_TESTS)
+ if(VALGRIND_FOUND)
add_test(${test_name}_valgrind valgrind --leak-check=full --show-leak-kinds=all --suppressions=${PROJECT_SOURCE_DIR}/tests/ld.supp --error-exitcode=1
- ${CMAKE_BINARY_DIR}/tests/${test_name})
+ ${CMAKE_BINARY_DIR}/tests/${test_name})
# set_property(TEST ${test_name}_valgrind PROPERTY ENVIRONMENT "LIBYANG_EXTENSIONS_PLUGINS_DIR=${CMAKE_BINARY_DIR}/src/extensions")
# set_property(TEST ${test_name}_valgrind APPEND PROPERTY ENVIRONMENT "LIBYANG_USER_TYPES_PLUGINS_DIR=${CMAKE_BINARY_DIR}/src/user_types")
- endforeach(test_name)
- else(VALGRIND_FOUND)
- message(WARNING "valgrind executable not found! Disabling memory leaks tests.")
- endif(VALGRIND_FOUND)
-endif()
+ else(VALGRIND_FOUND)
+ message(WARNING "valgrind executable not found! Disabling memory leaks tests.")
+ endif(VALGRIND_FOUND)
+ endif(ENABLE_VALGRIND_TESTS)
+endforeach()
if(ENABLE_COVERAGE)
# Destination