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',
36 'win/nacl_fast_mutex.c',
37 'win/nacl_find_addrsp.c',
38 'win/nacl_host_desc.c',
39 'win/nacl_host_dir.c',
40 'win/lock_impl_win.cc',
41 'win/nacl_secure_random.c',
42 'win/nacl_semaphore.c',
43 'win/nacl_sync_win.cc',
46 'win/nacl_timestamp.c',
50 'win/xlate_system_error.c',
52 time_slop_args += [ '-s', '10' ]
53 # Needed for rand_s().
55 CCFLAGS = ['/D_CRT_RAND_S',
59 elif env.Bit('linux'):
62 'linux/nacl_host_dir.c',
63 'linux/nacl_semaphore.c',
65 kernel_version = map(int, platform.release().split('.', 2)[:2])
66 if kernel_version < [3, 0]:
67 cputime_test_enabled = False
71 'osx/nacl_host_dir.c',
72 'osx/nacl_semaphore.c',
75 time_slop_args += [ '-s', '10' ]
79 'posix/aligned_malloc.c',
80 'posix/condition_variable.c',
84 'posix/nacl_fast_mutex.c',
85 'posix/nacl_file_lock.c', # only used on Linux, but built/tested on Posix
86 'posix/nacl_find_addrsp.c',
87 'posix/nacl_host_desc.c',
88 'posix/nacl_secure_random.c',
89 'posix/nacl_thread_id.c',
90 'posix/nacl_threads.c',
92 'posix/nacl_timestamp.c',
97 'nacl_global_secure_random.c',
98 'nacl_host_desc_common.c',
99 'nacl_interruptible_condvar.c',
100 'nacl_interruptible_mutex.c',
102 'nacl_secure_random_common.c',
103 'nacl_sync_checked.c',
104 'nacl_time_common.c',
109 env.DualLibrary('platform', platform_inputs)
112 PORT_TEST_SOURCES = ['platform_tests.cc']
114 if env.Bit('windows'):
115 PORT_TEST_SOURCES = [PORT_TEST_SOURCES,
116 'win/port_win_test.c']
117 if env.Bit('build_x86_64'):
118 PORT_TEST_SOURCES = [PORT_TEST_SOURCES,
121 port_test_exe = env.ComponentProgram('port_test',
123 EXTRA_LIBS=['platform','gio'])
125 node = env.CommandTest('port_test.out',
128 env.AddNodeToTestSuite(node,
130 'run_platform_tests')
133 nacl_semaphore_test_exe = env.ComponentProgram('nacl_semaphore_test',
134 ['nacl_semaphore_test.c'],
135 EXTRA_LIBS=['platform',
137 node = env.CommandTest('nacl_semaphore_test.out',
138 command=[nacl_semaphore_test_exe])
140 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_semaphore_test')
143 nacl_host_dir_test_exe = env.ComponentProgram('nacl_host_dir_test',
144 ['nacl_host_dir_test.c'],
145 EXTRA_LIBS=['platform',
150 # For -d, env.Dir does not work. bradnelson@ says SCons's underlay
151 # works for Files, but possibly not for Dir -- and apparently it does
152 # not, since the path that results is OBJ_DIR relative.
154 node = env.CommandTest('nacl_host_dir_test.out',
155 [nacl_host_dir_test_exe,
157 env.File('testdata/sample_dir1_expected.txt'),
159 env.MakeTempDir(prefix='tmp_platform')])
160 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_host_dir_test')
163 nacl_clock_test_exe = env.ComponentProgram('nacl_clock_test',
164 ['nacl_clock_test.c'],
165 EXTRA_LIBS=['platform'])
167 node = env.CommandTest('nacl_clock_test.out',
168 [nacl_clock_test_exe] + time_slop_args)
170 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_clock_test')
172 node = env.CommandTest('nacl_clock_cputime_test.out',
173 [nacl_clock_test_exe, '-c'],
176 env.AddNodeToTestSuite(node, ['large_tests'], 'run_nacl_clock_cputime_test',
177 is_broken=not cputime_test_enabled)
180 nacl_sync_test_exe = env.ComponentProgram('nacl_sync_test',
181 ['nacl_sync_test.c'],
182 EXTRA_LIBS=['platform'])
184 for flavor in ['lock_lock', 'lock_trylock',
185 'trylock_lock', 'trylock_trylock']:
186 name = 'nacl_sync_' + flavor + '_test'
187 node = env.CommandTest(name + '.out',
188 [nacl_sync_test_exe, '-T', flavor])
190 env.AddNodeToTestSuite(node, ['small_tests'], 'run_' + name)
192 nacl_host_desc_mmap_test_exe = env.ComponentProgram(
193 'nacl_host_desc_mmap_test',
194 ['nacl_host_desc_mmap_test.c'],
195 EXTRA_LIBS=['platform',
196 'nrd_xfer']) # nrd_xfer for NaClDescEffectorTrustedMem
199 node = env.CommandTest('nacl_host_desc_mmap_test.out',
200 [nacl_host_desc_mmap_test_exe, '-t',
201 env.MakeTempDir(prefix='tmp_platform')])
203 env.AddNodeToTestSuite(node, ['small_tests'], 'run_nacl_host_desc_mmap_test',
204 is_broken=env.UsingEmulator())
206 if env.Bit('windows'):
207 nacl_host_desc_mmap_win_test_exe = env.ComponentProgram(
208 'nacl_host_desc_mmap_win_test',
209 ['win/nacl_host_desc_mmap_win_test.c'],
210 EXTRA_LIBS=['platform',
213 node = env.CommandTest('nacl_host_desc_mmap_win_test.out',
214 [nacl_host_desc_mmap_win_test_exe,
215 '-t', env.MakeTempDir(prefix='tmp_platform')])
217 env.AddNodeToTestSuite(node, ['small_tests'],
218 'run_nacl_host_desc_mmap_win_test')
220 nacl_host_desc_pread_pwrite_test_exe = env.ComponentProgram(
221 'nacl_host_desc_pread_pwrite_test',
222 ['nacl_host_desc_pread_pwrite_test.c'],
223 EXTRA_LIBS=['platform', 'nrd_xfer'])
225 node = env.CommandTest('nacl_host_desc_pread_pwrite_test.out',
226 [nacl_host_desc_pread_pwrite_test_exe,
227 '-t', env.MakeTempDir(prefix='tmp_platform')])
229 env.AddNodeToTestSuite(node, ['small_tests'],
230 'run_nacl_host_desc_pread_pwrite_test')
232 nacl_host_desc_big_file_nexe = env.ComponentProgram(
233 'nacl_host_desc_big_file_test',
234 ['nacl_host_desc_big_file_test.c'],
235 EXTRA_LIBS=['platform', 'nrd_xfer'])
237 d = os.path.join(str(env.Dir('${TARGET_ROOT}')), 'large_temporary_files')
239 os.makedirs(d) # if scons-out is missing, MakeTempDir would fail
241 pass # but the directory may already exist.
243 if env.Bit('mac') or env.Bit('windows'):
244 # OSX's HFS has no support for sparse files, so we generate a lot of
245 # disk I/O and this is expensive. On Windows, NTFS support sparse
246 # files, but ReFs does not. (We don't run on VFAT, so we can ignore
247 # that case.) Whether this is an expensive test depends on the
248 # filesystem type, so we err on the side of caution.
251 # On Linux, sparse file support at the filesystem level means that
252 # the test is fast -- cost is proportional to actual number of bytes
256 node = env.CommandTest(
257 'nacl_host_desc_big_file_test.out',
258 [nacl_host_desc_big_file_nexe, '-t',
259 env.MakeTempDir(prefix='tmp_platform', dir=d)],
262 env.AddNodeToTestSuite(node,
263 [test_size + '_tests'],
264 'run_nacl_host_desc_big_file_test',
265 is_broken=env.UsingEmulator())
266 # Qemu appears to not honor big file support and fails the lseek w/ EINVAL
268 env.EnsureRequiredBuildWarnings()