[compiler-rt] 9c0302a - [fuzzer, CMake] Group fuzzer lit test into one check-fuzzer

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 14:45:06 PDT 2023


Author: Wu, Yingcong
Date: 2023-08-28T14:45:01-07:00
New Revision: 9c0302a77256d5ebc96dcc40d11d460c1a0b7c0d

URL: https://github.com/llvm/llvm-project/commit/9c0302a77256d5ebc96dcc40d11d460c1a0b7c0d
DIFF: https://github.com/llvm/llvm-project/commit/9c0302a77256d5ebc96dcc40d11d460c1a0b7c0d.diff

LOG: [fuzzer,CMake] Group fuzzer lit test into one check-fuzzer

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

Added: 
    

Modified: 
    compiler-rt/test/fuzzer/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/fuzzer/CMakeLists.txt b/compiler-rt/test/fuzzer/CMakeLists.txt
index b6237d1552e7c1..f0ba087a1b3260 100644
--- a/compiler-rt/test/fuzzer/CMakeLists.txt
+++ b/compiler-rt/test/fuzzer/CMakeLists.txt
@@ -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)
@@ -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()
 
@@ -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})


        


More information about the llvm-commits mailing list