George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 1 | # -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: |
| 2 | # Configuration file for the 'lit' test runner. |
| 3 | |
| 4 | import os |
| 5 | import lit.formats |
| 6 | |
| 7 | # Tell pylint that we know config and lit_config exist somewhere. |
| 8 | if 'PYLINT_IMPORT' in os.environ: |
| 9 | config = object() |
| 10 | lit_config = object() |
| 11 | |
| 12 | def 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. |
| 19 | config.name = 'libomptarget' |
| 20 | |
| 21 | # suffixes: A list of file extensions to treat as test files. |
| 22 | config.suffixes = ['.c', '.cpp', '.cc'] |
| 23 | |
| 24 | # test_source_root: The root path where tests are located. |
| 25 | config.test_source_root = os.path.dirname(__file__) |
| 26 | |
| 27 | # test_exec_root: The root object directory where output is placed |
| 28 | config.test_exec_root = config.libomptarget_obj_root |
| 29 | |
| 30 | # test format |
| 31 | config.test_format = lit.formats.ShTest() |
| 32 | |
| 33 | # compiler flags |
| 34 | config.test_cflags = config.test_openmp_flag + \ |
| 35 | " -I " + config.test_source_root + \ |
| 36 | " -I " + config.omp_header_directory + \ |
| 37 | " -L " + config.library_dir; |
NAKAMURA Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 38 | |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 39 | if config.omp_host_rtl_directory: |
| 40 | config.test_cflags = config.test_cflags + " -L " + \ |
NAKAMURA Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 41 | config.omp_host_rtl_directory |
| 42 | |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 43 | config.test_cflags = config.test_cflags + " " + config.test_extra_cflags |
| 44 | |
Sergey Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame^] | 45 | if config.libomptarget_debug: |
| 46 | config.available_features.add('libomptarget-debug') |
| 47 | |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 48 | # Setup environment to find dynamic library at runtime |
| 49 | if config.operating_system == 'Windows': |
| 50 | append_dynamic_library_path('PATH', config.library_dir, ";") |
| 51 | append_dynamic_library_path('PATH', config.omp_host_rtl_directory, ";") |
| 52 | elif 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 |
| 58 | else: # 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 Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 62 | |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 63 | # 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. |
| 69 | for 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 Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 80 | " | " + config.libomptarget_filecheck + " %s")) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 81 | config.substitutions.append(("%libomptarget-compilexx-and-run-" + \ |
| 82 | libomptarget_target, \ |
Sergey Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame^] | 83 | "%libomptarget-compilexx-" + libomptarget_target + " && " + \ |
| 84 | "%libomptarget-run-" + libomptarget_target)) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 85 | config.substitutions.append(("%libomptarget-compile-and-run-" + \ |
| 86 | libomptarget_target, \ |
Sergey Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame^] | 87 | "%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 Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 95 | "%clang-" + libomptarget_target + " %s -o %t-" + \ |
Sergey Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame^] | 96 | libomptarget_target)) |
| 97 | config.substitutions.append(("%libomptarget-run-" + \ |
| 98 | libomptarget_target, \ |
| 99 | "%t-" + libomptarget_target)) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 100 | config.substitutions.append(("%clangxx-" + libomptarget_target, \ |
NAKAMURA Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 101 | "%clangxx %cflags -fopenmp-targets=" + libomptarget_target)) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 102 | 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 Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame^] | 119 | 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 Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 128 | 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 | |
| 135 | config.substitutions.append(("%clangxx", config.test_cxx_compiler)) |
| 136 | config.substitutions.append(("%clang", config.test_c_compiler)) |
| 137 | config.substitutions.append(("%openmp_flag", config.test_openmp_flag)) |
| 138 | config.substitutions.append(("%cflags", config.test_cflags)) |