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]) |
| 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} ${SOURCES} -o ${TARGET}') |
| 54 |
| 55 # Compile trusted part of the test and link everything together. |
| 56 prog = trusted_env.ComponentProgram( |
| 57 test_name, |
| 58 [llc_result, exerciser_src], |
| 59 LIBS=['minsfi_runtime']) |
| 60 |
| 61 # Register the test. |
| 62 node = env.CommandTest('%s.out' % test_name, [prog]) |
| 63 env.AddNodeToTestSuite( |
| 64 node, |
| 65 ['small_tests', 'toolchain_tests', 'minsfi_tests'], |
| 66 'run_minsfi_' + test_name + '_test') |
| 67 |
| 68 CompileSandbox('memory_layout', 'test_memory_layout.c', 'sandbox_dummy.c') |
| 69 CompileSandbox('initializer', 'test_initializer.c', 'sandbox_dummy.c') |
OLD | NEW |