blob: aecd9d62c214491c1f81222c22cac145d2a0d5ad [file] [log] [blame]
# -*- Python -*-
import os
import platform
import re
import shutil
import site
import subprocess
import sys
import lit.formats
from lit.llvm import llvm_config
from lit.llvm.subst import FindTool
from lit.llvm.subst import ToolSubst
from distutils.spawn import find_executable
from helper import toolchain
# name: The name of this test suite. = 'lldb-shell'
# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
# suffixes: A list of file extensions to treat as test files. This is overriden
# by individual lit.local.cfg files in the test subdirectories.
config.suffixes = ['.test', '.cpp', '.s']
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.lldb_obj_root, 'test', 'Shell')
# Propagate environment vars.
# Support running the test suite under the lldb-repro wrapper. This makes it
# possible to capture a test suite run and then rerun all the test from the
# just captured reproducer.
lldb_repro_mode = lit_config.params.get('lldb-run-with-repro', None)
if lldb_repro_mode:
lit_config.note("Running Shell tests in {} mode.".format(lldb_repro_mode))
toolchain.use_lldb_repro_substitutions(config, lldb_repro_mode)
if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple):
def calculate_arch_features(arch_string):
# This will add a feature such as x86, arm, mips, etc for each built
# target
features = []
for arch in arch_string.split():
return features
# Run llvm-config and add automatically add features for whether we have
# assertions enabled, whether we are in debug mode, and what targets we
# are built for.
[('--assertion-mode', {'ON': 'asserts'}),
('--build-mode', {'DEBUG': 'debug'}),
('--targets-built', calculate_arch_features)
# Clean the module caches in the test build directory. This is necessary in an
# incremental build whenever clang changes underneath, so doing it once per
# invocation is close enough.
for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
if os.path.isdir(cachedir):
print("Deleting module cache at %s."%cachedir)
# Set a default per-test timeout of 10 minutes. Setting a timeout per test
# requires that killProcessAndChildren() is supported on the platform and
# lit complains if the value is set but it is not supported.
supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
if supported:
lit_config.maxIndividualTestTime = 600
lit_config.warning("Could not set a default per-test timeout. " + errormsg)
# If running tests natively, check for CPU features needed for some tests.
if 'native' in config.available_features:
cpuid_exe = lit.util.which('lit-cpuid', config.lldb_tools_dir)
if cpuid_exe is None:
lit_config.warning("lit-cpuid not found, tests requiring CPU extensions will be skipped")
out, err, exitcode = lit.util.executeCommand([cpuid_exe])
if exitcode == 0:
for x in out.split():
config.available_features.add('native-cpu-%s' % x)
lit_config.warning("lit-cpuid failed: %s" % err)
if config.lldb_enable_python:
if config.lldb_enable_lua:
if config.lldb_enable_lzma:
if find_executable('xz') != None:
if config.lldb_system_debugserver:
# NetBSD permits setting dbregs either if one is root
# or if user_set_dbregs is enabled
can_set_dbregs = True
if platform.system() == 'NetBSD' and os.geteuid() != 0:
output = subprocess.check_output(["/sbin/sysctl", "-n",
if output != "1":
can_set_dbregs = False
except subprocess.CalledProcessError:
can_set_dbregs = False
if can_set_dbregs:
if 'LD_PRELOAD' in os.environ: