blob: 9c76576e85e9a1e74a372f4388b4bfd46b59bee3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# 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
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# Generate CTestTestfile.cmake.
enable_testing()
# Include gtest_discover_tests macro.
include(GoogleTest)
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")
|