blob: cf63e660920f1dd8a0d244f1839ddedc56c4ab96 [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
Hans Wennborg464307f2016-01-19 19:26:43 +00005import subprocess
Jonathan Peyton614c7ef2015-09-21 20:41:31 +00006import lit.formats
7
8# Tell pylint that we know config and lit_config exist somewhere.
9if 'PYLINT_IMPORT' in os.environ:
10 config = object()
11 lit_config = object()
12
Jonathan Peyton01dcf362015-11-30 20:02:59 +000013def append_dynamic_library_path(path):
14 if config.operating_system == 'Windows':
15 name = 'PATH'
16 sep = ';'
17 elif config.operating_system == 'Darwin':
18 name = 'DYLD_LIBRARY_PATH'
19 sep = ':'
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000020 else:
Jonathan Peyton01dcf362015-11-30 20:02:59 +000021 name = 'LD_LIBRARY_PATH'
22 sep = ':'
23 if name in config.environment:
24 config.environment[name] = path + sep + config.environment[name]
25 else:
26 config.environment[name] = path
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000027
28# name: The name of this test suite.
29config.name = 'libomp'
30
31# suffixes: A list of file extensions to treat as test files.
32config.suffixes = ['.c']
33
34# test_source_root: The root path where tests are located.
35config.test_source_root = os.path.dirname(__file__)
36
37# test_exec_root: The root object directory where output is placed
38config.test_exec_root = config.libomp_obj_root
39
40# test format
41config.test_format = lit.formats.ShTest()
42
43# compiler flags
44config.test_cflags = config.test_openmp_flag + \
45 " -I " + config.test_source_root + \
46 " -I " + config.omp_header_directory + \
47 " -L " + config.library_dir + \
48 " " + config.test_extra_cflags
49
50# Setup environment to find dynamic library at runtime
Jonathan Peyton01dcf362015-11-30 20:02:59 +000051append_dynamic_library_path(config.library_dir)
52if config.using_hwloc:
53 append_dynamic_library_path(config.hwloc_library_dir)
54
55# Rpath modifications for Darwin
56if config.operating_system == 'Darwin':
Jonathan Peyton5a60bc52015-09-24 15:09:51 +000057 config.test_cflags += " -Wl,-rpath," + config.library_dir
Jonathan Peyton01dcf362015-11-30 20:02:59 +000058 if config.using_hwloc:
59 config.test_cflags += " -Wl,-rpath," + config.hwloc_library_dir
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000060
Hans Wennborg464307f2016-01-19 19:26:43 +000061# Find the SDK on Darwin
62if config.operating_system == 'Darwin':
63 cmd = subprocess.Popen(['xcrun', '--show-sdk-path'],
64 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
65 out, err = cmd.communicate()
66 out = out.strip()
67 res = cmd.wait()
68 if res == 0 and out:
69 config.test_cflags += " -isysroot " + out
70
Jonas Hahnfeldc8043012016-03-22 07:22:49 +000071# Disable OMPT tests if FileCheck was not found
72if config.has_ompt and config.test_filecheck == "":
73 lit_config.note("Not testing OMPT because FileCheck was not found")
74 config.has_ompt = False
75
76if config.has_ompt:
77 config.available_features.add("ompt")
78 if config.has_ompt_trace:
79 config.available_features.add("ompt-trace")
80 # for callback.h
81 config.test_cflags += " -I " + config.test_source_root + "/ompt"
82
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000083# substitutions
Jonas Hahnfeldc8043012016-03-22 07:22:49 +000084if config.has_ompt:
85 config.substitutions.append(("FileCheck", config.test_filecheck))
86 config.substitutions.append(("%sort-threads", "sort --numeric-sort --stable"))
87
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000088config.substitutions.append(("%libomp-compile-and-run", \
Jonathan Peyton28510722016-02-25 18:04:09 +000089 "%libomp-compile && %libomp-run"))
90config.substitutions.append(("%libomp-compile", \
91 "%clang %cflags %s -o %t -lm"))
92config.substitutions.append(("%libomp-run", "%t"))
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000093config.substitutions.append(("%clang", config.test_compiler))
94config.substitutions.append(("%openmp_flag", config.test_openmp_flag))
95config.substitutions.append(("%cflags", config.test_cflags))
96