retain.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. # retain.sh -- Tests for SHF_GNU_RETAIN.
  3. # Copyright (C) 2020-2022 Free Software Foundation, Inc.
  4. # This file is part of gold.
  5. # This program 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. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. # MA 02110-1301, USA.
  17. set -e
  18. check()
  19. {
  20. number_of_occurrence=`egrep "$2" ./$1 -o | wc -l`
  21. if [ $number_of_occurrence != $3 ]
  22. then
  23. echo "$1: \"$2\" $3: Failed"
  24. status=1
  25. fi
  26. }
  27. status=0
  28. check retain_1.out " T fnretain1" 1
  29. check retain_1.out " b lsretain0.2" 1
  30. check retain_1.out " b lsretain1.1" 1
  31. check retain_1.out " d lsretain2.0" 1
  32. check retain_1.out " B retain0" 1
  33. check retain_1.out " B retain1" 1
  34. check retain_1.out " D retain2" 1
  35. check retain_1.out " b sretain0" 1
  36. check retain_1.out " b sretain1" 1
  37. check retain_1.out " d sretain2" 1
  38. if grep discard retain_1.out
  39. then
  40. echo "retain_1.out: Garbage collection failed"
  41. status=1
  42. fi
  43. check retain_2.out " \(PREINIT_ARRAY\)" 1
  44. check retain_2.out " \(PREINIT_ARRAYSZ\)" 1
  45. check retain_2.out " \(INIT_ARRAY\)" 1
  46. check retain_2.out " \(INIT_ARRAYSZ\)" 1
  47. check retain_2.out " \(FINI_ARRAY\)" 1
  48. check retain_2.out " \(FINI_ARRAYSZ\)" 1
  49. exit $status