Index: lldb/trunk/packages/Python/lldbsuite/test/configuration.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/configuration.py +++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py @@ -76,11 +76,9 @@ # 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 Index: lldb/trunk/packages/Python/lldbsuite/test/dosep.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/dosep.py +++ lldb/trunk/packages/Python/lldbsuite/test/dosep.py @@ -1653,7 +1653,7 @@ # 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, Index: lldb/trunk/packages/Python/lldbsuite/test/dotest.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/dotest.py +++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py @@ -274,22 +274,21 @@ 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 @@ '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 @@ 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 @@ 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( Index: lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py +++ lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py @@ -69,10 +69,9 @@ '-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( Index: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py +++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py @@ -226,19 +226,19 @@ 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) Index: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py @@ -1714,7 +1714,7 @@ 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) Index: lldb/trunk/packages/Python/lldbsuite/test/test_categories.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/test_categories.py +++ lldb/trunk/packages/Python/lldbsuite/test/test_categories.py @@ -46,7 +46,7 @@ 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 @@ # 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