Skip to content

Commit

Permalink
move tests to tests/tests (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Risto97 authored Oct 5, 2024
1 parent 40fd096 commit 59c59e7
Show file tree
Hide file tree
Showing 64 changed files with 114 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ option(SOCMAKE_BUILD_TESTING "Enable SoCMake unit testing" OFF)

if("${SOCMAKE_BUILD_TESTING}")
include(CTest)
add_subdirectory(tests)
add_subdirectory(tests/tests)
endif()

# This is to prevent a warning
Expand Down
29 changes: 29 additions & 0 deletions tests/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.25)
project(SoCMake_testing)

include(CTest)

add_custom_target(check
COMMAND ctest $(JOBS) --output-on-failure
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/../../
)

add_custom_target(check_cdash
COMMAND ctest -D Nightly $(JOBS) --output-on-failure
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/../../
)

add_subdirectory(iverilog)
add_subdirectory(vhier)
add_subdirectory(peakrdl)

include("getcmaketest.cmake")
include(cmake_test/cmake_test)

ct_add_dir(add_ip USE_REL_PATH_NAMES LABEL)
ct_add_dir(ip_include_directories USE_REL_PATH_NAMES LABEL)
ct_add_dir(ip_compile_definitions USE_REL_PATH_NAMES LABEL)
ct_add_dir(alias_dereference USE_REL_PATH_NAMES LABEL)
ct_add_dir(check_languages USE_REL_PATH_NAMES LABEL)
ct_add_dir(ip_sources USE_REL_PATH_NAMES LABEL)
ct_add_dir(ip_link USE_REL_PATH_NAMES LABEL)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME add_ip)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This test will succed because its allowed to have short notation in `ip_link(ip)` call
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME add_ip_1_token)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME add_ip_description)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This tests should fail because its not allowed to have different than 4 or 1 tokens in `ip_link()` call
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME add_ip_fail_2_tokens_name_version)
ct_add_test(NAME ${TEST_NAME} EXPECTFAIL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This tests should fail because its not allowed to have different than 4 or 1 tokens in `ip_link()` call
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME add_ip_fail_3_tokens_vendor_lib_ip)
ct_add_test(NAME ${TEST_NAME} EXPECTFAIL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This tests should fail because its not allowed to have different than 4 or 1 tokens in `ip_link()` call
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME add_ip_fail_4_tokens_empty_token_1)
ct_add_test(NAME ${TEST_NAME} EXPECTFAIL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This tests should fail because its not allowed to have different than 4 or 1 tokens in `ip_link()` call
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME add_ip_fail_5_tokens)
ct_add_test(NAME ${TEST_NAME} EXPECTFAIL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME alias_dereference)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME check_languages_additional)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME check_languages_fatal)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME check_languages_standard)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME check_languages_warning)

Expand Down
46 changes: 46 additions & 0 deletions tests/tests/getcmaketest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
list(APPEND CMAKE_MODULE_PATH ${PROJECT_BINARY_DIR}/_deps/cmakepp_lang-src/cmake)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_BINARY_DIR}/_deps/cmake_test-src/cmake)
include_guard()

#[[[
# This function encapsulates the process of getting CMakeTest using CMake's
# FetchContent module. We have encapsulated it in a function so we can set
# the options for its configure step without affecting the options for the
# parent project's configure step (namely we do not want to build CMakeTest's
# unit tests).
#]]
macro(get_cmake_test)
include(cmake_test/cmake_test OPTIONAL RESULT_VARIABLE cmake_test_found)
if(NOT cmake_test_found)



# Store whether we are building tests or not, then turn off the tests
set(build_testing_old "${BUILD_TESTING}")
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
# Download CMakeTest and bring it into scope
include(FetchContent)
FetchContent_Declare(
cmake_test
GIT_REPOSITORY https://github.com/CMakePP/CMakeTest
GIT_TAG b07712effc7877c97712a5342a34f49b4e8ee3fb
)
FetchContent_MakeAvailable(cmake_test)

# Restore the previous value
set(BUILD_TESTING "${build_testing_old}" CACHE BOOL "" FORCE)
endif()
endmacro()

# FetchContent_Declare(
# cmakepp_lang
# GIT_REPOSITORY https://github.com/CMakePP/CMakePPLang
# )
# FetchContent_MakeAvailable(cmakepp_lang)
# include(cmakepp_lang/cmakepp_lang)

# Call the function we just wrote to get CMakeTest
get_cmake_test()

# Include CMakeTest
# include(cmake_test/cmake_test)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_compile_definitions)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_compile_definitions_get_multilang)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_compile_definitions_hier)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_include_directories)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_include_directories_get_multilang)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_link1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# CMake wraps INTERFACE_LINK_LIBRARIES with ::@(directory-id);...;::@
# Graph traversal functions should ignore this wrapper

include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../../CMakeLists.txt")
set(THIS_DIR ${CMAKE_CURRENT_LIST_DIR})

set(TEST_NAME ip_link_different_subdir)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This test is expected to throw FATAL_ERROR because `ip_link()` links ip1 to itself
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_link_self_link_fatal)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_sources_fail)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_sources)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt")
include("${CMAKE_CURRENT_LIST_DIR}/../../../CMakeLists.txt")

set(TEST_NAME ip_sources_get_multilang)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions tests/tests/peakrdl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(print)
12 changes: 12 additions & 0 deletions tests/tests/peakrdl/ip2.rdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
addrmap ip2 {
reg {
regwidth = 32;
field {
fieldwidth = 32;
} f1;
} testreg2;

`ifdef USE_IP1
ip1 ip1_i;
`endif
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("../../../SoCMakeConfig.cmake")
include("../../../../SoCMakeConfig.cmake")
cmake_minimum_required(VERSION 3.25)
project(peakrdl_print_test NONE)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include("../../SoCMakeConfig.cmake")
include("../../../SoCMakeConfig.cmake")

cmake_minimum_required(VERSION 3.25)
project(vhier_test)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 59c59e7

Please sign in to comment.