1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
timeout_sec = 10
all_test_cases = [
'ansi/alloc',
'ansi/sscanf',
'ansi/sprintf',
'ansi/snprintf',
'ansi/utf8',
'ansi/strtol',
'ansi/strtof',
'ansi/abs',
'ansi/longjmp',
'ansi/mbrtoc32',
'ansi/strverscmp',
'ansi/strftime',
'ansi/strchr',
'ansi/strrchr',
'ansi/wcsrtombs',
'ansi/wmemcmp',
'ansi/timegm',
'ansi/ungetc',
'ansi/wcsdup',
'ansi/wcsncasecmp',
'ansi/fopen',
'ansi/memmem',
'ansi/creal-cimag',
'ansi/fenv',
'ansi/qsort',
'ansi/freopen',
'ansi/strxfrm',
'ansi/calloc',
'bsd/ns_get_put',
'bsd/reallocarray',
'bsd/strl',
'bsd/sbrk',
'posix/inet_ntop',
'posix/inet_pton',
'posix/access',
'posix/pthread_barrier',
'posix/pthread_rwlock',
'posix/pthread_cond',
'posix/pthread_create',
'posix/pthread_cancel',
'posix/pthread_atfork',
'posix/pthread_cleanup',
'posix/pthread_kill',
'posix/pthread_mutex',
'posix/pthread_key',
'posix/pthread_thread_local',
'posix/pthread_attr',
'posix/pthread_schedparam',
'posix/pwd',
'posix/fdopen',
'posix/fopencookie',
'posix/fmemopen',
'posix/getaddrinfo',
'posix/getdelim',
'posix/getnameinfo',
'posix/getservbyname',
'posix/getservbyport',
'posix/grp',
'posix/dprintf',
'posix/posix_memalign',
'posix/posix_spawn',
'posix/index',
'posix/rindex',
'posix/search',
'posix/open_memstream',
'posix/popen',
'posix/system', # This test should be in the ANSI tests, but it depends on sys/wait.h
'posix/sigsuspend',
'posix/sigaltstack',
'posix/time',
'posix/realpath',
'posix/ffs',
'posix/getcwd',
'posix/memrchr',
'posix/wordexp',
'posix/rlimits',
'posix/accept4',
'posix/setpriority',
'posix/alarm',
'posix/abort', # This test should be in the ANSI tests, but it depends on sigaction
'posix/timer',
'posix/vfork',
'posix/wcwidth',
'posix/pause',
'posix/flockfile',
'posix/basename',
'posix/regex',
'posix/sigtimedwait',
'posix/if_indextoname',
'posix/readv-writev',
'posix/posix-timer',
'posix/strdupa',
'posix/mkstemp',
'posix/waitid',
'glibc/getopt',
'glibc/ffsl-ffsll',
'glibc/error_message_count',
'glibc/error_one_per_line',
'glibc/error_print_progname',
'glibc/error_expect_fail',
'glibc/error',
'glibc/error_at_line',
'linux/xattr',
'linux/pthread_setname_np',
'linux/pthread_attr',
'linux/cpuset',
'linux/malloc-usable-size',
]
if host_machine.system() == 'linux'
all_test_cases += 'glibc/linux-syscall'
endif
fail_test_cases = [
'posix/abort',
'glibc/error_expect_fail',
]
wrapped_test_cases = [
'glibc/error',
'glibc/error_at_line',
]
host_libc_excluded_test_cases = [
'bsd/strl', # These functions do not exist on Linux.
]
host_libc_noasan_test_cases = [
'posix/pthread_cancel',
'posix/pthread_attr', # does some stack overflowing to check stack size
'posix/posix_memalign',
'posix/search', # requires tdelete (#351)
'ansi/calloc', # does some overflowing
'linux/pthread_attr', # encounters memory leaks
]
extra_cflags_test_cases = {
'ansi/calloc': ['-Wno-alloc-size-larger-than'],
}
test_sources = []
test_link_args = []
test_c_args = []
use_pie = false
test_c_args = []
test_link_args = []
# Our ubsan implementation can't be used by the tests themselves,
# since it is internal to libc.so and ld.so.
test_override_options = ['b_sanitize=none']
if library_type == 'static'
libc_dep = declare_dependency(
include_directories: libc_include_dirs,
link_with: libc_static,
dependencies: [libc_deps, rtlib_deps]
)
use_pie = false
test_c_args += '-no-pie'
test_link_args += ['-no-pie', '-static']
test_sources += [
'../options/internal' / host_machine.cpu_family() / 'mlibc_crtbegin.S',
'../options/internal' / host_machine.cpu_family() / 'mlibc_crtend.S',
crt,
]
else
libc_dep = declare_dependency(
include_directories: libc_include_dirs,
link_with: libc_shared,
dependencies: [libc_deps, rtlib_deps]
)
test_link_args += ['-Wl,--dynamic-linker=' + meson.build_root() + '/ld.so']
if host_machine.system() in ['linux']
use_pie = true
test_sources += crt_pie
else
use_pie = false
test_sources += crt
# Meson doesn't set these for us (issue #4651).
test_c_args += '-no-pie'
test_link_args += '-no-pie'
endif
# Add the rtdl tests.
if not disable_posix_option
subdir('rtdl')
endif
endif
py = import('python').find_installation('python3')
foreach test_name : all_test_cases
test_subdir = test_name.split('/')[0]
test_short_name = test_name.split('/')[1]
test_exec_name = test_name.replace('/', '-')
if test_subdir == 'ansi' and disable_ansi_option
continue
elif test_subdir == 'bsd' and disable_bsd_option
continue
elif test_subdir == 'glibc' and disable_glibc_option
continue
elif test_subdir == 'posix' and disable_posix_option
continue
elif test_subdir == 'linux' and disable_linux_option
continue
endif
should_fail = fail_test_cases.contains(test_name)
exec = executable(test_exec_name, [test_name + '.c', test_sources],
dependencies: libc_dep,
build_rpath: meson.build_root(),
override_options: test_override_options,
c_args: test_c_args,
link_args: test_link_args,
pie: use_pie,
)
if wrapped_test_cases.contains(test_name)
test(test_short_name,
py,
suite: test_subdir,
should_fail: should_fail,
args: [
meson.source_root() + '/tests/' + test_name + '.py',
exec
],
timeout: timeout_sec,
)
else
test(test_short_name, exec, suite: test_subdir, should_fail: should_fail, timeout: timeout_sec)
endif
if build_tests_host_libc and not host_libc_excluded_test_cases.contains(test_name)
if test_name in host_libc_noasan_test_cases
host_libc_sanitize_options = 'b_sanitize=undefined'
else
host_libc_sanitize_options = 'b_sanitize=address,undefined'
endif
if test_name in extra_cflags_test_cases
extra_cflags = extra_cflags_test_cases[test_name]
else
extra_cflags = []
endif
exec = executable('host-libc-' + test_exec_name, test_name + '.c',
build_rpath: meson.build_root(),
override_options: host_libc_sanitize_options,
c_args: ['-D_GNU_SOURCE', '-DUSE_HOST_LIBC', '-pthread', extra_cflags],
link_args: ['-lresolv', '-ldl', '-pthread', '-lm', '-lrt'],
native: true,
)
test(test_short_name, exec, suite: ['host-libc', test_subdir], should_fail: should_fail, timeout: timeout_sec)
endif
endforeach
|