1*9880d681SAndroid Build Coastguard Worker# -*- Python -*- 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker# Configuration file for the 'lit' test runner. 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Workerimport os 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Workerimport lit.formats 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Worker# name: The name of this test suite. 10*9880d681SAndroid Build Coastguard Workerconfig.name = 'LLVM-Unit' 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Worker# suffixes: A list of file extensions to treat as test files. 13*9880d681SAndroid Build Coastguard Workerconfig.suffixes = [] 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker# is_early; Request to run this suite early. 16*9880d681SAndroid Build Coastguard Workerconfig.is_early = True 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker# test_source_root: The root path where tests are located. 19*9880d681SAndroid Build Coastguard Worker# test_exec_root: The root path where tests should be run. 20*9880d681SAndroid Build Coastguard Workerllvm_obj_root = getattr(config, 'llvm_obj_root', None) 21*9880d681SAndroid Build Coastguard Workerif llvm_obj_root is not None: 22*9880d681SAndroid Build Coastguard Worker config.test_exec_root = os.path.join(llvm_obj_root, 'unittests') 23*9880d681SAndroid Build Coastguard Worker config.test_source_root = config.test_exec_root 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker# testFormat: The test format to use to interpret tests. 26*9880d681SAndroid Build Coastguard Workerllvm_build_mode = getattr(config, 'llvm_build_mode', "Debug") 27*9880d681SAndroid Build Coastguard Workerconfig.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests') 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker# Propagate the temp directory. Windows requires this because it uses \Windows\ 30*9880d681SAndroid Build Coastguard Worker# if none of these are present. 31*9880d681SAndroid Build Coastguard Workerif 'TMP' in os.environ: 32*9880d681SAndroid Build Coastguard Worker config.environment['TMP'] = os.environ['TMP'] 33*9880d681SAndroid Build Coastguard Workerif 'TEMP' in os.environ: 34*9880d681SAndroid Build Coastguard Worker config.environment['TEMP'] = os.environ['TEMP'] 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker# Propagate path to symbolizer for ASan/MSan. 37*9880d681SAndroid Build Coastguard Workerfor symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']: 38*9880d681SAndroid Build Coastguard Worker if symbolizer in os.environ: 39*9880d681SAndroid Build Coastguard Worker config.environment[symbolizer] = os.environ[symbolizer] 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Worker# Win32 seeks DLLs along %PATH%. 42*9880d681SAndroid Build Coastguard Workerif sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir): 43*9880d681SAndroid Build Coastguard Worker config.environment['PATH'] = os.path.pathsep.join(( 44*9880d681SAndroid Build Coastguard Worker config.shlibdir, config.environment['PATH'])) 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker### 47*9880d681SAndroid Build Coastguard Worker 48*9880d681SAndroid Build Coastguard Worker# Check that the object root is known. 49*9880d681SAndroid Build Coastguard Workerif config.test_exec_root is None: 50*9880d681SAndroid Build Coastguard Worker # Otherwise, we haven't loaded the site specific configuration (the user is 51*9880d681SAndroid Build Coastguard Worker # probably trying to run on a test file directly, and either the site 52*9880d681SAndroid Build Coastguard Worker # configuration hasn't been created by the build system, or we are in an 53*9880d681SAndroid Build Coastguard Worker # out-of-tree build situation). 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker # Check for 'llvm_unit_site_config' user parameter, and use that if available. 56*9880d681SAndroid Build Coastguard Worker site_cfg = lit_config.params.get('llvm_unit_site_config', None) 57*9880d681SAndroid Build Coastguard Worker if site_cfg and os.path.exists(site_cfg): 58*9880d681SAndroid Build Coastguard Worker lit_config.load_config(config, site_cfg) 59*9880d681SAndroid Build Coastguard Worker raise SystemExit 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker # Try to detect the situation where we are using an out-of-tree build by 62*9880d681SAndroid Build Coastguard Worker # looking for 'llvm-config'. 63*9880d681SAndroid Build Coastguard Worker # 64*9880d681SAndroid Build Coastguard Worker # FIXME: I debated (i.e., wrote and threw away) adding logic to 65*9880d681SAndroid Build Coastguard Worker # automagically generate the lit.site.cfg if we are in some kind of fresh 66*9880d681SAndroid Build Coastguard Worker # build situation. This means knowing how to invoke the build system 67*9880d681SAndroid Build Coastguard Worker # though, and I decided it was too much magic. 68*9880d681SAndroid Build Coastguard Worker 69*9880d681SAndroid Build Coastguard Worker llvm_config = lit.util.which('llvm-config', config.environment['PATH']) 70*9880d681SAndroid Build Coastguard Worker if not llvm_config: 71*9880d681SAndroid Build Coastguard Worker lit_config.fatal('No site specific configuration available!') 72*9880d681SAndroid Build Coastguard Worker 73*9880d681SAndroid Build Coastguard Worker # Get the source and object roots. 74*9880d681SAndroid Build Coastguard Worker llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip() 75*9880d681SAndroid Build Coastguard Worker llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip() 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Worker # Validate that we got a tree which points to here. 78*9880d681SAndroid Build Coastguard Worker this_src_root = os.path.join(os.path.dirname(__file__),'..','..') 79*9880d681SAndroid Build Coastguard Worker if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root): 80*9880d681SAndroid Build Coastguard Worker lit_config.fatal('No site specific configuration available!') 81*9880d681SAndroid Build Coastguard Worker 82*9880d681SAndroid Build Coastguard Worker # Check that the site specific configuration exists. 83*9880d681SAndroid Build Coastguard Worker site_cfg = os.path.join(llvm_obj_root, 'test', 'Unit', 'lit.site.cfg') 84*9880d681SAndroid Build Coastguard Worker if not os.path.exists(site_cfg): 85*9880d681SAndroid Build Coastguard Worker lit_config.fatal('No site specific configuration available!') 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Worker # Okay, that worked. Notify the user of the automagic, and reconfigure. 88*9880d681SAndroid Build Coastguard Worker lit_config.note('using out-of-tree build at %r' % llvm_obj_root) 89*9880d681SAndroid Build Coastguard Worker lit_config.load_config(config, site_cfg) 90*9880d681SAndroid Build Coastguard Worker raise SystemExit 91