Index: packages/Python/lldbsuite/test/configuration.py =================================================================== --- packages/Python/lldbsuite/test/configuration.py +++ 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: packages/Python/lldbsuite/test/dosep.py =================================================================== --- packages/Python/lldbsuite/test/dosep.py +++ 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: packages/Python/lldbsuite/test/dotest.py =================================================================== --- packages/Python/lldbsuite/test/dotest.py +++ 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( @@ -1025,6 +1023,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. @@ -1174,124 +1192,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 # + checkCompiler() - iterArchs = False - iterCompilers = False + if not configuration.parsable: + print("compiler=%s" % configuration.compiler) - if isinstance(configuration.archs, list) and len(configuration.archs) >= 1: - iterArchs = True + # Iterating over all possible architecture and compiler combinations. + 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) - # - # 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])) + # Output the configuration. + if not configuration.parsable: + sys.stderr.write("\nConfiguration: " + configString + "\n") + # First, write out the number of collected test cases. 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 + 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 "")) - # 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 - - 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 "")) - - 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() + 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 = not result.wasSuccessful() if configuration.sdir_has_content and not configuration.parsable: sys.stderr.write( Index: packages/Python/lldbsuite/test/dotest_args.py =================================================================== --- packages/Python/lldbsuite/test/dotest_args.py +++ 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: packages/Python/lldbsuite/test/lldbinline.py =================================================================== --- packages/Python/lldbsuite/test/lldbinline.py +++ 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: packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- packages/Python/lldbsuite/test/lldbtest.py +++ 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: packages/Python/lldbsuite/test/test_categories.py =================================================================== --- packages/Python/lldbsuite/test/test_categories.py +++ 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