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 | ${PYTHON_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 ASan 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 | list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX) |
25 | if(NOT LLVM_USE_ASAN_INDEX EQUAL -1) |
26 | set(RUN_PYTHON_TESTS FALSE) |
27 | endif() |
28 | |
29 | # Tests fail on Windows, and need someone knowledgeable to fix. |
30 | # It's not clear whether it's a test or a valid binding problem. |
31 | if(WIN32) |
32 | set(RUN_PYTHON_TESTS FALSE) |
33 | endif() |
34 | |
35 | # AArch64 and Hexagon have known test failures that need to be |
36 | # addressed. |
37 | # SystemZ has broken Python/FFI interface: |
38 | # https://reviews.llvm.org/D52840#1265716 |
39 | if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$") |
40 | set(RUN_PYTHON_TESTS FALSE) |
41 | endif() |
42 | |
43 | if(RUN_PYTHON_TESTS) |
44 | set_property(GLOBAL APPEND PROPERTY |
45 | LLVM_ADDITIONAL_TEST_TARGETS check-clang-python) |
46 | endif() |
47 | |