blob: 9e08584c790e59ffc4e9cf57e540b5720c486150 [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
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000071# substitutions
72config.substitutions.append(("%libomp-compile-and-run", \
Jonathan Peyton28510722016-02-25 18:04:09 +000073 "%libomp-compile && %libomp-run"))
74config.substitutions.append(("%libomp-compile", \
75 "%clang %cflags %s -o %t -lm"))
76config.substitutions.append(("%libomp-run", "%t"))
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000077config.substitutions.append(("%clang", config.test_compiler))
78config.substitutions.append(("%openmp_flag", config.test_openmp_flag))
79config.substitutions.append(("%cflags", config.test_cflags))
80