blob: f7e533b104951df38eee65783d720469b9938002 [file] [log] [blame]
George Rokos2467df62017-01-25 21:27:24 +00001# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
2# Configuration file for the 'lit' test runner.
3
4import os
5import lit.formats
6
7# Tell pylint that we know config and lit_config exist somewhere.
8if 'PYLINT_IMPORT' in os.environ:
9 config = object()
10 lit_config = object()
11
12def append_dynamic_library_path(name, value, sep):
13 if name in config.environment:
14 config.environment[name] = value + sep + config.environment[name]
15 else:
16 config.environment[name] = value
17
18# name: The name of this test suite.
19config.name = 'libomptarget'
20
21# suffixes: A list of file extensions to treat as test files.
22config.suffixes = ['.c', '.cpp', '.cc']
23
24# test_source_root: The root path where tests are located.
25config.test_source_root = os.path.dirname(__file__)
26
27# test_exec_root: The root object directory where output is placed
28config.test_exec_root = config.libomptarget_obj_root
29
30# test format
31config.test_format = lit.formats.ShTest()
32
33# compiler flags
34config.test_cflags = config.test_openmp_flag + \
35 " -I " + config.test_source_root + \
36 " -I " + config.omp_header_directory + \
37 " -L " + config.library_dir;
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000038
George Rokos2467df62017-01-25 21:27:24 +000039if config.omp_host_rtl_directory:
40 config.test_cflags = config.test_cflags + " -L " + \
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000041 config.omp_host_rtl_directory
42
George Rokos2467df62017-01-25 21:27:24 +000043config.test_cflags = config.test_cflags + " " + config.test_extra_cflags
44
Sergey Dmitrievb305d262017-08-14 15:09:59 +000045if config.libomptarget_debug:
46 config.available_features.add('libomptarget-debug')
47
George Rokos2467df62017-01-25 21:27:24 +000048# Setup environment to find dynamic library at runtime
49if config.operating_system == 'Windows':
50 append_dynamic_library_path('PATH', config.library_dir, ";")
51 append_dynamic_library_path('PATH', config.omp_host_rtl_directory, ";")
52elif config.operating_system == 'Darwin':
53 append_dynamic_library_path('DYLD_LIBRARY_PATH', config.library_dir, ":")
54 append_dynamic_library_path('DYLD_LIBRARY_PATH', \
55 config.omp_host_rtl_directory, ";")
56 config.test_cflags += " -Wl,-rpath," + config.library_dir
57 config.test_cflags += " -Wl,-rpath," + config.omp_host_rtl_directory
58else: # Unices
59 append_dynamic_library_path('LD_LIBRARY_PATH', config.library_dir, ":")
60 append_dynamic_library_path('LD_LIBRARY_PATH', \
61 config.omp_host_rtl_directory, ":")
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000062
George Rokos2467df62017-01-25 21:27:24 +000063# substitutions
64# - for targets that exist in the system create the actual command.
65# - for valid targets that do not exist in the system, return false, so that the
66# same test can be used for different targets.
67
68# Scan all the valid targets.
69for libomptarget_target in config.libomptarget_all_targets:
70 # Is this target in the current system? If so create a compile, run and test
71 # command. Otherwise create command that return false.
72 if libomptarget_target in config.libomptarget_system_targets:
73 config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
74 libomptarget_target, \
75 "%libomptarget-compilexx-and-run-" + libomptarget_target + \
76 " | " + config.libomptarget_filecheck + " %s"))
77 config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
78 libomptarget_target, \
79 "%libomptarget-compile-and-run-" + libomptarget_target + \
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000080 " | " + config.libomptarget_filecheck + " %s"))
George Rokos2467df62017-01-25 21:27:24 +000081 config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
82 libomptarget_target, \
Sergey Dmitrievb305d262017-08-14 15:09:59 +000083 "%libomptarget-compilexx-" + libomptarget_target + " && " + \
84 "%libomptarget-run-" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +000085 config.substitutions.append(("%libomptarget-compile-and-run-" + \
86 libomptarget_target, \
Sergey Dmitrievb305d262017-08-14 15:09:59 +000087 "%libomptarget-compile-" + libomptarget_target + " && " + \
88 "%libomptarget-run-" + libomptarget_target))
89 config.substitutions.append(("%libomptarget-compilexx-" + \
90 libomptarget_target, \
91 "%clangxx-" + libomptarget_target + " %s -o %t-" + \
92 libomptarget_target))
93 config.substitutions.append(("%libomptarget-compile-" + \
94 libomptarget_target, \
George Rokos2467df62017-01-25 21:27:24 +000095 "%clang-" + libomptarget_target + " %s -o %t-" + \
Sergey Dmitrievb305d262017-08-14 15:09:59 +000096 libomptarget_target))
97 config.substitutions.append(("%libomptarget-run-" + \
98 libomptarget_target, \
99 "%t-" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +0000100 config.substitutions.append(("%clangxx-" + libomptarget_target, \
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +0000101 "%clangxx %cflags -fopenmp-targets=" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +0000102 config.substitutions.append(("%clang-" + libomptarget_target, \
103 "%clang %cflags -fopenmp-targets=" + libomptarget_target))
104 config.substitutions.append(("%fcheck-" + libomptarget_target, \
105 config.libomptarget_filecheck + " %s"))
106 else:
107 config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
108 libomptarget_target, \
109 "echo ignored-command"))
110 config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
111 libomptarget_target, \
112 "echo ignored-command"))
113 config.substitutions.append(("%libomptarget-compile-and-run-" + \
114 libomptarget_target, \
115 "echo ignored-command"))
116 config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
117 libomptarget_target, \
118 "echo ignored-command"))
Sergey Dmitrievb305d262017-08-14 15:09:59 +0000119 config.substitutions.append(("%libomptarget-compilexx-" + \
120 libomptarget_target, \
121 "echo ignored-command"))
122 config.substitutions.append(("%libomptarget-compile-" + \
123 libomptarget_target, \
124 "echo ignored-command"))
125 config.substitutions.append(("%libomptarget-run-" + \
126 libomptarget_target, \
127 "echo ignored-command"))
George Rokos2467df62017-01-25 21:27:24 +0000128 config.substitutions.append(("%clang-" + libomptarget_target, \
129 "echo ignored-command"))
130 config.substitutions.append(("%clangxx-" + libomptarget_target, \
131 "echo ignored-command"))
132 config.substitutions.append(("%fcheck-" + libomptarget_target, \
133 "echo ignored-command"))
134
135config.substitutions.append(("%clangxx", config.test_cxx_compiler))
136config.substitutions.append(("%clang", config.test_c_compiler))
137config.substitutions.append(("%openmp_flag", config.test_openmp_flag))
138config.substitutions.append(("%cflags", config.test_cflags))