File: test_categories.py

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (99 lines) | stat: -rw-r--r-- 4,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""
Provides definitions for various lldb test categories
"""

from __future__ import absolute_import
from __future__ import print_function

# System modules
import sys

# Third-party modules

# LLDB modules
from lldbsuite.support import gmodules

# Key: Category name
# Value: should be used in lldbtest's debug-info replication
debug_info_categories = {"dwarf": True, "dwo": True, "dsym": True, "gmodules": False}

all_categories = {
    "basic_process": "Basic process execution sniff tests.",
    "cmdline": "Tests related to the LLDB command-line interface",
    "dataformatters": "Tests related to the type command and the data formatters subsystem",
    "debugserver": "Debugserver tests",
    "dsym": "Tests that can be run with DSYM debug information",
    "dwarf": "Tests that can be run with DWARF debug information",
    "dwo": "Tests that can be run with DWO debug information",
    "dyntype": "Tests related to dynamic type support",
    "expression": "Tests related to the expression parser",
    "flakey": "Flakey test cases, i.e. tests that do not reliably pass at each execution",
    "frame-diagnose": "Frame diagnose tests",
    "fork": "Tests requiring the process plugin fork/vfork event support",
    "gmodules": "Tests that can be run with -gmodules debug information",
    "instrumentation-runtime": "Tests for the instrumentation runtime plugins",
    "libc++": "Test for libc++ data formatters",
    "libstdcxx": "Test for libstdcxx data formatters",
    "lldb-server": "Tests related to lldb-server",
    "lldb-dap": "Tests for the Debug Adaptor Protocol with lldb-dap",
    "llgs": "Tests for the gdb-server functionality of lldb-server",
    "objc": "Tests related to the Objective-C programming language support",
    "pyapi": "Tests related to the Python API",
    "std-module": "Tests related to importing the std module",
    "stresstest": "Tests related to stressing lldb limits",
    "swiftmaccatalyst": "Tests which require swift maccatalyst stdlib support",
    "watchpoint": "Watchpoint-related tests",
}


def unique_string_match(yourentry, list):
    candidate = None
    for item in list:
        if not item.startswith(yourentry):
            continue
        if candidate:
            return None
        candidate = item
    return candidate


def is_supported_on_platform(category, platform, compiler_path):
    if category == "dwo":
        # -gsplit-dwarf is not implemented by clang on Windows.
        return platform in ["linux", "freebsd"]
    elif category == "dsym":
        return platform in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]
    elif category == "gmodules":
        # First, check to see if the platform can even support gmodules.
        if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]:
            return False
        return gmodules.is_compiler_clang_with_gmodules(compiler_path)
    return True


def validate(categories, exact_match):
    """
    For each category in categories, ensure that it's a valid category (if exact_match is false,
    unique prefixes are also accepted). If a category is invalid, print a message and quit.
       If all categories are valid, return the list of categories. Prefixes are expanded in the
       returned list.
    """
    result = []
    for category in categories:
        origCategory = category
        if category not in all_categories and not exact_match:
            category = unique_string_match(category, all_categories)
        if (category not in all_categories) or category is None:
            print(
                "fatal error: category '" + origCategory + "' is not a valid category"
            )
            print(
                "if you have added a new category, please edit test_categories.py, adding your new category to all_categories"
            )
            print(
                "else, please specify one or more of the following: "
                + str(list(all_categories.keys()))
            )
            sys.exit(1)
        result.append(category)
    return result