2 # Copyright (c) 2012 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.
6 # This is a basic functionality test to exercise the irt plumbing.
12 time_check = env.File('${SCONSTRUCT_DIR}/tools/time_check.py')
14 if env.Bit('tests_use_irt'):
15 clock_irt_test_nexe = env.ComponentProgram('clock_irt_test',
17 EXTRA_LIBS=['${NONIRT_LIBS}'],
20 node = env.CommandSelLdrTestNacl(
23 wrapper_program_prefix = [
24 '${PYTHON}', time_check, '-S',
26 '"Realtime\sclock\svalue[^\d]*(\d+\.\d*|\d*\.\d+)"',
29 env.AddNodeToTestSuite(node, ['small_tests'], 'run_clock_irt_test')
31 # The clock_gettime function is provided in librt in the glibc-based
32 # toolchain, whereas in the newlib-based toolchain it is in libc.
33 # This is because the clock_gettime etc functions were part of the
34 # "Advanced Real Time" portion of POSIX, and on normal glibc-based
35 # systems the Advanced Real Time functions are all in the rt library.
36 # In newlib, there is no librt, and everything got put into libc
39 if env.Bit('nacl_glibc'):
40 env.Append(LIBS=['-lrt'])
42 clock_get_test_nexe = env.ComponentProgram('clock_get_test',
44 EXTRA_LIBS=['${NONIRT_LIBS}'])
46 node = env.CommandSelLdrTestNacl(
49 wrapper_program_prefix = [
50 '${PYTHON}', time_check, '-S',
52 '"Realtime\sclock\svalue[^\d]*(\d+\.\d*|\d*\.\d+)"',
55 env.AddNodeToTestSuite(node, ['small_tests'], 'run_clock_get_test')
57 clock_test_nexe = env.ComponentProgram('clock_test',
59 EXTRA_LIBS=['${PTHREAD_LIBS}',
62 # On OSX and Windows, we have observed sleep returning early. The
63 # time_slop_args is used in clock_test to permit some extra slop
64 # in the elapsed time (in ms).
67 # On Linux the older scheduler implementation did not account properly
68 # for the time process spent waiting on the futex in thread join. This
69 # affects the CLOCK_PROCESS/THREAD_CPUTIME_ID clock test and we therefore
70 # disable this test on older kernels.
71 cputime_test_enabled = True
73 if env.Bit('host_windows') or env.Bit('host_mac'):
74 time_slop_args += [ '-s', '10' ]
75 elif env.Bit('host_linux'):
76 kernel_version = map(int, platform.release().split('.', 2)[:2])
77 if kernel_version < [3, 0]:
78 cputime_test_enabled = False
79 if env.UsingEmulator():
80 # The CPU time test uses threads and fences, which are flaky under QEMU.
81 cputime_test_enabled = False
82 # This test is flaky on mac10.7-newlib-dbg-asan.
83 # See https://code.google.com/p/nativeclient/issues/detail?id=3906
84 if env.Bit('asan') and env.Bit('host_mac'):
85 cputime_test_enabled = False
87 node = env.CommandSelLdrTestNacl(
92 env.AddNodeToTestSuite(node, ['small_tests'], 'run_clock_test')
94 node = env.CommandSelLdrTestNacl(
95 'clock_cputime_test.out',
100 env.AddNodeToTestSuite(node, ['large_tests'], 'run_clock_cputime_test',
101 is_broken=not cputime_test_enabled)