1# Copyright (C) 2003-2021 Free Software Foundation, Inc.
2#
3# This file is part of GCC.
4#
5# GCC is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# GCC is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with GCC; see the file COPYING3.  If not see
17# <http://www.gnu.org/licenses/>.
18
19# This harness is for testing builtin support.  Each test has two files:
20#
21#    - foo.c defines the main testing function, main_test().
22#    - foo-lib.c implements the library functions that foo.c is testing.
23#
24# The functions in foo-lib.c will often want to abort on certain inputs.
25# They can use the global variable inside_main to see whether they are
26# being called from the test program or part of the common runtime.
27#
28# In many cases, the library functions will behave as normal at -O0
29# and abort when optimisation is enabled.  Such implementations should
30# go into the lib/ directory so that they can be included by any test
31# that needs them.  They shouldn't call any external functions in case
32# those functions were overridden too.
33
34load_lib torture-options.exp
35load_lib c-torture.exp
36
37torture-init
38set-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
39
40set additional_flags "-fno-tree-dse -fno-tree-loop-distribute-patterns -fno-tracer -fno-ipa-ra -fno-inline-functions"
41if [istarget "powerpc-*-darwin*"] {
42   lappend additional_flags "-Wl,-multiply_defined,suppress"
43}
44if { [istarget *-*-eabi*]
45     || [istarget *-*-elf]
46     || [istarget *-*-mingw*]
47     || [istarget *-*-rtems*] } {
48   lappend additional_flags "-Wl,--allow-multiple-definition"
49}
50
51foreach src [lsort [find $srcdir/$subdir *.c]] {
52    if {![string match *-lib.c $src] && [runtest_file_p $runtests $src]} {
53	c-torture-execute [list $src \
54			        [file root $src]-lib.c \
55			        $srcdir/$subdir/lib/main.c] \
56				$additional_flags
57    }
58}
59
60torture-finish
61