Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +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 |
Jonas Hahnfeld | e46a494 | 2016-03-24 12:52:20 +0000 | [diff] [blame] | 5 | import re |
Hans Wennborg | 464307f | 2016-01-19 19:26:43 +0000 | [diff] [blame] | 6 | import subprocess |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 7 | import lit.formats |
| 8 | |
| 9 | # Tell pylint that we know config and lit_config exist somewhere. |
| 10 | if 'PYLINT_IMPORT' in os.environ: |
| 11 | config = object() |
| 12 | lit_config = object() |
| 13 | |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 14 | def append_dynamic_library_path(path): |
| 15 | if config.operating_system == 'Windows': |
| 16 | name = 'PATH' |
| 17 | sep = ';' |
| 18 | elif config.operating_system == 'Darwin': |
| 19 | name = 'DYLD_LIBRARY_PATH' |
| 20 | sep = ':' |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 21 | else: |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 22 | name = 'LD_LIBRARY_PATH' |
| 23 | sep = ':' |
| 24 | if name in config.environment: |
| 25 | config.environment[name] = path + sep + config.environment[name] |
| 26 | else: |
| 27 | config.environment[name] = path |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 28 | |
| 29 | # name: The name of this test suite. |
| 30 | config.name = 'libomp' |
| 31 | |
| 32 | # suffixes: A list of file extensions to treat as test files. |
Jonathan Peyton | 16a05bc | 2017-10-20 19:42:32 +0000 | [diff] [blame] | 33 | config.suffixes = ['.c', '.cpp'] |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 34 | |
| 35 | # test_source_root: The root path where tests are located. |
| 36 | config.test_source_root = os.path.dirname(__file__) |
| 37 | |
| 38 | # test_exec_root: The root object directory where output is placed |
| 39 | config.test_exec_root = config.libomp_obj_root |
| 40 | |
| 41 | # test format |
| 42 | config.test_format = lit.formats.ShTest() |
| 43 | |
| 44 | # compiler flags |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 45 | config.test_flags = " -I " + config.test_source_root + \ |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 46 | " -I " + config.omp_header_directory + \ |
| 47 | " -L " + config.library_dir + \ |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 48 | " " + config.test_extra_flags |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 49 | |
Jonathan Peyton | 1ab887d | 2016-05-23 17:50:32 +0000 | [diff] [blame] | 50 | # extra libraries |
| 51 | libs = "" |
| 52 | if config.has_libm: |
| 53 | libs += " -lm" |
Michal Gorny | 018d135 | 2017-02-24 22:15:24 +0000 | [diff] [blame] | 54 | if config.has_libatomic: |
| 55 | libs += " -latomic" |
Jonathan Peyton | 1ab887d | 2016-05-23 17:50:32 +0000 | [diff] [blame] | 56 | |
Jonas Hahnfeld | e46a494 | 2016-03-24 12:52:20 +0000 | [diff] [blame] | 57 | # Allow XFAIL to work |
| 58 | config.target_triple = [ ] |
Jonas Hahnfeld | fc473de | 2017-11-30 17:08:31 +0000 | [diff] [blame] | 59 | for feature in config.test_compiler_features: |
| 60 | config.available_features.add(feature) |
Jonas Hahnfeld | e46a494 | 2016-03-24 12:52:20 +0000 | [diff] [blame] | 61 | |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 62 | # Setup environment to find dynamic library at runtime |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 63 | append_dynamic_library_path(config.library_dir) |
| 64 | if config.using_hwloc: |
| 65 | append_dynamic_library_path(config.hwloc_library_dir) |
Jonathan Peyton | e3e2aaf | 2017-05-31 20:35:22 +0000 | [diff] [blame] | 66 | config.available_features.add('hwloc') |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 67 | |
| 68 | # Rpath modifications for Darwin |
| 69 | if config.operating_system == 'Darwin': |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 70 | config.test_flags += " -Wl,-rpath," + config.library_dir |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 71 | if config.using_hwloc: |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 72 | config.test_flags += " -Wl,-rpath," + config.hwloc_library_dir |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 73 | |
Hans Wennborg | 464307f | 2016-01-19 19:26:43 +0000 | [diff] [blame] | 74 | # Find the SDK on Darwin |
| 75 | if config.operating_system == 'Darwin': |
| 76 | cmd = subprocess.Popen(['xcrun', '--show-sdk-path'], |
| 77 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 78 | out, err = cmd.communicate() |
| 79 | out = out.strip() |
| 80 | res = cmd.wait() |
| 81 | if res == 0 and out: |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 82 | config.test_flags += " -isysroot " + out |
Hans Wennborg | 464307f | 2016-01-19 19:26:43 +0000 | [diff] [blame] | 83 | |
Jonas Hahnfeld | c804301 | 2016-03-22 07:22:49 +0000 | [diff] [blame] | 84 | # Disable OMPT tests if FileCheck was not found |
| 85 | if config.has_ompt and config.test_filecheck == "": |
| 86 | lit_config.note("Not testing OMPT because FileCheck was not found") |
| 87 | config.has_ompt = False |
| 88 | |
| 89 | if config.has_ompt: |
| 90 | config.available_features.add("ompt") |
Jonas Hahnfeld | c804301 | 2016-03-22 07:22:49 +0000 | [diff] [blame] | 91 | # for callback.h |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 92 | config.test_flags += " -I " + config.test_source_root + "/ompt" |
Jonas Hahnfeld | c804301 | 2016-03-22 07:22:49 +0000 | [diff] [blame] | 93 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 94 | if 'Linux' in config.operating_system: |
| 95 | config.available_features.add("linux") |
| 96 | |
Jonathan Peyton | 48db80c | 2017-10-20 19:45:43 +0000 | [diff] [blame] | 97 | # to run with icc INTEL_LICENSE_FILE must be set |
| 98 | if 'INTEL_LICENSE_FILE' in os.environ: |
| 99 | config.environment['INTEL_LICENSE_FILE'] = os.environ['INTEL_LICENSE_FILE'] |
| 100 | |
Jonas Hahnfeld | c804301 | 2016-03-22 07:22:49 +0000 | [diff] [blame] | 101 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 102 | # substitutions |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 103 | config.substitutions.append(("%libomp-compile-and-run", \ |
Jonathan Peyton | 2851072 | 2016-02-25 18:04:09 +0000 | [diff] [blame] | 104 | "%libomp-compile && %libomp-run")) |
Jonathan Peyton | 16a05bc | 2017-10-20 19:42:32 +0000 | [diff] [blame] | 105 | config.substitutions.append(("%libomp-cxx-compile-and-run", \ |
| 106 | "%libomp-cxx-compile && %libomp-run")) |
| 107 | config.substitutions.append(("%libomp-cxx-compile", \ |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 108 | "%clangXX %openmp_flags %flags -std=c++11 %s -o %t" + libs)) |
Jonathan Peyton | 2851072 | 2016-02-25 18:04:09 +0000 | [diff] [blame] | 109 | config.substitutions.append(("%libomp-compile", \ |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 110 | "%clang %openmp_flags %flags %s -o %t" + libs)) |
Jonathan Peyton | 2851072 | 2016-02-25 18:04:09 +0000 | [diff] [blame] | 111 | config.substitutions.append(("%libomp-run", "%t")) |
Jonathan Peyton | 16a05bc | 2017-10-20 19:42:32 +0000 | [diff] [blame] | 112 | config.substitutions.append(("%clangXX", config.test_cxx_compiler)) |
Jonas Hahnfeld | 18bec60 | 2017-11-29 19:31:52 +0000 | [diff] [blame] | 113 | config.substitutions.append(("%clang", config.test_c_compiler)) |
| 114 | config.substitutions.append(("%openmp_flags", config.test_openmp_flags)) |
| 115 | config.substitutions.append(("%flags", config.test_flags)) |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 116 | |
Joachim Protze | 82e94a5 | 2017-11-01 10:08:30 +0000 | [diff] [blame] | 117 | if config.has_ompt: |
| 118 | config.substitutions.append(("FileCheck", config.test_filecheck)) |
| 119 | config.substitutions.append(("%sort-threads", "sort --numeric-sort --stable")) |
Jonas Hahnfeld | d0ef19e | 2017-11-11 13:59:48 +0000 | [diff] [blame] | 120 | if config.operating_system == 'Windows': |
| 121 | # No such environment variable on Windows. |
| 122 | config.substitutions.append(("%preload-tool", "true ||")) |
| 123 | elif config.operating_system == 'Darwin': |
| 124 | config.substitutions.append(("%preload-tool", "env DYLD_INSERT_LIBRARIES=%T/tool.so")) |
| 125 | else: |
| 126 | config.substitutions.append(("%preload-tool", "env LD_PRELOAD=%T/tool.so")) |