-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[clang][python][test] Move python binding tests to lit framework #142948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rorth
wants to merge
2
commits into
llvm:main
Choose a base branch
from
rorth:clang-python-test-lit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
# UNSUPPORTED: !libclang-loadable | ||
|
||
# Tests fail on Windows, and need someone knowledgeable to fix. | ||
# It's not clear whether it's a test or a valid binding problem. | ||
# XFAIL: target={{.*windows.*}} | ||
|
||
# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628. | ||
# XFAIL: target={{.*-aix.*}} | ||
|
||
# AArch64 and Hexagon have known test failures that need to be addressed. | ||
# SystemZ has broken Python/FFI interface: | ||
# https://reviews.llvm.org/D52840#1265716 | ||
# XFAIL: target={{(aarch64|hexagon|s390x)-.*}} | ||
# python SEGVs on Linux/sparc64 when loading libclang.so. Seems to be an FFI | ||
# issue, too. | ||
# XFAIL: target={{sparc.*-.*-linux.*}} | ||
|
||
# Tests will fail if cross-compiling for a different target, as tests will try | ||
# to use the host Python3_EXECUTABLE and make FFI calls to functions in target | ||
# libraries. | ||
# | ||
# FIXME: Consider a solution that allows better control over these tests in | ||
# a crosscompiling scenario. e.g. registering them with lit to allow them to | ||
# be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to | ||
# allow specifying a python interpreter compiled for the target that could | ||
# be executed using qemu-user. | ||
# | ||
# FIXME: Handle CMAKE_CROSSCOMPILING. | ||
# Again, might already be handled by libclang-loadable. | ||
|
||
# RUN: env PYTHONPATH=%S/../../../bindings/python \ | ||
# RUN: CLANG_LIBRARY_PATH=`llvm-config --libdir` \ | ||
# RUN: %python -m unittest discover -s %S/tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
def is_libclang_loadable(): | ||
# Do not try to run if libclang was built with sanitizers because | ||
# the sanitizer library will likely be loaded too late to perform | ||
# interception and will then fail. | ||
# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't | ||
# portable so its easier just to not run the tests when building | ||
# with ASan. | ||
if config.llvm_use_sanitizer != "": | ||
return False | ||
try: | ||
sys.path.append(os.path.join(config.clang_src_dir, "bindings/python")) | ||
from clang.cindex import Config | ||
conf = Config() | ||
Config.set_library_path(config.clang_lib_dir) | ||
conf.lib | ||
return True | ||
except Exception as e: | ||
# Expected failure modes are considered benign when nothing can be | ||
# done about them. | ||
# | ||
# Cannot load a 32-bit libclang.so into a 64-bit python. | ||
if "wrong ELF class: ELFCLASS32" in str(e): | ||
return False | ||
# If libclang.so is missing, it must have been disabled intentionally, | ||
# e.g. by building with LLVM_ENABLE_PIC=OFF. | ||
elif "No such file or directory" in str(e): | ||
return False | ||
# Unexpected failure modes need to be investigated to either fix an | ||
# underlying bug or accept the failure, so return True. This causes | ||
# tests to run and FAIL, drawing developer attention. | ||
else: | ||
print("warning: unhandled failure in is_libclang_loadable: " | ||
+ str(e), file=sys.stderr) | ||
return True | ||
|
||
if is_libclang_loadable(): | ||
config.available_features.add("libclang-loadable") | ||
|
||
config.suffixes = ['.sh'] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while, the workflow probably doesn't run because there's an error here:
So far the workflow consisted of a single step, so there was no need to open a
steps
section, but since we have two steps this now becomes necessary. I.e. you'd need something like this:(there's no need to adapt this now, because we still have other issues as described above)