1 # Test runner infrastructure for Clang. This configures the Clang test trees 2 # for use by Lit, and delegates to LLVM's lit test handlers. 3 4 if (CMAKE_CFG_INTDIR STREQUAL ".") 5 set(LLVM_BUILD_MODE ".") 6 else () 7 set(LLVM_BUILD_MODE "%(build_mode)s") 8 endif () 9 10 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) 11 12 configure_lit_site_cfg( 13 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in 14 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg 15 ) 16 17 configure_lit_site_cfg( 18 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in 19 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg 20 ) 21 22 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF) 23 if(CLANG_TEST_USE_VG) 24 set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg") 25 endif () 26 27 list(APPEND CLANG_TEST_DEPS 28 clang clang-headers 29 clang-format 30 c-index-test diagtool 31 clang-tblgen 32 ) 33 34 if(CLANG_ENABLE_STATIC_ANALYZER) 35 list(APPEND CLANG_TEST_DEPS 36 clang-check 37 ) 38 endif() 39 40 if (CLANG_ENABLE_ARCMT) 41 list(APPEND CLANG_TEST_DEPS 42 arcmt-test 43 c-arcmt-test 44 ) 45 endif () 46 47 if (ENABLE_CLANG_EXAMPLES) 48 list(APPEND CLANG_TEST_DEPS 49 AnnotateFunctions 50 clang-interpreter 51 PrintFunctionNames 52 ) 53 endif () 54 55 if (ENABLE_CLANG_STATIC_ANALYZER AND ENABLE_CLANG_EXAMPLES) 56 list(APPEND CLANG_TEST_DEPS 57 SampleAnalyzerPlugin 58 ) 59 endif () 60 61 set(CLANG_TEST_PARAMS 62 clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg 63 ) 64 65 if( NOT CLANG_BUILT_STANDALONE ) 66 list(APPEND CLANG_TEST_DEPS 67 llvm-config 68 FileCheck count not 69 llc 70 llvm-bcanalyzer 71 llvm-nm 72 llvm-objdump 73 llvm-profdata 74 llvm-readobj 75 llvm-symbolizer 76 opt 77 ) 78 79 if(TARGET llvm-lto) 80 list(APPEND CLANG_TEST_DEPS llvm-lto) 81 endif() 82 endif() 83 84 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS}) 85 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests") 86 87 add_lit_testsuite(check-clang "Running the Clang regression tests" 88 ${CMAKE_CURRENT_BINARY_DIR} 89 #LIT ${LLVM_LIT} 90 PARAMS ${CLANG_TEST_PARAMS} 91 DEPENDS ${CLANG_TEST_DEPS} 92 ARGS ${CLANG_TEST_EXTRA_ARGS} 93 ) 94 set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") 95 96 add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR} 97 PARAMS ${CLANG_TEST_PARAMS} 98 DEPENDS ${CLANG_TEST_DEPS} 99 ) 100 101 # Add a legacy target spelling: clang-test 102 add_custom_target(clang-test) 103 add_dependencies(clang-test check-clang) 104 set_target_properties(clang-test PROPERTIES FOLDER "Clang tests") 105