@@ -8,36 +8,65 @@ if(COMPILER_RT_INCLUDE_TESTS)
8
8
list (APPEND LIBFUZZER_TEST_DEPS FuzzerUnitTests)
9
9
endif ()
10
10
11
- set (LIBFUZZER_TESTSUITES )
11
+ set (EXCLUDE_FROM_ALL ON )
12
12
13
+ add_custom_target (check-fuzzer)
13
14
14
15
if (COMPILER_RT_INCLUDE_TESTS)
15
16
# libFuzzer unit tests.
16
17
configure_lit_site_cfg(
17
18
${CMAKE_CURRENT_SOURCE_DIR} /unit/lit.site.cfg.in
18
19
${CMAKE_CURRENT_BINARY_DIR} /unit/lit.site.cfg)
19
- list (APPEND LIBFUZZER_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR} /unit)
20
+ add_lit_testsuite(check-fuzzer-unit "Running Fuzzer unit tests"
21
+ ${CMAKE_CURRENT_BINARY_DIR} /unit
22
+ DEPENDS ${LIBFUZZER_TEST_DEPS} )
23
+ set_target_properties (check-fuzzer-unit PROPERTIES FOLDER "Compiler-RT Tests" )
24
+ add_dependencies (check-fuzzer check-fuzzer-unit)
20
25
endif ()
21
26
22
- foreach (arch ${FUZZER_SUPPORTED_ARCH} )
23
- set (LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER} )
24
- get_test_cc_for_arch(${arch} LIBFUZZER_TEST_COMPILER LIBFUZZER_TEST_FLAGS)
27
+ macro (test_fuzzer stdlib)
28
+ cmake_parse_arguments (TEST "" "" "DEPS" ${ARGN} )
29
+ string (REPLACE "+" "x" stdlib_name ${stdlib} )
30
+ string (REPLACE "-" ";" stdlib_list ${stdlib_name} )
31
+ set (STDLIB_CAPITALIZED "" )
32
+ foreach (part IN LISTS stdlib_list)
33
+ string (SUBSTRING ${part} 0 1 first_letter)
34
+ string (TOUPPER ${first_letter} first_letter)
35
+ string (REGEX REPLACE "^.(.*)" "${first_letter} \\ 1" part "${part} " )
36
+ set (STDLIB_CAPITALIZED "${STDLIB_CAPITALIZED}${part} " )
37
+ endforeach ()
38
+ foreach (arch ${FUZZER_SUPPORTED_ARCH} )
39
+ set (LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER} )
40
+ get_test_cc_for_arch(${arch} LIBFUZZER_TEST_COMPILER LIBFUZZER_TEST_FLAGS)
25
41
26
- string (TOUPPER ${arch} ARCH_UPPER_CASE)
27
- set (CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME} Config)
42
+ set (LIBFUZZER_TEST_STDLIB ${stdlib} )
28
43
29
- # LIT-based libFuzzer tests.
30
- configure_lit_site_cfg(
31
- ${CMAKE_CURRENT_SOURCE_DIR} /lit.site.cfg.in
32
- ${CMAKE_CURRENT_BINARY_DIR} /${CONFIG_NAME} /lit.site.cfg
33
- )
34
- list (APPEND LIBFUZZER_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR} /${CONFIG_NAME} )
44
+ string (TOUPPER ${arch} ARCH_UPPER_CASE)
45
+ set (CONFIG_NAME ${ARCH_UPPER_CASE}${STDLIB_CAPITALIZED}${OS_NAME} Config)
35
46
36
- endforeach ()
47
+ # LIT-based libFuzzer tests.
48
+ configure_lit_site_cfg(
49
+ ${CMAKE_CURRENT_SOURCE_DIR} /lit.site.cfg.in
50
+ ${CMAKE_CURRENT_BINARY_DIR} /${CONFIG_NAME} /lit.site.cfg
51
+ )
37
52
38
- set (EXCLUDE_FROM_ALL ON )
53
+ add_lit_testsuite(check-fuzzer-${stdlib_name} "Running Fuzzer ${stdlib} tests"
54
+ ${CMAKE_CURRENT_BINARY_DIR} /${CONFIG_NAME}
55
+ DEPENDS ${LIBFUZZER_TEST_DEPS} )
56
+ if (TEST_DEPS)
57
+ add_dependencies (check-fuzzer-${stdlib_name} ${TEST_DEPS} )
58
+ endif ()
59
+ set_target_properties (check-fuzzer-${stdlib_name} PROPERTIES FOLDER "Compiler-RT Tests" )
60
+ add_dependencies (check-fuzzer check-fuzzer-${stdlib_name} )
61
+ endforeach ()
62
+ endmacro ()
39
63
40
- add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
41
- ${LIBFUZZER_TESTSUITES}
42
- DEPENDS ${LIBFUZZER_TEST_DEPS} )
43
- set_target_properties (check-fuzzer PROPERTIES FOLDER "Compiler-RT Tests" )
64
+ test_fuzzer("default" )
65
+ if ("${CMAKE_SYSTEM_NAME} " STREQUAL "Linux" )
66
+ if (TARGET cxx_shared)
67
+ test_fuzzer("libc++" DEPS cxx_shared)
68
+ endif ()
69
+ if (TARGET cxx_static)
70
+ test_fuzzer("static-libc++" DEPS cxx_static)
71
+ endif ()
72
+ endif ()
0 commit comments