Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / clock / nacl.scons
1 # -*- python -*-
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.
5
6 # This is a basic functionality test to exercise the irt plumbing.
7
8 import platform
9
10 Import('env')
11
12 time_check = env.File('${SCONSTRUCT_DIR}/tools/time_check.py')
13
14 if env.Bit('tests_use_irt'):
15   clock_irt_test_nexe = env.ComponentProgram('clock_irt_test',
16                                              'clock_irt_test.c',
17                                              EXTRA_LIBS=['${NONIRT_LIBS}'],
18                                              )
19
20   node = env.CommandSelLdrTestNacl(
21       'clock_irt_test.out',
22       clock_irt_test_nexe,
23       wrapper_program_prefix = [
24         '${PYTHON}', time_check, '-S',
25         '-r',
26         '"Realtime\sclock\svalue[^\d]*(\d+\.\d*|\d*\.\d+)"',
27         '--'])
28
29   env.AddNodeToTestSuite(node, ['small_tests'], 'run_clock_irt_test')
30
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
37 # instead.
38
39 if env.Bit('nacl_glibc'):
40   env.Append(LIBS=['-lrt'])
41
42 clock_get_test_nexe = env.ComponentProgram('clock_get_test',
43                                            'clock_get_test.c',
44                                            EXTRA_LIBS=['${NONIRT_LIBS}'])
45
46 node = env.CommandSelLdrTestNacl(
47     'clock_get_test.out',
48     clock_get_test_nexe,
49     wrapper_program_prefix = [
50       '${PYTHON}', time_check, '-S',
51       '-r',
52       '"Realtime\sclock\svalue[^\d]*(\d+\.\d*|\d*\.\d+)"',
53       '--'])
54
55 env.AddNodeToTestSuite(node, ['small_tests'], 'run_clock_get_test')
56
57 clock_test_nexe = env.ComponentProgram('clock_test',
58                                        'clock_test.c',
59                                        EXTRA_LIBS=['${PTHREAD_LIBS}',
60                                                    '${NONIRT_LIBS}'])
61
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).
65 time_slop_args = []
66
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
72
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
86
87 node = env.CommandSelLdrTestNacl(
88     'clock_test.out',
89     clock_test_nexe,
90     time_slop_args)
91
92 env.AddNodeToTestSuite(node, ['small_tests'], 'run_clock_test')
93
94 node = env.CommandSelLdrTestNacl(
95     'clock_cputime_test.out',
96     clock_test_nexe,
97     ['-c'],
98     size='large')
99
100 env.AddNodeToTestSuite(node, ['large_tests'], 'run_clock_cputime_test',
101                         is_broken=not cputime_test_enabled)