Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: tests/callingconv_case_by_case/nacl.scons

Issue 8502006: Extend callingconv_case_by_case test to exercise the "pnaclcall" (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: comment Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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):
25 env.Append(CCFLAGS=['-msse2']) 25 for (i, e) in enumerate(envlist):
26 for i in xrange(4): 26 # Add -Wno-long-long because we use c99 long long constants in C++ code.
27 envlist.append(env.Clone()) # Same CC for all... 27 e.Append(CCFLAGS=['-DMODULE' + str(i), '-Wno-long-long'])
28 link_env = env 28
29 else: 29 def MakeSelfTestEnv(base_env, extra_flags):
30 """ Make a list of four (nearly identical) envs which use the same CC
31 for compiling the four modules to test self-consistency. """
32 base_env = base_env.Clone()
33 base_env.Append(CCFLAGS=extra_flags)
34 # Same CC for all, but assign different module defines later.
35 envlist = [base_env.Clone() for dummy_count in xrange(4)]
36 AddCommonFlags(envlist)
37 link_env = base_env
38 return (envlist, link_env)
39
40 def MakeCrossEnvs(base_env, extra_gcc_flags, extra_pnacl_flags):
41 """ Make a list of four (nearly identical) envs, some of which use gcc
42 and some use pnacl, for compiling the four modules to test consistency. """
43 envlist = []
30 # For module0 44 # For module0
31 cc1_env = env.Clone() 45 cc1_env = base_env.Clone()
32 cc1_env.PNaClForceNative() 46 cc1_env.PNaClForceNative()
47 cc1_env.Append(CCFLAGS=extra_pnacl_flags)
33 envlist.append(cc1_env) 48 envlist.append(cc1_env)
34 # For module1 49 # For module1
35 cc2_env = env.PNaClGetNNaClEnv() 50 cc2_env = base_env.PNaClGetNNaClEnv()
36 # Assume that for nacl-gcc, the bots have at least sse2. 51 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) 52 envlist.append(cc2_env)
41 envlist.append(cc2_env.Clone()) # For module2 53 envlist.append(cc2_env.Clone()) # For module2
42 envlist.append(cc1_env.Clone()) # For module3 54 envlist.append(cc1_env.Clone()) # For module3
43
44 link_env = cc1_env # To allow linking native objects (from ForceNative). 55 link_env = cc1_env # To allow linking native objects (from ForceNative).
45 56 AddCommonFlags(envlist)
46 for (i, e) in enumerate(envlist): 57 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 58
50 59
51 # Once the gcc flag is added (and/or if we do something with llvm). 60 if not env.Bit('bitcode'):
52 tis_broken = env.Bit('bitcode') and env.Bit('target_x86_64') 61 # For gcc, only do a self-consistency test.
62 # Assume for nacl-gcc the bots have at least sse2.
63 envlist, link_env = MakeSelfTestEnv(env, ['-msse2'])
64 test_configurations.append((envlist, link_env, ''))
65 else:
66 if env.Bit('target_arm'):
67 # For arm, there is no gcc, so just test pnacl (via native objects).
68 native_env = env.Clone()
69 native_env.PNaClForceNative()
70 envlist, link_env = MakeSelfTestEnv(native_env, [])
71 test_configurations.append((envlist, link_env, ''))
72 elif env.Bit('target_x86_32'):
73 # For x86-32 there is gcc, but no compatibility flags.
74 envlist, link_env = MakeCrossEnvs(env, ['-msse2'], [])
75 test_configurations.append((envlist, link_env, ''))
76 elif env.Bit('target_x86_64'):
77 # For x86-64 PNaCl we have more things to test.
78 # First test the command line flag.
79 envlist, link_env = MakeCrossEnvs(env,
80 ['-msse2', '-mpnacl-cconv'], [])
81 test_configurations.append((envlist, link_env, ''))
82 envlist, link_env = MakeCrossEnvs(env,
83 ['-msse2', '-DTEST_ATTRIBUTE_VIA_DECL'],
84 [])
85 test_configurations.append((envlist, link_env, '_decl'))
86 envlist, link_env = MakeCrossEnvs(env,
87 ['-msse2', '-DTEST_ATTRIBUTE_VIA_FP'],
88 [])
89 test_configurations.append((envlist, link_env, '_fp'))
90 else:
91 raise "Unknown target architecture!"
53 92
54 for test_source in ["return_structs.cc", 93 ######################################################################
55 "call_structs.cc"]: 94
95 for test_source in ['return_structs.cc',
96 'call_structs.cc']:
56 test_name = test_source.split('.')[0] 97 test_name = test_source.split('.')[0]
57 objfiles = [] 98 for (envlist, link_env, test_suffix) in test_configurations:
58 for (i, e) in enumerate(envlist): 99 objfiles = []
59 obj = e.ComponentObject(test_name + '.' + str(i), test_source) 100 test_full_name = test_name + test_suffix
60 objfiles.append(obj) 101 for (i, e) in enumerate(envlist):
61 prog = link_env.ComponentProgram(test_name, 102 obj = e.ComponentObject(test_full_name + '.' + str(i),
62 objfiles, 103 test_source)
63 EXTRA_LIBS=['${NONIRT_LIBS}']) 104 objfiles.append(obj)
64 node = env.CommandSelLdrTestNacl(test_name + '.out', 105 prog = link_env.ComponentProgram(test_full_name,
65 prog) 106 objfiles,
66 env.AddNodeToTestSuite(node, ['small_tests'], 107 EXTRA_LIBS=['${NONIRT_LIBS}'])
67 'run_' + test_name + '_test', 108 node = env.CommandSelLdrTestNacl(test_full_name + '.out',
68 is_broken=tis_broken) 109 prog)
110 env.AddNodeToTestSuite(node, ['small_tests', 'toolchain_tests'],
111 'run_' + test_full_name + '_test')
OLDNEW
« no previous file with comments | « tests/callingconv_case_by_case/for_each_type.h ('k') | tests/callingconv_case_by_case/return_structs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698