1# -*clang- Python -*- 2 3import os 4import platform 5import re 6import subprocess 7 8import lit.formats 9import lit.util 10 11# Configuration file for the 'lit' test runner. 12 13# name: The name of this test suite. 14config.name = 'Polly' 15 16# testFormat: The test format to use to interpret tests. 17# 18# For now we require '&&' between commands, until they get globally killed and 19# the test runner updated. 20execute_external = platform.system() != 'Windows' 21config.test_format = lit.formats.ShTest(execute_external) 22 23# suffixes: A list of file extensions to treat as test files. 24config.suffixes = ['.ll'] 25 26# test_source_root: The root path where tests are located. 27config.test_source_root = os.path.dirname(__file__) 28 29# test_exec_root: The root path where tests should be run. 30config.test_exec_root = os.path.join(config.polly_obj_root, 'test') 31 32# Tweak the PATH to include the tools dir and the scripts dir. 33base_paths = [config.llvm_tools_dir, config.environment['PATH']] 34path = os.path.pathsep.join(base_paths + config.extra_paths) 35config.environment['PATH'] = path 36 37path = os.path.pathsep.join((config.llvm_libs_dir, 38 config.environment.get('LD_LIBRARY_PATH',''))) 39config.environment['LD_LIBRARY_PATH'] = path 40 41# opt knows whether it is compiled with -DNDEBUG. 42import subprocess 43try: 44 opt_cmd = subprocess.Popen([os.path.join(config.llvm_tools_dir, 'opt'), '-version'], 45 stdout = subprocess.PIPE, 46 env=config.environment) 47except OSError: 48 print("Could not find opt in " + config.llvm_tools_dir) 49 exit(42) 50 51if re.search(r'with assertions', opt_cmd.stdout.read().decode('ascii')): 52 config.available_features.add('asserts') 53opt_cmd.wait() 54 55try: 56 llvm_config_cmd = subprocess.Popen([os.path.join( 57 config.llvm_tools_dir, 58 'llvm-config'), 59 '--targets-built'], 60 stdout = subprocess.PIPE, 61 env=config.environment) 62except OSError: 63 print("Could not find llvm-config in " + config.llvm_tools_dir) 64 exit(42) 65 66if re.search(r'NVPTX', llvm_config_cmd.stdout.read().decode('ascii')): 67 config.available_features.add('nvptx-registered-target') 68llvm_config_cmd.wait() 69