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"
55 config.test_flags = " -I " + config.omp_header_directory + flags
56 config.test_flags_use_compiler_omp_h = flags
63 if config.has_libatomic:
66 # Allow REQUIRES / UNSUPPORTED / XFAIL to work
67 config.target_triple = [ ]
68 for feature in config.test_compiler_features:
69 config.available_features.add(feature)
71 # Setup environment to find dynamic library at runtime
72 if config.using_hwloc:
73 prepend_dynamic_library_path(config.hwloc_library_dir)
74 config.available_features.add('hwloc')
75 # Note: please keep config.library_dir *after* any potentially system
76 # directories, as otherwise preinstalled openmp libraries will be used
78 prepend_dynamic_library_path(config.library_dir)
80 # Rpath modifications for Darwin
81 if config.operating_system == 'Darwin':
82 config.test_flags += " -Wl,-rpath," + config.library_dir
83 if config.using_hwloc:
84 config.test_flags += " -Wl,-rpath," + config.hwloc_library_dir
86 # Find the SDK on Darwin
87 if config.operating_system == 'Darwin':
88 cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
89 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
90 out, err = cmd.communicate()
91 out = out.strip().decode()
94 config.test_flags += " -isysroot " + out
96 # Disable OMPT tests if FileCheck was not found
97 if config.has_ompt and config.test_filecheck == "":
98 lit_config.note("Not testing OMPT because FileCheck was not found")
99 config.has_ompt = False
102 config.available_features.add("ompt")
104 config.test_flags += " -I " + config.test_source_root + "/ompt"
106 if config.has_ompx_taskgraph:
107 config.available_features.add("ompx_taskgraph")
109 if 'Linux' in config.operating_system:
110 config.available_features.add("linux")
112 if config.operating_system == 'NetBSD':
113 config.available_features.add("netbsd")
115 if config.operating_system == 'Darwin':
116 config.available_features.add("darwin")
118 if config.operating_system in ['Linux', 'Windows']:
119 config.available_features.add('affinity')
121 if config.operating_system in ['Linux']:
122 config.available_features.add('hidden-helper')
124 target_arch = getattr(config, 'target_arch', None)
126 config.available_features.add(target_arch + '-target-arch')
127 if target_arch in ['x86_64', 'i386']:
128 config.available_features.add('x86-target-arch')
130 import multiprocessing
132 if multiprocessing.cpu_count() > 1:
133 config.available_features.add('multicpu')
134 except NotImplementedError:
137 # to run with icc INTEL_LICENSE_FILE must be set
138 if 'INTEL_LICENSE_FILE' in os.environ:
139 config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
141 # set default environment variables for test
142 if 'CHECK_OPENMP_ENV' in os.environ:
143 test_env = os.environ['CHECK_OPENMP_ENV'].split()
145 name = env.split('=')[0]
146 value = env.split('=')[1]
147 config.environment[name] = value
150 config.substitutions.append(("%libomp-compile-and-run", \
151 "%libomp-compile && %libomp-run"))
152 config.substitutions.append(("%libomp-irbuilder-compile-and-run", \
153 "%libomp-irbuilder-compile && %libomp-run"))
154 config.substitutions.append(("%libomp-c99-compile-and-run", \
155 "%libomp-c99-compile && %libomp-run"))
156 config.substitutions.append(("%libomp-cxx-compile-and-run", \
157 "%libomp-cxx-compile && %libomp-run"))
158 config.substitutions.append(("%libomp-cxx-compile-c", \
159 "%clangXX %openmp_flags %flags -std=c++17 -x c++ %s -o %t" + libs))
160 config.substitutions.append(("%libomp-cxx-compile", \
161 "%clangXX %openmp_flags %flags -std=c++17 %s -o %t" + libs))
162 config.substitutions.append(("%libomp-compile", \
163 "%clang %openmp_flags %flags %s -o %t" + libs))
164 config.substitutions.append(("%libomp-irbuilder-compile", \
165 "%clang %openmp_flags %flags -fopenmp-enable-irbuilder %s -o %t" + libs))
166 config.substitutions.append(("%libomp-c99-compile", \
167 "%clang %openmp_flags %flags -std=c99 %s -o %t" + libs))
168 config.substitutions.append(("%libomp-run", "%t"))
169 config.substitutions.append(("%clangXX", config.test_cxx_compiler))
170 config.substitutions.append(("%clang", config.test_c_compiler))
171 config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
172 # %flags-use-compiler-omp-h allows us to use the test compiler's omp.h file which
173 # may have different definitions of structures than our omp.h file.
174 if config.is_standalone_build and config.test_compiler_has_omp_h:
175 config.substitutions.append(("%flags-use-compiler-omp-h",
176 config.test_flags_use_compiler_omp_h))
178 # If testing the runtime within an LLVM tree, then always include omp.h
179 # directory associated with the new clang compiler.
180 config.substitutions.append(("%flags-use-compiler-omp-h",
182 config.substitutions.append(("%flags", config.test_flags))
183 config.substitutions.append(("%python", '"%s"' % (sys.executable)))
184 config.substitutions.append(("%not", config.test_not))
187 config.substitutions.append(("FileCheck", "tee %%t.out | %s" % config.test_filecheck))
188 config.substitutions.append(("%sort-threads", "sort -n -s"))
189 if config.operating_system == 'Windows':
190 # No such environment variable on Windows.
191 config.substitutions.append(("%preload-tool", "true ||"))
192 config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
193 elif config.operating_system == 'Darwin':
194 config.substitutions.append(("%preload-tool", "env DYLD_INSERT_LIBRARIES=%T/tool.so"))
195 # No such linker flag on Darwin.
196 config.substitutions.append(("%no-as-needed-flag", ""))
198 config.substitutions.append(("%preload-tool", "env LD_PRELOAD=%T/tool.so"))
199 config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
201 config.substitutions.append(("FileCheck", config.test_filecheck))