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 | 21 # Do not run these tests with pexes, assuming they are portable, since |
20 # they use inline assembler. | 22 # they use inline assembler. |
21 if env.Bit('bitcode') and env.Bit('pnacl_generate_pexe'): | 23 if env.Bit('bitcode') and env.Bit('pnacl_generate_pexe'): |
22 Return() | 24 Return() |
23 | 25 |
24 # The file partly_invalid.c contains inline assembler | 26 # The file partly_invalid.c contains inline assembler |
25 if env.Bit('bitcode'): | 27 if env.Bit('bitcode'): |
26 env.AddBiasForPNaCl() | 28 env.AddBiasForPNaCl() |
27 env.PNaClForceNative() | 29 env.PNaClForceNative() |
28 | 30 |
29 # Newlib + PIC doesn't provide native ___tls_get_addr, so gold complains. | 31 # Newlib + PIC doesn't provide native ___tls_get_addr, so gold complains. |
30 if env.Bit('bitcode') and env.Bit('nacl_pic'): | 32 if env.Bit('bitcode') and env.Bit('nacl_pic'): |
31 Return() | 33 Return() |
32 | 34 |
33 # TODO(mseaborn): Extend the ARM validator to support this. | 35 # TODO(mseaborn): Extend the ARM validator to support this. |
34 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=2369 | 36 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=2369 |
35 if env.Bit('build_arm'): | 37 if env.Bit('build_arm'): |
36 Return() | 38 Return() |
37 | 39 |
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', | 40 partly_invalid_nexe = env.ComponentProgram('partly_invalid', 'partly_invalid.c', |
42 EXTRA_LIBS=['${NONIRT_LIBS}']) | 41 EXTRA_LIBS=['${NONIRT_LIBS}']) |
43 | 42 |
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, | 43 # This alias is to ensure this test works with built_elsewhere=1, |
58 # because with that option CommandSelLdrTestNacl() assumes all its | 44 # because with that option CommandSelLdrTestNacl() assumes all its |
59 # inputs have already been built (which is not necessarily a good | 45 # inputs have already been built (which is not necessarily a good |
60 # idea, but apparently true for all other cases so far). | 46 # idea, but apparently true for all other cases so far). |
61 env.Alias('all_test_programs', node) | 47 env.Alias('all_test_programs', node) |
62 | 48 |
63 # For speed, SConstruct disables the validator (using '-cc') for | 49 # For speed, SConstruct disables the validator (using '-cc') for |
64 # Valgrind+nacl-glibc tests, which breaks one test below. | 50 # Valgrind+nacl-glibc tests, which breaks one test below. |
65 is_validation_disabled = env.IsRunningUnderValgrind() and env.Bit('nacl_glibc') | 51 is_validation_disabled = env.IsRunningUnderValgrind() and env.Bit('nacl_glibc') |
66 | 52 |
67 test_suites = ['small_tests', 'nonpexe_tests'] | 53 test_suites = ['small_tests'] |
Mark Seaborn
2014/10/08 22:32:58
Shouldn't nonpexe_tests be kept? This is still co
shyamsundarr
2014/10/09 16:19:26
non_pexe tests never included tests in this direct
Mark Seaborn
2014/10/09 18:17:48
I see. That makes sense.
| |
68 | 54 |
69 # Without any debug flags, the executable fails validation. | 55 # Without any debug flags, the executable fails validation. |
70 if env.Bit('nacl_static_link'): | 56 if env.Bit('nacl_static_link'): |
71 # The exit status produced by sel_ldr. | 57 # The exit status produced by sel_ldr. |
72 validation_failure_status = '1' | 58 validation_failure_status = '1' |
73 else: | 59 else: |
74 # The exit status produced by the dynamic linker. | 60 # The exit status produced by the dynamic linker. |
75 validation_failure_status = '127' | 61 validation_failure_status = '127' |
76 node = env.CommandSelLdrTestNacl( | 62 node = env.CommandSelLdrTestNacl( |
77 'partly_invalid_1.out', partly_invalid_nexe, | 63 'partly_invalid_1.out', partly_invalid_nexe, |
78 exit_status=validation_failure_status) | 64 exit_status=validation_failure_status) |
79 env.AddNodeToTestSuite(node, test_suites, 'run_without_stubout_1_test', | 65 env.AddNodeToTestSuite(node, test_suites, 'run_without_stubout_1_test', |
80 is_broken=is_validation_disabled) | 66 is_broken=is_validation_disabled) |
81 | 67 |
82 # With "-c", the executable runs to completion but is not safe. | 68 # With "-c", the executable runs to completion but is not safe. |
83 node = env.CommandSelLdrTestNacl( | 69 node = env.CommandSelLdrTestNacl( |
84 'partly_invalid_2.out', partly_invalid_nexe, | 70 'partly_invalid_2.out', partly_invalid_nexe, |
85 stdout_golden=env.File('without_stubout.stdout'), | 71 stdout_golden=env.File('without_stubout.stdout'), |
86 sel_ldr_flags=['-c']) | 72 sel_ldr_flags=['-c']) |
87 env.AddNodeToTestSuite(node, test_suites, 'run_without_stubout_2_test') | 73 env.AddNodeToTestSuite(node, test_suites, 'run_without_stubout_2_test') |
88 | 74 |
Mark Seaborn
2014/10/08 22:32:58
Nit: remove trailing empty lines
shyamsundarr
2014/10/09 16:19:26
Done.
| |
89 # With "-s", the executable runs part way but then faults. | |
90 | 75 |
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 |