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 = []
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.
54settings = []
55
56# Path to the FileCheck testing tool. Not optional.
57filecheck = None
58
59# Path to the yaml2obj tool. Not optional.
60yaml2obj = None
61
62# The arch might dictate some specific CFLAGS to be passed to the toolchain to build
63# the inferior programs.  The global variable cflags_extras provides a hook to do
64# just that.
65cflags_extras = ''
66
67# The filters (testclass.testmethod) used to admit tests into our test suite.
68filters = []
69
70# The regular expression pattern to match against eligible filenames as
71# our test cases.
72regexp = None
73
74# Sets of tests which are excluded at runtime
75skip_tests = None
76xfail_tests = None
77
78# Set this flag if there is any session info dumped during the test run.
79sdir_has_content = False
80# svn_info stores the output from 'svn info lldb.base.dir'.
81svn_info = ''
82
83# Default verbosity is 0.
84verbose = 0
85
86# By default, search from the script directory.
87# We can't use sys.path[0] to determine the script directory
88# because it doesn't work under a debugger
89testdirs = [lldbsuite.lldb_test_root]
90
91# The root of the test case tree (where the actual tests reside, not the test
92# infrastructure).
93test_src_root = lldbsuite.lldb_test_root
94
95# Separator string.
96separator = '-' * 70
97
98failed = False
99
100# LLDB Remote platform setting
101lldb_platform_name = None
102lldb_platform_url = None
103lldb_platform_working_dir = None
104
105# Apple SDK
106apple_sdk = None
107
108# The base directory in which the tests are being built.
109test_build_dir = None
110
111# The clang module cache directory used by lldb.
112lldb_module_cache_dir = None
113# The clang module cache directory used by clang.
114clang_module_cache_dir = None
115
116# Test results handling globals
117test_result = None
118
119# The names of all tests. Used to assert we don't have two tests with the
120# same base name.
121all_tests = set()
122
123# LLDB library directory.
124lldb_libs_dir = None
125
126libcxx_include_dir = None
127libcxx_include_target_dir = None
128libcxx_library_dir = None
129
130# A plugin whose tests will be enabled, like intel-pt.
131enabled_plugins = []
132
133
134def shouldSkipBecauseOfCategories(test_categories):
135    if use_categories:
136        if len(test_categories) == 0 or len(
137                categories_list & set(test_categories)) == 0:
138            return True
139
140    for category in skip_categories:
141        if category in test_categories:
142            return True
143
144    return False
145
146
147def get_filecheck_path():
148    """
149    Get the path to the FileCheck testing tool.
150    """
151    if filecheck and os.path.lexists(filecheck):
152        return filecheck
153
154def get_yaml2obj_path():
155    """
156    Get the path to the yaml2obj tool.
157    """
158    if yaml2obj and os.path.lexists(yaml2obj):
159        return yaml2obj
160