brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · d9a6bbf Raw
67 lines · plain
1# Test target to run Python test suite from main build.2 3# Avoid configurations including '-include' from interfering with4# our tests by setting CLANG_NO_DEFAULT_CONFIG.5add_custom_target(check-clang-python6    COMMAND ${CMAKE_COMMAND} -E env7            CLANG_NO_DEFAULT_CONFIG=18            CLANG_LIBRARY_PATH=$<TARGET_FILE_DIR:libclang>9            "${Python3_EXECUTABLE}" -m unittest discover10    DEPENDS libclang11    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)12 13set(RUN_PYTHON_TESTS TRUE)14set_target_properties(check-clang-python PROPERTIES FOLDER "Clang/Tests")15 16# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON17if(NOT LLVM_ENABLE_PIC)18  set(RUN_PYTHON_TESTS FALSE)19endif()20 21# Do not try to run if libclang was built with sanitizers because22# the sanitizer library will likely be loaded too late to perform23# interception and will then fail.24# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't25# portable so its easier just to not run the tests when building26# with ASan.27if(NOT LLVM_USE_SANITIZER STREQUAL "")28  set(RUN_PYTHON_TESTS FALSE)29endif()30 31# Tests fail on Windows, and need someone knowledgeable to fix.32# It's not clear whether it's a test or a valid binding problem.33if(WIN32)34  set(RUN_PYTHON_TESTS FALSE)35endif()36 37# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.38if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")39  set(RUN_PYTHON_TESTS FALSE)40endif()41 42# AArch64, Hexagon, and Sparc have known test failures that need to be43# addressed.44# SystemZ has broken Python/FFI interface:45# https://reviews.llvm.org/D52840#126571646if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")47  set(RUN_PYTHON_TESTS FALSE)48endif()49 50# Tests will fail if cross-compiling for a different target, as tests will try51# to use the host Python3_EXECUTABLE and make FFI calls to functions in target52# libraries.53if(CMAKE_CROSSCOMPILING)54  # FIXME: Consider a solution that allows better control over these tests in55  # a crosscompiling scenario. e.g. registering them with lit to allow them to56  # be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to57  # allow specifying a python interpreter compiled for the target that could58  # be executed using qemu-user.59  message(WARNING "check-clang-python not added to check-all as these tests fail in a cross-build setup")60  set(RUN_PYTHON_TESTS FALSE)61endif()62 63if(RUN_PYTHON_TESTS)64    set_property(GLOBAL APPEND PROPERTY65                 LLVM_ALL_ADDITIONAL_TEST_TARGETS check-clang-python)66endif()67