xref: /openbsd-src/gnu/llvm/lldb/packages/Python/lldbsuite/test/configuration.py (revision 24bb5fcea3ed904bc467217bdaadb5dfc618d5bf)
1"""
2Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3See https://llvm.org/LICENSE.txt for license information.
4SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
6Provides the configuration class, which holds all information related to
7how this invocation of the test suite should be run.
8"""
9
10from __future__ import absolute_import
11from __future__ import print_function
12
13# System modules
14import os
15
16
17# Third-party modules
18import unittest2
19
20# LLDB Modules
21import lldbsuite
22
23
24# The test suite.
25suite = unittest2.TestSuite()
26
27# The list of categories we said we care about
28categories_list = None
29# set to true if we are going to use categories for cherry-picking test cases
30use_categories = False
31# Categories we want to skip
32skip_categories = ["darwin-log"]
33# Categories we expect to fail
34xfail_categories = []
35# use this to track per-category failures
36failures_per_category = {}
37
38# The path to LLDB.framework is optional.
39lldb_framework_path = None
40
41# Test suite repeat count.  Can be overwritten with '-# count'.
42count = 1
43
44# The 'arch' and 'compiler' can be specified via command line.
45arch = None
46compiler = None
47dsymutil = None
48sdkroot = None
49
50# The overriden dwarf verison.
51dwarf_version = 0
52
53# Any overridden settings.
54# Always disable default dynamic types for testing purposes.
55settings = [('target.prefer-dynamic-value', 'no-dynamic-values')]
56
57# Path to the FileCheck testing tool. Not optional.
58filecheck = None
59
60# Path to the yaml2obj tool. Not optional.
61yaml2obj = None
62
63# The arch might dictate some specific CFLAGS to be passed to the toolchain to build
64# the inferior programs.  The global variable cflags_extras provides a hook to do
65# just that.
66cflags_extras = ''
67
68# The filters (testclass.testmethod) used to admit tests into our test suite.
69filters = []
70
71# The regular expression pattern to match against eligible filenames as
72# our test cases.
73regexp = None
74
75# Sets of tests which are excluded at runtime
76skip_tests = None
77xfail_tests = None
78
79# By default, recorded session info for errored/failed test are dumped into its
80# own file under a session directory named after the timestamp of the test suite
81# run.  Use '-s session-dir-name' to specify a specific dir name.
82sdir_name = None
83
84# Valid options:
85# f - test file name (without extension)
86# n - test class name
87# m - test method name
88# a - architecture
89# c - compiler path
90# The default is to write all fields.
91session_file_format = 'fnmac'
92
93# Set this flag if there is any session info dumped during the test run.
94sdir_has_content = False
95# svn_info stores the output from 'svn info lldb.base.dir'.
96svn_info = ''
97
98# Default verbosity is 0.
99verbose = 0
100
101# By default, search from the script directory.
102# We can't use sys.path[0] to determine the script directory
103# because it doesn't work under a debugger
104testdirs = [lldbsuite.lldb_test_root]
105
106# Separator string.
107separator = '-' * 70
108
109failed = False
110
111# LLDB Remote platform setting
112lldb_platform_name = None
113lldb_platform_url = None
114lldb_platform_working_dir = None
115
116# The base directory in which the tests are being built.
117test_build_dir = None
118
119# The clang module cache directory used by lldb.
120lldb_module_cache_dir = None
121# The clang module cache directory used by clang.
122clang_module_cache_dir = None
123
124# Test results handling globals
125test_result = None
126
127# Reproducers
128capture_path = None
129replay_path = None
130
131# Test rerun configuration vars
132rerun_all_issues = False
133
134# The names of all tests. Used to assert we don't have two tests with the
135# same base name.
136all_tests = set()
137
138# LLDB library directory.
139lldb_libs_dir = None
140
141# A plugin whose tests will be enabled, like intel-pt.
142enabled_plugins = []
143
144
145def shouldSkipBecauseOfCategories(test_categories):
146    if use_categories:
147        if len(test_categories) == 0 or len(
148                categories_list & set(test_categories)) == 0:
149            return True
150
151    for category in skip_categories:
152        if category in test_categories:
153            return True
154
155    return False
156
157
158def get_filecheck_path():
159    """
160    Get the path to the FileCheck testing tool.
161    """
162    if filecheck and os.path.lexists(filecheck):
163        return filecheck
164
165def get_yaml2obj_path():
166    """
167    Get the path to the yaml2obj tool.
168    """
169    if yaml2obj and os.path.lexists(yaml2obj):
170        return yaml2obj
171
172def is_reproducer_replay():
173    """
174    Returns true when dotest is being replayed from a reproducer. Never use
175    this method to guard SB API calls as it will cause a divergence between
176    capture and replay.
177    """
178    return replay_path is not None
179
180def is_reproducer():
181    """
182    Returns true when dotest is capturing a reproducer or is being replayed
183    from a reproducer. Use this method to guard SB API calls.
184    """
185    return capture_path or replay_path
186