blob: 88b20e967fc16c63117be349515cf91f180c15b1 [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
45# Setup environment to find dynamic library at runtime
46if config.operating_system == 'Windows':
47 append_dynamic_library_path('PATH', config.library_dir, ";")
48 append_dynamic_library_path('PATH', config.omp_host_rtl_directory, ";")
49elif config.operating_system == 'Darwin':
50 append_dynamic_library_path('DYLD_LIBRARY_PATH', config.library_dir, ":")
51 append_dynamic_library_path('DYLD_LIBRARY_PATH', \
52 config.omp_host_rtl_directory, ";")
53 config.test_cflags += " -Wl,-rpath," + config.library_dir
54 config.test_cflags += " -Wl,-rpath," + config.omp_host_rtl_directory
55else: # Unices
56 append_dynamic_library_path('LD_LIBRARY_PATH', config.library_dir, ":")
57 append_dynamic_library_path('LD_LIBRARY_PATH', \
58 config.omp_host_rtl_directory, ":")
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000059
George Rokos2467df62017-01-25 21:27:24 +000060# substitutions
61# - for targets that exist in the system create the actual command.
62# - for valid targets that do not exist in the system, return false, so that the
63# same test can be used for different targets.
64
65# Scan all the valid targets.
66for libomptarget_target in config.libomptarget_all_targets:
67 # Is this target in the current system? If so create a compile, run and test
68 # command. Otherwise create command that return false.
69 if libomptarget_target in config.libomptarget_system_targets:
70 config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
71 libomptarget_target, \
72 "%libomptarget-compilexx-and-run-" + libomptarget_target + \
73 " | " + config.libomptarget_filecheck + " %s"))
74 config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
75 libomptarget_target, \
76 "%libomptarget-compile-and-run-" + libomptarget_target + \
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000077 " | " + config.libomptarget_filecheck + " %s"))
George Rokos2467df62017-01-25 21:27:24 +000078 config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
79 libomptarget_target, \
80 "%clangxx-" + libomptarget_target + " %s -o %t-" + \
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000081 libomptarget_target + " && %t-" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +000082 config.substitutions.append(("%libomptarget-compile-and-run-" + \
83 libomptarget_target, \
84 "%clang-" + libomptarget_target + " %s -o %t-" + \
85 libomptarget_target + " && %t-" + libomptarget_target))
86 config.substitutions.append(("%clangxx-" + libomptarget_target, \
NAKAMURA Takumi0c7d6ef2017-07-20 23:12:39 +000087 "%clangxx %cflags -fopenmp-targets=" + libomptarget_target))
George Rokos2467df62017-01-25 21:27:24 +000088 config.substitutions.append(("%clang-" + libomptarget_target, \
89 "%clang %cflags -fopenmp-targets=" + libomptarget_target))
90 config.substitutions.append(("%fcheck-" + libomptarget_target, \
91 config.libomptarget_filecheck + " %s"))
92 else:
93 config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
94 libomptarget_target, \
95 "echo ignored-command"))
96 config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
97 libomptarget_target, \
98 "echo ignored-command"))
99 config.substitutions.append(("%libomptarget-compile-and-run-" + \
100 libomptarget_target, \
101 "echo ignored-command"))
102 config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
103 libomptarget_target, \
104 "echo ignored-command"))
105 config.substitutions.append(("%clang-" + libomptarget_target, \
106 "echo ignored-command"))
107 config.substitutions.append(("%clangxx-" + libomptarget_target, \
108 "echo ignored-command"))
109 config.substitutions.append(("%fcheck-" + libomptarget_target, \
110 "echo ignored-command"))
111
112config.substitutions.append(("%clangxx", config.test_cxx_compiler))
113config.substitutions.append(("%clang", config.test_c_compiler))
114config.substitutions.append(("%openmp_flag", config.test_openmp_flag))
115config.substitutions.append(("%cflags", config.test_cflags))