1# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: 2# Configuration file for the 'lit' test runner. 3 4import os 5import lit.formats 6 7# Tell pylint that we know config and lit_config exist somewhere. 8if 'PYLINT_IMPORT' in os.environ: 9 config = object() 10 lit_config = object() 11 12# Use the CUDA device as suggested by the env 13if 'CUDA_VISIBLE_DEVICES' in os.environ: 14 config.environment['CUDA_VISIBLE_DEVICES'] = os.environ['CUDA_VISIBLE_DEVICES'] 15 16# Allow running the tests with omptarget debug output 17if 'LIBOMPTARGET_DEBUG' in os.environ: 18 config.environment['LIBOMPTARGET_DEBUG'] = os.environ['LIBOMPTARGET_DEBUG'] 19 20def append_dynamic_library_path(name, value, sep): 21 if name in config.environment: 22 config.environment[name] = value + sep + config.environment[name] 23 else: 24 config.environment[name] = value 25 26# name: The name of this test suite. 27config.name = 'libomptarget' 28 29# suffixes: A list of file extensions to treat as test files. 30config.suffixes = ['.c', '.cpp', '.cc'] 31 32# test_source_root: The root path where tests are located. 33config.test_source_root = os.path.dirname(__file__) 34 35# test_exec_root: The root object directory where output is placed 36config.test_exec_root = config.libomptarget_obj_root 37 38# test format 39config.test_format = lit.formats.ShTest() 40 41# compiler flags 42config.test_flags = " -I " + config.test_source_root + \ 43 " -I " + config.omp_header_directory + \ 44 " -L " + config.library_dir; 45 46if config.omp_host_rtl_directory: 47 config.test_flags = config.test_flags + " -L " + \ 48 config.omp_host_rtl_directory 49 50config.test_flags = config.test_flags + " " + config.test_extra_flags 51 52# Allow REQUIRES / UNSUPPORTED / XFAIL to work 53config.target_triple = [ ] 54for feature in config.test_compiler_features: 55 config.available_features.add(feature) 56 57if config.libomptarget_debug: 58 config.available_features.add('libomptarget-debug') 59 60# Setup environment to find dynamic library at runtime 61if config.operating_system == 'Windows': 62 append_dynamic_library_path('PATH', config.library_dir, ";") 63 append_dynamic_library_path('PATH', config.omp_host_rtl_directory, ";") 64elif config.operating_system == 'Darwin': 65 append_dynamic_library_path('DYLD_LIBRARY_PATH', config.library_dir, ":") 66 append_dynamic_library_path('DYLD_LIBRARY_PATH', \ 67 config.omp_host_rtl_directory, ";") 68 config.test_flags += " -Wl,-rpath," + config.library_dir 69 config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory 70else: # Unices 71 append_dynamic_library_path('LD_LIBRARY_PATH', config.library_dir, ":") 72 append_dynamic_library_path('LD_LIBRARY_PATH', \ 73 config.omp_host_rtl_directory, ":") 74 append_dynamic_library_path('LIBRARY_PATH', config.library_dir, ":") 75 append_dynamic_library_path('LIBRARY_PATH', \ 76 config.omp_host_rtl_directory, ":") 77 78# substitutions 79# - for targets that exist in the system create the actual command. 80# - for valid targets that do not exist in the system, return false, so that the 81# same test can be used for different targets. 82 83# Scan all the valid targets. 84for libomptarget_target in config.libomptarget_all_targets: 85 # Is this target in the current system? If so create a compile, run and test 86 # command. Otherwise create command that return false. 87 if libomptarget_target in config.libomptarget_system_targets: 88 config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \ 89 libomptarget_target, \ 90 "%libomptarget-compilexx-and-run-" + libomptarget_target + \ 91 " | " + config.libomptarget_filecheck + " %s")) 92 config.substitutions.append(("%libomptarget-compile-run-and-check-" + \ 93 libomptarget_target, \ 94 "%libomptarget-compile-and-run-" + libomptarget_target + \ 95 " | " + config.libomptarget_filecheck + " %s")) 96 config.substitutions.append(("%libomptarget-compilexx-and-run-" + \ 97 libomptarget_target, \ 98 "%libomptarget-compilexx-" + libomptarget_target + " && " + \ 99 "%libomptarget-run-" + libomptarget_target)) 100 config.substitutions.append(("%libomptarget-compile-and-run-" + \ 101 libomptarget_target, \ 102 "%libomptarget-compile-" + libomptarget_target + " && " + \ 103 "%libomptarget-run-" + libomptarget_target)) 104 config.substitutions.append(("%libomptarget-compilexx-" + \ 105 libomptarget_target, \ 106 "%clangxx-" + libomptarget_target + " %s -o %t-" + \ 107 libomptarget_target)) 108 config.substitutions.append(("%libomptarget-compile-" + \ 109 libomptarget_target, \ 110 "%clang-" + libomptarget_target + " %s -o %t-" + \ 111 libomptarget_target)) 112 config.substitutions.append(("%libomptarget-run-" + \ 113 libomptarget_target, \ 114 "%t-" + libomptarget_target)) 115 config.substitutions.append(("%libomptarget-run-fail-" + \ 116 libomptarget_target, \ 117 "%not --crash %t-" + libomptarget_target)) 118 config.substitutions.append(("%clangxx-" + libomptarget_target, \ 119 "%clangxx %openmp_flags %flags -fopenmp-targets=" + libomptarget_target)) 120 config.substitutions.append(("%clang-" + libomptarget_target, \ 121 "%clang %openmp_flags %flags -fopenmp-targets=" + libomptarget_target)) 122 config.substitutions.append(("%fcheck-" + libomptarget_target, \ 123 config.libomptarget_filecheck + " %s")) 124 else: 125 config.substitutions.append(("%libomptarget-compile-run-and-check-" + \ 126 libomptarget_target, \ 127 "echo ignored-command")) 128 config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \ 129 libomptarget_target, \ 130 "echo ignored-command")) 131 config.substitutions.append(("%libomptarget-compile-and-run-" + \ 132 libomptarget_target, \ 133 "echo ignored-command")) 134 config.substitutions.append(("%libomptarget-compilexx-and-run-" + \ 135 libomptarget_target, \ 136 "echo ignored-command")) 137 config.substitutions.append(("%libomptarget-compilexx-" + \ 138 libomptarget_target, \ 139 "echo ignored-command")) 140 config.substitutions.append(("%libomptarget-compile-" + \ 141 libomptarget_target, \ 142 "echo ignored-command")) 143 config.substitutions.append(("%libomptarget-run-" + \ 144 libomptarget_target, \ 145 "echo ignored-command")) 146 config.substitutions.append(("%libomptarget-run-fail-" + \ 147 libomptarget_target, \ 148 "echo ignored-command")) 149 config.substitutions.append(("%clang-" + libomptarget_target, \ 150 "echo ignored-command")) 151 config.substitutions.append(("%clangxx-" + libomptarget_target, \ 152 "echo ignored-command")) 153 config.substitutions.append(("%fcheck-" + libomptarget_target, \ 154 "echo ignored-command")) 155 156config.substitutions.append(("%clangxx", config.test_cxx_compiler)) 157config.substitutions.append(("%clang", config.test_c_compiler)) 158config.substitutions.append(("%openmp_flags", config.test_openmp_flags)) 159config.substitutions.append(("%flags", config.test_flags)) 160config.substitutions.append(("%not", config.libomptarget_not)) 161