Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
85 lines (72 loc) · 3.38 KB
/
Copy pathCMakeLists.txt
File metadata and controls
85 lines (72 loc) · 3.38 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
cmake_minimum_required(VERSION 3.16)
# Host tests for emulator components. Buildable two ways:
# - standalone, with the host toolchain (sanitizers on):
# cmake -S tests -B tests/build
# cmake --build tests/build
# ctest --test-dir tests/build
# - as part of the cross build (compile-checks the headers for the target)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
project(minicast_tests CXX)
enable_testing()
endif()
set(dyna ${CMAKE_CURRENT_SOURCE_DIR}/../libswirl/hw/sh4/dyna)
# regalloc.h can't be included without the full emulator headers; generate a
# copy with the emu includes stripped and pair it with the mocks in mockshil.h
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/regalloc_under_test.h
COMMAND ${CMAKE_COMMAND}
-DIN=${dyna}/regalloc.h
-DOUT=${CMAKE_CURRENT_BINARY_DIR}/regalloc_under_test.h
-P ${CMAKE_CURRENT_SOURCE_DIR}/strip_emu_includes.cmake
DEPENDS ${dyna}/regalloc.h ${CMAKE_CURRENT_SOURCE_DIR}/strip_emu_includes.cmake
COMMENT "Generating regalloc_under_test.h from regalloc.h"
)
add_executable(regalloc_fuzz
regalloc_fuzz.cpp
${CMAKE_CURRENT_BINARY_DIR}/regalloc_under_test.h
)
set_property(TARGET regalloc_fuzz PROPERTY CXX_STANDARD 17)
target_include_directories(regalloc_fuzz PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
if(NOT CMAKE_CROSSCOMPILING)
target_compile_options(regalloc_fuzz PRIVATE -O1 -g -fsanitize=address,undefined)
target_link_options(regalloc_fuzz PRIVATE -fsanitize=address,undefined)
endif()
# args: <base seed> <iterations per pool/flag combination>
add_test(NAME regalloc_fuzz COMMAND regalloc_fuzz 1 5000)
# the allocator intentionally keeps the last block's spans until the next
# DoAlloc; that reads as a leak at process exit
set_tests_properties(regalloc_fuzz PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0")
# constprop()/rw_related() are extracted verbatim from shil.cpp and compiled
# against the mocks in constprop_mocks.h
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/constprop_under_test.h
COMMAND ${CMAKE_COMMAND}
-DIN=${dyna}/shil.cpp
-DOUT=${CMAKE_CURRENT_BINARY_DIR}/constprop_under_test.h
-P ${CMAKE_CURRENT_SOURCE_DIR}/extract_constprop.cmake
DEPENDS ${dyna}/shil.cpp ${CMAKE_CURRENT_SOURCE_DIR}/extract_constprop.cmake
${CMAKE_CURRENT_SOURCE_DIR}/constprop_mocks.h
COMMENT "Generating constprop_under_test.h from shil.cpp"
)
add_executable(constprop_test
constprop_test.cpp
${CMAKE_CURRENT_BINARY_DIR}/constprop_under_test.h
)
set_property(TARGET constprop_test PROPERTY CXX_STANDARD 17)
target_include_directories(constprop_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT CMAKE_CROSSCOMPILING)
target_compile_options(constprop_test PRIVATE -O1 -g -fsanitize=address,undefined)
target_link_options(constprop_test PRIVATE -fsanitize=address,undefined)
endif()
# args: <base seed> <fuzz iterations>
add_test(NAME constprop_test COMMAND constprop_test 1 3000)
add_executable(disc_list_test
disc_list_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../disc_list.cpp
)
set_property(TARGET disc_list_test PROPERTY CXX_STANDARD 17)
if(NOT CMAKE_CROSSCOMPILING)
target_compile_options(disc_list_test PRIVATE -O1 -g -fsanitize=address,undefined)
target_link_options(disc_list_test PRIVATE -fsanitize=address,undefined)
endif()
add_test(NAME disc_list_test COMMAND disc_list_test)