1da0c48c4Sopenharmony_ci#! /bin/sh 2da0c48c4Sopenharmony_ci# Copyright (C) 2005, 2006, 2013 Red Hat, Inc. 3da0c48c4Sopenharmony_ci# This file is part of elfutils. 4da0c48c4Sopenharmony_ci# 5da0c48c4Sopenharmony_ci# This file is free software; you can redistribute it and/or modify 6da0c48c4Sopenharmony_ci# it under the terms of the GNU General Public License as published by 7da0c48c4Sopenharmony_ci# the Free Software Foundation; either version 3 of the License, or 8da0c48c4Sopenharmony_ci# (at your option) any later version. 9da0c48c4Sopenharmony_ci# 10da0c48c4Sopenharmony_ci# elfutils is distributed in the hope that it will be useful, but 11da0c48c4Sopenharmony_ci# WITHOUT ANY WARRANTY; without even the implied warranty of 12da0c48c4Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13da0c48c4Sopenharmony_ci# GNU General Public License for more details. 14da0c48c4Sopenharmony_ci# 15da0c48c4Sopenharmony_ci# You should have received a copy of the GNU General Public License 16da0c48c4Sopenharmony_ci# along with this program. If not, see <http://www.gnu.org/licenses/>. 17da0c48c4Sopenharmony_ci 18da0c48c4Sopenharmony_ci 19da0c48c4Sopenharmony_ci. $srcdir/test-subr.sh 20da0c48c4Sopenharmony_ci 21da0c48c4Sopenharmony_ci# This tests all the miscellaneous components of backend support 22da0c48c4Sopenharmony_ci# against whatever this build is running on. A platform will fail 23da0c48c4Sopenharmony_ci# this test if it is missing parts of the backend implementation. 24da0c48c4Sopenharmony_ci# 25da0c48c4Sopenharmony_ci# As new backend code is added to satisfy the test, be sure to update 26da0c48c4Sopenharmony_ci# the fixed test cases (run-allregs.sh et al) to test that backend 27da0c48c4Sopenharmony_ci# in all builds. 28da0c48c4Sopenharmony_ci 29da0c48c4Sopenharmony_citempfiles native.c native 30da0c48c4Sopenharmony_ciecho 'main () { while (1) pause (); }' > native.c 31da0c48c4Sopenharmony_ci 32da0c48c4Sopenharmony_cinative=0 33da0c48c4Sopenharmony_cikill_native() 34da0c48c4Sopenharmony_ci{ 35da0c48c4Sopenharmony_ci test $native -eq 0 || { 36da0c48c4Sopenharmony_ci kill -9 $native 2> /dev/null || : 37da0c48c4Sopenharmony_ci wait $native 2> /dev/null || : 38da0c48c4Sopenharmony_ci } 39da0c48c4Sopenharmony_ci native=0 40da0c48c4Sopenharmony_ci} 41da0c48c4Sopenharmony_ci 42da0c48c4Sopenharmony_cinative_cleanup() 43da0c48c4Sopenharmony_ci{ 44da0c48c4Sopenharmony_ci kill_native 45da0c48c4Sopenharmony_ci test_cleanup 46da0c48c4Sopenharmony_ci} 47da0c48c4Sopenharmony_ci 48da0c48c4Sopenharmony_cinative_exit() 49da0c48c4Sopenharmony_ci{ 50da0c48c4Sopenharmony_ci native_cleanup 51da0c48c4Sopenharmony_ci exit_cleanup 52da0c48c4Sopenharmony_ci} 53da0c48c4Sopenharmony_ci 54da0c48c4Sopenharmony_citrap native_cleanup 1 2 15 55da0c48c4Sopenharmony_citrap native_exit 0 56da0c48c4Sopenharmony_ci 57da0c48c4Sopenharmony_cifor cc in "$HOSTCC" "$HOST_CC" cc gcc "$CC"; do 58da0c48c4Sopenharmony_ci test "x$cc" != x || continue 59da0c48c4Sopenharmony_ci $cc -o native -g native.c > /dev/null 2>&1 && 60da0c48c4Sopenharmony_ci # Some shell versions don't do this right without the braces. 61da0c48c4Sopenharmony_ci { ./native > /dev/null 2>&1 & native=$! ; } && 62da0c48c4Sopenharmony_ci sleep 1 && kill -0 $native 2> /dev/null && 63da0c48c4Sopenharmony_ci break || 64da0c48c4Sopenharmony_ci native=0 65da0c48c4Sopenharmony_cidone 66da0c48c4Sopenharmony_ci 67da0c48c4Sopenharmony_cinative_test() 68da0c48c4Sopenharmony_ci{ 69da0c48c4Sopenharmony_ci # Try the build against itself, i.e. $config_host. 70da0c48c4Sopenharmony_ci testrun "$@" -e $1 > /dev/null 71da0c48c4Sopenharmony_ci 72da0c48c4Sopenharmony_ci # Try the build against a presumed native process, running this sh. 73da0c48c4Sopenharmony_ci # For tests requiring debug information, this may not test anything. 74da0c48c4Sopenharmony_ci testrun "$@" -p $$ > /dev/null 75da0c48c4Sopenharmony_ci 76da0c48c4Sopenharmony_ci # Try the build against the trivial native program we just built with -g. 77da0c48c4Sopenharmony_ci test $native -eq 0 || testrun "$@" -p $native > /dev/null 78da0c48c4Sopenharmony_ci} 79da0c48c4Sopenharmony_ci 80da0c48c4Sopenharmony_cinative_test ${abs_builddir}/allregs 81da0c48c4Sopenharmony_cinative_test ${abs_builddir}/funcretval 82da0c48c4Sopenharmony_ci 83da0c48c4Sopenharmony_ci# We do this explicitly rather than letting the trap 0 cover it, 84da0c48c4Sopenharmony_ci# because as of version 3.1 bash prints the "Killed" report for 85da0c48c4Sopenharmony_ci# $native when we do the kill inside the exit handler. 86da0c48c4Sopenharmony_cinative_cleanup 87da0c48c4Sopenharmony_ci 88da0c48c4Sopenharmony_ciexit 0 89