check-testfiles.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/sh
  2. # check-testfiles.sh -- Check we distributed all the test files we need
  3. # Copyright (C) 2007-2021 Free Software Foundation, Inc.
  4. #
  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. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. rv=0
  18. makelist () {
  19. ls "${1}"/*/testsuite/*/*"${2}" | sed -e 's/.*\///' | sort
  20. }
  21. diagnose () {
  22. makelist "${distdir}" "$1" > dist"${1}".txt &&
  23. makelist "${srcdir}" "$1" > src"${1}".txt &&
  24. diff src"${1}".txt dist"${1}".txt
  25. rm -f src"${1}".txt dist"${1}".txt
  26. echo
  27. }
  28. check_shipfiles () {
  29. distcount=`ls ${distdir}/*/testsuite/*/*${suffix} | wc -l`
  30. srccount=`ls ${srcdir}/*/testsuite/*/*${suffix} | wc -l`
  31. if test $distcount -eq $srccount ; then
  32. echo "All $srccount of the $suffix files are accounted for"
  33. else
  34. echo "ERROR: Missing $suffix files: source $srccount distributed $distcount" >&2
  35. rv=1
  36. diagnose "${suffix}"
  37. fi
  38. }
  39. main () {
  40. distdir="$1"
  41. srcdir="$2"
  42. shift 2
  43. if test "$#" -gt 0 ; then
  44. for suffix ; do
  45. check_shipfiles "$suffix"
  46. done
  47. exit $rv
  48. else
  49. echo "You did not specify any test file suffixes." >&2
  50. exit 1
  51. fi
  52. }
  53. main "$@"