OLD | NEW |
---|---|
1 # -*- python -*- | 1 # -*- python -*- |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 Import('env') | 6 Import('env') |
7 | 7 |
8 if 'TRUSTED_ENV' not in env: | 8 if 'TRUSTED_ENV' not in env: |
9 Return() | 9 Return() |
10 | 10 |
11 # Even if stubout mode is not supported sel_ldr still must run valid .nexes. | 11 # Even if stubout mode is not supported sel_ldr still must run valid .nexes. |
12 # TODO(shyamsundarr): consider removing support for stubout mode completely | |
13 # from code, given that currently only MIPS supports it and it is untested. | |
12 hello_world_nexe = env.File('${STAGING_DIR}/hello_world${PROGSUFFIX}') | 14 hello_world_nexe = env.File('${STAGING_DIR}/hello_world${PROGSUFFIX}') |
13 node = env.CommandSelLdrTestNacl( | 15 node = env.CommandSelLdrTestNacl( |
14 'hello_world_stub_out_run.out', hello_world_nexe, | 16 'hello_world_stub_out_run.out', hello_world_nexe, |
15 sel_ldr_flags=['-s']) | 17 sel_ldr_flags=['-s']) |
16 env.AddNodeToTestSuite( | 18 env.AddNodeToTestSuite( |
17 node, ['small_tests'], 'run_valid_nexe_with_stubout_test') | 19 node, ['small_tests'], 'run_valid_nexe_with_stubout_test') |
18 | 20 |
19 # Do not run these tests with pexes, assuming they are portable, since | |
20 # they use inline assembler. | |
21 if env.Bit('bitcode') and env.Bit('pnacl_generate_pexe'): | |
22 Return() | |
23 | |
24 # The file partly_invalid.c contains inline assembler | |
25 if env.Bit('bitcode'): | |
26 env.AddBiasForPNaCl() | |
27 env.PNaClForceNative() | |
28 | |
29 # Newlib + PIC doesn't provide native ___tls_get_addr, so gold complains. | |
30 if env.Bit('bitcode') and env.Bit('nacl_pic'): | |
31 Return() | |
32 | |
33 # TODO(mseaborn): Extend the ARM validator to support this. | |
34 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=2369 | |
35 if env.Bit('build_arm'): | |
36 Return() | |
37 | |
38 stubout_tool = env['TRUSTED_ENV'].File( | |
39 '${STAGING_DIR}/${PROGPREFIX}ncval_stubout${PROGSUFFIX}') | |
40 | |
41 partly_invalid_nexe = env.ComponentProgram('partly_invalid', 'partly_invalid.c', | |
42 EXTRA_LIBS=['${NONIRT_LIBS}']) | |
43 | |
44 | |
45 # R-DFA does not support stubout mode but we need to create at least file | |
46 # partly_invalid.nexe used in PPAPI tests thus we first create a rule for | |
47 # this file and only then bail out. | |
48 if env.Bit('validator_ragel'): | |
49 Return() | |
50 | |
51 partly_invalid_stubout_nexe = env.File('partly_invalid_stubout${PROGSUFFIX}') | |
52 | |
53 node = env.Command( | |
54 target=partly_invalid_stubout_nexe, | |
55 source=[stubout_tool, partly_invalid_nexe], | |
56 action=[Action('${SOURCES[0]} ${SOURCES[1]} -o $TARGET')]) | |
57 # This alias is to ensure this test works with built_elsewhere=1, | |
58 # because with that option CommandSelLdrTestNacl() assumes all its | |
59 # inputs have already been built (which is not necessarily a good | |
60 # idea, but apparently true for all other cases so far). | |
61 env.Alias('all_test_programs', node) | |
62 | |
63 # For speed, SConstruct disables the validator (using '-cc') for | |
64 # Valgrind+nacl-glibc tests, which breaks one test below. | |
65 is_validation_disabled = env.IsRunningUnderValgrind() and env.Bit('nacl_glibc') | |
66 | |
67 test_suites = ['small_tests', 'nonpexe_tests'] | |
68 | |
69 # Without any debug flags, the executable fails validation. | |
Mark Seaborn
2014/10/07 21:53:46
Can we keep this test case?
I have a strong suspi
shyamsundarr
2014/10/08 19:59:03
Done.
| |
70 if env.Bit('nacl_static_link'): | |
71 # The exit status produced by sel_ldr. | |
72 validation_failure_status = '1' | |
73 else: | |
74 # The exit status produced by the dynamic linker. | |
75 validation_failure_status = '127' | |
76 node = env.CommandSelLdrTestNacl( | |
77 'partly_invalid_1.out', partly_invalid_nexe, | |
78 exit_status=validation_failure_status) | |
79 env.AddNodeToTestSuite(node, test_suites, 'run_without_stubout_1_test', | |
80 is_broken=is_validation_disabled) | |
81 | |
82 # With "-c", the executable runs to completion but is not safe. | |
83 node = env.CommandSelLdrTestNacl( | |
84 'partly_invalid_2.out', partly_invalid_nexe, | |
85 stdout_golden=env.File('without_stubout.stdout'), | |
86 sel_ldr_flags=['-c']) | |
87 env.AddNodeToTestSuite(node, test_suites, 'run_without_stubout_2_test') | |
88 | |
89 # With "-s", the executable runs part way but then faults. | |
90 | |
91 if env.Bit('target_mips32'): | |
92 partly_invalid_exit_status = 'sigtrap' | |
93 else: | |
94 partly_invalid_exit_status = 'untrusted_sigsegv' | |
95 | |
96 # Valgrind and ASan interfere with the exit status | |
97 testing_on_asan_or_valgrind = (env.Bit('running_on_valgrind') or | |
98 env.Bit('asan')) | |
99 node = env.CommandSelLdrTestNacl( | |
100 'partly_invalid_3.out', partly_invalid_nexe, | |
101 stdout_golden=env.File('with_stubout.stdout'), | |
102 sel_ldr_flags=['-s'], | |
103 exit_status=partly_invalid_exit_status) | |
104 env.AddNodeToTestSuite(node, test_suites, 'run_stubout_mode_test', | |
105 is_broken=testing_on_asan_or_valgrind) | |
106 | |
107 # Using the standalone ncval_stubout tool to rewrite the executable | |
108 # offline should be equivalent to using sel_ldr's "-s" option. | |
109 # This tool exists only for x86. | |
110 node = env.CommandSelLdrTestNacl( | |
111 'partly_invalid_stubout.out', | |
112 partly_invalid_stubout_nexe, | |
113 stdout_golden=env.File('with_stubout.stdout'), | |
114 exit_status='untrusted_sigsegv') | |
115 env.AddNodeToTestSuite(node, test_suites, 'run_offline_stubout_test', | |
116 is_broken=(env.Bit('target_mips32') or | |
117 testing_on_asan_or_valgrind)) | |
OLD | NEW |