[Lldb-commits] [lldb] r297811 - dotest.py: remove the ability to specify different architectures/compilers in a single invocation
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 15 01:52:00 PDT 2017
Author: labath
Date: Wed Mar 15 03:51:59 2017
New Revision: 297811
URL: http://llvm.org/viewvc/llvm-project?rev=297811&view=rev
Log:
dotest.py: remove the ability to specify different architectures/compilers in a single invocation
Summary:
This has been broken at least since the new test result framework was
added, which was over a year ago. It looks like nobody has missed it
since.
Removing this makes the gmodules handling code saner, as it already did
not know how to handle the multiple-compilers case.
My motivation for this is libc++ data formatters support on android -- I
am trying make a central way of determining whether libc++ tests can be
run, and without this, I would have to resort to similar hacks as the
gmodules code.
Reviewers: jingham, zturner
Subscribers: danalbert, tfiala, lldb-commits
Differential Revision: https://reviews.llvm.org/D30779
Modified:
lldb/trunk/packages/Python/lldbsuite/test/configuration.py
lldb/trunk/packages/Python/lldbsuite/test/dosep.py
lldb/trunk/packages/Python/lldbsuite/test/dotest.py
lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
lldb/trunk/packages/Python/lldbsuite/test/test_categories.py
Modified: lldb/trunk/packages/Python/lldbsuite/test/configuration.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/configuration.py?rev=297811&r1=297810&r2=297811&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/configuration.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py Wed Mar 15 03:51:59 2017
@@ -76,11 +76,9 @@ lldbFrameworkPath = None
# Test suite repeat count. Can be overwritten with '-# count'.
count = 1
-# The 'archs' and 'compilers' can be specified via command line. The corresponding
-# options can be specified more than once. For example, "-A x86_64 -A i386"
-# => archs=['x86_64', 'i386'] and "-C gcc -C clang" => compilers=['gcc', 'clang'].
-archs = None # Must be initialized after option parsing
-compilers = None # Must be initialized after option parsing
+# The 'arch' and 'compiler' can be specified via command line.
+arch = None # Must be initialized after option parsing
+compiler = None # Must be initialized after option parsing
# The arch might dictate some specific CFLAGS to be passed to the toolchain to build
# the inferior programs. The global variable cflags_extras provides a hook to do
Modified: lldb/trunk/packages/Python/lldbsuite/test/dosep.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dosep.py?rev=297811&r1=297810&r2=297811&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/dosep.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dosep.py Wed Mar 15 03:51:59 2017
@@ -1653,7 +1653,7 @@ def main(num_threads, test_subdir, test_
# will be passed along to the timeout pre-kill handler and allows for loose
# coupling of its implementation.
runner_context = {
- "archs": configuration.archs,
+ "arch": configuration.arch,
"platform_name": configuration.lldb_platform_name,
"platform_url": configuration.lldb_platform_url,
"platform_working_dir": configuration.lldb_platform_working_dir,
Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=297811&r1=297810&r2=297811&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Wed Mar 15 03:51:59 2017
@@ -274,22 +274,21 @@ def parseOptionsAndInitTestdirs():
if args.h:
do_help = True
- if args.compilers:
- configuration.compilers = args.compilers
+ if args.compiler:
+ configuration.compiler = args.compiler
else:
# Use a compiler appropriate appropriate for the Apple SDK if one was
# specified
if platform_system == 'Darwin' and args.apple_sdk:
- configuration.compilers = [
- seven.get_command_output(
- 'xcrun -sdk "%s" -find clang 2> /dev/null' %
- (args.apple_sdk))]
+ configuration.compiler = seven.get_command_output(
+ 'xcrun -sdk "%s" -find clang 2> /dev/null' %
+ (args.apple_sdk))
else:
# 'clang' on ubuntu 14.04 is 3.4 so we try clang-3.5 first
candidateCompilers = ['clang-3.5', 'clang', 'gcc']
for candidate in candidateCompilers:
if which(candidate):
- configuration.compilers = [candidate]
+ configuration.compiler = candidate
break
if args.channels:
@@ -304,18 +303,17 @@ def parseOptionsAndInitTestdirs():
'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
(args.apple_sdk))
- if args.archs:
- configuration.archs = args.archs
- for arch in configuration.archs:
- if arch.startswith(
- 'arm') and platform_system == 'Darwin' and not args.apple_sdk:
+ if args.arch:
+ configuration.arch = args.arch
+ if configuration.arch.startswith(
+ 'arm') and platform_system == 'Darwin' and not args.apple_sdk:
+ os.environ['SDKROOT'] = seven.get_command_output(
+ 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
+ if not os.path.exists(os.environ['SDKROOT']):
os.environ['SDKROOT'] = seven.get_command_output(
- 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
- if not os.path.exists(os.environ['SDKROOT']):
- os.environ['SDKROOT'] = seven.get_command_output(
- 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
+ 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
else:
- configuration.archs = [platform_machine]
+ configuration.arch = platform_machine
if args.categoriesList:
configuration.categoriesList = set(
@@ -1028,6 +1026,26 @@ def setDefaultTripleForPlatform():
return {}
+def checkCompiler():
+ # Add some intervention here to sanity check that the compiler requested is sane.
+ # If found not to be an executable program, we abort.
+ c = configuration.compiler
+ if which(c):
+ return
+
+ if not sys.platform.startswith("darwin"):
+ raise Exception(c + " is not a valid compiler")
+
+ pipe = subprocess.Popen(
+ ['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ cmd_output = pipe.stdout.read()
+ if not cmd_output or "not found" in cmd_output:
+ raise Exception(c + " is not a valid compiler")
+
+ configuration.compiler = cmd_output.split('\n')[0]
+ print("'xcrun -find %s' returning %s" % (c, configuration.compiler))
+
+
def run_suite():
# On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
# does not exist before proceeding to running the test suite.
@@ -1177,124 +1195,65 @@ def run_suite():
raise
#
- # Invoke the default TextTestRunner to run the test suite, possibly iterating
- # over different configurations.
+ # Invoke the default TextTestRunner to run the test suite
#
-
- iterArchs = False
- iterCompilers = False
-
- if isinstance(configuration.archs, list) and len(configuration.archs) >= 1:
- iterArchs = True
-
- #
- # Add some intervention here to sanity check that the compilers requested are sane.
- # If found not to be an executable program, the invalid one is dropped
- # from the list.
- for i in range(len(configuration.compilers)):
- c = configuration.compilers[i]
- if which(c):
- continue
- else:
- if sys.platform.startswith("darwin"):
- pipe = subprocess.Popen(
- ['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- cmd_output = pipe.stdout.read()
- if cmd_output:
- if "not found" in cmd_output:
- print("dropping %s from the compilers used" % c)
- configuration.compilers.remove(i)
- else:
- configuration.compilers[i] = cmd_output.split('\n')[0]
- print(
- "'xcrun -find %s' returning %s" %
- (c, configuration.compilers[i]))
+ checkCompiler()
if not configuration.parsable:
- print("compilers=%s" % str(configuration.compilers))
-
- if not configuration.compilers or len(configuration.compilers) == 0:
- print("No eligible compiler found, exiting.")
- exitTestSuite(1)
-
- if isinstance(
- configuration.compilers,
- list) and len(
- configuration.compilers) >= 1:
- iterCompilers = True
-
- # If we iterate on archs or compilers, there is a chance we want to split
- # stderr/stdout.
- if iterArchs or iterCompilers:
- old_stderr = sys.stderr
- old_stdout = sys.stdout
- new_stderr = None
- new_stdout = None
+ print("compiler=%s" % configuration.compiler)
# Iterating over all possible architecture and compiler combinations.
- for ia in range(len(configuration.archs) if iterArchs else 1):
- archConfig = ""
- if iterArchs:
- os.environ["ARCH"] = configuration.archs[ia]
- archConfig = "arch=%s" % configuration.archs[ia]
- for ic in range(len(configuration.compilers) if iterCompilers else 1):
- if iterCompilers:
- os.environ["CC"] = configuration.compilers[ic]
- configString = "%s compiler=%s" % (
- archConfig, configuration.compilers[ic])
- else:
- configString = archConfig
+ os.environ["ARCH"] = configuration.arch
+ os.environ["CC"] = configuration.compiler
+ configString = "arch=%s compiler=%s" % (configuration.arch,
+ configuration.compiler)
+
+ # Translate ' ' to '-' for pathname component.
+ if six.PY2:
+ import string
+ tbl = string.maketrans(' ', '-')
+ else:
+ tbl = str.maketrans(' ', '-')
+ configPostfix = configString.translate(tbl)
- if iterArchs or iterCompilers:
- # Translate ' ' to '-' for pathname component.
- if six.PY2:
- import string
- tbl = string.maketrans(' ', '-')
- else:
- tbl = str.maketrans(' ', '-')
- configPostfix = configString.translate(tbl)
-
- # Output the configuration.
- if not configuration.parsable:
- sys.stderr.write("\nConfiguration: " + configString + "\n")
-
- #print("sys.stderr name is", sys.stderr.name)
- #print("sys.stdout name is", sys.stdout.name)
-
- # First, write out the number of collected test cases.
- if not configuration.parsable:
- sys.stderr.write(configuration.separator + "\n")
- sys.stderr.write(
- "Collected %d test%s\n\n" %
- (configuration.suite.countTestCases(),
- configuration.suite.countTestCases() != 1 and "s" or ""))
+ # Output the configuration.
+ if not configuration.parsable:
+ sys.stderr.write("\nConfiguration: " + configString + "\n")
- if configuration.parsable:
- v = 0
- else:
- v = configuration.verbose
+ # First, write out the number of collected test cases.
+ if not configuration.parsable:
+ sys.stderr.write(configuration.separator + "\n")
+ sys.stderr.write(
+ "Collected %d test%s\n\n" %
+ (configuration.suite.countTestCases(),
+ configuration.suite.countTestCases() != 1 and "s" or ""))
- # Invoke the test runner.
- if configuration.count == 1:
- result = unittest2.TextTestRunner(
- stream=sys.stderr,
- verbosity=v,
- resultclass=test_result.LLDBTestResult).run(
- configuration.suite)
- else:
- # We are invoking the same test suite more than once. In this case,
- # mark __ignore_singleton__ flag as True so the signleton pattern is
- # not enforced.
- test_result.LLDBTestResult.__ignore_singleton__ = True
- for i in range(configuration.count):
-
- result = unittest2.TextTestRunner(
- stream=sys.stderr,
- verbosity=v,
- resultclass=test_result.LLDBTestResult).run(
- configuration.suite)
+ if configuration.parsable:
+ v = 0
+ else:
+ v = configuration.verbose
+
+ # Invoke the test runner.
+ if configuration.count == 1:
+ result = unittest2.TextTestRunner(
+ stream=sys.stderr,
+ verbosity=v,
+ resultclass=test_result.LLDBTestResult).run(
+ configuration.suite)
+ else:
+ # We are invoking the same test suite more than once. In this case,
+ # mark __ignore_singleton__ flag as True so the signleton pattern is
+ # not enforced.
+ test_result.LLDBTestResult.__ignore_singleton__ = True
+ for i in range(configuration.count):
+
+ result = unittest2.TextTestRunner(
+ stream=sys.stderr,
+ verbosity=v,
+ resultclass=test_result.LLDBTestResult).run(
+ configuration.suite)
- configuration.failed = configuration.failed or not result.wasSuccessful()
+ configuration.failed = not result.wasSuccessful()
if configuration.sdir_has_content and not configuration.parsable:
sys.stderr.write(
Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py?rev=297811&r1=297810&r2=297811&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py Wed Mar 15 03:51:59 2017
@@ -69,10 +69,9 @@ def create_parser():
'-A',
'--arch',
metavar='arch',
- action='append',
- dest='archs',
+ dest='arch',
help=textwrap.dedent('''Specify the architecture(s) to test. This option can be specified more than once'''))
- group.add_argument('-C', '--compiler', metavar='compiler', dest='compilers', action='append', help=textwrap.dedent(
+ group.add_argument('-C', '--compiler', metavar='compiler', dest='compiler', help=textwrap.dedent(
'''Specify the compiler(s) used to build the inferior executables. The compiler path can be an executable basename or a full path to a compiler executable. This option can be specified multiple times.'''))
if sys.platform == 'darwin':
group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', default="macosx", help=textwrap.dedent(
Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py?rev=297811&r1=297810&r2=297811&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py Wed Mar 15 03:51:59 2017
@@ -226,19 +226,19 @@ def MakeInlineTest(__file, __globals, de
target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
if test_categories.is_supported_on_platform(
- "dsym", target_platform, configuration.compilers):
+ "dsym", target_platform, configuration.compiler):
test.test_with_dsym = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dsym, decorators)
if test_categories.is_supported_on_platform(
- "dwarf", target_platform, configuration.compilers):
+ "dwarf", target_platform, configuration.compiler):
test.test_with_dwarf = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dwarf, decorators)
if test_categories.is_supported_on_platform(
- "dwo", target_platform, configuration.compilers):
+ "dwo", target_platform, configuration.compiler):
test.test_with_dwo = ApplyDecoratorsToFunction(
test._InlineTest__test_with_dwo, decorators)
if test_categories.is_supported_on_platform(
- "gmodules", target_platform, configuration.compilers):
+ "gmodules", target_platform, configuration.compiler):
test.test_with_gmodules = ApplyDecoratorsToFunction(
test._InlineTest__test_with_gmodules, decorators)
Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=297811&r1=297810&r2=297811&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Wed Mar 15 03:51:59 2017
@@ -1714,7 +1714,7 @@ class LLDBTestCaseFactory(type):
supported_categories = [
x for x in categories if test_categories.is_supported_on_platform(
- x, target_platform, configuration.compilers)]
+ x, target_platform, configuration.compiler)]
if "dsym" in supported_categories:
@decorators.add_test_categories(["dsym"])
@wraps(attrvalue)
Modified: lldb/trunk/packages/Python/lldbsuite/test/test_categories.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/test_categories.py?rev=297811&r1=297810&r2=297811&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/test_categories.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/test_categories.py Wed Mar 15 03:51:59 2017
@@ -46,7 +46,7 @@ def unique_string_match(yourentry, list)
return candidate
-def is_supported_on_platform(category, platform, compiler_paths):
+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"]
@@ -56,17 +56,7 @@ def is_supported_on_platform(category, p
# First, check to see if the platform can even support gmodules.
if platform not in ["linux", "freebsd", "darwin", "macosx", "ios"]:
return False
- # If all compilers specified support gmodules, we'll enable it.
- for compiler_path in compiler_paths:
- if not gmodules.is_compiler_clang_with_gmodules(compiler_path):
- # Ideally in a multi-compiler scenario during a single test run, this would
- # allow gmodules on compilers that support it and not on ones that don't.
- # However, I didn't see an easy way for all the callers of this to know
- # the compiler being used for a test invocation. As we tend to run with
- # a single compiler per test run, this shouldn't be a major
- # issue.
- return False
- return True
+ return gmodules.is_compiler_clang_with_gmodules(compiler_path)
return True
More information about the lldb-commits
mailing list