Home | History | Annotate | Line # | Download | only in tests
      1 # Test target to run Python test suite from main build.
      2 
      3 add_custom_target(check-clang-python
      4     COMMAND ${CMAKE_COMMAND} -E env
      5             CLANG_LIBRARY_PATH=$<TARGET_FILE_DIR:libclang>
      6             "${Python3_EXECUTABLE}" -m unittest discover
      7     DEPENDS libclang
      8     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
      9 
     10 set(RUN_PYTHON_TESTS TRUE)
     11 set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests")
     12 
     13 # Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
     14 if(NOT LLVM_ENABLE_PIC)
     15   set(RUN_PYTHON_TESTS FALSE)
     16 endif()
     17 
     18 # Do not try to run if libclang was built with sanitizers because
     19 # the sanitizer library will likely be loaded too late to perform
     20 # interception and will then fail.
     21 # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
     22 # portable so its easier just to not run the tests when building
     23 # with ASan.
     24 if(NOT LLVM_USE_SANITIZER STREQUAL "")
     25   set(RUN_PYTHON_TESTS FALSE)
     26 endif()
     27 
     28 # Tests fail on Windows, and need someone knowledgeable to fix.
     29 # It's not clear whether it's a test or a valid binding problem.
     30 if(WIN32)
     31   set(RUN_PYTHON_TESTS FALSE)
     32 endif()
     33 
     34 # The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
     35 if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
     36   set(RUN_PYTHON_TESTS FALSE)
     37 endif()
     38 
     39 # AArch64, Hexagon, and Sparc have known test failures that need to be
     40 # addressed.
     41 # SystemZ has broken Python/FFI interface:
     42 # https://reviews.llvm.org/D52840#1265716
     43 if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
     44   set(RUN_PYTHON_TESTS FALSE)
     45 endif()
     46 
     47 if(RUN_PYTHON_TESTS)
     48     set_property(GLOBAL APPEND PROPERTY
     49                  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
     50 endif()
     51