1# 2# SPDX-License-Identifier: BSD-3-Clause 3# 4# Copyright © 2020 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 36semihost_tests = [ 37 'semihost-argv', 38 'semihost-exit', 39 'semihost-exit-extended', 40 'semihost-clock', 41 'semihost-errno', 42 'semihost-flen', 43 'semihost-get-cmdline', 44 'semihost-gettimeofday', 45 'semihost-istty', 46 'semihost-open', 47 'semihost-read', 48 'semihost-remove', 49 'semihost-rename', 50 'semihost-seek', 51 'semihost-system', 52 'semihost-time', 53 'semihost-times', 54 'semihost-writec', 55 'semihost-write0', 56] 57 58# These tests should pass, but are currently broken under qemu 59semihost_broken = [ 60 'semihost-elapsed', 61 'semihost-heapinfo', 62 'semihost-readc', 63 'semihost-tickfreq', 64 'semihost-tmpnam', 65 ] 66 67semihost_fail_tests = [ 68 'semihost-exit-failure', 69 'semihost-exit-extended-failure', 70 'semihost-system-failure', 71] 72 73command_line = 'hello world' 74 75foreach target : targets 76 value = get_variable('target_' + target) 77 78 _libs = [get_variable('lib_c' + target)] 79 _libs += [get_variable('lib_semihost' + target)] 80 if is_variable('crt0_semihost' + target) 81 _objs = [get_variable('crt0_semihost'+ target)] 82 elif is_variable('crt0_hosted' + target) 83 _objs = [get_variable('crt0_hosted'+ target)] 84 else 85 _objs = [] 86 endif 87 88 _c_args = value[1] + test_c_args + ['-DCOMMAND_LINE="' + command_line + '"'] 89 90 _link_args = value[1] + test_link_args 91 92 foreach semihost_test : semihost_tests 93 semihost_test_src = semihost_test + '.c' 94 if target == '' 95 semihost_test_name = semihost_test 96 else 97 semihost_test_name = semihost_test + '_' + target 98 endif 99 100 test(semihost_test_name, 101 executable(semihost_test_name, [semihost_test_src], 102 c_args: _c_args, 103 link_args: double_printf_link_args + _link_args, 104 objects: _objs, 105 link_with: _libs, 106 link_depends: test_link_depends, 107 include_directories: inc), 108 args: ['--', command_line], 109 depends: bios_bin, 110 env: test_env) 111 endforeach 112 113 foreach semihost_fail_test : semihost_fail_tests 114 semihost_fail_test_src = semihost_fail_test + '.c' 115 if target == '' 116 semihost_fail_test_name = semihost_fail_test 117 else 118 semihost_fail_test_name = semihost_fail_test + '_' + target 119 endif 120 121 test(semihost_fail_test_name, 122 executable(semihost_fail_test_name, [semihost_fail_test_src], 123 c_args: _c_args, 124 link_args: _link_args, 125 objects: _objs, 126 link_with: _libs, 127 link_depends: test_link_depends, 128 include_directories: inc), 129 args: ['--', command_line], 130 env: test_env, 131 should_fail: true) 132 endforeach 133 134endforeach 135