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