Home | History | Annotate | Download | only in test
      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 this is a stand-alone Clang build, we fake up our own Lit support here
      5 # rather than relying on LLVM's.
      6 
      7 set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
      8 set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
      9 
     10 configure_lit_site_cfg(
     11   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
     12   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
     13   )
     14 
     15 configure_lit_site_cfg(
     16   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
     17   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
     18   )
     19 
     20 if( PATH_TO_LLVM_BUILD )
     21   set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}")
     22 endif()
     23 
     24 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
     25 if(CLANG_TEST_USE_VG)
     26   set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
     27 endif ()
     28 
     29 set(CLANG_TEST_DEPS
     30   clang clang-headers
     31   c-index-test diagtool arcmt-test c-arcmt-test
     32   clang-check clang-format
     33   )
     34 set(CLANG_TEST_PARAMS
     35   clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
     36   )
     37 
     38 if(CLANG_INCLUDE_TESTS)  
     39   list(APPEND CLANG_TEST_DEPS ClangUnitTests)
     40   list(APPEND CLANG_TEST_PARAMS
     41     clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
     42     )
     43 endif()
     44 
     45 if( NOT CLANG_BUILT_STANDALONE )
     46   list(APPEND CLANG_TEST_DEPS
     47     llc opt FileCheck count not llvm-symbolizer
     48     )
     49 
     50   add_lit_testsuite(check-clang "Running the Clang regression tests"
     51     ${CMAKE_CURRENT_BINARY_DIR}
     52     PARAMS ${CLANG_TEST_PARAMS}
     53     DEPENDS ${CLANG_TEST_DEPS}
     54     ARGS ${CLANG_TEST_EXTRA_ARGS}
     55     )
     56   set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
     57 
     58 else()
     59 
     60   include(FindPythonInterp)
     61   if(PYTHONINTERP_FOUND)
     62     if( LLVM_MAIN_SRC_DIR )
     63       set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
     64     else()
     65       set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit")
     66       # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths.
     67       if( NOT EXISTS ${LIT} )
     68         set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit")
     69       endif()
     70     endif()
     71 
     72     set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
     73     separate_arguments(LIT_ARGS)
     74     
     75     list(APPEND CLANG_TEST_PARAMS build_mode=${CMAKE_CFG_INTDIR})
     76 
     77     foreach(param ${CLANG_TEST_PARAMS})
     78       list(APPEND LIT_ARGS --param ${param})
     79     endforeach()
     80 
     81     add_custom_target(check-clang
     82       COMMAND ${PYTHON_EXECUTABLE}
     83               ${LIT}
     84               ${LIT_ARGS}
     85               ${CMAKE_CURRENT_BINARY_DIR}
     86               ${CLANG_TEST_EXTRA_ARGS}
     87       COMMENT "Running Clang regression tests"
     88       DEPENDS ${CLANG_TEST_DEPS}
     89       )
     90     set_target_properties(check-clang PROPERTIES FOLDER "Clang tests")
     91   endif()
     92 
     93 endif()
     94 
     95 # Add a legacy target spelling: clang-test
     96 add_custom_target(clang-test)
     97 add_dependencies(clang-test check-clang)
     98 set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")
     99