| OLD | NEW | 
|---|
| 1 # Taken from utils/lit/tests in the LLVM tree and hacked together to support | 1 # Taken from utils/lit/tests in the LLVM tree and hacked together to support | 
| 2 # our tests. | 2 # our tests. | 
| 3 | 3 | 
| 4 # -*- Python -*- | 4 # -*- Python -*- | 
| 5 | 5 | 
| 6 import os | 6 import os | 
| 7 import re | 7 import re | 
| 8 import sys | 8 import sys | 
| 9 | 9 | 
| 10 import lit.formats | 10 import lit.formats | 
| 11 | 11 | 
|  | 12 sys.path.insert(0, 'pydir') | 
|  | 13 from utils import FindBaseNaCl | 
|  | 14 | 
| 12 # name: The name of this test suite. | 15 # name: The name of this test suite. | 
| 13 config.name = 'subzero' | 16 config.name = 'subzero' | 
| 14 | 17 | 
| 15 # testFormat: The test format to use to interpret tests. | 18 # testFormat: The test format to use to interpret tests. | 
| 16 config.test_format = lit.formats.ShTest() | 19 config.test_format = lit.formats.ShTest() | 
| 17 | 20 | 
| 18 # suffixes: A list of file extensions to treat as test files. | 21 # suffixes: A list of file extensions to treat as test files. | 
| 19 config.suffixes = ['.ll'] | 22 config.suffixes = ['.ll'] | 
| 20 | 23 | 
| 21 # test_source_root: The root path where tests are located. | 24 # test_source_root: The root path where tests are located. | 
| 22 config.test_source_root = os.path.dirname(__file__) | 25 config.test_source_root = os.path.dirname(__file__) | 
| 23 config.test_exec_root = config.test_source_root | 26 config.test_exec_root = config.test_source_root | 
| 24 config.target_triple = '(unused)' | 27 config.target_triple = '(unused)' | 
| 25 | 28 | 
| 26 src_root = os.path.abspath(os.path.join(config.test_source_root, '..')) | 29 src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero') | 
| 27 bin_root = src_root | 30 bin_root = src_root | 
| 28 config.substitutions.append(('%{src_root}', src_root)) | 31 config.substitutions.append(('%{src_root}', src_root)) | 
| 29 config.substitutions.append(('%{python}', sys.executable)) | 32 config.substitutions.append(('%{python}', sys.executable)) | 
| 30 | 33 | 
|  | 34 pydir = os.path.join(bin_root, 'pydir') | 
|  | 35 | 
| 31 # Finding LLVM binary tools. All tools used in the tests must be listed in | 36 # Finding LLVM binary tools. All tools used in the tests must be listed in | 
| 32 # the llvmbintools list. | 37 # the llvmbintools list. | 
| 33 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) | 38 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) | 
| 34 | 39 | 
| 35 # Finding Subzero tools | 40 # Finding Subzero tools | 
| 36 llvm2icetool = os.path.join(bin_root, 'llvm2ice') | 41 llvm2icetool = os.path.join(bin_root, 'llvm2ice') | 
| 37 config.substitutions.append( | 42 config.substitutions.append( | 
| 38   ('%llvm2iceinsts', ' '.join([os.path.join(bin_root, 'llvm2iceinsts.py'), | 43   ('%llvm2iceinsts', ' '.join([os.path.join(pydir, 'llvm2iceinsts.py'), | 
| 39                                '--llvm2ice', llvm2icetool, | 44                                '--llvm2ice', llvm2icetool, | 
| 40                                '--llvm-bin-path', llvmbinpath | 45                                '--llvm-bin-path', llvmbinpath | 
| 41                              ]))) | 46                              ]))) | 
| 42 config.substitutions.append(('%llvm2ice', llvm2icetool)) | 47 config.substitutions.append(('%llvm2ice', llvm2icetool)) | 
| 43 config.substitutions.append(('%szdiff', os.path.join(bin_root, 'szdiff.py'))) | 48 config.substitutions.append(('%szdiff', os.path.join(pydir, 'szdiff.py'))) | 
| 44 | 49 | 
| 45 llvmbintools = [r"\bFileCheck\b", r"\bllvm-as\b", r"\bllvm-mc\b", | 50 llvmbintools = [r"\bFileCheck\b", r"\bllvm-as\b", r"\bllvm-mc\b", | 
| 46                 r"\bllvm-objdump\b", r"\bnot\b", r"\bpnacl-freeze\b"] | 51                 r"\bllvm-objdump\b", r"\bnot\b", r"\bpnacl-freeze\b"] | 
| 47 | 52 | 
| 48 for tool in llvmbintools: | 53 for tool in llvmbintools: | 
| 49   # The re.sub() line is adapted from one of LLVM's lit.cfg files. | 54   # The re.sub() line is adapted from one of LLVM's lit.cfg files. | 
| 50   # Extract the tool name from the pattern.  This relies on the tool | 55   # Extract the tool name from the pattern.  This relies on the tool | 
| 51   # name being surrounded by \b word match operators.  If the | 56   # name being surrounded by \b word match operators.  If the | 
| 52   # pattern starts with "| ", include it in the string to be | 57   # pattern starts with "| ", include it in the string to be | 
| 53   # substituted. | 58   # substituted. | 
| 54   substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", | 59   substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", | 
| 55                         r"\2" + llvmbinpath + "/" + r"\4", | 60                         r"\2" + llvmbinpath + "/" + r"\4", | 
| 56                         tool) | 61                         tool) | 
| 57   config.substitutions.append((tool, substitution)) | 62   config.substitutions.append((tool, substitution)) | 
| 58 | 63 | 
| 59 # Add a feature to detect the Python version. | 64 # Add a feature to detect the Python version. | 
| 60 config.available_features.add("python%d.%d" % (sys.version_info[0], | 65 config.available_features.add("python%d.%d" % (sys.version_info[0], | 
| 61                                                sys.version_info[1])) | 66                                                sys.version_info[1])) | 
| 62 | 67 | 
| 63 # Debugging output | 68 # Debugging output | 
| 64 def dbg(s): | 69 def dbg(s): | 
| 65   print '[DBG] %s' % s | 70   print '[DBG] %s' % s | 
| 66 | 71 | 
| 67 dbg('bin_root = %s' % bin_root) | 72 dbg('bin_root = %s' % bin_root) | 
| 68 dbg('llvmbinpath = %s' % llvmbinpath) | 73 dbg('llvmbinpath = %s' % llvmbinpath) | 
| OLD | NEW | 
|---|