Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2014 The Native Client Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 Import('env') | |
| 6 | |
| 7 if 'TRUSTED_ENV' not in env: | |
| 8 Return() | |
| 9 trusted_env = env['TRUSTED_ENV'] | |
| 10 | |
| 11 if not env.Bit('bitcode') or not env.Bit('minsfi') or \ | |
| 12 not trusted_env.Bit('build_x86') or trusted_env.Bit('windows'): | |
| 13 Return() | |
| 14 | |
| 15 def CompileSandbox(test_name, exerciser_src, sandbox_src, ptrsize=0): | |
| 16 if ptrsize == 0: | |
| 17 ptrsize = 24 if trusted_env.Bit('build_x86_32') else 32 | |
| 18 | |
| 19 bc_env = env.Clone() | |
| 20 bc_env.Replace(CCFLAGS=[], LINKFLAGS=[]) | |
| 21 | |
| 22 # Compile the untrusted file. | |
| 23 # We cannot pass the source file directly to the ComponentProgram call | |
| 24 # because we want to reuse the same sandbox source for multiple tests and | |
| 25 # that requires giving each instance a different object file name. | |
| 26 input_obj = bc_env.ComponentObject( | |
| 27 test_name + '.obj.bc', | |
| 28 [ sandbox_src ]) | |
|
jvoung (off chromium)
2014/09/09 21:15:45
nit: style guide says to just have [foo] without t
dbrazdil
2014/09/09 22:17:43
Done.
| |
| 29 | |
| 30 # Link bitcode files into a single module. (flags set in naclsdk.py) | |
| 31 input_module = bc_env.ComponentProgram( | |
| 32 test_name + '.preopt.bc', | |
| 33 [ input_obj ]) | |
| 34 | |
| 35 # Run the PNaCl and MinSFI passes. | |
| 36 opt_result = env.Command( | |
| 37 test_name + '.postopt.bc', | |
| 38 [ input_module ], | |
| 39 '${PNACLOPT} ' | |
| 40 '-strip-debug ' | |
| 41 '-minsfi-strip-tls ' | |
| 42 '-pnacl-abi-simplify-preopt ' | |
| 43 '-pnacl-abi-simplify-postopt ' | |
| 44 '-minsfi ' | |
| 45 '-minsfi-ptrsize=%d ' | |
| 46 '${SOURCES} -o ${TARGET}' | |
| 47 % ptrsize) | |
| 48 | |
| 49 # Translate bitcode into native code. | |
| 50 llc_result = env.Command( | |
| 51 test_name + '.minsfi.o', | |
| 52 [ opt_result ], | |
| 53 '${LLC} ' | |
|
jvoung (off chromium)
2014/09/09 21:15:45
You could probably just have ${LLC} ${SOURCES} -o
dbrazdil
2014/09/09 22:17:43
Done.
| |
| 54 '${SOURCES} -o ${TARGET}') | |
| 55 | |
| 56 # Compile trusted part of the test and link everything together. | |
| 57 prog = trusted_env.ComponentProgram( | |
| 58 test_name, | |
| 59 [ llc_result, exerciser_src ], | |
| 60 LIBS=[ 'minsfi_runtime' ]) | |
| 61 | |
| 62 # Register the test. | |
| 63 node = env.CommandTest('%s.out' % test_name, [ prog ]) | |
| 64 env.AddNodeToTestSuite( | |
| 65 node, | |
| 66 ['small_tests', 'toolchain_tests', 'minsfi_tests'], | |
| 67 'run_minsfi_' + test_name + '_test') | |
| 68 | |
| 69 CompileSandbox('memory_layout', 'test_memory_layout.c', 'sandbox_dummy.c') | |
| 70 CompileSandbox('initializer', 'test_initializer.c', 'sandbox_dummy.c') | |
| OLD | NEW |