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

Side by Side Diff: tools/llvm/utman-test.sh

Issue 8391032: Part 2 of 3: Moving tools/llvm to pnacl/ (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « tools/llvm/utman.sh ('k') | tools/toolchain_tester/torture_test.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 #
6 #@ PNaCl Test Helper
7 #@-------------------------------------------------------------------
8 #@
9 #@ SCons Test Usage:
10 #@
11 #@ utman-test.sh test-<arch>-<mode> [extra_arguments_to_scons]
12 #@
13 #@ Runs the SCons tests with selected arch and mode.
14 #@ Valid arches:
15 #@ x86-32
16 #@ x86-64
17 #@ arm
18 #@ Available modes:
19 #@ newlib (same as omitting mode)
20 #@ pic
21 #@ sbtc
22 #@ glibc
23 #@ browser
24 #@ browser-glibc
25 #@
26 #@ For example: tools/llvm/utman-test.sh test-x86-32-glibc
27 #@
28 #@ The env variables: UTMAN_CONCURRENCY, UTMAN_BUILDBOT, UTMAN_DEBUG
29 #@ control behavior of this script
30 #@
31 #@
32
33 ######################################################################
34 # Config
35 ######################################################################
36
37 set -o nounset
38 set -o errexit
39
40 # The script is located in "native_client/tools/llvm".
41 # Set pwd to native_client/
42 cd "$(dirname "$0")"/../..
43 if [[ $(basename "$(pwd)") != "native_client" ]] ; then
44 echo "ERROR: cannot find native_client/ directory"
45 exit -1
46 fi
47 readonly NACL_ROOT="$(pwd)"
48
49 readonly DRYRUN=${DRYRUN:-false}
50
51 # This is only used by Spec2K test scripts.
52 readonly PNACL_LIBMODE=${LIBMODE:-newlib}
53 export PNACL_LIBMODE
54
55 source tools/llvm/common-tools.sh
56 SetScriptPath "${NACL_ROOT}/tools/llvm/utman-test.sh"
57 SetLogDirectory "${NACL_ROOT}/toolchain/test-log"
58
59 # For different levels of make parallelism change this in your env
60 readonly UTMAN_CONCURRENCY=${UTMAN_CONCURRENCY:-8}
61
62 readonly OTHER_TEST_SCRIPT="${NACL_ROOT}/buildbot/buildbot_pnacl.sh"
63
64 ######################################################################
65 ######################################################################
66 #
67 # < TESTING >
68 #
69 ######################################################################
70 ######################################################################
71
72 # TODO(robertm): figure out what to do about concurrency in debug mode.
73 # Perhaps it is fine just tweaking that via UTMAN_CONCURRENCY.
74 if ${UTMAN_DEBUG} || ${UTMAN_BUILDBOT}; then
75 readonly SCONS_ARGS=(MODE=nacl,opt-host
76 bitcode=1
77 --verbose
78 -j${UTMAN_CONCURRENCY})
79 else
80 readonly SCONS_ARGS=(MODE=nacl,opt-host
81 bitcode=1
82 naclsdk_validate=0
83 sysinfo=0
84 -j${UTMAN_CONCURRENCY})
85 fi
86
87 #@ show-tests - see what tests can be run
88 show-tests() {
89 StepBanner "SHOWING TESTS"
90 cat $(find tests -name nacl.scons) | grep -o 'run_[A-Za-z_-]*' | sort | uniq
91 }
92
93 Run() {
94 if ${DRYRUN}; then
95 echo "$@"
96 else
97 "$@"
98 fi
99 }
100
101 RunScons() {
102 local arch="$1"
103 shift 1
104 Run ./scons "${SCONS_ARGS[@]}" platform=${arch} "$@"
105 }
106
107 # Returns true if the arguments specify a test
108 # or target name to SCons.
109 has-target-name() {
110 while [ $# -gt 0 ]; do
111 # Skip arguments of the form -foo, --foo, or foo=bar.
112 if [[ "$1" =~ ^-.* ]] || [[ "$1" =~ = ]]; then
113 shift 1
114 continue
115 fi
116 return 0
117 done
118 return 1
119 }
120
121 scons-clean () {
122 local arch=$1
123 local mode=$2
124 local frontend=clang
125 if [ "${mode}" == "newlib" ] ; then
126 Run rm -rf scons-out/nacl-${arch}-pnacl-${frontend}
127 else
128 Run rm -rf scons-out/nacl-${arch}-pnacl-${mode}-${frontend}
129 fi
130 }
131
132 build-sbtc-prerequisites() {
133 local arch=$1
134 # Sandboxed translators currently only require irt_core since they do not
135 # use PPAPI.
136 RunScons ${arch} sel_ldr sel_universal irt_core
137 }
138
139 # TODO(pdox):
140 # "mode" is presently a combination of multiple bits:
141 # Newlib vs. GLibC, sandboxed vs unsandboxed, PIC vs non-PIC
142 # These options should be isolated and kept separate.
143 get-mode-flags() {
144 local mode="$1"
145 local modeflags=""
146 case ${mode} in
147 newlib)
148 ;;
149 sbtc)
150 modeflags="use_sandboxed_translator=1"
151 ;;
152 pic)
153 modeflags="nacl_pic=1"
154 ;;
155 glibc)
156 modeflags="--nacl_glibc"
157 ;;
158 *)
159 echo "Unknown mode" 1>&2
160 exit -1
161 esac
162 echo ${modeflags}
163 }
164
165 scons-tests () {
166 local arch="$1"
167 local mode="$2"
168 shift 2
169 scons-clean ${arch} ${mode}
170
171 if [ ${mode} == "sbtc" ]; then
172 build-sbtc-prerequisites "${arch}"
173 fi
174
175 local modeflags=$(get-mode-flags ${mode})
176
177 if has-target-name "$@" ; then
178 RunScons ${arch} ${modeflags} "$@"
179 else
180 RunScons ${arch} ${modeflags} "$@"
181 RunScons ${arch} ${modeflags} "$@" smoke_tests
182 fi
183 }
184
185 browser-tests() {
186 local arch="$1"
187 local extra="$2"
188 # This calls out to the other buildbot test script. We should have
189 # buildbot_toolchain_arm_untrusted.sh use the same tests directly.
190 # TODO(jvoung): remove these when unified.
191 # scons browser-tests are currently broken with concurrency, so use -j1
192 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=2019
193 Run ${OTHER_TEST_SCRIPT} browser-tests \
194 "${arch}" "--mode=opt-host,nacl -j1 ${extra}"
195 }
196
197 test-arm() { scons-tests arm newlib "$@" ; }
198 test-x86-32() { scons-tests x86-32 newlib "$@" ; }
199 test-x86-64() { scons-tests x86-64 newlib "$@" ; }
200
201 test-arm-newlib() { scons-tests arm newlib "$@" ; }
202 test-x86-32-newlib() { scons-tests x86-32 newlib "$@" ; }
203 test-x86-64-newlib() { scons-tests x86-64 newlib "$@" ; }
204
205 test-arm-pic() { scons-tests arm pic "$@" ; }
206 test-x86-32-pic() { scons-tests x86-32 pic "$@" ; }
207 test-x86-64-pic() { scons-tests x86-64 pic "$@" ; }
208
209 test-arm-sbtc() { scons-tests arm sbtc "$@" ; }
210 test-x86-32-sbtc() { scons-tests x86-32 sbtc "$@" ; }
211 test-x86-64-sbtc() { scons-tests x86-64 sbtc "$@" ; }
212
213 test-arm-glibc() { scons-tests arm glibc "$@" ; }
214 test-x86-32-glibc() { scons-tests x86-32 glibc "$@" ; }
215 test-x86-64-glibc() { scons-tests x86-64 glibc "$@" ; }
216
217 test-arm-browser() { browser-tests "arm" "" ; }
218 test-x86-32-browser() { browser-tests "x86-32" "" ; }
219 test-x86-64-browser() { browser-tests "x86-64" "" ; }
220
221 test-arm-browser-glibc() { browser-tests "arm" "--nacl_glibc" ; }
222 test-x86-32-browser-glibc() { browser-tests "x86-32" "--nacl_glibc" ; }
223 test-x86-64-browser-glibc() { browser-tests "x86-64" "--nacl_glibc" ; }
224
225 #@
226 #@ test-all - Run arm, x86-32, and x86-64 tests. (all should pass)
227 test-all() {
228 if [ $# -ne 0 ]; then
229 echo "test-all does not take any arguments"
230 exit -1
231 fi
232
233 FAIL_FAST=true ${OTHER_TEST_SCRIPT} mode-test-all ${UTMAN_CONCURRENCY}
234 }
235
236 #@
237 #@ test-spec <official-spec-dir> <setup> [ref|train] [<benchmarks>]*
238 #@ - run spec tests
239 test-spec() {
240 if [[ $# -lt 2 ]]; then
241 echo "not enough arguments for test-spec"
242 exit 1
243 fi;
244 official=$(GetAbsolutePath $1)
245 setup=$2
246 shift 2
247 spushd tests/spec2k
248 ./run_all.sh BuildPrerequisitesSetupBased ${setup}
249 ./run_all.sh CleanBenchmarks "$@"
250 ./run_all.sh PopulateFromSpecHarness ${official} "$@"
251 ./run_all.sh BuildAndRunBenchmarks ${setup} "$@"
252 spopd
253 }
254
255 #+ CollectTimingInfo <directory> <timing_result_file> <tagtype...>
256 #+ CD's into the directory in a subshell and collects all the
257 #+ relevant timed run info
258 #+ tagtype just gets printed out.
259 CollectTimingInfo() {
260 wd=$1
261 result_file=$2
262 setup=$3
263 (cd ${wd};
264 mkdir -p $(dirname ${result_file})
265 echo "##################################################" >>${result_file}
266 date +"# Completed at %F %H:%M:%S %A ${result_file}" >> ${result_file}
267 echo "# " ${wd}
268 echo "#" $(uname -a) >> ${result_file}
269 echo "# SETUP: ${setup}" >>${result_file}
270 echo "##################################################" >>${result_file}
271 echo "# COMPILE " >> ${result_file}
272 for ff in $(find . -name "*.compile_time"); do
273 cat ${ff} >> ${result_file}
274 done
275 echo "# RUN " >> ${result_file}
276 for ff in $(find . -name "*.run_time"); do
277 cat ${ff} >> ${result_file}
278 done
279 cat ${result_file}
280 )
281 }
282
283 #@
284 #@ timed-test-spec <result-file> <official-spec-dir> <setup> ... - run spec and
285 #@ measure time / size data. Data is emitted to stdout, but also collected
286 #@ in <result-file>. <result-file> is not cleared across runs (but temp files
287 #@ are cleared on each run).
288 #@ Note that the VERIFY variable effects the timing!
289 timed-test-spec() {
290 if ${BUILD_PLATFORM_MAC} ; then
291 echo "Timed-test-spec is not currently supported on MacOS"
292 exit -1
293 fi
294 if [ "$#" -lt "3" ]; then
295 echo "timed-test-spec {result-file} {spec2krefdir} {setupfunc}" \
296 "[ref|train] [benchmark]*"
297 exit 1
298 fi
299 result_file=$1
300 official=$(GetAbsolutePath $2)
301 setup=$3
302 shift 3
303 spushd tests/spec2k
304 ./run_all.sh BuildPrerequisitesSetupBased ${setup}
305 ./run_all.sh CleanBenchmarks "$@"
306 ./run_all.sh PopulateFromSpecHarness ${official} "$@"
307 ./run_all.sh TimedBuildAndRunBenchmarks ${setup} "$@"
308 CollectTimingInfo $(pwd) ${result_file} ${setup}
309 spopd
310 }
311
312 #@ help - Usage information.
313 help() {
314 Usage
315 }
316
317 #@ help-full - Usage information including internal functions.
318 help-full() {
319 Usage2
320 }
321
322 ######################################################################
323 ######################################################################
324 #
325 # < MAIN >
326 #
327 ######################################################################
328 ######################################################################
329
330 [ $# = 0 ] && set -- help # Avoid reference to undefined $1.
331 if [ "$(type -t $1)" != "function" ]; then
332 #Usage
333 echo "ERROR: unknown function '$1'." >&2
334 echo "For help, try:"
335 echo " $0 help"
336 exit 1
337 fi
338
339 "$@"
OLDNEW
« no previous file with comments | « tools/llvm/utman.sh ('k') | tools/toolchain_tester/torture_test.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698