3 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
15 # On OSX and Windows, we have observed sleep returning early. The
16 # time_slop_args is used in nacl_clock_test to permit some extra slop
17 # in the elapsed time (in ms).
20 # On Linux the older scheduler implementation did not account properly for
21 # the time process spent waiting on the futex in thread join. This affects
22 # the CLOCK_PROCESS/THREAD_CPUTIME_ID clock test and we therefore disable
23 # this test on older kernels. In a coverage build, the test becomes
24 # unreasonably slow. This test seems to crash sometimes under QEMU.
25 cputime_test_enabled = (not env.Bit('coverage_enabled') and
26 not env.UsingEmulator())
28 if env.Bit('windows'):
30 'win/aligned_malloc.c',
31 'win/condition_variable.cc',
35 'win/nacl_fast_mutex.c',
36 'win/nacl_find_addrsp.c',
37 'win/nacl_host_desc.c',
38 'win/nacl_host_dir.c',
39 'win/lock_impl_win.cc',
40 'win/nacl_secure_random.c',
41 'win/nacl_semaphore.c',
42 'win/nacl_sync_win.cc',
45 'win/nacl_timestamp.c',
49 'win/xlate_system_error.c',
51 time_slop_args += [ '-s', '10' ]
52 # Needed for rand_s().
54 CCFLAGS = ['/D_CRT_RAND_S',
58 elif env.Bit('linux'):
61 'linux/nacl_host_dir.c',
62 'linux/nacl_semaphore.c',
64 kernel_version = map(int, platform.release().split('.', 2)[:2])
65 if kernel_version < [3, 0]:
66 cputime_test_enabled = False
70 'osx/nacl_host_dir.c',
71 'osx/nacl_semaphore.c',
74 time_slop_args += [ '-s', '10' ]
78 'posix/aligned_malloc.c',
79 'posix/condition_variable.c',
82 'posix/nacl_fast_mutex.c',
83 'posix/nacl_file_lock.c', # only used on Linux, but built/tested on Posix
84 'posix/nacl_find_addrsp.c',
85 'posix/nacl_host_desc.c',
86 'posix/nacl_secure_random.c',
87 'posix/nacl_thread_id.c',
88 'posix/nacl_threads.c',
90 'posix/nacl_timestamp.c',
95 'nacl_global_secure_random.c',
96 'nacl_host_desc_common.c',
97 'nacl_interruptible_condvar.c',
98 'nacl_interruptible_mutex.c',
100 'nacl_secure_random_common.c',
101 'nacl_sync_checked.c',
102 'nacl_time_common.c',
107 env.DualLibrary('platform', platform_inputs)
110 PORT_TEST_SOURCES = ['platform_tests.cc']
112 if env.Bit('windows'):
113 PORT_TEST_SOURCES = [PORT_TEST_SOURCES,
114 'win/port_win_test.c']
115 if env.Bit('build_x86_64'):
116 PORT_TEST_SOURCES = [PORT_TEST_SOURCES,
119 port_test_exe = env.ComponentProgram('port_test',
121 EXTRA_LIBS=['platform','gio'])
123 node = env.CommandTest('port_test.out',
126 env.AddNodeToTestSuite(node,
128 'run_platform_tests')
131 nacl_semaphore_test_exe = env.ComponentProgram('nacl_semaphore_test',
132 ['nacl_semaphore_test.c'],
133 EXTRA_LIBS=['platform',
135 node = env.CommandTest('nacl_semaphore_test.out',
136 command=[nacl_semaphore_test_exe])
138 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_semaphore_test')
141 nacl_host_dir_test_exe = env.ComponentProgram('nacl_host_dir_test',
142 ['nacl_host_dir_test.c'],
143 EXTRA_LIBS=['platform',
148 # For -d, env.Dir does not work. bradnelson@ says SCons's underlay
149 # works for Files, but possibly not for Dir -- and apparently it does
150 # not, since the path that results is OBJ_DIR relative.
152 node = env.CommandTest('nacl_host_dir_test.out',
153 [nacl_host_dir_test_exe,
155 env.File('testdata/sample_dir1_expected.txt'),
157 env.MakeTempDir(prefix='tmp_platform')])
158 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_host_dir_test')
161 nacl_clock_test_exe = env.ComponentProgram('nacl_clock_test',
162 ['nacl_clock_test.c'],
163 EXTRA_LIBS=['platform'])
165 node = env.CommandTest('nacl_clock_test.out',
166 [nacl_clock_test_exe] + time_slop_args)
168 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_clock_test')
170 node = env.CommandTest('nacl_clock_cputime_test.out',
171 [nacl_clock_test_exe, '-c'],
174 env.AddNodeToTestSuite(node, ['large_tests'], 'run_nacl_clock_cputime_test',
175 is_broken=not cputime_test_enabled)
178 nacl_sync_test_exe = env.ComponentProgram('nacl_sync_test',
179 ['nacl_sync_test.c'],
180 EXTRA_LIBS=['platform'])
182 for flavor in ['lock_lock', 'lock_trylock',
183 'trylock_lock', 'trylock_trylock']:
184 name = 'nacl_sync_' + flavor + '_test'
185 node = env.CommandTest(name + '.out',
186 [nacl_sync_test_exe, '-T', flavor])
188 env.AddNodeToTestSuite(node, ['small_tests'], 'run_' + name)
190 nacl_host_desc_mmap_test_exe = env.ComponentProgram(
191 'nacl_host_desc_mmap_test',
192 ['nacl_host_desc_mmap_test.c'],
193 EXTRA_LIBS=['platform',
194 'nrd_xfer']) # nrd_xfer for NaClDescEffectorTrustedMem
197 node = env.CommandTest('nacl_host_desc_mmap_test.out',
198 [nacl_host_desc_mmap_test_exe, '-t',
199 env.MakeTempDir(prefix='tmp_platform')])
201 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_host_desc_mmap_test',
202 is_broken=env.UsingEmulator())
204 if env.Bit('windows'):
205 nacl_host_desc_mmap_win_test_exe = env.ComponentProgram(
206 'nacl_host_desc_mmap_win_test',
207 ['win/nacl_host_desc_mmap_win_test.c'],
208 EXTRA_LIBS=['platform',
211 node = env.CommandTest('nacl_host_desc_mmap_win_test.out',
212 [nacl_host_desc_mmap_win_test_exe,
213 '-t', env.MakeTempDir(prefix='tmp_platform')])
215 env.AddNodeToTestSuite(node, ['small_tests'],
216 'run_nacl_host_desc_mmap_win_test')
218 nacl_host_desc_pread_pwrite_test_exe = env.ComponentProgram(
219 'nacl_host_desc_pread_pwrite_test',
220 ['nacl_host_desc_pread_pwrite_test.c'],
221 EXTRA_LIBS=['platform', 'nrd_xfer'])
223 node = env.CommandTest('nacl_host_desc_pread_pwrite_test.out',
224 [nacl_host_desc_pread_pwrite_test_exe,
225 '-t', env.MakeTempDir(prefix='tmp_platform')])
227 env.AddNodeToTestSuite(node, ['small_tests'],
228 'run_nacl_host_desc_pread_pwrite_test')
230 nacl_host_desc_big_file_nexe = env.ComponentProgram(
231 'nacl_host_desc_big_file_test',
232 ['nacl_host_desc_big_file_test.c'],
233 EXTRA_LIBS=['platform'])
235 d = os.path.join(str(env.Dir('${TARGET_ROOT}')), 'large_temporary_files')
237 os.makedirs(d) # if scons-out is missing, MakeTempDir would fail
239 pass # but the directory may already exist.
241 if env.Bit('mac') or env.Bit('windows'):
242 # OSX's HFS has no support for sparse files, so we generate a lot of
243 # disk I/O and this is expensive. On Windows, NTFS support sparse
244 # files, but ReFs does not. (We don't run on VFAT, so we can ignore
245 # that case.) Whether this is an expensive test depends on the
246 # filesystem type, so we err on the side of caution.
249 # On Linux, sparse file support at the filesystem level means that
250 # the test is fast -- cost is proportional to actual number of bytes
254 node = env.CommandTest(
255 'nacl_host_desc_big_file_test.out',
256 [nacl_host_desc_big_file_nexe, '-t',
257 env.MakeTempDir(prefix='tmp_platform', dir=d)],
260 env.AddNodeToTestSuite(node,
261 [test_size + '_tests'],
262 'run_nacl_host_desc_big_file_test',
263 is_broken=env.UsingEmulator())
264 # Qemu appears to not honor big file support and fails the lseek w/ EINVAL
266 env.EnsureRequiredBuildWarnings()