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 |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 34 | config.test_flags = " -I " + config.test_source_root + \ |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 35 | " -I " + config.omp_header_directory + \ |
| 36 | " -L " + config.library_dir; |
NAKAMURA Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 37 | |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 38 | if config.omp_host_rtl_directory: |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 39 | config.test_flags = config.test_flags + " -L " + \ |
NAKAMURA Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 40 | config.omp_host_rtl_directory |
| 41 | |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 42 | config.test_flags = config.test_flags + " " + config.test_extra_flags |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 43 | |
Sergey Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame] | 44 | if config.libomptarget_debug: |
| 45 | config.available_features.add('libomptarget-debug') |
| 46 | |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 47 | # Setup environment to find dynamic library at runtime |
| 48 | if config.operating_system == 'Windows': |
| 49 | append_dynamic_library_path('PATH', config.library_dir, ";") |
| 50 | append_dynamic_library_path('PATH', config.omp_host_rtl_directory, ";") |
| 51 | elif 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 Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 55 | config.test_flags += " -Wl,-rpath," + config.library_dir |
| 56 | config.test_flags += " -Wl,-rpath," + config.omp_host_rtl_directory |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 57 | else: # 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 Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 61 | |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 62 | # 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. |
| 68 | for 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 Takumi | 0c7d6ef | 2017-07-20 23:12:39 +0000 | [diff] [blame] | 79 | " | " + config.libomptarget_filecheck + " %s")) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 80 | config.substitutions.append(("%libomptarget-compilexx-and-run-" + \ |
| 81 | libomptarget_target, \ |
Sergey Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame] | 82 | "%libomptarget-compilexx-" + libomptarget_target + " && " + \ |
| 83 | "%libomptarget-run-" + libomptarget_target)) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 84 | config.substitutions.append(("%libomptarget-compile-and-run-" + \ |
| 85 | libomptarget_target, \ |
Sergey Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame] | 86 | "%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 Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 94 | "%clang-" + libomptarget_target + " %s -o %t-" + \ |
Sergey Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame] | 95 | libomptarget_target)) |
| 96 | config.substitutions.append(("%libomptarget-run-" + \ |
| 97 | libomptarget_target, \ |
| 98 | "%t-" + libomptarget_target)) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 99 | config.substitutions.append(("%clangxx-" + libomptarget_target, \ |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 100 | "%clangxx %openmp_flags %flags -fopenmp-targets=" + libomptarget_target)) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 101 | config.substitutions.append(("%clang-" + libomptarget_target, \ |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 102 | "%clang %openmp_flags %flags -fopenmp-targets=" + libomptarget_target)) |
George Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 103 | 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 Dmitriev | b305d26 | 2017-08-14 15:09:59 +0000 | [diff] [blame] | 118 | 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 Rokos | 2467df6 | 2017-01-25 21:27:24 +0000 | [diff] [blame] | 127 | 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 | |
| 134 | config.substitutions.append(("%clangxx", config.test_cxx_compiler)) |
| 135 | config.substitutions.append(("%clang", config.test_c_compiler)) |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 136 | config.substitutions.append(("%openmp_flags", config.test_openmp_flags)) |
| 137 | config.substitutions.append(("%flags", config.test_flags)) |