Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # -*- python -*- | 1 # -*- python -*- |
| 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 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 | 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 # Case-by-case calling Convention Test for PNaCl and nacl-gcc compatibility. | 8 # Case-by-case calling Convention Test for PNaCl and nacl-gcc compatibility. |
| 9 | 9 |
| 10 # We make 4 modules. | 10 # We make 4 modules. |
| 11 # CC1 emits MODULE0 and CC2 MODULE1, CC2 emits MODULE2 and CC1 MODULE3 | 11 # CC1 emits MODULE0 and CC2 MODULE1, CC2 emits MODULE2 and CC1 MODULE3 |
| 12 # For the call test: | 12 # For the call test: |
| 13 # MODULE0(cc1) -> MODULE0(cc1) -> MODULE1(cc2) -> MODULE2(cc2) -> MODULE3(cc1). | 13 # MODULE0(cc1) -> MODULE0(cc1) -> MODULE1(cc2) -> MODULE2(cc2) -> MODULE3(cc1). |
| 14 # For the return test, the dataflow is reversed. | 14 # For the return test, the dataflow is reversed. |
| 15 | 15 |
| 16 # Environments for building module sources | 16 # For x86-64, there is a compatibility flag and calling conv attribute. |
| 17 envlist = [] | 17 # We use the same framework to test those as well. |
| 18 | 18 |
| 19 # For nacl-gcc, only do a self-test. | 19 |
| 20 # For ARM, there is no nacl-gcc so only do a self-test. | 20 # List of (4 envs for the modules, link_env, test_name_suffix) |
| 21 # Otherwise, mix them up! | 21 # to apply to each source. The 4 envs may have different flags. |
| 22 if not env.Bit('bitcode') or env.Bit('target_arm'): | 22 test_configurations = [] |
| 23 if not env.Bit('bitcode'): | 23 |
| 24 # Assume that for nacl-gcc, the bots have at least sse2. | 24 def AddCommonFlags(envlist): |
|
robertm
2011/11/16 20:38:28
I think it would be better to sort of inline this,
jvoung - send to chromium...
2011/11/17 23:06:01
Well there's the part where it needs to give each
| |
| 25 env.Append(CCFLAGS=['-msse2']) | 25 for (i, e) in enumerate(envlist): |
| 26 # Add -Wno-long-long because we use c99 long long constants in C++ code. | |
| 27 e.Append(CCFLAGS=['-DMODULE' + str(i), '-Wno-long-long']) | |
| 28 | |
| 29 def MakeSelfTestEnv(base_env, extra_flags): | |
|
robertm
2011/11/16 20:38:28
more explanation for how this is used would not hu
jvoung - send to chromium...
2011/11/17 23:06:01
Done.
| |
| 30 base_env = base_env.Clone() | |
| 31 base_env.Append(CCFLAGS=extra_flags) | |
| 32 envlist = [] | |
| 26 for i in xrange(4): | 33 for i in xrange(4): |
| 27 envlist.append(env.Clone()) # Same CC for all... | 34 envlist.append(base_env.Clone()) # Same CC for all... |
| 28 link_env = env | 35 AddCommonFlags(envlist) |
| 29 else: | 36 link_env = base_env |
| 37 return (envlist, link_env) | |
| 38 | |
| 39 def MakeCrossEnvs(base_env, extra_gcc_flags, extra_pnacl_flags): | |
| 40 envlist = [] | |
| 30 # For module0 | 41 # For module0 |
| 31 cc1_env = env.Clone() | 42 cc1_env = base_env.Clone() |
| 32 cc1_env.PNaClForceNative() | 43 cc1_env.PNaClForceNative() |
| 44 cc1_env.Append(CCFLAGS=extra_pnacl_flags) | |
| 33 envlist.append(cc1_env) | 45 envlist.append(cc1_env) |
| 34 # For module1 | 46 # For module1 |
| 35 cc2_env = env.PNaClGetNNaClEnv() | 47 cc2_env = base_env.PNaClGetNNaClEnv() |
| 36 # Assume that for nacl-gcc, the bots have at least sse2. | 48 cc2_env.Append(CCFLAGS=extra_gcc_flags) |
| 37 cc2_env.Append(CCFLAGS=['-msse2']) | |
| 38 # Add nacl-gcc compatibility flag (to be committed). | |
| 39 # cc2_env.Append(CCFLAGS=['-mstructs-on-stack']) | |
| 40 envlist.append(cc2_env) | 49 envlist.append(cc2_env) |
| 41 envlist.append(cc2_env.Clone()) # For module2 | 50 envlist.append(cc2_env.Clone()) # For module2 |
| 42 envlist.append(cc1_env.Clone()) # For module3 | 51 envlist.append(cc1_env.Clone()) # For module3 |
| 43 | |
| 44 link_env = cc1_env # To allow linking native objects (from ForceNative). | 52 link_env = cc1_env # To allow linking native objects (from ForceNative). |
| 45 | 53 AddCommonFlags(envlist) |
| 46 for (i, e) in enumerate(envlist): | 54 return (envlist, link_env) |
| 47 # Add -Wno-long-long because we use c99 long long constants in C++ code. | |
| 48 e.Append(CCFLAGS=['-DMODULE' + str(i), '-Wno-long-long']) | |
| 49 | 55 |
| 50 | 56 |
| 51 # Once the gcc flag is added (and/or if we do something with llvm). | 57 if not env.Bit('bitcode'): |
| 52 tis_broken = env.Bit('bitcode') and env.Bit('target_x86_64') | 58 # For gcc, only do a self-consistency test. |
| 59 # Assume for nacl-gcc the bots have at least sse2. | |
| 60 envlist, link_env = MakeSelfTestEnv(env, ['-msse2']) | |
| 61 test_configurations.append((envlist, link_env, '')) | |
| 62 else: | |
| 63 if env.Bit('target_arm'): | |
| 64 # For arm, there is no gcc, so just test pnacl (via native objects). | |
| 65 native_env = env.Clone() | |
| 66 native_env.PNaClForceNative() | |
| 67 envlist, link_env = MakeSelfTestEnv(native_env, []) | |
| 68 test_configurations.append((envlist, link_env, '')) | |
| 69 elif env.Bit('target_x86_32'): | |
| 70 # For x86-32 there is gcc, but no compatibility flags. | |
| 71 envlist, link_env = MakeCrossEnvs(env, ['-msse2'], []) | |
| 72 test_configurations.append((envlist, link_env, '')) | |
| 73 elif env.Bit('target_x86_64'): | |
| 74 # For x86-64 PNaCl we have more things to test. | |
| 75 # First test the command line flag. | |
| 76 envlist, link_env = MakeCrossEnvs(env, | |
| 77 ['-msse2', '-mpnacl-cconv'], []) | |
| 78 test_configurations.append((envlist, link_env, '')) | |
| 79 envlist, link_env = MakeCrossEnvs(env, | |
| 80 ['-msse2', '-DTEST_ATTRIBUTE_VIA_DECL'], | |
| 81 []) | |
| 82 test_configurations.append((envlist, link_env, '_decl')) | |
| 83 envlist, link_env = MakeCrossEnvs(env, | |
| 84 ['-msse2', '-DTEST_ATTRIBUTE_VIA_FP'], | |
| 85 []) | |
| 86 test_configurations.append((envlist, link_env, '_fp')) | |
| 87 else: | |
| 88 raise "Unknown target architecture!" | |
| 53 | 89 |
| 54 for test_source in ["return_structs.cc", | 90 # Helper function to make test nodes. |
|
robertm
2011/11/16 20:38:28
it might be simpler to not inline this one
jvoung - send to chromium...
2011/11/17 23:06:01
Done (you mean to inline this one).
| |
| 55 "call_structs.cc"]: | 91 def MakeProgramAndTest(objfiles, test_name): |
| 56 test_name = test_source.split('.')[0] | |
| 57 objfiles = [] | |
| 58 for (i, e) in enumerate(envlist): | |
| 59 obj = e.ComponentObject(test_name + '.' + str(i), test_source) | |
| 60 objfiles.append(obj) | |
| 61 prog = link_env.ComponentProgram(test_name, | 92 prog = link_env.ComponentProgram(test_name, |
| 62 objfiles, | 93 objfiles, |
| 63 EXTRA_LIBS=['${NONIRT_LIBS}']) | 94 EXTRA_LIBS=['${NONIRT_LIBS}']) |
| 64 node = env.CommandSelLdrTestNacl(test_name + '.out', | 95 node = env.CommandSelLdrTestNacl(test_name + '.out', |
| 65 prog) | 96 prog) |
| 66 env.AddNodeToTestSuite(node, ['small_tests'], | 97 env.AddNodeToTestSuite(node, ['small_tests', 'toolchain_tests'], |
| 67 'run_' + test_name + '_test', | 98 'run_' + test_name + '_test') |
| 68 is_broken=tis_broken) | 99 |
| 100 ###################################################################### | |
| 101 | |
| 102 for test_source in ['return_structs.cc', | |
| 103 'call_structs.cc']: | |
| 104 test_name = test_source.split('.')[0] | |
| 105 for (envlist, link_env, test_suffix) in test_configurations: | |
| 106 objfiles = [] | |
| 107 for (i, e) in enumerate(envlist): | |
| 108 obj = e.ComponentObject(test_name + test_suffix + '.' + str(i), | |
| 109 test_source) | |
| 110 objfiles.append(obj) | |
| 111 MakeProgramAndTest(objfiles, test_name + test_suffix) | |
| OLD | NEW |