1#
2# SPDX-License-Identifier: BSD-3-Clause
3#
4# Copyright © 2019 Keith Packard
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12#
13# 2. Redistributions in binary form must reproduce the above
14#    copyright notice, this list of conditions and the following
15#    disclaimer in the documentation and/or other materials provided
16#    with the distribution.
17#
18# 3. Neither the name of the copyright holder nor the names of its
19#    contributors may be used to endorse or promote products derived
20#    from this software without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33# OF THE POSSIBILITY OF SUCH DAMAGE.
34#
35math_test_src = [
36  'acosf_vec.c',
37  'acoshf_vec.c',
38  'acosh_vec.c',
39  'acos_vec.c',
40  'asinf_vec.c',
41  'asinhf_vec.c',
42  'asinh_vec.c',
43  'asin_vec.c',
44  'atan2f_vec.c',
45  'atan2_vec.c',
46  'atanf_vec.c',
47  'atanhf_vec.c',
48  'atanh_vec.c',
49  'atan_vec.c',
50  'ceilf_vec.c',
51  'ceil_vec.c',
52  'copysign_vec.c',
53  'copysignf_vec.c',
54  'convert.c',
55  'conv_vec.c',
56  'cosf_vec.c',
57  'coshf_vec.c',
58  'cosh_vec.c',
59  'cos_vec.c',
60  'dvec.c',
61  'erfcf_vec.c',
62  'erfc_vec.c',
63  'erff_vec.c',
64  'erf_vec.c',
65  'expf_vec.c',
66  'exp_vec.c',
67  'fabsf_vec.c',
68  'fabs_vec.c',
69  'floorf_vec.c',
70  'floor_vec.c',
71  'fmodf_vec.c',
72  'fmod_vec.c',
73  'gammaf_vec.c',
74  'gamma_vec.c',
75  'hypotf_vec.c',
76  'hypot_vec.c',
77  'iconv_vec.c',
78  'issignaling_vec.c',
79  'j0f_vec.c',
80  'j0_vec.c',
81  'j1f_vec.c',
82  'j1_vec.c',
83  'jnf_vec.c',
84  'jn_vec.c',
85  'log10f_vec.c',
86  'log10_vec.c',
87  'log1pf_vec.c',
88  'log1p_vec.c',
89  'log2f_vec.c',
90  'log2_vec.c',
91  'logf_vec.c',
92  'log_vec.c',
93  'math2.c',
94  'math.c',
95  'modf_vec.c',
96  'modff_vec.c',
97  'pow_vec.c',
98  'powf_vec.c',
99  'scalb_vec.c',
100  'scalbn_vec.c',
101  'sinf_vec.c',
102  'sinhf_vec.c',
103  'sinh_vec.c',
104  'sin_vec.c',
105  'sprint_ivec.c',
106  'sprint_vec.c',
107  'sqrtf_vec.c',
108  'sqrt_vec.c',
109  'string.c',
110  'tanf_vec.c',
111  'tanhf_vec.c',
112  'tanh_vec.c',
113  'tan_vec.c',
114  'test.c',
115  'test_is.c',
116  'trunc_vec.c',
117  'truncf_vec.c',
118  'y0f_vec.c',
119  'y0_vec.c',
120  'y1f_vec.c',
121  'y1_vec.c',
122  'ynf_vec.c',
123  'yn_vec.c',
124]
125
126if has_ieeefp_funcs
127  math_test_src += [
128    'test_ieee.c',
129  ]
130endif
131
132#  'dcvt.c',
133
134foreach target : targets
135  value = get_variable('target_' + target)
136
137  libs = [get_variable('lib_c' + target)]
138  if is_variable('lib_semihost' + target)
139    libs += [get_variable('lib_semihost' + target)]
140  endif
141  if is_variable('crt0_hosted' + target)
142    objs = [get_variable('crt0_hosted'+ target)]
143  else
144    objs = []
145  endif
146
147  if target == ''
148    test_name = 'math_test'
149  else
150    test_name = 'math_test_' + target
151  endif
152
153  test(test_name,
154       executable(test_name, math_test_src,
155		  c_args: value[1] + double_printf_compile_args + test_c_args,
156		  objects: objs,
157		  link_with: libs,
158		  link_args: value[1] + double_printf_link_args + test_link_args,
159		  include_directories: inc),
160       depends: bios_bin,
161       env: test_env)
162endforeach
163
164if enable_native_tests
165
166  native_lib_m = cc.find_library('m', required: false)
167
168  if native_lib_m.found()
169    test('math-native',
170	 executable('math_test_native', math_test_src,
171		    c_args: native_c_args,
172		    dependencies: native_lib_m))
173  endif
174endif
175