• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2# Copyright (C) 2005, 2006, 2013 Red Hat, Inc.
3# This file is part of elfutils.
4#
5# This file 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 of the License, or
8# (at your option) any later version.
9#
10# elfutils is distributed in the hope that it will be useful, but
11# 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 this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
19. $srcdir/test-subr.sh
20
21# This tests all the miscellaneous components of backend support
22# against whatever this build is running on.  A platform will fail
23# this test if it is missing parts of the backend implementation.
24#
25# As new backend code is added to satisfy the test, be sure to update
26# the fixed test cases (run-allregs.sh et al) to test that backend
27# in all builds.
28
29tempfiles native.c native
30printf '#include <unistd.h>\nint main (void) { while (1) pause (); }\n' \
31  > native.c
32
33native=0
34kill_native()
35{
36  test $native -eq 0 || {
37    kill -9 $native 2> /dev/null || :
38    wait $native 2> /dev/null || :
39  }
40  native=0
41}
42
43native_cleanup()
44{
45  kill_native
46  test_cleanup
47}
48
49native_exit()
50{
51  native_cleanup
52  exit_cleanup
53}
54
55trap native_cleanup 1 2 15
56trap native_exit 0
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 &&
61  # Some shell versions don't do this right without the braces.
62  { ./native > /dev/null 2>&1 & native=$! ; } &&
63  sleep 1 && kill -0 $native 2> /dev/null &&
64  break ||
65  native=0
66done
67
68native_test()
69{
70  # Try the build against itself, i.e. $config_host.
71  testrun "$@" -e $1 > /dev/null
72
73  # Try the build against a presumed native process, running this sh.
74  # For tests requiring debug information, this may not test anything.
75  testrun "$@" -p $$ > /dev/null
76
77  # Try the build against the trivial native program we just built with -g.
78  test $native -eq 0 || testrun "$@" -p $native > /dev/null
79}
80
81native_test ${abs_builddir}/allregs
82native_test ${abs_builddir}/funcretval
83
84# We do this explicitly rather than letting the trap 0 cover it,
85# because as of version 3.1 bash prints the "Killed" report for
86# $native when we do the kill inside the exit handler.
87native_cleanup
88
89exit 0
90