1da0c48c4Sopenharmony_ci#! /bin/sh 2da0c48c4Sopenharmony_ci# Copyright (C) 2018 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. $srcdir/test-subr.sh 19da0c48c4Sopenharmony_ci 20da0c48c4Sopenharmony_cistatus=0 21da0c48c4Sopenharmony_ci 22da0c48c4Sopenharmony_ci# Use the original file from run-strip-test.sh but with many sections 23da0c48c4Sopenharmony_citestfiles testfile 24da0c48c4Sopenharmony_citempfiles testfile1.strip testfile2.strip testfile1.debug testfile2.debug testfile.unstrip 25da0c48c4Sopenharmony_ci 26da0c48c4Sopenharmony_ciecho "Adding sections to testfile" 27da0c48c4Sopenharmony_citestrun ${abs_builddir}/addsections 65535 testfile || 28da0c48c4Sopenharmony_ci{ echo "*** failure addsections testfile"; status=1; } 29da0c48c4Sopenharmony_ci 30da0c48c4Sopenharmony_ciecho "Testing strip -o" 31da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip -o testfile1.strip -f testfile1.debug testfile || 32da0c48c4Sopenharmony_ci{ echo "*** failure strip -o"; status=1; } 33da0c48c4Sopenharmony_ci 34da0c48c4Sopenharmony_ci# Do the parts check out? 35da0c48c4Sopenharmony_ciecho "elflint testfile1.strip" 36da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elflint --gnu -q testfile1.strip || 37da0c48c4Sopenharmony_ci{ echo "*** failure elflint testfile1.strip"; status=1; } 38da0c48c4Sopenharmony_ci 39da0c48c4Sopenharmony_ciecho "elflint testfile1.debug" 40da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile1.debug || 41da0c48c4Sopenharmony_ci{ echo "*** failure elflint testfile1.debug"; status=1; } 42da0c48c4Sopenharmony_ci 43da0c48c4Sopenharmony_ci# Now test unstrip recombining those files. 44da0c48c4Sopenharmony_ciecho "unstrip" 45da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile1.strip testfile1.debug || 46da0c48c4Sopenharmony_ci{ echo "*** failure unstrip"; status=1; } 47da0c48c4Sopenharmony_ci 48da0c48c4Sopenharmony_ciecho "elfcmp" 49da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elfcmp testfile testfile.unstrip || 50da0c48c4Sopenharmony_ci{ echo "*** failure elfcmp"; status=1; } 51da0c48c4Sopenharmony_ci 52da0c48c4Sopenharmony_ci# test strip -g 53da0c48c4Sopenharmony_ciecho "Testing strip -g" 54da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip -g -o testfile2.strip -f testfile2.debug testfile || 55da0c48c4Sopenharmony_ci{ echo "*** failure strip -g"; status=1; } 56da0c48c4Sopenharmony_ci 57da0c48c4Sopenharmony_ci# Do the parts check out? 58da0c48c4Sopenharmony_ciecho "elflint testfile2.strip" 59da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elflint --gnu -q testfile2.strip || 60da0c48c4Sopenharmony_ci{ echo "*** failure elflint testfile2.strip"; status=1; } 61da0c48c4Sopenharmony_ci 62da0c48c4Sopenharmony_ciecho "elflint testfile2.debug" 63da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile2.debug || 64da0c48c4Sopenharmony_ci{ echo "*** failure elflint testfile2.debug"; status=1; } 65da0c48c4Sopenharmony_ci 66da0c48c4Sopenharmony_ci# Now strip "in-place" and make sure it is smaller. 67da0c48c4Sopenharmony_ciecho "Testing strip in-place" 68da0c48c4Sopenharmony_ciSIZE_original=$(stat -c%s testfile) 69da0c48c4Sopenharmony_ciecho "original size $SIZE_original" 70da0c48c4Sopenharmony_ci 71da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/strip testfile || 72da0c48c4Sopenharmony_ci{ echo "*** failure strip in-place"; status=1; } 73da0c48c4Sopenharmony_ci 74da0c48c4Sopenharmony_ciSIZE_stripped=$(stat -c%s testfile) 75da0c48c4Sopenharmony_ciecho "stripped size $SIZE_stripped" 76da0c48c4Sopenharmony_citest $SIZE_stripped -lt $SIZE_original || 77da0c48c4Sopenharmony_ci { echo "*** failure in-place strip file not smaller $original"; exit 1; } 78da0c48c4Sopenharmony_ci 79da0c48c4Sopenharmony_ciecho "elflint in-place" 80da0c48c4Sopenharmony_citestrun ${abs_top_builddir}/src/elflint --gnu -q testfile || 81da0c48c4Sopenharmony_ci{ echo "*** failure elflint in-place"; status=1; } 82da0c48c4Sopenharmony_ci 83da0c48c4Sopenharmony_ciexit $status 84