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 |
Hans Wennborg | 464307f | 2016-01-19 19:26:43 +0000 | [diff] [blame^] | 5 | import subprocess |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 6 | import lit.formats |
| 7 | |
| 8 | # Tell pylint that we know config and lit_config exist somewhere. |
| 9 | if 'PYLINT_IMPORT' in os.environ: |
| 10 | config = object() |
| 11 | lit_config = object() |
| 12 | |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 13 | def append_dynamic_library_path(path): |
| 14 | if config.operating_system == 'Windows': |
| 15 | name = 'PATH' |
| 16 | sep = ';' |
| 17 | elif config.operating_system == 'Darwin': |
| 18 | name = 'DYLD_LIBRARY_PATH' |
| 19 | sep = ':' |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 20 | else: |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 21 | name = 'LD_LIBRARY_PATH' |
| 22 | sep = ':' |
| 23 | if name in config.environment: |
| 24 | config.environment[name] = path + sep + config.environment[name] |
| 25 | else: |
| 26 | config.environment[name] = path |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 27 | |
| 28 | # name: The name of this test suite. |
| 29 | config.name = 'libomp' |
| 30 | |
| 31 | # suffixes: A list of file extensions to treat as test files. |
| 32 | config.suffixes = ['.c'] |
| 33 | |
| 34 | # test_source_root: The root path where tests are located. |
| 35 | config.test_source_root = os.path.dirname(__file__) |
| 36 | |
| 37 | # test_exec_root: The root object directory where output is placed |
| 38 | config.test_exec_root = config.libomp_obj_root |
| 39 | |
| 40 | # test format |
| 41 | config.test_format = lit.formats.ShTest() |
| 42 | |
| 43 | # compiler flags |
| 44 | config.test_cflags = config.test_openmp_flag + \ |
| 45 | " -I " + config.test_source_root + \ |
| 46 | " -I " + config.omp_header_directory + \ |
| 47 | " -L " + config.library_dir + \ |
| 48 | " " + config.test_extra_cflags |
| 49 | |
| 50 | # Setup environment to find dynamic library at runtime |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 51 | append_dynamic_library_path(config.library_dir) |
| 52 | if config.using_hwloc: |
| 53 | append_dynamic_library_path(config.hwloc_library_dir) |
| 54 | |
| 55 | # Rpath modifications for Darwin |
| 56 | if config.operating_system == 'Darwin': |
Jonathan Peyton | 5a60bc5 | 2015-09-24 15:09:51 +0000 | [diff] [blame] | 57 | config.test_cflags += " -Wl,-rpath," + config.library_dir |
Jonathan Peyton | 01dcf36 | 2015-11-30 20:02:59 +0000 | [diff] [blame] | 58 | if config.using_hwloc: |
| 59 | config.test_cflags += " -Wl,-rpath," + config.hwloc_library_dir |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 60 | |
Hans Wennborg | 464307f | 2016-01-19 19:26:43 +0000 | [diff] [blame^] | 61 | # Find the SDK on Darwin |
| 62 | if config.operating_system == 'Darwin': |
| 63 | cmd = subprocess.Popen(['xcrun', '--show-sdk-path'], |
| 64 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 65 | out, err = cmd.communicate() |
| 66 | out = out.strip() |
| 67 | res = cmd.wait() |
| 68 | if res == 0 and out: |
| 69 | config.test_cflags += " -isysroot " + out |
| 70 | |
Jonathan Peyton | 614c7ef | 2015-09-21 20:41:31 +0000 | [diff] [blame] | 71 | # substitutions |
| 72 | config.substitutions.append(("%libomp-compile-and-run", \ |
| 73 | "%clang %cflags %s -o %t -lm && %t")) |
| 74 | config.substitutions.append(("%clang", config.test_compiler)) |
| 75 | config.substitutions.append(("%openmp_flag", config.test_openmp_flag)) |
| 76 | config.substitutions.append(("%cflags", config.test_cflags)) |
| 77 | |