blob: cc085d63eda3ff6068513bede25d799e216c7a56 [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
Jonas Hahnfeld18bec602017-11-29 19:31:52 +000034config.test_flags = " -I " + config.test_source_root + \
George Rokos2467df62017-01-25 21:27:24 +000035 " -I " + config.omp_header_directory + \
36 " -L " + config.library_dir;
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000037
George Rokos2467df62017-01-25 21:27:24 +000038if config.omp_host_rtl_directory:
Jonas Hahnfeld18bec602017-11-29 19:31:52 +000039 config.test_flags = config.test_flags + " -L " + \
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000040 config.omp_host_rtl_directory
41
Jonas Hahnfeld18bec602017-11-29 19:31:52 +000042config.test_flags = config.test_flags + " " + config.test_extra_flags
George Rokos2467df62017-01-25 21:27:24 +000043
Sergey Dmitrievb305d262017-08-14 15:09:59 +000044if config.libomptarget_debug:
45 config.available_features.add('libomptarget-debug')
46
George Rokos2467df62017-01-25 21:27:24 +000047# Setup environment to find dynamic library at runtime
48if config.operating_system == 'Windows':
49 append_dynamic_library_path('PATH', config.library_dir, ";")
50 append_dynamic_library_path('PATH', config.omp_host_rtl_directory, ";")
51elif config.operating_system == 'Darwin':
52 append_dynamic_library_path('DYLD_LIBRARY_PATH', config.library_dir, ":")
53 append_dynamic_library_path('DYLD_LIBRARY_PATH', \
54 config.omp_host_rtl_directory, ";")
Jonas Hahnfeld18bec602017-11-29 19:31:52 +000055 config.test_flags += " -Wl,-rpath," + config.library_dir
56 config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory
George Rokos2467df62017-01-25 21:27:24 +000057else: # Unices
58 append_dynamic_library_path('LD_LIBRARY_PATH', config.library_dir, ":")
59 append_dynamic_library_path('LD_LIBRARY_PATH', \
60 config.omp_host_rtl_directory, ":")
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000061
George Rokos2467df62017-01-25 21:27:24 +000062# substitutions
63# - for targets that exist in the system create the actual command.
64# - for valid targets that do not exist in the system, return false, so that the
65# same test can be used for different targets.
66
67# Scan all the valid targets.
68for libomptarget_target in config.libomptarget_all_targets:
69 # Is this target in the current system? If so create a compile, run and test
70 # command. Otherwise create command that return false.
71 if libomptarget_target in config.libomptarget_system_targets:
72 config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
73 libomptarget_target, \
74 "%libomptarget-compilexx-and-run-" + libomptarget_target + \
75 " | " + config.libomptarget_filecheck + " %s"))
76 config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
77 libomptarget_target, \
78 "%libomptarget-compile-and-run-" + libomptarget_target + \
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000079 " | " + config.libomptarget_filecheck + " %s"))
George Rokos2467df62017-01-25 21:27:24 +000080 config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
81 libomptarget_target, \
Sergey Dmitrievb305d262017-08-14 15:09:59 +000082 "%libomptarget-compilexx-" + libomptarget_target + " && " + \
83 "%libomptarget-run-" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +000084 config.substitutions.append(("%libomptarget-compile-and-run-" + \
85 libomptarget_target, \
Sergey Dmitrievb305d262017-08-14 15:09:59 +000086 "%libomptarget-compile-" + libomptarget_target + " && " + \
87 "%libomptarget-run-" + libomptarget_target))
88 config.substitutions.append(("%libomptarget-compilexx-" + \
89 libomptarget_target, \
90 "%clangxx-" + libomptarget_target + " %s -o %t-" + \
91 libomptarget_target))
92 config.substitutions.append(("%libomptarget-compile-" + \
93 libomptarget_target, \
George Rokos2467df62017-01-25 21:27:24 +000094 "%clang-" + libomptarget_target + " %s -o %t-" + \
Sergey Dmitrievb305d262017-08-14 15:09:59 +000095 libomptarget_target))
96 config.substitutions.append(("%libomptarget-run-" + \
97 libomptarget_target, \
98 "%t-" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +000099 config.substitutions.append(("%clangxx-" + libomptarget_target, \
Jonas Hahnfeld18bec602017-11-29 19:31:52 +0000100 "%clangxx %openmp_flags %flags -fopenmp-targets=" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +0000101 config.substitutions.append(("%clang-" + libomptarget_target, \
Jonas Hahnfeld18bec602017-11-29 19:31:52 +0000102 "%clang %openmp_flags %flags -fopenmp-targets=" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +0000103 config.substitutions.append(("%fcheck-" + libomptarget_target, \
104 config.libomptarget_filecheck + " %s"))
105 else:
106 config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
107 libomptarget_target, \
108 "echo ignored-command"))
109 config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
110 libomptarget_target, \
111 "echo ignored-command"))
112 config.substitutions.append(("%libomptarget-compile-and-run-" + \
113 libomptarget_target, \
114 "echo ignored-command"))
115 config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
116 libomptarget_target, \
117 "echo ignored-command"))
Sergey Dmitrievb305d262017-08-14 15:09:59 +0000118 config.substitutions.append(("%libomptarget-compilexx-" + \
119 libomptarget_target, \
120 "echo ignored-command"))
121 config.substitutions.append(("%libomptarget-compile-" + \
122 libomptarget_target, \
123 "echo ignored-command"))
124 config.substitutions.append(("%libomptarget-run-" + \
125 libomptarget_target, \
126 "echo ignored-command"))
George Rokos2467df62017-01-25 21:27:24 +0000127 config.substitutions.append(("%clang-" + libomptarget_target, \
128 "echo ignored-command"))
129 config.substitutions.append(("%clangxx-" + libomptarget_target, \
130 "echo ignored-command"))
131 config.substitutions.append(("%fcheck-" + libomptarget_target, \
132 "echo ignored-command"))
133
134config.substitutions.append(("%clangxx", config.test_cxx_compiler))
135config.substitutions.append(("%clang", config.test_c_compiler))
Jonas Hahnfeld18bec602017-11-29 19:31:52 +0000136config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
137config.substitutions.append(("%flags", config.test_flags))