1# -*- Python -*- 2 3# Configuration file for the 'lit' test runner. 4 5# name: The name of this test suite. 6config.name = 'slang_lit_tests' 7 8# suffixes: A list of file extensions to treat as test files. 9config.suffixes = ['.rs', '.ll'] 10 11# testFormat: The test format to use to interpret tests. 12import lit.formats 13config.test_format = lit.formats.ShTest() 14 15# Get the base build directory for the android source tree from environment. 16config.base_path = os.getenv('ANDROID_BUILD_TOP') 17 18# test_source_root: The path where tests are located (default is the test suite 19# root). 20config.test_source_root = None 21 22# test_exec_root: The path where tests are located (default is the test suite 23# root). 24config.test_exec_root = os.path.join(config.base_path, 'out', 'tests', 'slang', 'lit-tests') 25 26# target_triple: Used by ShTest and TclTest formats for XFAIL checks. 27config.target_triple = 'slang' 28 29def inferTool(binary_name, env_var, PATH): 30 # Determine which tool to use. 31 tool = os.getenv(env_var) 32 33 # If the user set the overriding environment variable, use it 34 if tool and os.path.isfile(tool): 35 return tool 36 37 # Otherwise look in the path. 38 import lit.util 39 tool = lit.util.which(binary_name, PATH) 40 41 if not tool: 42 lit_config.fatal("couldn't find " + binary_name + " program in " + PATH + " , try setting " 43 + env_var + " in your environment") 44 45 return os.path.abspath(tool) 46 47config.slang = inferTool('llvm-rs-cc', 'SLANG', os.path.join(os.getenv('ANDROID_HOST_OUT'), 'bin')).replace('\\', '/') 48config.llvm_rs_as = inferTool('llvm-rs-as', 'LLVM_RS_AS', os.path.join(os.getenv('ANDROID_HOST_OUT'), 'bin')).replace('\\', '/') 49 50config.filecheck = inferTool('FileCheck', 'FILECHECK', config.environment['PATH']) 51config.rs_filecheck_wrapper = inferTool('rs-filecheck-wrapper.sh', 'RS_FILECHECK_WRAPPER', os.path.join(config.base_path, 'frameworks', 'compile', 'slang', 'lit-tests')) 52config.scriptc_filecheck_wrapper = inferTool('scriptc-filecheck-wrapper.sh', 'SCRIPTC_FILECHECK_WRAPPER', os.path.join(config.base_path, 'frameworks', 'compile', 'slang', 'lit-tests')) 53 54# Use most up-to-date headers for includes. 55config.slang_includes = "-I " + os.path.join(config.base_path, 'frameworks', 'rs', 'script_api', 'include') + " " \ 56 + "-I " + os.path.join(config.base_path, 'external', 'clang', 'lib', 'Headers') 57 58config.slang_options = "-emit-llvm -o " + config.test_exec_root \ 59 + " -output-dep-dir " + config.test_exec_root \ 60 + " -java-reflection-path-base " + config.test_exec_root 61 62if not lit_config.quiet: 63 lit_config.note('using slang: %r' % config.slang) 64 lit_config.note('using llvm-rs-as: %r' % config.llvm_rs_as) 65 lit_config.note('using FileCheck: %r' % config.filecheck) 66 lit_config.note('using rs-filecheck-wrapper.sh: %r' % config.rs_filecheck_wrapper) 67 lit_config.note('using output directory: %r' % config.test_exec_root) 68 69# Tools configuration substitutions 70config.substitutions.append( ('%Slang', ' ' + config.slang + ' ' + config.slang_includes + ' ' + config.slang_options ) ) 71config.substitutions.append( ('%llvm-rs-as', config.llvm_rs_as) ) 72config.substitutions.append( ('%rs-filecheck-wrapper', ' ' + config.rs_filecheck_wrapper + ' ' + config.test_exec_root + ' ' + config.filecheck + ' ') ) 73config.substitutions.append( ('%scriptc-filecheck-wrapper', ' ' + config.scriptc_filecheck_wrapper + ' --output=' + config.test_exec_root + ' --filecheck=' + config.filecheck + ' ') ) 74lit_config.note(config.substitutions) 75