2 # Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
8 def AddTest(env, src, exit_status='0', golden_file=None, test_suffix='',
9 is_broken=False, compile_env=None, link_env=None,
11 name = src.split('.')[0] + test_suffix
13 compile_env = compile_env or env
14 link_env = link_env or env
16 obj = compile_env.ComponentObject(name, src)
17 nexe = link_env.ComponentProgram(
18 name, obj, EXTRA_LIBS=['${NONIRT_LIBS}'] + EXTRA_LIBS)
19 node = env.CommandSelLdrTestNacl(
20 name + '.out', nexe, exit_status=exit_status,
21 stdout_golden=golden_file)
22 env.AddNodeToTestSuite(
23 node, ['toolchain_tests', 'small_tests'], 'run_' + name + '_test',
26 c_flags = ['-std=gnu99']
27 cxx_flags = (['-Wc++11-narrowing', '-std=gnu++11']
28 if env.Bit('bitcode') else ['-std=gnu++0x'])
30 native_env = env.Clone()
31 if env.Bit('bitcode'):
33 elif env.Bit('target_x86_32'):
34 native_flags = ['-msse2', '-msse3', '-msse4']
35 elif env.Bit('target_x86_64'):
36 native_flags = ['-msse2', '-msse3', '-msse4']
37 elif env.Bit('target_arm'):
38 native_flags = ['--target=armv7a-unknown-nacl-gnueabi','-mfloat-abi=hard']
39 elif env.Bit('target_mips32'):
41 native_env.Append(CFLAGS=c_flags)
42 native_env.Append(CXXFLAGS=cxx_flags)
43 native_env.Append(CCFLAGS=native_flags)
44 # C++ code can't use vector literals because of the following warning:
45 # compound literals are a C99-specific feature
46 # Remove pedantic to work around this issue.
47 native_env.FilterOut(CCFLAGS=['-pedantic'])
50 ref_flags = ['-DVREFIMPL']
51 ref_env.Append(CFLAGS=c_flags)
52 ref_env.Append(CXXFLAGS=cxx_flags)
53 ref_env.Append(CCFLAGS=ref_flags)
55 # TODO(jfb): The native environment currently doesn't compile.
56 if env.Bit('bitcode'):
57 AddTest(native_env, 'simd.cc', test_suffix='_native')
58 AddTest(ref_env, 'simd.cc', test_suffix='_ref')
60 # GCC 4.4 doesn't support all features of the vector extensions in C.
61 # TODO(jfb) Re-enable testing when we migrate to a newer GCC.
62 if env.Bit('bitcode') and env['TOOLCHAIN_FEATURE_VERSION'] >= 5:
63 AddTest(native_env, 'vector_extension.c',
64 golden_file=native_env.File('vector_extension.stdout'))
65 AddTest(native_env, 'vector_shuffle.cc',
66 golden_file=native_env.File('vector_shuffle.stdout'))