Debian Codegraph @

openmp/tools/archer/tests/lit.cfg

raw
1 # -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
2 # Configuration file for the 'lit' test runner.
3
4 import os
5 import re
6 import subprocess
7 import lit.formats
8
9 # Tell pylint that we know config and lit_config exist somewhere.
10 if 'PYLINT_IMPORT' in os.environ:
11 config = object()
12 lit_config = object()
13
14 def get_path_separator():
15 return ';' if config.operating_system == 'Windows' else ':'
16
17 def append_dynamic_library_path(path):
18 if config.operating_system == 'Windows':
19 name = 'PATH'
20 elif config.operating_system == 'Darwin':
21 name = 'DYLD_LIBRARY_PATH'
22 else:
23 name = 'LD_LIBRARY_PATH'
24 sep = get_path_separator()
25 if name in config.environment:
26 config.environment[name] = path + sep + config.environment[name]
27 else:
28 config.environment[name] = path
29
30 def append_path(path):
31 name = 'PATH'
32 sep = get_path_separator()
33 if name in config.environment:
34 config.environment[name] = config.environment[name] + sep + path
35 else:
36 config.environment[name] = path
37
38 # name: The name of this test suite.
39 config.name = 'libarcher'
40
41 # suffixes: A list of file extensions to treat as test files.
42 config.suffixes = ['.c', '.cpp']
43
44 # test_source_root: The root path where tests are located.
45 config.test_source_root = os.path.dirname(__file__)
46
47 # test_exec_root: The root object directory where output is placed
48 config.test_exec_root = config.libarcher_obj_root
49
50 # test format
51 config.test_format = lit.formats.ShTest()
52
53 # compiler flags
54 config.test_flags = " -I " + config.test_source_root + \
55 " -I " + config.omp_header_dir + \
56 " -L " + config.omp_library_dir + \
57 " -Wl,-rpath," + config.omp_library_dir + \
58 " " + config.test_archer_flags + \
59 " " + config.test_extra_flags
60
61 config.archer_flags = "-gdwarf-4 -O1 -fsanitize=thread"
62
63
64 # extra libraries
65 libs = ""
66 if config.has_libatomic:
67 libs += " -latomic"
68
69 # Allow XFAIL to work
70 for feature in config.test_compiler_features:
71 config.available_features.add(feature)
72
73 # Setup environment to find dynamic library at runtime
74 append_dynamic_library_path(config.omp_library_dir)
75 append_dynamic_library_path(config.libarcher_obj_root+"/..")
76
77 # Add LLVM bin dir to PATH.
78 # llvm-symbolizer is needed to correctly resolve addresses, without relying on
79 # system's addr2line.
80 append_path(os.path.dirname(config.test_c_compiler))
81
82 # Rpath modifications for Darwin
83 if config.operating_system == 'Darwin':
84 config.test_flags += " -Wl,-rpath," + config.omp_library_dir
85
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()
92 res = cmd.wait()
93 if res == 0 and out:
94 config.test_flags += " -isysroot " + out
95
96 if 'Linux' in config.operating_system:
97 config.available_features.add("linux")
98
99 if config.has_tsan:
100 config.available_features.add("tsan")
101
102 # to run with icc INTEL_LICENSE_FILE must be set
103 if 'INTEL_LICENSE_FILE' in os.environ:
104 config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
105
106 # set default environment variables for test
107 if 'CHECK_OPENMP_ENV' in os.environ:
108 test_env = os.environ['CHECK_OPENMP_ENV'].split()
109 for env in test_env:
110 name = env.split('=')[0]
111 value = env.split('=')[1]
112 config.environment[name] = value
113
114 config.environment['ARCHER_OPTIONS'] = "report_data_leak=1"
115
116 # Race Tests
117 config.substitutions.append(("%libarcher-compile-and-run-race-noserial", \
118 "%%libarcher-compile && env ARCHER_OPTIONS=\"ignore_serial=1 %s\" %%libarcher-run-race" \
119 % config.environment['ARCHER_OPTIONS']))
120 config.substitutions.append(("%libarcher-compile-and-run-race", \
121 "%libarcher-compile && %libarcher-run-race"))
122 config.substitutions.append(("%libarcher-compile-and-run-nosuppression", \
123 "%libarcher-compile && %libarcher-run-nosuppression"))
124 config.substitutions.append(("%libarcher-compile-and-run", \
125 "%libarcher-compile && %libarcher-run"))
126 config.substitutions.append(("%libarcher-cxx-compile-and-run", \
127 "%libarcher-cxx-compile && %libarcher-run"))
128 config.substitutions.append(("%libarcher-cxx-compile", \
129 "%clang-archerXX %openmp_flags %archer_flags %flags -std=c++17 %s -o %t" + libs))
130 config.substitutions.append(("%libarcher-compile", \
131 "%clang-archer %openmp_flags %archer_flags %flags %s -o %t" + libs))
132 config.substitutions.append(("%libarcher-run-race", "%suppression %deflake %t 2>&1 | tee %t.log"))
133 config.substitutions.append(("%libarcher-run-nosuppression", "%nosuppression %t 2>&1 | tee %t.log"))
134 config.substitutions.append(("%libarcher-run", "%suppression %t 2>&1 | tee %t.log"))
135 config.substitutions.append(("%clang-archerXX", config.test_cxx_compiler))
136 config.substitutions.append(("%clang-archer", config.test_c_compiler))
137 config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
138 config.substitutions.append(("%archer_flags", config.archer_flags))
139 config.substitutions.append(("%flags", config.test_flags))
140 config.substitutions.append(("%nosuppression", "env TSAN_OPTIONS='ignore_noninstrumented_modules=0:exitcode=0'"))
141 config.substitutions.append(("%suppression", "env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1'"))
142 config.substitutions.append(("%deflake", os.path.join(os.path.dirname(__file__), "deflake.bash")))
143
144 config.substitutions.append(("FileCheck", config.test_filecheck))
145 config.substitutions.append(("%not", config.test_not))
146 config.substitutions.append(("%sort-threads", "sort --numeric-sort --stable"))