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# 35 36# Some arrays have more members than what can be supported on some targets. 37# Split the arrays into chunks of ~4k, and compile a separate test for each 38# chunk. Meson 0.58 has range(), but 0.53 is supported, so make an array 39# of numbers to iterate over. 40 41if get_option('split-large-tests') 42 test_parts = [ 43 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 44 '10', '11', '12', '13', '14', '15', '16', 45 ] 46else 47 test_parts = ['-1'] 48endif 49 50math_test_src = [ 51 'acosf_vec.c', 52 'acoshf_vec.c', 53 'acosh_vec.c', 54 'acos_vec.c', 55 'asinf_vec.c', 56 'asinhf_vec.c', 57 'asinh_vec.c', 58 'asin_vec.c', 59 'atan2f_vec.c', 60 'atan2_vec.c', 61 'atanf_vec.c', 62 'atanhf_vec.c', 63 'atanh_vec.c', 64 'atan_vec.c', 65 'ceilf_vec.c', 66 'ceil_vec.c', 67 'copysign_vec.c', 68 'copysignf_vec.c', 69 'convert.c', 70 'conv_vec.c', 71 'cosf_vec.c', 72 'coshf_vec.c', 73 'cosh_vec.c', 74 'cos_vec.c', 75 'dvec.c', 76 'erfcf_vec.c', 77 'erfc_vec.c', 78 'erff_vec.c', 79 'erf_vec.c', 80 'expf_vec.c', 81 'exp_vec.c', 82 'fabsf_vec.c', 83 'fabs_vec.c', 84 'floorf_vec.c', 85 'floor_vec.c', 86 'fmodf_vec.c', 87 'fmod_vec.c', 88 'gammaf_vec.c', 89 'gamma_vec.c', 90 'hypotf_vec.c', 91 'hypot_vec.c', 92 'iconv_vec.c', 93 'issignaling_vec.c', 94 'j0f_vec.c', 95 'j0_vec.c', 96 'j1f_vec.c', 97 'j1_vec.c', 98 'jnf_vec.c', 99 'jn_vec.c', 100 'log10f_vec.c', 101 'log10_vec.c', 102 'log1pf_vec.c', 103 'log1p_vec.c', 104 'log2f_vec.c', 105 'log2_vec.c', 106 'logf_vec.c', 107 'log_vec.c', 108 'math2.c', 109 'math.c', 110 'modf_vec.c', 111 'modff_vec.c', 112 'pow_vec.c', 113 'powf_vec.c', 114 'scalb_vec.c', 115 'scalbn_vec.c', 116 'sinf_vec.c', 117 'sinhf_vec.c', 118 'sinh_vec.c', 119 'sin_vec.c', 120 'sprint_ivec.c', 121 'sprint_vec.c', 122 'sqrtf_vec.c', 123 'sqrt_vec.c', 124 'string.c', 125 'tanf_vec.c', 126 'tanhf_vec.c', 127 'tanh_vec.c', 128 'tan_vec.c', 129 'test.c', 130 'test_is.c', 131 'trunc_vec.c', 132 'truncf_vec.c', 133 'y0f_vec.c', 134 'y0_vec.c', 135 'y1f_vec.c', 136 'y1_vec.c', 137 'ynf_vec.c', 138 'yn_vec.c', 139] 140 141if has_ieeefp_funcs 142 math_test_src += [ 143 'test_ieee.c', 144 ] 145endif 146 147# 'dcvt.c', 148 149skip_math_test = meson.get_cross_property('skip_math_test', []) 150 151foreach target : targets 152 153 if target in skip_math_test 154 continue 155 endif 156 157 value = get_variable('target_' + target) 158 159 libs = [get_variable('lib_c' + target)] 160 if is_variable('lib_semihost' + target) 161 libs += [get_variable('lib_semihost' + target)] 162 endif 163 if is_variable('crt0_hosted' + target) 164 objs = [get_variable('crt0_hosted'+ target)] 165 else 166 objs = [] 167 endif 168 169 _c_args = value[1] + get_variable('test_c_args_' + target, test_c_args) 170 _link_args = value[1] + get_variable('test_link_args_' + target, test_link_args) 171 _link_depends = get_variable('test_link_depends_' + target, test_link_depends) 172 173 _c_args = double_printf_compile_args + _c_args 174 _link_args = double_printf_link_args + _link_args 175 176 foreach test_part : test_parts 177 if test_part == '-1' 178 test_part_name = '' 179 else 180 test_part_name = '_' + test_part 181 endif 182 if target == '' 183 test_name = 'math_test' + test_part_name 184 else 185 test_name = 'math_test' + test_part_name + '_' + target 186 endif 187 test(test_name, 188 executable(test_name, math_test_src, 189 c_args: _c_args + ['-DTEST_PART=' + test_part], 190 objects: objs, 191 link_with: libs, 192 link_args: _link_args, 193 link_depends: _link_depends, 194 include_directories: inc), 195 depends: bios_bin, 196 env: test_env) 197 endforeach 198endforeach 199 200if enable_native_tests 201 202 native_lib_m = cc.find_library('m', required: false) 203 204 if native_lib_m.found() 205 defines = ['-DINCLUDE_GENERATE', '-DTEST_PART=-1'] 206 test('math_test_native', 207 executable('math_test_native', math_test_src, 208 c_args: native_c_args + defines, 209 link_args: native_c_args, 210 dependencies: native_lib_m)) 211 endif 212endif 213