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

Unified 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: Fix issues in patch set 3. 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 side-by-side diff with in-line comments
Download patch
Index: tests_lit/lit.cfg
diff --git a/tests_lit/lit.cfg b/tests_lit/lit.cfg
index 825f7d2b3051d4bc366080b71cdbb696fc540b91..33eb0505ddd1c86bb987e08305493db07e98f42f 100644
--- a/tests_lit/lit.cfg
+++ b/tests_lit/lit.cfg
@@ -1,7 +1,35 @@
+# -*- Python -*-
# Taken from utils/lit/tests in the LLVM tree and hacked together to support
# our tests.
-
-# -*- Python -*-
+#
+# Note: This configuration has simple commands to run Subzero's translator.
+# They have the form %X2i (i.e. %p2i, %l2i, and %lc2i) where X is defined
+# as follows:
+#
+# p : Run Subzero's translator, building ICE from PNaCl bitcode directly.
+# l : Run Subzero's translator, converting the .ll file to a PNaCl bitcode
+# file, reading in the bitcode file and generating LLVM IR, and
+# then convert LLVM IR to ICE IR.
+# lc : Run Subzero's translator, directly parsing the .ll file into LLVM IR,
+# and then convert it to ICE IR.
+#
+# These commands can be used in RUN lines by FileCheck. If the Subzero build,
Jim Stichnoth 2014/10/20 16:44:29 How about something like this: If the Subzero bui
Karl 2014/10/20 21:00:42 Done.
+# that is being tested, doesn't build the corresponding Subzero translator,
+# the command will simply return successfully, generating no output. This
+# allows translation tests to be able to conditionally test the translator,
+# based on the translator built.
+#
+# This conditional handling of translation introduces potential problems
+# when the output is piped to another command on a RUN line. Executables
+# like FileCheck expect non-empty input.
+#
+# To handle the problem that the pipe is conditional, any command that
+# doesn't accept empty input should be prefixed by a corresponding %ifX
+# (i.e. %ifp, %ifl, or %ifpc).
+#
+# Note: Currently, all build targets allow %p2i. Hence it is not necessary
+# to specify %ifp. However, if you want to be safe about future changes
+# to build targets, use %ifp. Currently, %ifp is implemented as a nop.
import os
import re
@@ -11,6 +39,7 @@ import lit.formats
sys.path.insert(0, 'pydir')
from utils import FindBaseNaCl
+from ifatts import GetFileAttributes
# name: The name of this test suite.
config.name = 'subzero'
@@ -37,34 +66,36 @@ pydir = os.path.join(bin_root, 'pydir')
# the llvmbintools list.
llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH'))
-# Finding Subzero tools
+# Define the location of the llvm2ice tool.
llvm2icetool = os.path.join(bin_root, 'llvm2ice')
-
-# Convert LLVM source to PNaCl bitcode, read using the
-# Subzero bitcode reader, and then translate.
-config.substitutions.append(
- ('%p2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'),
- '--llvm2ice', llvm2icetool,
- '--llvm-bin-path', llvmbinpath
- ])))
-
-# Convert LLVM source to PNaCl bitcode, read using the PNaCl bitcode reader,
-# convert to ICE using the ICE Converter, and then translate.
-# TODO(kschimpf) Deprecated, remove once p2i working.
-config.substitutions.append(
- ('%l2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'),
- '--llvm', '--llvm2ice', llvm2icetool,
- '--llvm-bin-path', llvmbinpath
- ])))
-
-# Read LLVM source, convert to ICE using the ICE converter, and then translate.
-# Note: l2i is preferred over lc2i, since it uses PNaCl bitcode.
-# TODO(kschimpf) Deprecated, remove once p2i working.
-config.substitutions.append(
- ('%lc2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'),
- '--llvm-source', '--llvm2ice', llvm2icetool,
- '--llvm-bin-path', llvmbinpath
- ])))
+llvm2icetoolatts = os.path.join(bin_root, 'llvm2ice.build_atts')
+
+# Add build attributes of llvm2ice tool to the set of available features.
+config.available_features.update(GetFileAttributes(llvm2icetoolatts))
Karl 2014/10/16 16:51:48 Here is the code that defines what symbols will be
+
+# Base command for testing build attributes
+if_atts_cmd = [os.path.join(pydir, 'ifatts.py'), llvm2icetoolatts]
+ifp_atts_cmd = if_atts_cmd + ['--command']
+ifnm_atts_cmd = if_atts_cmd + ['--att=nonminal', '--command']
Jim Stichnoth 2014/10/20 18:06:03 nonminimal
Karl 2014/10/20 21:00:42 Removed, since we no longer treat minimal/nonminim
+
+# Base command for running llvm2ice
+llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'),
+ '--llvm2ice', llvm2icetool,
+ '--llvm-bin-path', llvmbinpath]
+
+# Run commands only if corresponding build attributes apply, including
+# for each compiler setup.
+config.substitutions.append(('%ifp', ' '))
+config.substitutions.append(('%iflc', ' '.join(ifnm_atts_cmd)))
+config.substitutions.append(('%ifl', ' '.join(ifnm_atts_cmd)))
+config.substitutions.append(('%if', ' '.join(if_atts_cmd)))
+
+# Translate LLVM source for each compiler setup.
+config.substitutions.append(('%p2i', ' '.join(llvm2ice_cmd)))
+config.substitutions.append(('%l2i', ' '.join(ifnm_atts_cmd + llvm2ice_cmd
+ + ['--llvm'])))
+config.substitutions.append(('%lc2i', ' '.join(ifnm_atts_cmd + llvm2ice_cmd
+ + ['--llvm-source'])))
config.substitutions.append(('%llvm2ice', llvm2icetool))
config.substitutions.append(('%szdiff', os.path.join(pydir, 'szdiff.py')))

Powered by Google App Engine
This is Rietveld 408576698