Roland McGrath | 94d26ad | 2005-12-13 23:24:37 +0000 | [diff] [blame] | 1 | #! /bin/sh |
Mark Wielaard | 527e21e | 2013-04-27 23:15:44 +0200 | [diff] [blame] | 2 | # Copyright (C) 2005, 2006, 2013 Red Hat, Inc. |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 3 | # This file is part of elfutils. |
Roland McGrath | 94d26ad | 2005-12-13 23:24:37 +0000 | [diff] [blame] | 4 | # |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 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. |
Roland McGrath | 94d26ad | 2005-12-13 23:24:37 +0000 | [diff] [blame] | 9 | # |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 10 | # elfutils is distributed in the hope that it will be useful, but |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 14 | # |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 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/>. |
Ulrich Drepper | 361df7d | 2006-04-04 21:38:57 +0000 | [diff] [blame] | 17 | |
Roland McGrath | 94d26ad | 2005-12-13 23:24:37 +0000 | [diff] [blame] | 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 | |
| 29 | tempfiles native.c native |
| 30 | echo 'main () { while (1) pause (); }' > native.c |
| 31 | |
| 32 | native=0 |
Roland McGrath | c40f58a | 2006-01-13 20:13:21 +0000 | [diff] [blame] | 33 | kill_native() |
| 34 | { |
| 35 | test $native -eq 0 || { |
| 36 | kill -9 $native 2> /dev/null || : |
| 37 | wait $native 2> /dev/null || : |
| 38 | } |
| 39 | native=0 |
| 40 | } |
| 41 | |
Roland McGrath | 94d26ad | 2005-12-13 23:24:37 +0000 | [diff] [blame] | 42 | native_cleanup() |
| 43 | { |
Roland McGrath | c40f58a | 2006-01-13 20:13:21 +0000 | [diff] [blame] | 44 | kill_native |
| 45 | test_cleanup |
Roland McGrath | 94d26ad | 2005-12-13 23:24:37 +0000 | [diff] [blame] | 46 | } |
Roland McGrath | c40f58a | 2006-01-13 20:13:21 +0000 | [diff] [blame] | 47 | |
Mark Wielaard | 527e21e | 2013-04-27 23:15:44 +0200 | [diff] [blame] | 48 | native_exit() |
| 49 | { |
| 50 | native_cleanup |
| 51 | exit_cleanup |
| 52 | } |
| 53 | |
| 54 | trap native_cleanup 1 2 15 |
| 55 | trap native_exit 0 |
Roland McGrath | 94d26ad | 2005-12-13 23:24:37 +0000 | [diff] [blame] | 56 | |
| 57 | for cc in "$HOSTCC" "$HOST_CC" cc gcc "$CC"; do |
| 58 | test "x$cc" != x || continue |
| 59 | $cc -o native -g native.c > /dev/null 2>&1 && |
Roland McGrath | c373d85 | 2006-10-10 00:25:21 +0000 | [diff] [blame] | 60 | # Some shell versions don't do this right without the braces. |
| 61 | { ./native > /dev/null 2>&1 & native=$! ; } && |
Roland McGrath | 94d26ad | 2005-12-13 23:24:37 +0000 | [diff] [blame] | 62 | sleep 1 && kill -0 $native 2> /dev/null && |
| 63 | break || |
| 64 | native=0 |
| 65 | done |
| 66 | |
| 67 | native_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 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 80 | native_test ${abs_builddir}/allregs |
| 81 | native_test ${abs_builddir}/funcretval |
Roland McGrath | c40f58a | 2006-01-13 20:13:21 +0000 | [diff] [blame] | 82 | |
| 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. |
| 86 | native_cleanup |
| 87 | |
| 88 | exit 0 |