xref: /llvm-project/openmp/tools/archer/tests/lit.cfg (revision 11a9ab125737e4b43a98073ccf238cef9c8501b9)
12b8115b1Sprotze@itc.rwth-aachen.de# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
22b8115b1Sprotze@itc.rwth-aachen.de# Configuration file for the 'lit' test runner.
32b8115b1Sprotze@itc.rwth-aachen.de
42b8115b1Sprotze@itc.rwth-aachen.deimport os
52b8115b1Sprotze@itc.rwth-aachen.deimport re
62b8115b1Sprotze@itc.rwth-aachen.deimport subprocess
72b8115b1Sprotze@itc.rwth-aachen.deimport lit.formats
82b8115b1Sprotze@itc.rwth-aachen.de
92b8115b1Sprotze@itc.rwth-aachen.de# Tell pylint that we know config and lit_config exist somewhere.
102b8115b1Sprotze@itc.rwth-aachen.deif 'PYLINT_IMPORT' in os.environ:
112b8115b1Sprotze@itc.rwth-aachen.de    config = object()
122b8115b1Sprotze@itc.rwth-aachen.de    lit_config = object()
132b8115b1Sprotze@itc.rwth-aachen.de
142b8115b1Sprotze@itc.rwth-aachen.dedef append_dynamic_library_path(path):
152b8115b1Sprotze@itc.rwth-aachen.de    if config.operating_system == 'Windows':
162b8115b1Sprotze@itc.rwth-aachen.de        name = 'PATH'
172b8115b1Sprotze@itc.rwth-aachen.de        sep = ';'
182b8115b1Sprotze@itc.rwth-aachen.de    elif config.operating_system == 'Darwin':
192b8115b1Sprotze@itc.rwth-aachen.de        name = 'DYLD_LIBRARY_PATH'
202b8115b1Sprotze@itc.rwth-aachen.de        sep = ':'
212b8115b1Sprotze@itc.rwth-aachen.de    else:
222b8115b1Sprotze@itc.rwth-aachen.de        name = 'LD_LIBRARY_PATH'
232b8115b1Sprotze@itc.rwth-aachen.de        sep = ':'
242b8115b1Sprotze@itc.rwth-aachen.de    if name in config.environment:
252b8115b1Sprotze@itc.rwth-aachen.de        config.environment[name] = path + sep + config.environment[name]
262b8115b1Sprotze@itc.rwth-aachen.de    else:
272b8115b1Sprotze@itc.rwth-aachen.de        config.environment[name] = path
282b8115b1Sprotze@itc.rwth-aachen.de
292b8115b1Sprotze@itc.rwth-aachen.de# name: The name of this test suite.
302b8115b1Sprotze@itc.rwth-aachen.deconfig.name = 'libarcher'
312b8115b1Sprotze@itc.rwth-aachen.de
322b8115b1Sprotze@itc.rwth-aachen.de# suffixes: A list of file extensions to treat as test files.
332b8115b1Sprotze@itc.rwth-aachen.deconfig.suffixes = ['.c', '.cpp']
342b8115b1Sprotze@itc.rwth-aachen.de
352b8115b1Sprotze@itc.rwth-aachen.de# test_source_root: The root path where tests are located.
362b8115b1Sprotze@itc.rwth-aachen.deconfig.test_source_root = os.path.dirname(__file__)
372b8115b1Sprotze@itc.rwth-aachen.de
382b8115b1Sprotze@itc.rwth-aachen.de# test_exec_root: The root object directory where output is placed
392b8115b1Sprotze@itc.rwth-aachen.deconfig.test_exec_root = config.libarcher_obj_root
402b8115b1Sprotze@itc.rwth-aachen.de
412b8115b1Sprotze@itc.rwth-aachen.de# test format
422b8115b1Sprotze@itc.rwth-aachen.deconfig.test_format = lit.formats.ShTest()
432b8115b1Sprotze@itc.rwth-aachen.de
442b8115b1Sprotze@itc.rwth-aachen.de# compiler flags
452b8115b1Sprotze@itc.rwth-aachen.deconfig.test_flags = " -I " + config.test_source_root + \
462b8115b1Sprotze@itc.rwth-aachen.de    " -I " + config.omp_header_dir + \
472b8115b1Sprotze@itc.rwth-aachen.de    " -L " + config.omp_library_dir + \
482b8115b1Sprotze@itc.rwth-aachen.de    " -Wl,-rpath," + config.omp_library_dir + \
491eaebe19SHan Zhu    " " + config.test_archer_flags + \
501eaebe19SHan Zhu    " " + config.test_extra_flags
512b8115b1Sprotze@itc.rwth-aachen.de
520fd5f696SJoachim Protzeconfig.archer_flags = "-gdwarf-4 -O1 -fsanitize=thread"
532b8115b1Sprotze@itc.rwth-aachen.de
542b8115b1Sprotze@itc.rwth-aachen.de
552b8115b1Sprotze@itc.rwth-aachen.de# extra libraries
562b8115b1Sprotze@itc.rwth-aachen.delibs = ""
572b8115b1Sprotze@itc.rwth-aachen.deif config.has_libatomic:
582b8115b1Sprotze@itc.rwth-aachen.de    libs += " -latomic"
592b8115b1Sprotze@itc.rwth-aachen.de
602b8115b1Sprotze@itc.rwth-aachen.de# Allow XFAIL to work
612b8115b1Sprotze@itc.rwth-aachen.deconfig.target_triple = [ ]
622b8115b1Sprotze@itc.rwth-aachen.defor feature in config.test_compiler_features:
632b8115b1Sprotze@itc.rwth-aachen.de    config.available_features.add(feature)
642b8115b1Sprotze@itc.rwth-aachen.de
652b8115b1Sprotze@itc.rwth-aachen.de# Setup environment to find dynamic library at runtime
662b8115b1Sprotze@itc.rwth-aachen.deappend_dynamic_library_path(config.omp_library_dir)
6784637408SJoachim Protzeappend_dynamic_library_path(config.libarcher_obj_root+"/..")
682b8115b1Sprotze@itc.rwth-aachen.de
692b8115b1Sprotze@itc.rwth-aachen.de# Rpath modifications for Darwin
702b8115b1Sprotze@itc.rwth-aachen.deif config.operating_system == 'Darwin':
712b8115b1Sprotze@itc.rwth-aachen.de    config.test_flags += " -Wl,-rpath," + config.omp_library_dir
722b8115b1Sprotze@itc.rwth-aachen.de
732b8115b1Sprotze@itc.rwth-aachen.de# Find the SDK on Darwin
742b8115b1Sprotze@itc.rwth-aachen.deif config.operating_system == 'Darwin':
752b8115b1Sprotze@itc.rwth-aachen.de  cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
762b8115b1Sprotze@itc.rwth-aachen.de                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
772b8115b1Sprotze@itc.rwth-aachen.de  out, err = cmd.communicate()
782b8115b1Sprotze@itc.rwth-aachen.de  out = out.strip()
792b8115b1Sprotze@itc.rwth-aachen.de  res = cmd.wait()
802b8115b1Sprotze@itc.rwth-aachen.de  if res == 0 and out:
812b8115b1Sprotze@itc.rwth-aachen.de    config.test_flags += " -isysroot " + out
822b8115b1Sprotze@itc.rwth-aachen.de
832b8115b1Sprotze@itc.rwth-aachen.deif 'Linux' in config.operating_system:
842b8115b1Sprotze@itc.rwth-aachen.de    config.available_features.add("linux")
852b8115b1Sprotze@itc.rwth-aachen.de
86*11a9ab12SEisuke Kawashimaif config.has_tsan:
8784637408SJoachim Protze    config.available_features.add("tsan")
8884637408SJoachim Protze
892b8115b1Sprotze@itc.rwth-aachen.de# to run with icc INTEL_LICENSE_FILE must be set
902b8115b1Sprotze@itc.rwth-aachen.deif 'INTEL_LICENSE_FILE' in os.environ:
912b8115b1Sprotze@itc.rwth-aachen.de    config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
922b8115b1Sprotze@itc.rwth-aachen.de
9381bc7cf6SJoachim Jenke# set default environment variables for test
9481bc7cf6SJoachim Jenkeif 'CHECK_OPENMP_ENV' in os.environ:
9581bc7cf6SJoachim Jenke    test_env = os.environ['CHECK_OPENMP_ENV'].split()
9681bc7cf6SJoachim Jenke    for env in test_env:
9781bc7cf6SJoachim Jenke        name = env.split('=')[0]
9881bc7cf6SJoachim Jenke        value = env.split('=')[1]
9981bc7cf6SJoachim Jenke        config.environment[name] = value
10081bc7cf6SJoachim Jenke
10108d8f1a9SJoachim Protzeconfig.environment['ARCHER_OPTIONS'] = "report_data_leak=1"
10208d8f1a9SJoachim Protze
1032b8115b1Sprotze@itc.rwth-aachen.de# Race Tests
104fdc9dfc8SJoachim Protzeconfig.substitutions.append(("%libarcher-compile-and-run-race-noserial", \
10508d8f1a9SJoachim Protze    "%%libarcher-compile && env ARCHER_OPTIONS=\"ignore_serial=1 %s\" %%libarcher-run-race" \
10608d8f1a9SJoachim Protze    % config.environment['ARCHER_OPTIONS']))
1072b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%libarcher-compile-and-run-race", \
1082b8115b1Sprotze@itc.rwth-aachen.de    "%libarcher-compile && %libarcher-run-race"))
10923419bfdSJoachim Protzeconfig.substitutions.append(("%libarcher-compile-and-run-nosuppression", \
11023419bfdSJoachim Protze                             "%libarcher-compile && %libarcher-run-nosuppression"))
1112b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%libarcher-compile-and-run", \
1122b8115b1Sprotze@itc.rwth-aachen.de                             "%libarcher-compile && %libarcher-run"))
1132b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%libarcher-cxx-compile-and-run", \
1142b8115b1Sprotze@itc.rwth-aachen.de    "%libarcher-cxx-compile && %libarcher-run"))
1152b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%libarcher-cxx-compile", \
116af28b27dSRon Lieberman    "%clang-archerXX %openmp_flags %archer_flags %flags -std=c++17 %s -o %t" + libs))
1172b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%libarcher-compile", \
1182b8115b1Sprotze@itc.rwth-aachen.de                             "%clang-archer %openmp_flags %archer_flags %flags %s -o %t" + libs))
1192b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%libarcher-run-race", "%suppression %deflake %t 2>&1 | tee %t.log"))
12023419bfdSJoachim Protzeconfig.substitutions.append(("%libarcher-run-nosuppression", "%nosuppression %t 2>&1 | tee %t.log"))
1212b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%libarcher-run", "%suppression %t 2>&1 | tee %t.log"))
1222b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%clang-archerXX", config.test_cxx_compiler))
1232b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%clang-archer", config.test_c_compiler))
1242b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%openmp_flags", config.test_openmp_flags))
1252b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%archer_flags", config.archer_flags))
1262b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%flags", config.test_flags))
12769f87400SJoachim Protzeconfig.substitutions.append(("%nosuppression", "env TSAN_OPTIONS='ignore_noninstrumented_modules=0:exitcode=0'"))
12823419bfdSJoachim Protzeconfig.substitutions.append(("%suppression", "env TSAN_OPTIONS='ignore_noninstrumented_modules=0:ignore_noninstrumented_modules=1'"))
1292b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%deflake", os.path.join(os.path.dirname(__file__), "deflake.bash")))
1302b8115b1Sprotze@itc.rwth-aachen.de
1312b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("FileCheck", config.test_filecheck))
132dd5ba4b5SJoel E. Dennyconfig.substitutions.append(("%not", config.test_not))
1332b8115b1Sprotze@itc.rwth-aachen.deconfig.substitutions.append(("%sort-threads", "sort --numeric-sort --stable"))
1342b8115b1Sprotze@itc.rwth-aachen.deif config.operating_system == 'Windows':
1352b8115b1Sprotze@itc.rwth-aachen.de    # No such environment variable on Windows.
1362b8115b1Sprotze@itc.rwth-aachen.de    config.substitutions.append(("%preload-tool", "true ||"))
1372b8115b1Sprotze@itc.rwth-aachen.deelif config.operating_system == 'Darwin':
1382b8115b1Sprotze@itc.rwth-aachen.de    config.substitutions.append(("%preload-tool", "env DYLD_INSERT_LIBRARIES=%T/tool.so"))
1392b8115b1Sprotze@itc.rwth-aachen.deelse:
1402b8115b1Sprotze@itc.rwth-aachen.de    config.substitutions.append(("%preload-tool", "env LD_PRELOAD=%T/tool.so"))
141