Subzero: Move python scripts into a common pydir.
This makes it much easier to run scripts from different working directories, as long as they are run somewhere under the native_client directory.
BUG= none
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/554013002
diff --git a/crosstest/runtests.sh b/crosstest/runtests.sh
index cc353ab..761db64 100755
--- a/crosstest/runtests.sh
+++ b/crosstest/runtests.sh
@@ -5,6 +5,9 @@
set -eux
+# TODO(stichnot): Use FindBaseNaCl so that the script can be run from
+# anywhere within the native_client directory.
+PATH="../pydir:${PATH}"
OPTLEVELS="m1 2"
ATTRIBUTES="sse2 sse4.1"
OUTDIR=Output
@@ -15,7 +18,7 @@
for optlevel in ${OPTLEVELS} ; do
for attribute in ${ATTRIBUTES} ; do
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -23,7 +26,7 @@
--driver=simple_loop_main.c \
--output=simple_loop_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -31,7 +34,7 @@
--driver=mem_intrin_main.cpp \
--output=mem_intrin_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -41,7 +44,7 @@
--driver=test_arith_main.cpp \
--output=test_arith_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -49,14 +52,14 @@
--driver=test_bitmanip_main.cpp \
--output=test_bitmanip_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ --target=x8632 \
--dir="${OUTDIR}" \
--test=test_calling_conv.cpp \
--driver=test_calling_conv_main.cpp \
--output=test_calling_conv_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -64,7 +67,7 @@
--driver=test_cast_main.cpp \
--output=test_cast_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -72,7 +75,7 @@
--driver=test_fcmp_main.cpp \
--output=test_fcmp_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -80,7 +83,7 @@
--driver=test_global_main.cpp \
--output=test_global_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -88,7 +91,7 @@
--driver=test_icmp_main.cpp \
--output=test_icmp_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -96,7 +99,7 @@
--driver=test_select_main.cpp \
--output=test_select_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -107,7 +110,7 @@
# Compile the non-subzero object files straight from source
# since the native LLVM backend does not understand how to
# lower NaCl-specific intrinsics.
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ \
--target=x8632 \
--dir="${OUTDIR}" \
@@ -116,7 +119,7 @@
--driver=test_sync_atomic_main.cpp \
--output=test_sync_atomic_O${optlevel}_${attribute}
- ./crosstest.py -O${optlevel} --mattr ${attribute} \
+ crosstest.py -O${optlevel} --mattr ${attribute} \
--prefix=Subzero_ --target=x8632 \
--dir="${OUTDIR}" \
--test=test_vector_ops.ll \
diff --git a/crosstest/crosstest.py b/pydir/crosstest.py
similarity index 99%
rename from crosstest/crosstest.py
rename to pydir/crosstest.py
index 432cb9d..2df00f1 100755
--- a/crosstest/crosstest.py
+++ b/pydir/crosstest.py
@@ -7,7 +7,6 @@
import sys
import tempfile
-sys.path.insert(0, '../pydir')
from utils import shellcmd
from utils import FindBaseNaCl
diff --git a/llvm2iceinsts.py b/pydir/llvm2iceinsts.py
similarity index 96%
rename from llvm2iceinsts.py
rename to pydir/llvm2iceinsts.py
index 29ddd14..9861242 100755
--- a/llvm2iceinsts.py
+++ b/pydir/llvm2iceinsts.py
@@ -7,8 +7,6 @@
import subprocess
import sys
-sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pydir'))
-
from utils import shellcmd
if __name__ == '__main__':
diff --git a/szdiff.py b/pydir/szdiff.py
similarity index 100%
rename from szdiff.py
rename to pydir/szdiff.py
diff --git a/tests_lit/lit.cfg b/tests_lit/lit.cfg
index ba26097..5e94f1e 100644
--- a/tests_lit/lit.cfg
+++ b/tests_lit/lit.cfg
@@ -9,6 +9,9 @@
import lit.formats
+sys.path.insert(0, 'pydir')
+from utils import FindBaseNaCl
+
# name: The name of this test suite.
config.name = 'subzero'
@@ -23,11 +26,13 @@
config.test_exec_root = config.test_source_root
config.target_triple = '(unused)'
-src_root = os.path.abspath(os.path.join(config.test_source_root, '..'))
+src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero')
bin_root = src_root
config.substitutions.append(('%{src_root}', src_root))
config.substitutions.append(('%{python}', sys.executable))
+pydir = os.path.join(bin_root, 'pydir')
+
# Finding LLVM binary tools. All tools used in the tests must be listed in
# the llvmbintools list.
llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH'))
@@ -35,12 +40,12 @@
# Finding Subzero tools
llvm2icetool = os.path.join(bin_root, 'llvm2ice')
config.substitutions.append(
- ('%llvm2iceinsts', ' '.join([os.path.join(bin_root, 'llvm2iceinsts.py'),
+ ('%llvm2iceinsts', ' '.join([os.path.join(pydir, 'llvm2iceinsts.py'),
'--llvm2ice', llvm2icetool,
'--llvm-bin-path', llvmbinpath
])))
config.substitutions.append(('%llvm2ice', llvm2icetool))
-config.substitutions.append(('%szdiff', os.path.join(bin_root, 'szdiff.py')))
+config.substitutions.append(('%szdiff', os.path.join(pydir, 'szdiff.py')))
llvmbintools = [r"\bFileCheck\b", r"\bllvm-as\b", r"\bllvm-mc\b",
r"\bllvm-objdump\b", r"\bnot\b", r"\bpnacl-freeze\b"]