| 1 |
""" |
| 2 |
Provides definitions for various lldb test categories |
| 3 |
""" |
| 4 |
|
| 5 |
# System modules |
| 6 |
import sys |
| 7 |
|
| 8 |
# Third-party modules |
| 9 |
|
| 10 |
# LLDB modules |
| 11 |
from lldbsuite.support import gmodules |
| 12 |
|
| 13 |
# Key: Category name |
| 14 |
# Value: should be used in lldbtest's debug-info replication |
| 15 |
debug_info_categories = {"dwarf": True, "dwo": True, "dsym": True, "gmodules": False} |
| 16 |
|
| 17 |
all_categories = { |
| 18 |
"basic_process": "Basic process execution sniff tests.", |
| 19 |
"cmdline": "Tests related to the LLDB command-line interface", |
| 20 |
"dataformatters": "Tests related to the type command and the data formatters subsystem", |
| 21 |
"debugserver": "Debugserver tests", |
| 22 |
"dsym": "Tests that can be run with DSYM debug information", |
| 23 |
"dwarf": "Tests that can be run with DWARF debug information", |
| 24 |
"dwo": "Tests that can be run with DWO debug information", |
| 25 |
"dyntype": "Tests related to dynamic type support", |
| 26 |
"expression": "Tests related to the expression parser", |
| 27 |
"flakey": "Flakey test cases, i.e. tests that do not reliably pass at each execution", |
| 28 |
"fork": "Tests requiring the process plugin fork/vfork event support", |
| 29 |
"gmodules": "Tests that can be run with -gmodules debug information", |
| 30 |
"instrumentation-runtime": "Tests for the instrumentation runtime plugins", |
| 31 |
"libc++": "Test for libc++ data formatters", |
| 32 |
"libstdcxx": "Test for libstdcxx data formatters", |
| 33 |
"lldb-server": "Tests related to lldb-server", |
| 34 |
"lldb-dap": "Tests for the Debug Adaptor Protocol with lldb-dap", |
| 35 |
"llgs": "Tests for the gdb-server functionality of lldb-server", |
| 36 |
"pexpect": "Tests requiring the pexpect library to be available", |
| 37 |
"objc": "Tests related to the Objective-C programming language support", |
| 38 |
"pyapi": "Tests related to the Python API", |
| 39 |
"std-module": "Tests related to importing the std module", |
| 40 |
"stresstest": "Tests related to stressing lldb limits", |
| 41 |
"watchpoint": "Watchpoint-related tests", |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
def unique_string_match(yourentry, list): |
| 46 |
candidate = None |
| 47 |
for item in list: |
| 48 |
if not item.startswith(yourentry): |
| 49 |
continue |
| 50 |
if candidate: |
| 51 |
return None |
| 52 |
candidate = item |
| 53 |
return candidate |
| 54 |
|
| 55 |
|
| 56 |
def is_supported_on_platform(category, platform, compiler_path): |
| 57 |
if category == "dwo": |
| 58 |
# -gsplit-dwarf is not implemented by clang on Windows. |
| 59 |
return platform in ["linux", "freebsd"] |
| 60 |
elif category == "dsym": |
| 61 |
return platform in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"] |
| 62 |
elif category == "gmodules": |
| 63 |
# First, check to see if the platform can even support gmodules. |
| 64 |
if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]: |
| 65 |
return False |
| 66 |
return gmodules.is_compiler_clang_with_gmodules(compiler_path) |
| 67 |
return True |
| 68 |
|
| 69 |
|
| 70 |
def validate(categories, exact_match): |
| 71 |
""" |
| 72 |
For each category in categories, ensure that it's a valid category (if exact_match is false, |
| 73 |
unique prefixes are also accepted). If a category is invalid, print a message and quit. |
| 74 |
If all categories are valid, return the list of categories. Prefixes are expanded in the |
| 75 |
returned list. |
| 76 |
""" |
| 77 |
result = [] |
| 78 |
for category in categories: |
| 79 |
origCategory = category |
| 80 |
if category not in all_categories and not exact_match: |
| 81 |
category = unique_string_match(category, all_categories) |
| 82 |
if (category not in all_categories) or category is None: |
| 83 |
print( |
| 84 |
"fatal error: category '" + origCategory + "' is not a valid category" |
| 85 |
) |
| 86 |
print( |
| 87 |
"if you have added a new category, please edit test_categories.py, adding your new category to all_categories" |
| 88 |
) |
| 89 |
print( |
| 90 |
"else, please specify one or more of the following: " |
| 91 |
+ str(list(all_categories.keys())) |
| 92 |
) |
| 93 |
sys.exit(1) |
| 94 |
result.append(category) |
| 95 |
return result |