1 # -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
2 # Configuration file for the 'lit' test runner.
9 # Tell pylint that we know config and lit_config exist somewhere.
10 if 'PYLINT_IMPORT' in os.environ:
14 def prepend_dynamic_library_path(path):
15 target_arch = getattr(config, 'target_arch', None)
16 if config.operating_system == 'Windows':
19 elif config.operating_system == 'Darwin':
20 name = 'DYLD_LIBRARY_PATH'
22 elif target_arch == 've':
23 name = 'VE_LD_LIBRARY_PATH'
26 name = 'LD_LIBRARY_PATH'
28 if name in config.environment:
29 config.environment[name] = path + sep + config.environment[name]
31 config.environment[name] = path
33 # name: The name of this test suite.
34 config.name = 'libomp'
36 # suffixes: A list of file extensions to treat as test files.
37 config.suffixes = ['.c', '.cpp']
39 # test_source_root: The root path where tests are located.
40 config.test_source_root = os.path.dirname(__file__)
42 # test_exec_root: The root object directory where output is placed
43 config.test_exec_root = config.libomp_obj_root
46 config.test_format = lit.formats.ShTest()
49 flags = " -I " + config.test_source_root + \
50 " -L " + config.library_dir + \
51 " " + config.test_extra_flags
52 if config.has_omit_frame_pointer_flag:
53 flags += " -fno-omit-frame-pointer"
54 if config.target_arch == "s390x":
55 flags += " -mbackchain"
57 config.test_flags = " -I " + config.omp_header_directory + flags
58 config.test_flags_use_compiler_omp_h = flags
65 if config.has_libatomic:
68 # Allow REQUIRES / UNSUPPORTED / XFAIL to work
69 config.target_triple = [ ]
70 for feature in config.test_compiler_features:
71 config.available_features.add(feature)
73 # Setup environment to find dynamic library at runtime
74 if config.using_hwloc:
75 prepend_dynamic_library_path(config.hwloc_library_dir)
76 config.available_features.add('hwloc')
77 # Note: please keep config.library_dir *after* any potentially system
78 # directories, as otherwise preinstalled openmp libraries will be used
80 prepend_dynamic_library_path(config.library_dir)
82 # Rpath modifications for Darwin
83 if config.operating_system == 'Darwin':
84 config.test_flags += " -Wl,-rpath," + config.library_dir
85 if config.using_hwloc:
86 config.test_flags += " -Wl,-rpath," + config.hwloc_library_dir
88 # Find the SDK on Darwin
89 if config.operating_system == 'Darwin':
90 cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
91 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
92 out, err = cmd.communicate()
93 out = out.strip().decode()
96 config.test_flags += " -isysroot " + out
98 # Disable OMPT tests if FileCheck was not found
99 if config.has_ompt and config.test_filecheck == "":
100 lit_config.note("Not testing OMPT because FileCheck was not found")
101 config.has_ompt = False
104 config.available_features.add("ompt")
106 config.test_flags += " -I " + config.test_source_root + "/ompt"
108 if config.has_ompx_taskgraph:
109 config.available_features.add("ompx_taskgraph")
111 if 'Linux' in config.operating_system:
112 config.available_features.add("linux")
114 if config.operating_system == 'NetBSD':
115 config.available_features.add("netbsd")
117 if config.operating_system == 'Darwin':
118 config.available_features.add("darwin")
120 if config.operating_system in ['Linux', 'Windows']:
121 config.available_features.add('affinity')
123 if config.operating_system in ['Linux']:
124 config.available_features.add('hidden-helper')
126 target_arch = getattr(config, 'target_arch', None)
128 config.available_features.add(target_arch + '-target-arch')
129 if target_arch in ['x86_64', 'i386']:
130 config.available_features.add('x86-target-arch')
132 import multiprocessing
134 if multiprocessing.cpu_count() > 1:
135 config.available_features.add('multicpu')
136 except NotImplementedError:
139 # to run with icc INTEL_LICENSE_FILE must be set
140 if 'INTEL_LICENSE_FILE' in os.environ:
141 config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
143 # set default environment variables for test
144 if 'CHECK_OPENMP_ENV' in os.environ:
145 test_env = os.environ['CHECK_OPENMP_ENV'].split()
147 name = env.split('=')[0]
148 value = env.split('=')[1]
149 config.environment[name] = value
152 config.substitutions.append(("%libomp-compile-and-run", \
153 "%libomp-compile && %libomp-run"))
154 config.substitutions.append(("%libomp-irbuilder-compile-and-run", \
155 "%libomp-irbuilder-compile && %libomp-run"))
156 config.substitutions.append(("%libomp-c99-compile-and-run", \
157 "%libomp-c99-compile && %libomp-run"))
158 config.substitutions.append(("%libomp-cxx-compile-and-run", \
159 "%libomp-cxx-compile && %libomp-run"))
160 config.substitutions.append(("%libomp-cxx-compile-c", \
161 "%clangXX %openmp_flags %flags -std=c++17 -x c++ %s -o %t" + libs))
162 config.substitutions.append(("%libomp-cxx-compile", \
163 "%clangXX %openmp_flags %flags -std=c++17 %s -o %t" + libs))
164 config.substitutions.append(("%libomp-compile", \
165 "%clang %openmp_flags %flags %s -o %t" + libs))
166 config.substitutions.append(("%libomp-irbuilder-compile", \
167 "%clang %openmp_flags %flags -fopenmp-enable-irbuilder %s -o %t" + libs))
168 config.substitutions.append(("%libomp-c99-compile", \
169 "%clang %openmp_flags %flags -std=c99 %s -o %t" + libs))
170 config.substitutions.append(("%libomp-run", "%t"))
171 config.substitutions.append(("%clangXX", config.test_cxx_compiler))
172 config.substitutions.append(("%clang", config.test_c_compiler))
173 config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
174 # %flags-use-compiler-omp-h allows us to use the test compiler's omp.h file which
175 # may have different definitions of structures than our omp.h file.
176 if config.is_standalone_build and config.test_compiler_has_omp_h:
177 config.substitutions.append(("%flags-use-compiler-omp-h",
178 config.test_flags_use_compiler_omp_h))
180 # If testing the runtime within an LLVM tree, then always include omp.h
181 # directory associated with the new clang compiler.
182 config.substitutions.append(("%flags-use-compiler-omp-h",
184 config.substitutions.append(("%flags", config.test_flags))
185 config.substitutions.append(("%python", '"%s"' % (sys.executable)))
186 config.substitutions.append(("%not", config.test_not))
189 config.substitutions.append(("FileCheck", "tee %%t.out | %s" % config.test_filecheck))
190 config.substitutions.append(("%sort-threads", "sort -n -s"))
191 if config.operating_system == 'Windows':
192 # No such environment variable on Windows.
193 config.substitutions.append(("%preload-tool", "true ||"))
194 config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
195 elif config.operating_system == 'Darwin':
196 config.substitutions.append(("%preload-tool", "env DYLD_INSERT_LIBRARIES=%T/tool.so"))
197 # No such linker flag on Darwin.
198 config.substitutions.append(("%no-as-needed-flag", ""))
200 config.substitutions.append(("%preload-tool", "env LD_PRELOAD=%T/tool.so"))
201 config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
203 config.substitutions.append(("FileCheck", config.test_filecheck))