Home | History | Annotate | Download | only in test
      1 # -*- Python -*-
      2 
      3 # Configuration file for 'lit' test runner.
      4 # This file contains common rules for various compiler-rt testsuites.
      5 # It is mostly copied from lit.cfg used by Clang.
      6 import os
      7 import platform
      8 
      9 import lit.formats
     10 import lit.util
     11 
     12 # Setup test format
     13 execute_external = (platform.system() != 'Windows'
     14                     or lit_config.getBashPath() not in [None, ""])
     15 config.test_format = lit.formats.ShTest(execute_external)
     16 
     17 # Setup clang binary.
     18 compiler_path = getattr(config, 'clang', None)
     19 if (not compiler_path) or (not os.path.exists(compiler_path)):
     20   lit_config.fatal("Can't find compiler on path %r" % compiler_path)
     21 
     22 compiler_id = getattr(config, 'compiler_id', None)
     23 if compiler_id == "Clang":
     24   if platform.system() != 'Windows':
     25     config.cxx_mode_flags = ["--driver-mode=g++"]
     26   else:
     27     config.cxx_mode_flags = []
     28 elif compiler_id == 'GNU':
     29   config.cxx_mode_flags = ["-x c++"]
     30 else:
     31   lit_config.fatal("Unsupported compiler id: %r" % compiler_id)
     32 # Add compiler ID to the list of available features.
     33 config.available_features.add(compiler_id)
     34 
     35 # Clear some environment variables that might affect Clang.
     36 possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
     37                                'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
     38                                'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
     39                                'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
     40                                'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
     41                                'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
     42                                'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
     43                                'LIBCLANG_RESOURCE_USAGE',
     44                                'LIBCLANG_CODE_COMPLETION_LOGGING']
     45 # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
     46 if platform.system() != 'Windows':
     47     possibly_dangerous_env_vars.append('INCLUDE')
     48 for name in possibly_dangerous_env_vars:
     49   if name in config.environment:
     50     del config.environment[name]
     51 
     52 # Tweak PATH to include llvm tools dir.
     53 llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
     54 if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
     55   lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
     56 path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
     57 config.environment['PATH'] = path
     58 
     59 # Help MSVS link.exe find the standard libraries.
     60 if platform.system() == 'Windows':
     61   config.environment['LIB'] = os.environ['LIB']
     62 
     63 # Use ugly construction to explicitly prohibit "clang", "clang++" etc.
     64 # in RUN lines.
     65 config.substitutions.append(
     66     (' clang', """\n\n*** Do not use 'clangXXX' in tests,
     67      instead define '%clangXXX' substitution in lit config. ***\n\n""") )
     68 
     69 # Allow tests to be executed on a simulator or remotely.
     70 config.substitutions.append( ('%run', config.emulator) )
     71 
     72 # Add supported compiler_rt architectures to a list of available features.
     73 compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
     74 if compiler_rt_arch:
     75   for arch in compiler_rt_arch.split(";"):
     76     config.available_features.add(arch + "-supported-target")
     77 
     78 compiler_rt_debug = getattr(config, 'compiler_rt_debug', False)
     79 if not compiler_rt_debug:
     80   config.available_features.add('compiler-rt-optimized')
     81 
     82 lit.util.usePlatformSdkOnDarwin(config, lit_config)
     83