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.fsck file as its sole argument. It must
19 # be a hex dump that can be converted to a filesystem image with xxd.
20 # fsck.fat is run on that image to attempt to fix the problem and then
21 # it is run a second time to determine if the problem has been fixed.
22 # The test fails if the first run does not detect an error or if the
23 # second run still detects an error.
27 $RUN "../src/fsck.fat" "$@"
32 echo "$0 called with wrong number of arguments"
35 testname=$(basename "$1" .fsck)
38 if [ "$XXD_FOUND" != "yes" ]; then
39 echo "xxd not available, required by test"
40 exit 77 # report test skipped
44 if [ -f "$testname.args" ]; then
45 ARGS=$(cat "$testname.args")
52 # make sure there aren't files remaining from earlier run
53 rm -f "${testname}.img" "${testname}.refimg"
55 xxd -r "${srcdir}/${testname}.fsck" "${testname}.img" || exit 99
58 echo "First fsck run to check and fix error..."
59 run_fsck -a $ARGS "${testname}.img"
61 if [ $success -eq 0 ]; then
62 echo "*** Error was not detected by fsck."
64 elif [ $success -eq 1 ]; then
65 echo "Second fsck run to check if error was fixed..."
66 run_fsck -n "${testname}.img"
69 if [ $success -ne 0 ]; then
70 echo "*** Error was not fixed by fsck."
73 xxd -r "${srcdir}/${testname}.xxd" "${testname}.refimg" || exit 99
74 cmp "${testname}.img" "${testname}.refimg"
77 if [ $success -eq 2 ]; then
85 rm -f "${testname}.img" "${testname}.refimg"