xref: /openbsd-src/gnu/llvm/lldb/packages/Python/lldbsuite/test/configuration.py (revision 46035553bfdd96e63c94e32da0210227ec2e3cf1)
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        # Must be initialized after option parsing
46compiler = None    # Must be initialized after option parsing
47
48# The overriden dwarf verison.
49dwarf_version = 0
50
51# Any overridden settings.
52# Always disable default dynamic types for testing purposes.
53settings = [('target.prefer-dynamic-value', 'no-dynamic-values')]
54
55# Path to the FileCheck testing tool. Not optional.
56filecheck = None
57
58# The arch might dictate some specific CFLAGS to be passed to the toolchain to build
59# the inferior programs.  The global variable cflags_extras provides a hook to do
60# just that.
61cflags_extras = ''
62
63# The filters (testclass.testmethod) used to admit tests into our test suite.
64filters = []
65
66# The regular expression pattern to match against eligible filenames as
67# our test cases.
68regexp = None
69
70# Sets of tests which are excluded at runtime
71skip_tests = None
72xfail_tests = None
73
74# By default, recorded session info for errored/failed test are dumped into its
75# own file under a session directory named after the timestamp of the test suite
76# run.  Use '-s session-dir-name' to specify a specific dir name.
77sdir_name = None
78
79# Valid options:
80# f - test file name (without extension)
81# n - test class name
82# m - test method name
83# a - architecture
84# c - compiler path
85# The default is to write all fields.
86session_file_format = 'fnmac'
87
88# Set this flag if there is any session info dumped during the test run.
89sdir_has_content = False
90
91# svn_info stores the output from 'svn info lldb.base.dir'.
92svn_info = ''
93
94# Default verbosity is 0.
95verbose = 0
96
97# By default, search from the script directory.
98# We can't use sys.path[0] to determine the script directory
99# because it doesn't work under a debugger
100testdirs = [os.path.dirname(os.path.realpath(__file__))]
101
102# Separator string.
103separator = '-' * 70
104
105failed = False
106
107# LLDB Remote platform setting
108lldb_platform_name = None
109lldb_platform_url = None
110lldb_platform_working_dir = None
111
112# The base directory in which the tests are being built.
113test_build_dir = None
114
115# The clang module cache directory used by lldb.
116lldb_module_cache_dir = None
117# The clang module cache directory used by clang.
118clang_module_cache_dir = None
119
120# The only directory to scan for tests. If multiple test directories are
121# specified, and an exclusive test subdirectory is specified, the latter option
122# takes precedence.
123exclusive_test_subdir = None
124
125# Test results handling globals
126results_filename = None
127results_formatter_name = None
128results_formatter_object = None
129results_formatter_options = None
130test_result = None
131
132# Test rerun configuration vars
133rerun_all_issues = False
134
135# The names of all tests. Used to assert we don't have two tests with the
136# same base name.
137all_tests = set()
138
139def shouldSkipBecauseOfCategories(test_categories):
140    if use_categories:
141        if len(test_categories) == 0 or len(
142                categories_list & set(test_categories)) == 0:
143            return True
144
145    for category in skip_categories:
146        if category in test_categories:
147            return True
148
149    return False
150
151
152def get_absolute_path_to_exclusive_test_subdir():
153    """
154    If an exclusive test subdirectory is specified, return its absolute path.
155    Otherwise return None.
156    """
157    test_directory = os.path.dirname(os.path.realpath(__file__))
158
159    if not exclusive_test_subdir:
160        return
161
162    if len(exclusive_test_subdir) > 0:
163        test_subdir = os.path.join(test_directory, exclusive_test_subdir)
164        if os.path.isdir(test_subdir):
165            return test_subdir
166
167        print('specified test subdirectory {} is not a valid directory\n'
168                .format(test_subdir))
169
170
171def get_absolute_path_to_root_test_dir():
172    """
173    If an exclusive test subdirectory is specified, return its absolute path.
174    Otherwise, return the absolute path of the root test directory.
175    """
176    test_subdir = get_absolute_path_to_exclusive_test_subdir()
177    if test_subdir:
178        return test_subdir
179
180    return os.path.dirname(os.path.realpath(__file__))
181
182
183def get_filecheck_path():
184    """
185    Get the path to the FileCheck testing tool.
186    """
187    if filecheck and os.path.lexists(filecheck):
188        return filecheck
189