• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 re
6import subprocess
7import lit.formats
8
9# Tell pylint that we know config and lit_config exist somewhere.
10if 'PYLINT_IMPORT' in os.environ:
11    config = object()
12    lit_config = object()
13
14def append_dynamic_library_path(path):
15    if config.operating_system == 'Windows':
16        name = 'PATH'
17        sep = ';'
18    elif config.operating_system == 'Darwin':
19        name = 'DYLD_LIBRARY_PATH'
20        sep = ':'
21    else:
22        name = 'LD_LIBRARY_PATH'
23        sep = ':'
24    if name in config.environment:
25        config.environment[name] = path + sep + config.environment[name]
26    else:
27        config.environment[name] = path
28
29# name: The name of this test suite.
30config.name = 'libomp'
31
32# suffixes: A list of file extensions to treat as test files.
33config.suffixes = ['.c', '.cpp']
34
35# test_source_root: The root path where tests are located.
36config.test_source_root = os.path.dirname(__file__)
37
38# test_exec_root: The root object directory where output is placed
39config.test_exec_root = config.libomp_obj_root
40
41# test format
42config.test_format = lit.formats.ShTest()
43
44# compiler flags
45config.test_flags = " -I " + config.test_source_root + \
46    " -I " + config.omp_header_directory + \
47    " -L " + config.library_dir + \
48    " " + config.test_extra_flags
49
50# extra libraries
51libs = ""
52if config.has_libm:
53    libs += " -lm"
54if config.has_libatomic:
55    libs += " -latomic"
56
57# Allow REQUIRES / UNSUPPORTED / XFAIL to work
58config.target_triple = [ ]
59for feature in config.test_compiler_features:
60    config.available_features.add(feature)
61
62# Setup environment to find dynamic library at runtime
63append_dynamic_library_path(config.library_dir)
64if config.using_hwloc:
65    append_dynamic_library_path(config.hwloc_library_dir)
66    config.available_features.add('hwloc')
67
68# Rpath modifications for Darwin
69if config.operating_system == 'Darwin':
70    config.test_flags += " -Wl,-rpath," + config.library_dir
71    if config.using_hwloc:
72        config.test_flags += " -Wl,-rpath," + config.hwloc_library_dir
73
74# Find the SDK on Darwin
75if config.operating_system == 'Darwin':
76  cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
77                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
78  out, err = cmd.communicate()
79  out = out.strip()
80  res = cmd.wait()
81  if res == 0 and out:
82    config.test_flags += " -isysroot " + out
83
84# Disable OMPT tests if FileCheck was not found
85if config.has_ompt and config.test_filecheck == "":
86    lit_config.note("Not testing OMPT because FileCheck was not found")
87    config.has_ompt = False
88
89if config.has_ompt:
90    config.available_features.add("ompt")
91    # for callback.h
92    config.test_flags += " -I " + config.test_source_root + "/ompt"
93
94if 'Linux' in config.operating_system:
95    config.available_features.add("linux")
96
97if config.operating_system == 'NetBSD':
98    config.available_features.add("netbsd")
99
100if config.operating_system in ['Linux', 'Windows']:
101    config.available_features.add('affinity')
102
103import multiprocessing
104try:
105    if multiprocessing.cpu_count() > 1:
106        config.available_features.add('multicpu')
107except NotImplementedError:
108    pass
109
110# to run with icc INTEL_LICENSE_FILE must be set
111if 'INTEL_LICENSE_FILE' in os.environ:
112    config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
113
114# substitutions
115config.substitutions.append(("%libomp-compile-and-run", \
116    "%libomp-compile && %libomp-run"))
117config.substitutions.append(("%libomp-cxx-compile-and-run", \
118    "%libomp-cxx-compile && %libomp-run"))
119config.substitutions.append(("%libomp-cxx-compile-c", \
120    "%clangXX %openmp_flags %flags -std=c++14 -x c++ %s -o %t" + libs))
121config.substitutions.append(("%libomp-cxx-compile", \
122    "%clangXX %openmp_flags %flags -std=c++14 %s -o %t" + libs))
123config.substitutions.append(("%libomp-compile", \
124    "%clang %openmp_flags %flags %s -o %t" + libs))
125config.substitutions.append(("%libomp-run", "%t"))
126config.substitutions.append(("%clangXX", config.test_cxx_compiler))
127config.substitutions.append(("%clang", config.test_c_compiler))
128config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
129config.substitutions.append(("%flags", config.test_flags))
130config.substitutions.append(("%python", '"%s"' % (sys.executable)))
131config.substitutions.append(("%not", config.test_not))
132
133if config.has_ompt:
134    config.substitutions.append(("FileCheck", "tee %%t.out | %s" % config.test_filecheck))
135    config.substitutions.append(("%sort-threads", "sort -n -s"))
136    if config.operating_system == 'Windows':
137        # No such environment variable on Windows.
138        config.substitutions.append(("%preload-tool", "true ||"))
139        config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
140    elif config.operating_system == 'Darwin':
141        config.substitutions.append(("%preload-tool", "env DYLD_INSERT_LIBRARIES=%T/tool.so"))
142        # No such linker flag on Darwin.
143        config.substitutions.append(("%no-as-needed-flag", ""))
144    else:
145        config.substitutions.append(("%preload-tool", "env LD_PRELOAD=%T/tool.so"))
146        config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
147else:
148    config.substitutions.append(("FileCheck", config.test_filecheck))
149