blob: e64b252fb11ed74924c1e360f01bdc9b7ff82693 [file] [log] [blame]
Roland McGrath94d26ad2005-12-13 23:24:37 +00001#! /bin/sh
Roland McGrathc40f58a2006-01-13 20:13:21 +00002# Copyright (C) 2005, 2006 Red Hat, Inc.
Ulrich Drepper361df7d2006-04-04 21:38:57 +00003# This file is part of Red Hat elfutils.
Roland McGrath94d26ad2005-12-13 23:24:37 +00004#
Ulrich Drepper361df7d2006-04-04 21:38:57 +00005# Red Hat elfutils is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by the
7# Free Software Foundation; version 2 of the License.
Roland McGrath94d26ad2005-12-13 23:24:37 +00008#
Ulrich Drepper361df7d2006-04-04 21:38:57 +00009# Red Hat elfutils is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with Red Hat elfutils; if not, write to the Free Software Foundation,
Ulrich Drepper1e9ef502006-04-04 22:29:06 +000016# Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
Ulrich Drepper361df7d2006-04-04 21:38:57 +000017#
18# Red Hat elfutils is an included package of the Open Invention Network.
19# An included package of the Open Invention Network is a package for which
20# Open Invention Network licensees cross-license their patents. No patent
21# license is granted, either expressly or impliedly, by designation as an
22# included package. Should you wish to participate in the Open Invention
23# Network licensing program, please visit www.openinventionnetwork.com
24# <http://www.openinventionnetwork.com>.
25
Roland McGrath94d26ad2005-12-13 23:24:37 +000026
27. $srcdir/test-subr.sh
28
29# This tests all the miscellaneous components of backend support
30# against whatever this build is running on. A platform will fail
31# this test if it is missing parts of the backend implementation.
32#
33# As new backend code is added to satisfy the test, be sure to update
34# the fixed test cases (run-allregs.sh et al) to test that backend
35# in all builds.
36
37tempfiles native.c native
38echo 'main () { while (1) pause (); }' > native.c
39
40native=0
Roland McGrathc40f58a2006-01-13 20:13:21 +000041kill_native()
42{
43 test $native -eq 0 || {
44 kill -9 $native 2> /dev/null || :
45 wait $native 2> /dev/null || :
46 }
47 native=0
48}
49
Roland McGrath94d26ad2005-12-13 23:24:37 +000050native_cleanup()
51{
Roland McGrathc40f58a2006-01-13 20:13:21 +000052 kill_native
53 test_cleanup
Roland McGrath94d26ad2005-12-13 23:24:37 +000054}
Roland McGrathc40f58a2006-01-13 20:13:21 +000055
Roland McGrath94d26ad2005-12-13 23:24:37 +000056trap native_cleanup 0 1 2 15
57
58for cc in "$HOSTCC" "$HOST_CC" cc gcc "$CC"; do
59 test "x$cc" != x || continue
60 $cc -o native -g native.c > /dev/null 2>&1 &&
Roland McGrath124a7982005-12-15 02:37:09 +000061 ./native > /dev/null 2>&1 & native=$! &&
Roland McGrath94d26ad2005-12-13 23:24:37 +000062 sleep 1 && kill -0 $native 2> /dev/null &&
63 break ||
64 native=0
65done
66
67native_test()
68{
69 # Try the build against itself, i.e. $config_host.
70 testrun "$@" -e $1 > /dev/null
71
72 # Try the build against a presumed native process, running this sh.
73 # For tests requiring debug information, this may not test anything.
74 testrun "$@" -p $$ > /dev/null
75
76 # Try the build against the trivial native program we just built with -g.
77 test $native -eq 0 || testrun "$@" -p $native > /dev/null
78}
79
80native_test ./allregs
81native_test ./funcretval
Roland McGrathc40f58a2006-01-13 20:13:21 +000082
83# We do this explicitly rather than letting the trap 0 cover it,
84# because as of version 3.1 bash prints the "Killed" report for
85# $native when we do the kill inside the exit handler.
86native_cleanup
87
88exit 0