Skip to content

Commit

Permalink
[fuzzer,CMake] Group fuzzer lit test into one check-fuzzer
Browse files Browse the repository at this point in the history
For now check-fuzzer is just a cmake target that depends
on different check-fuzzer-xxx lit test targets. This causes
check-fuzzer get seperate lit test results like this:

```
********************
********************
Failed Tests (1):
  libFuzzer :: fuzzer-flags.test

Testing Time: 19.80s
  Unsupported      :   7
  Passed           : 128
  Expectedly Failed:   3
  Failed           :   1
make[3]: *** [projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer-default-x86_64.dir/build.make:71: projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer-default-x86_64] Error 1
make[2]: *** [CMakeFiles/Makefile2:36745: projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer-default-x86_64.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
--

********************
********************
Failed Tests (1):
  libFuzzer :: fuzzer-flags.test

Testing Time: 24.33s
  Unsupported:  21
  Passed     : 117
  Failed     :   1
make[3]: *** [projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer-default-i386.dir/build.make:71: projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer-default-i386] Error 1
make[2]: *** [CMakeFiles/Makefile2:36697: projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer-default-i386.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:36608: projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer.dir/rule] Error 2
make: *** [Makefile:10719: check-fuzzer] Error 2
```

This patch replaces check-fuzzer-xxx lit test sub-targets with one big check-fuzzer lit test target, just like sanitizer_common test.

```
********************
********************
Failed Tests (2):
  libFuzzer :: fuzzer-flags.test
  libFuzzer :: fuzzer-flags.test

Testing Time: 25.10s
  Unsupported      :  28
  Passed           : 303
  Expectedly Failed:   3
  Failed           :   2
make[3]: *** [projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer.dir/build.make:71: projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer] Error 1
make[2]: *** [CMakeFiles/Makefile2:36618: projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:36625: projects/compiler-rt/test/fuzzer/CMakeFiles/check-fuzzer.dir/rule] Error 2
make: *** [Makefile:10719: check-fuzzer] Error 2
```

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D158717
  • Loading branch information
yingcong-wu authored and MaskRay committed Aug 28, 2023
1 parent e4eb8d9 commit 9c0302a
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions compiler-rt/test/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@ if(COMPILER_RT_INCLUDE_TESTS)
list(APPEND LIBFUZZER_TEST_DEPS FuzzedDataProviderUnitTests)
endif()

add_custom_target(check-fuzzer)
set(LIBFUZZER_TESTSUITES)

if(COMPILER_RT_INCLUDE_TESTS)
# libFuzzer unit tests.
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg.py)
add_lit_testsuite(check-fuzzer-unit "Running Fuzzer unit tests"
${CMAKE_CURRENT_BINARY_DIR}/unit
DEPENDS ${LIBFUZZER_TEST_DEPS})
set_target_properties(check-fuzzer-unit PROPERTIES FOLDER "Compiler-RT Tests")
add_dependencies(check-fuzzer check-fuzzer-unit)
list(APPEND LIBFUZZER_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/unit)
endif()

macro(test_fuzzer stdlib)
Expand Down Expand Up @@ -67,16 +63,10 @@ macro(test_fuzzer stdlib)
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
)

add_lit_testsuite(check-fuzzer-${stdlib_name}-${arch}
"Running libFuzzer ${stdlib} tests for arch ${arch}"
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
DEPENDS ${LIBFUZZER_TEST_DEPS})
list(APPEND LIBFUZZER_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
if(TEST_DEPS)
add_dependencies(check-fuzzer-${stdlib_name}-${arch} ${TEST_DEPS})
list(APPEND LIBFUZZER_TEST_DEPS ${TEST_DEPS})
endif()
set_target_properties(check-fuzzer-${stdlib_name}-${arch}
PROPERTIES FOLDER "Compiler-RT Tests")
add_dependencies(check-fuzzer check-fuzzer-${stdlib_name}-${arch})
endforeach()
endmacro()

Expand All @@ -90,6 +80,13 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
endif()
endif()

if(LIBFUZZER_TESTSUITES)
add_lit_testsuite(check-fuzzer "Running libFuzzer tests"
${LIBFUZZER_TESTSUITES}
DEPENDS ${LIBFUZZER_TEST_DEPS})
set_target_properties(check-fuzzer PROPERTIES FOLDER "Compiler-RT Tests")
endif()

if (APPLE)
set(LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER})
set(FUZZER_APPLE_PLATFORMS ${FUZZER_SUPPORTED_OS})
Expand Down

0 comments on commit 9c0302a

Please sign in to comment.