aboutsummaryrefslogtreecommitdiff
path: root/test/CMakeLists.txt
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-11-01 18:41:44 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-11-01 18:41:44 +0100
commit291364e1b408d29236034854b7ed30f080e5b6c9 (patch)
treef55efb5954ea6374295f2e04d98041b766992660 /test/CMakeLists.txt
parentccaae5eb310ae8aabd77f8fe53f181f4afe0365b (diff)
downloadsysc-playground-291364e1b408d29236034854b7ed30f080e5b6c9.tar.gz
sysc-playground-291364e1b408d29236034854b7ed30f080e5b6c9.zip
lt_bus: add initial support for global bus locking
Diffstat (limited to 'test/CMakeLists.txt')
-rw-r--r--test/CMakeLists.txt44
1 files changed, 34 insertions, 10 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b67735a..714e18a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,8 +1,10 @@
-# Fetch googletest.
+# Fetch googletest (latest greatest, okay in this repo).
# https://google.github.io/googletest/quickstart-cmake.html#set-up-a-project
include(FetchContent)
FetchContent_Declare(
- googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
+ googletest
+ GIT_REPOSITORY https://github.com/google/googletest.git
+ GIT_TAG main
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
@@ -12,11 +14,33 @@ enable_testing()
# Include gtest_discover_tests macro.
include(GoogleTest)
-foreach(T IN ITEMS lt_bus)
- set(TGT test-${T})
- add_executable(${TGT} ${T}.cc)
- target_include_directories(${TGT} PRIVATE ${SRC})
- target_compile_options(${TGT} PRIVATE -Wall -Wextra)
- target_link_libraries(${TGT} GTest::gmock_main SystemC::systemc)
- gtest_discover_tests(${TGT})
-endforeach()
+macro(test_int name kind)
+ set(target test-${name})
+ add_executable(${target} ${name}.cc)
+ target_include_directories(${target} PRIVATE ${SRC})
+ target_compile_options(${target} PRIVATE -Wall -Wextra)
+ if(${kind} STREQUAL "gtest")
+ target_link_libraries(${target} GTest::gmock_main)
+ target_link_libraries(${target} SystemC::systemc)
+ gtest_discover_tests(${target})
+ elseif(${kind} STREQUAL "sim")
+ target_link_libraries(${target} SystemC::systemc)
+ add_test(NAME ${target} COMMAND ${target})
+ else()
+ message(FATAL_ERROR "unknown test kind '${kind}'")
+ endif()
+endmacro()
+
+macro(sim_test name)
+ test_int(${name} "sim")
+endmacro()
+
+macro(gtest_test name)
+ test_int(${name} "gtest")
+endmacro()
+
+# Google tests.
+gtest_test("lt_bus")
+
+# Simulation tests.
+sim_test("lt_bus_locked")