2 # Copyright (C) 2016 Andreas Bombe <aeb@debian.org>
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # This script expects a testname.mkfs file as its sole argument. It must
19 # be a shell snippet setting the variables ARGS, SIZE and CMP_LIMIT. ARGS and
20 # SIZE are used in the mkfs invocation and the result is compared against a
21 # reference image generated from the hexdump in testname.xxd. The comparison
22 # is stopped after CMP_LIMIT since freshly build FAT filesystems are just
23 # zeros after the initial info sectors, FATs and root directory.
27 "../src/mkfs.fat" "$@"
31 "../src/fsck.fat" "$@"
36 echo "$0 called with wrong number of arguments"
39 testname=$(basename "$1" .mkfs)
42 if [ "$XXD_FOUND" != "yes" ]; then
43 echo "xxd not available, required by test"
44 exit 77 # report test skipped
51 # make sure there aren't files remaining from earlier run
52 rm -f "${testname}.out" "${testname}.refimg"
54 xxd -r "${srcdir}/${testname}.xxd" "${testname}.refimg" || exit 99
55 run_mkfs -C -v --invariant $ARGS "${testname}.out" $SIZE || exit 99
60 if [ -n "$CMP_LIMIT" ]; then
61 limitarg="--bytes=$CMP_LIMIT"
63 cmp $limitarg "${testname}.out" "${testname}.refimg"
66 if [ $success -eq 0 ]; then
68 echo "Testing fsck..."
69 run_fsck -n "${testname}.out"
73 rm -f "${testname}.out" "${testname}.refimg"
75 if [ $success -eq 2 ]; then