blob: 655e8d6a6bbabf93e0610254eca779171afd662b [file] [log] [blame]
Jonathan Peyton614c7ef2015-09-21 20:41:31 +00001# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
2# Configuration file for the 'lit' test runner.
3
4import os
Jonas Hahnfelde46a4942016-03-24 12:52:20 +00005import re
Hans Wennborg464307f2016-01-19 19:26:43 +00006import subprocess
Jonathan Peyton614c7ef2015-09-21 20:41:31 +00007import 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
Jonathan Peyton01dcf362015-11-30 20:02:59 +000014def 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 = ':'
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000021 else:
Jonathan Peyton01dcf362015-11-30 20:02:59 +000022 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
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000028
29# name: The name of this test suite.
30config.name = 'libomp'
31
32# suffixes: A list of file extensions to treat as test files.
Jonathan Peyton16a05bc2017-10-20 19:42:32 +000033config.suffixes = ['.c', '.cpp']
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000034
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_cflags = config.test_openmp_flag + \
46 " -I " + config.test_source_root + \
47 " -I " + config.omp_header_directory + \
48 " -L " + config.library_dir + \
49 " " + config.test_extra_cflags
50
Jonathan Peyton1ab887d2016-05-23 17:50:32 +000051# extra libraries
52libs = ""
53if config.has_libm:
54 libs += " -lm"
Michal Gorny018d1352017-02-24 22:15:24 +000055if config.has_libatomic:
56 libs += " -latomic"
Jonathan Peyton1ab887d2016-05-23 17:50:32 +000057
Jonas Hahnfelde46a4942016-03-24 12:52:20 +000058# Allow XFAIL to work
59config.target_triple = [ ]
60if re.search('gcc', config.test_compiler) is not None:
61 config.available_features.add('gcc')
62
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000063# Setup environment to find dynamic library at runtime
Jonathan Peyton01dcf362015-11-30 20:02:59 +000064append_dynamic_library_path(config.library_dir)
65if config.using_hwloc:
66 append_dynamic_library_path(config.hwloc_library_dir)
Jonathan Peytone3e2aaf2017-05-31 20:35:22 +000067 config.available_features.add('hwloc')
Jonathan Peyton01dcf362015-11-30 20:02:59 +000068
69# Rpath modifications for Darwin
70if config.operating_system == 'Darwin':
Jonathan Peyton5a60bc52015-09-24 15:09:51 +000071 config.test_cflags += " -Wl,-rpath," + config.library_dir
Jonathan Peyton01dcf362015-11-30 20:02:59 +000072 if config.using_hwloc:
73 config.test_cflags += " -Wl,-rpath," + config.hwloc_library_dir
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000074
Hans Wennborg464307f2016-01-19 19:26:43 +000075# Find the SDK on Darwin
76if config.operating_system == 'Darwin':
77 cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
78 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
79 out, err = cmd.communicate()
80 out = out.strip()
81 res = cmd.wait()
82 if res == 0 and out:
83 config.test_cflags += " -isysroot " + out
84
Jonas Hahnfeldc8043012016-03-22 07:22:49 +000085# Disable OMPT tests if FileCheck was not found
86if config.has_ompt and config.test_filecheck == "":
87 lit_config.note("Not testing OMPT because FileCheck was not found")
88 config.has_ompt = False
89
90if config.has_ompt:
91 config.available_features.add("ompt")
Jonas Hahnfeldc8043012016-03-22 07:22:49 +000092 # for callback.h
93 config.test_cflags += " -I " + config.test_source_root + "/ompt"
94
Joachim Protze82e94a52017-11-01 10:08:30 +000095if 'Linux' in config.operating_system:
96 config.available_features.add("linux")
97
Jonathan Peyton48db80c2017-10-20 19:45:43 +000098# to run with icc INTEL_LICENSE_FILE must be set
99if 'INTEL_LICENSE_FILE' in os.environ:
100 config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE']
101
Jonas Hahnfeldc8043012016-03-22 07:22:49 +0000102
Joachim Protze82e94a52017-11-01 10:08:30 +0000103# substitutions
Jonathan Peyton614c7ef2015-09-21 20:41:31 +0000104config.substitutions.append(("%libomp-compile-and-run", \
Jonathan Peyton28510722016-02-25 18:04:09 +0000105 "%libomp-compile && %libomp-run"))
Jonathan Peyton16a05bc2017-10-20 19:42:32 +0000106config.substitutions.append(("%libomp-cxx-compile-and-run", \
107 "%libomp-cxx-compile && %libomp-run"))
108config.substitutions.append(("%libomp-cxx-compile", \
109 "%clangXX %cflags -std=c++11 %s -o %t" + libs))
Jonathan Peyton28510722016-02-25 18:04:09 +0000110config.substitutions.append(("%libomp-compile", \
Jonathan Peyton1ab887d2016-05-23 17:50:32 +0000111 "%clang %cflags %s -o %t" + libs))
Joachim Protze82e94a52017-11-01 10:08:30 +0000112config.substitutions.append(("%libomp-tool", \
113 "%clang %cflags -shared -fPIC -o %T/tool.so" + libs))
Jonathan Peyton28510722016-02-25 18:04:09 +0000114config.substitutions.append(("%libomp-run", "%t"))
Jonathan Peyton16a05bc2017-10-20 19:42:32 +0000115config.substitutions.append(("%clangXX", config.test_cxx_compiler))
Jonathan Peyton614c7ef2015-09-21 20:41:31 +0000116config.substitutions.append(("%clang", config.test_compiler))
117config.substitutions.append(("%openmp_flag", config.test_openmp_flag))
118config.substitutions.append(("%cflags", config.test_cflags))
119
Joachim Protze82e94a52017-11-01 10:08:30 +0000120if config.has_ompt:
121 config.substitutions.append(("FileCheck", config.test_filecheck))
122 config.substitutions.append(("%sort-threads", "sort --numeric-sort --stable"))