1*7304104dSAndroid Build Coastguard Worker#! /bin/sh 2*7304104dSAndroid Build Coastguard Worker# Copyright (C) 2013 Red Hat, Inc. 3*7304104dSAndroid Build Coastguard Worker# This file is part of elfutils. 4*7304104dSAndroid Build Coastguard Worker# 5*7304104dSAndroid Build Coastguard Worker# This file is free software; you can redistribute it and/or modify 6*7304104dSAndroid Build Coastguard Worker# it under the terms of the GNU General Public License as published by 7*7304104dSAndroid Build Coastguard Worker# the Free Software Foundation; either version 3 of the License, or 8*7304104dSAndroid Build Coastguard Worker# (at your option) any later version. 9*7304104dSAndroid Build Coastguard Worker# 10*7304104dSAndroid Build Coastguard Worker# elfutils is distributed in the hope that it will be useful, but 11*7304104dSAndroid Build Coastguard Worker# WITHOUT ANY WARRANTY; without even the implied warranty of 12*7304104dSAndroid Build Coastguard Worker# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*7304104dSAndroid Build Coastguard Worker# GNU General Public License for more details. 14*7304104dSAndroid Build Coastguard Worker# 15*7304104dSAndroid Build Coastguard Worker# You should have received a copy of the GNU General Public License 16*7304104dSAndroid Build Coastguard Worker# along with this program. If not, see <http://www.gnu.org/licenses/>. 17*7304104dSAndroid Build Coastguard Worker 18*7304104dSAndroid Build Coastguard Worker. $srcdir/test-subr.sh 19*7304104dSAndroid Build Coastguard Worker 20*7304104dSAndroid Build Coastguard Worker# See run-readelf-dwz-multi.sh 21*7304104dSAndroid Build Coastguard Workertestfiles libtestfile_multi_shared.so testfile_multi_main testfile_multi.dwz 22*7304104dSAndroid Build Coastguard Workertestfiles testfile-dwzstr testfile-dwzstr.multi 23*7304104dSAndroid Build Coastguard Worker 24*7304104dSAndroid Build Coastguard Workertestrun_compare ${abs_builddir}/allfcts testfile_multi_main libtestfile_multi_shared.so testfile-dwzstr <<\EOF 25*7304104dSAndroid Build Coastguard Worker/home/mark/src/tests/dwz/main.c:3:main 26*7304104dSAndroid Build Coastguard Worker/home/mark/src/tests/dwz/shared.c:3:call_foo 27*7304104dSAndroid Build Coastguard Worker/home/mark/src/tests/main.c:8:main 28*7304104dSAndroid Build Coastguard WorkerEOF 29*7304104dSAndroid Build Coastguard Worker 30*7304104dSAndroid Build Coastguard Worker# - test-offset-loop.c 31*7304104dSAndroid Build Coastguard Worker# 32*7304104dSAndroid Build Coastguard Worker# #include <stdbool.h> 33*7304104dSAndroid Build Coastguard Worker# #include <string.h> 34*7304104dSAndroid Build Coastguard Worker# #include <errno.h> 35*7304104dSAndroid Build Coastguard Worker# void padding (int x, int y, int z) { } 36*7304104dSAndroid Build Coastguard Worker# static inline bool is_error (int err) { return err != 0; } 37*7304104dSAndroid Build Coastguard Worker# static inline int get_errno (void) { return errno; } 38*7304104dSAndroid Build Coastguard Worker# int main () { return is_error (get_errno ()); } 39*7304104dSAndroid Build Coastguard Worker# 40*7304104dSAndroid Build Coastguard Worker# gcc -g -O2 test-offset-loop.c -o test-offset-loop 41*7304104dSAndroid Build Coastguard Worker# cp test-offset-loop test-offset-loop2 42*7304104dSAndroid Build Coastguard Worker# dwz test-offset-loop test-offset-loop2 -m test-offset-loop.alt 43*7304104dSAndroid Build Coastguard Worker 44*7304104dSAndroid Build Coastguard Workertestfiles test-offset-loop test-offset-loop.alt 45*7304104dSAndroid Build Coastguard Workertempfiles allfcts.out 46*7304104dSAndroid Build Coastguard Worker 47*7304104dSAndroid Build Coastguard Worker# Use head to capture output because the output could be infinite... 48*7304104dSAndroid Build Coastguard Workertestrun ${abs_builddir}/allfcts test-offset-loop | head -n 20 > allfcts.out 49*7304104dSAndroid Build Coastguard Workertestrun_compare cat allfcts.out <<\EOF 50*7304104dSAndroid Build Coastguard Worker/tmp/test-offset-loop.c:6:get_errno 51*7304104dSAndroid Build Coastguard Worker/tmp/test-offset-loop.c:5:is_error 52*7304104dSAndroid Build Coastguard Worker/tmp/test-offset-loop.c:4:padding 53*7304104dSAndroid Build Coastguard Worker/tmp/test-offset-loop.c:7:main 54*7304104dSAndroid Build Coastguard WorkerEOF 55*7304104dSAndroid Build Coastguard Worker 56*7304104dSAndroid Build Coastguard Worker# allfcts has a too simple mechanism for setting the alt file. 57*7304104dSAndroid Build Coastguard Worker# check that if we don't set it, things still work (because libdw will 58*7304104dSAndroid Build Coastguard Worker# find the alt file for us). 59*7304104dSAndroid Build Coastguard Workermkdir subdir 60*7304104dSAndroid Build Coastguard Workermv test-offset-loop test-offset-loop.alt subdir/ 61*7304104dSAndroid Build Coastguard Workertestrun ${abs_builddir}/allfcts subdir/test-offset-loop > allfcts.out 62*7304104dSAndroid Build Coastguard Workertestrun_compare cat allfcts.out <<\EOF 63*7304104dSAndroid Build Coastguard WorkerWarning: no alt file found. 64*7304104dSAndroid Build Coastguard Worker/tmp/test-offset-loop.c:6:get_errno 65*7304104dSAndroid Build Coastguard Worker/tmp/test-offset-loop.c:5:is_error 66*7304104dSAndroid Build Coastguard Worker/tmp/test-offset-loop.c:4:padding 67*7304104dSAndroid Build Coastguard Worker/tmp/test-offset-loop.c:7:main 68*7304104dSAndroid Build Coastguard WorkerEOF 69*7304104dSAndroid Build Coastguard Worker 70*7304104dSAndroid Build Coastguard Workerrm -rf subdir 71*7304104dSAndroid Build Coastguard Worker 72*7304104dSAndroid Build Coastguard Workerexit 0 73