Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: tests_lit/lit.cfg

Issue 659513005: Allow conditional lit tests in Subzero, based on build flags. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #
4 # Note: For X2i and ifX commands, the following values are allowed for X
5 # (i.e. compiler setup):
6 #
7 # m : Run when llvm2ice corresponds to minimal Subzero
8 # p : Run when llvm2ice corresponds to Subzero building ICE from PNaCl
9 # bitcode directly.
10 # l : Run when llvm2ice corresponds to Subzero building ICE by reading
11 # PNaCL bitcode into LLVM IR, and converting to ICE.
12 # lc : Runwhen llvm2ice corresponds to Subzero parsing LLVM source into
13 # LLVM IR, and converting to ICE.
3 14
4 # -*- Python -*- 15 # -*- Python -*-
5 16
6 import os 17 import os
7 import re 18 import re
8 import sys 19 import sys
9 20
10 import lit.formats 21 import lit.formats
11 22
12 sys.path.insert(0, 'pydir') 23 sys.path.insert(0, 'pydir')
13 from utils import FindBaseNaCl 24 from utils import FindBaseNaCl
25 from buildatts import getBuildAttributes
14 26
15 # name: The name of this test suite. 27 # name: The name of this test suite.
16 config.name = 'subzero' 28 config.name = 'subzero'
17 29
18 # testFormat: The test format to use to interpret tests. 30 # testFormat: The test format to use to interpret tests.
19 config.test_format = lit.formats.ShTest() 31 config.test_format = lit.formats.ShTest()
20 32
21 # suffixes: A list of file extensions to treat as test files. 33 # suffixes: A list of file extensions to treat as test files.
22 config.suffixes = ['.ll'] 34 config.suffixes = ['.ll']
23 35
24 # test_source_root: The root path where tests are located. 36 # test_source_root: The root path where tests are located.
25 config.test_source_root = os.path.dirname(__file__) 37 config.test_source_root = os.path.dirname(__file__)
26 config.test_exec_root = config.test_source_root 38 config.test_exec_root = config.test_source_root
27 config.target_triple = '(unused)' 39 config.target_triple = '(unused)'
28 40
29 src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero') 41 src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero')
30 bin_root = src_root 42 bin_root = src_root
31 config.substitutions.append(('%{src_root}', src_root)) 43 config.substitutions.append(('%{src_root}', src_root))
32 config.substitutions.append(('%{python}', sys.executable)) 44 config.substitutions.append(('%{python}', sys.executable))
33 45
34 pydir = os.path.join(bin_root, 'pydir') 46 pydir = os.path.join(bin_root, 'pydir')
35 47
36 # Finding LLVM binary tools. All tools used in the tests must be listed in 48 # Finding LLVM binary tools. All tools used in the tests must be listed in
37 # the llvmbintools list. 49 # the llvmbintools list.
38 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) 50 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH'))
39 51
40 # Finding Subzero tools 52 # Define the location of the llvm2ice tool.
41 llvm2icetool = os.path.join(bin_root, 'llvm2ice') 53 llvm2icetool = os.path.join(bin_root, 'llvm2ice')
42 54
43 # Convert LLVM source to PNaCl bitcode, read using the 55 # Add build attributes of llvm2ice tool to the set of available features.
44 # Subzero bitcode reader, and then translate. 56 config.available_features.update(getBuildAttributes(llvm2icetool))
45 config.substitutions.append(
46 ('%p2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'),
47 '--llvm2ice', llvm2icetool,
48 '--llvm-bin-path', llvmbinpath
49 ])))
50 57
51 # Convert LLVM source to PNaCl bitcode, read using the PNaCl bitcode reader, 58 # Base command for testing build attributes
52 # convert to ICE using the ICE Converter, and then translate. 59 if_atts_cmd = [os.path.join(pydir, 'buildatts.py'), '--llvm2ice', llvm2icetool]
53 # TODO(kschimpf) Deprecated, remove once p2i working. 60 ifm_atts_cmd = if_atts_cmd + ['--att=minimal', '--att=p2i']
54 config.substitutions.append( 61 ifp_atts_cmd = if_atts_cmd + ['--att=p2i']
55 ('%l2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'), 62 ifl_atts_cmd = if_atts_cmd + ['--att=l2i']
56 '--llvm', '--llvm2ice', llvm2icetool, 63 iflc_atts_cmd = if_atts_cmd + ['--att=lc2i']
57 '--llvm-bin-path', llvmbinpath
58 ])))
59 64
60 # Read LLVM source, convert to ICE using the ICE converter, and then translate. 65 # Base command for running llvm2ice
61 # Note: l2i is preferred over lc2i, since it uses PNaCl bitcode. 66 llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'),
62 # TODO(kschimpf) Deprecated, remove once p2i working. 67 '--llvm2ice', llvm2icetool,
63 config.substitutions.append( 68 '--llvm-bin-path', llvmbinpath]
64 ('%lc2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'), 69
65 '--llvm-source', '--llvm2ice', llvm2icetool, 70 # Run commands only if corresponding build attributes apply, including
66 '--llvm-bin-path', llvmbinpath 71 # for each compiler setup.
67 ]))) 72 config.substitutions.append(('%ifm', ' '.join(ifm_atts_cmd)))
73 config.substitutions.append(('%ifp', ' '.join(ifp_atts_cmd)))
74 config.substitutions.append(('%iflc', ' '.join(iflc_atts_cmd)))
75 config.substitutions.append(('%ifl', ' '.join(ifl_atts_cmd)))
76 config.substitutions.append(('%if', ' '.join(if_atts_cmd)))
77
78 # Translate LLVM source for each compiler setup.
79 config.substitutions.append(('%m2i', ' '.join(ifm_atts_cmd + llvm2ice_cmd)))
80 config.substitutions.append(('%p2i', ' '.join(ifp_atts_cmd + llvm2ice_cmd)))
81 config.substitutions.append(('%l2i', ' '.join(ifl_atts_cmd + llvm2ice_cmd
82 + ['--llvm'])))
83 config.substitutions.append(('%lc2i', ' '.join(iflc_atts_cmd + llvm2ice_cmd
84 + ['--llvm-source'])))
68 85
69 config.substitutions.append(('%llvm2ice', llvm2icetool)) 86 config.substitutions.append(('%llvm2ice', llvm2icetool))
70 config.substitutions.append(('%szdiff', os.path.join(pydir, 'szdiff.py'))) 87 config.substitutions.append(('%szdiff', os.path.join(pydir, 'szdiff.py')))
71 88
72 llvmbintools = [r"\bFileCheck\b", r"\bllvm-as\b", r"\bllvm-mc\b", 89 llvmbintools = [r"\bFileCheck\b", r"\bllvm-as\b", r"\bllvm-mc\b",
73 r"\bllvm-objdump\b", r"\bnot\b", r"\bpnacl-freeze\b", 90 r"\bllvm-objdump\b", r"\bnot\b", r"\bpnacl-freeze\b",
74 r"\bpnacl-bcdis\b"] 91 r"\bpnacl-bcdis\b"]
75 92
76 for tool in llvmbintools: 93 for tool in llvmbintools:
77 # The re.sub() line is adapted from one of LLVM's lit.cfg files. 94 # The re.sub() line is adapted from one of LLVM's lit.cfg files.
78 # Extract the tool name from the pattern. This relies on the tool 95 # Extract the tool name from the pattern. This relies on the tool
79 # name being surrounded by \b word match operators. If the 96 # name being surrounded by \b word match operators. If the
80 # pattern starts with "| ", include it in the string to be 97 # pattern starts with "| ", include it in the string to be
81 # substituted. 98 # substituted.
82 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", 99 substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
83 r"\2" + llvmbinpath + "/" + r"\4", 100 r"\2" + llvmbinpath + "/" + r"\4",
84 tool) 101 tool)
85 config.substitutions.append((tool, substitution)) 102 config.substitutions.append((tool, substitution))
86 103
87 # Add a feature to detect the Python version. 104 # Add a feature to detect the Python version.
88 config.available_features.add("python%d.%d" % (sys.version_info[0], 105 config.available_features.add("python%d.%d" % (sys.version_info[0],
89 sys.version_info[1])) 106 sys.version_info[1]))
90 107
91 # Debugging output 108 # Debugging output
92 def dbg(s): 109 def dbg(s):
93 print '[DBG] %s' % s 110 print '[DBG] %s' % s
94 111
95 dbg('bin_root = %s' % bin_root) 112 dbg('bin_root = %s' % bin_root)
96 dbg('llvmbinpath = %s' % llvmbinpath) 113 dbg('llvmbinpath = %s' % llvmbinpath)
OLDNEW
« pydir/buildatts.py ('K') | « pydir/buildatts.py ('k') | tests_lit/reader_tests/binops.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698