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. |
| 33 | config.suffixes = ['.c'] |
| 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 |
| 45 | config.test_cflags = config.test_openmp_flag + \ |
| 46 | " -I " + config.test_source_root + \ |
| 47 | " -I " + config.omp_header_directory + \ |
| 48 | " -L " + config.library_dir + \ |
| 49 | " " + config.test_extra_cflags |
| 50 | |
Jonathan Peyton | 1ab887d | 2016-05-23 17:50:32 +0000 | [diff] [blame^] | 51 | # extra libraries |
| 52 | libs = "" |
| 53 | if config.has_libm: |
| 54 | libs += " -lm" |
| 55 | |
Jonas Hahnfeld | e46a494 | 2016-03-24 12:52:20 +0000 | [diff] [blame] | 56 | # Allow XFAIL to work |
| 57 | config.target_triple = [ ] |
| 58 | if re.search('gcc', config.test_compiler) is not None: |
| 59 | config.available_features.add('gcc') |
| 60 | |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 61 | # Setup environment to find dynamic library at runtime |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 62 | append_dynamic_library_path(config.library_dir) |
| 63 | if config.using_hwloc: |
| 64 | append_dynamic_library_path(config.hwloc_library_dir) |
| 65 | |
| 66 | # Rpath modifications for Darwin |
| 67 | if config.operating_system == 'Darwin': |
Jonathan Peyton | 5a60bc5 | 2015-09-24 15:09:51 +0000 | [diff] [blame] | 68 | config.test_cflags += " -Wl,-rpath," + config.library_dir |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 69 | if config.using_hwloc: |
| 70 | config.test_cflags += " -Wl,-rpath," + config.hwloc_library_dir |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 71 | |
Hans Wennborg | 464307f | 2016-01-19 19:26:43 +0000 | [diff] [blame] | 72 | # Find the SDK on Darwin |
| 73 | if config.operating_system == 'Darwin': |
| 74 | cmd = subprocess.Popen(['xcrun', '--show-sdk-path'], |
| 75 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 76 | out, err = cmd.communicate() |
| 77 | out = out.strip() |
| 78 | res = cmd.wait() |
| 79 | if res == 0 and out: |
| 80 | config.test_cflags += " -isysroot " + out |
| 81 | |
Jonas Hahnfeld | c804301 | 2016-03-22 07:22:49 +0000 | [diff] [blame] | 82 | # Disable OMPT tests if FileCheck was not found |
| 83 | if config.has_ompt and config.test_filecheck == "": |
| 84 | lit_config.note("Not testing OMPT because FileCheck was not found") |
| 85 | config.has_ompt = False |
| 86 | |
| 87 | if config.has_ompt: |
| 88 | config.available_features.add("ompt") |
Jonas Hahnfeld | c804301 | 2016-03-22 07:22:49 +0000 | [diff] [blame] | 89 | # for callback.h |
| 90 | config.test_cflags += " -I " + config.test_source_root + "/ompt" |
| 91 | |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 92 | # substitutions |
Jonas Hahnfeld | c804301 | 2016-03-22 07:22:49 +0000 | [diff] [blame] | 93 | if config.has_ompt: |
| 94 | config.substitutions.append(("FileCheck", config.test_filecheck)) |
| 95 | config.substitutions.append(("%sort-threads", "sort --numeric-sort --stable")) |
| 96 | |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 97 | config.substitutions.append(("%libomp-compile-and-run", \ |
Jonathan Peyton | 2851072 | 2016-02-25 18:04:09 +0000 | [diff] [blame] | 98 | "%libomp-compile && %libomp-run")) |
| 99 | config.substitutions.append(("%libomp-compile", \ |
Jonathan Peyton | 1ab887d | 2016-05-23 17:50:32 +0000 | [diff] [blame^] | 100 | "%clang %cflags %s -o %t" + libs)) |
Jonathan Peyton | 2851072 | 2016-02-25 18:04:09 +0000 | [diff] [blame] | 101 | config.substitutions.append(("%libomp-run", "%t")) |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 102 | config.substitutions.append(("%clang", config.test_compiler)) |
| 103 | config.substitutions.append(("%openmp_flag", config.test_openmp_flag)) |
| 104 | config.substitutions.append(("%cflags", config.test_cflags)) |
| 105 | |