2 # Copyright 2009 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.
9 # Do not run any of the compiles below when in built_elsewhere mode
10 # because we cannot assume having a working compiler.
11 if env.Bit('built_elsewhere'):
14 nacl_base_lib_inputs = [
18 env.DualLibrary('nacl_base', nacl_base_lib_inputs,
19 EXTRA_LIBS=['platform'])
21 nacl_base_test_exe = env.ComponentProgram('nacl_base_test',
24 node = env.CommandTest(
26 command=[nacl_base_test_exe])
27 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_base_test')
29 def FailsGood(exit_status):
35 # Compile-time failures in nacl_macros.h only work for gcc right now.
36 if not env.Bit('windows'):
38 # fail_compile_c_env is a special build environment that succeeds
39 # iff there was a compile-time failure -- i.e., the various
40 # assertion macros made gcc notice that there was a problem. Since
41 # the assertion macros should work for both C and C++ compiles (or
42 # there are two versions of the macros), we also build using
43 # fail_compile_cxx_env. These environments and tests detect false
44 # negatives. Because the macros could fail by generating build
45 # failures when none should occur (false positives), we also have
46 # the _ok tests, even those such false positives ought to be quickly
47 # detected in normal use.
49 fail_compile_c_env = env.Clone()
50 fail_compile_c_env['CCCOM'] = Action(fail_compile_c_env['CCCOM'],
51 exitstatfunc=FailsGood)
53 fail_compile_cxx_env = env.Clone()
54 fail_compile_cxx_env['CCCOM'] = Action(fail_compile_cxx_env['CXXCOM'],
55 exitstatfunc=FailsGood)
57 for build_env, name_modifier in [ (fail_compile_c_env, '_c'),
58 (fail_compile_cxx_env, '_cxx') ]:
59 for test_base in ['nacl_base_assert_is_array',
60 'nacl_base_assert_is_pointer',
61 'nacl_base_array_size']:
62 for env_to_use, ok in [(env, '_ok'), (build_env, '')]:
64 obj = env_to_use.ComponentObject(test_base + ok +
65 name_modifier + '_test',
66 [test_base + ok + '_test.c'])
67 env_to_use.AlwaysBuild(obj)
68 env_to_use.Alias('small_tests', obj)
69 env_to_use.Alias('compile_tests', obj)
71 nacl_min_max_test_exe = env.ComponentProgram('nacl_min_max_test',
72 ['nacl_min_max_test.c'])
74 node = env.CommandTest(
75 'nacl_min_max_test.out',
76 command=[nacl_min_max_test_exe])
77 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_min_max_test')
79 # build nacl_min_max_test.c as a C++ program to make sure that there
80 # aren't weird operator precedence issues that would cause the min/max
81 # macros to behave differently
82 nacl_min_max_env = env.Clone()
83 nacl_min_max_env['CCCOM'] = Action(nacl_min_max_env['CXXCOM'])
84 if nacl_min_max_env.Bit('clang'):
85 nacl_min_max_env.Append(CXXFLAGS='-Wno-deprecated')
86 nacl_min_max_cpp_test_obj = nacl_min_max_env.ComponentObject(
87 'nacl_min_max_cpp_test',
88 ['nacl_min_max_test.c'])
89 nacl_min_max_cpp_test_exe = nacl_min_max_env.ComponentProgram(
90 'nacl_min_max_cpp_test',
91 nacl_min_max_cpp_test_obj)
92 node = env.CommandTest(
93 'nacl_min_max_cpp_test.out',
94 command=[nacl_min_max_cpp_test_exe])
95 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_min_max_cpp_test')