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 18rv=0 19 20 21makelist () { 22 ls "${1}"/*/testsuite/*/*"${2}" | sed -e 's/.*\///' | sort 23} 24 25diagnose () { 26 makelist "${distdir}" "$1" > dist"${1}".txt && 27 makelist "${srcdir}" "$1" > src"${1}".txt && 28 diff src"${1}".txt dist"${1}".txt 29 rm -f src"${1}".txt dist"${1}".txt 30 echo 31} 32 33 34check_shipfiles () { 35 distcount=`ls ${distdir}/*/testsuite/*/*${suffix} | wc -l` 36 srccount=`ls ${srcdir}/*/testsuite/*/*${suffix} | wc -l` 37 if test $distcount -eq $srccount ; then 38 echo "All $srccount of the $suffix files are accounted for" 39 else 40 echo "ERROR: Missing $suffix files: source $srccount distributed $distcount" >&2 41 rv=1 42 diagnose "${suffix}" 43 fi 44} 45 46 47main () { 48 distdir="$1" 49 srcdir="$2" 50 shift 2 51 if test "$#" -gt 0 ; then 52 for suffix ; do 53 check_shipfiles "$suffix" 54 done 55 exit $rv 56 else 57 echo "You did not specify any test file suffixes." >&2 58 exit 1 59 fi 60} 61 62main "$@" 63