"Fossies" - the Fresh Open Source Software Archive 
Member "dosfstools-4.2/tests/test-mkfs" (31 Jan 2021, 2170 Bytes) of package /linux/misc/dosfstools-4.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "test-mkfs":
4.1_vs_4.2.
1 #!/bin/sh
2 # Copyright (C) 2016 Andreas Bombe <aeb@debian.org>
3 #
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.
8 #
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 #
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/>.
16 #
17 #
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.
24
25
26 run_mkfs () {
27 $RUN "../src/mkfs.fat" "$@"
28 }
29
30 run_fsck () {
31 $RUN "../src/fsck.fat" "$@"
32 }
33
34
35 if [ $# -ne 1 ]; then
36 echo "$0 called with wrong number of arguments"
37 exit 99
38 fi
39 testname=$(basename "$1" .mkfs)
40
41
42 if [ "$XXD_FOUND" != "yes" ]; then
43 echo "xxd not available, required by test"
44 exit 77 # report test skipped
45 fi
46
47
48 . "$1" || exit 99
49 echo "Test $testname"
50
51 # make sure there aren't files remaining from earlier run
52 rm -f "${testname}.out" "${testname}.refimg"
53
54 xxd -r "${srcdir}/${testname}.xxd" "${testname}.refimg" || exit 99
55 run_mkfs -C -v --invariant $ARGS "${testname}.out" $SIZE || exit 99
56
57 echo
58 echo "Comparing..."
59 limitarg=
60 if [ -n "$CMP_LIMIT" ]; then
61 limitarg="--bytes=$CMP_LIMIT"
62 fi
63 cmp $limitarg "${testname}.out" "${testname}.refimg"
64 success=$?
65
66 echo
67 echo "Testing fsck..."
68 run_fsck -n "${testname}.out"
69 success_fsck=$?
70
71 if [ $success -eq 0 ]; then
72 success=$success_fsck
73 fi
74
75 rm -f "${testname}.out" "${testname}.refimg"
76
77 if [ $success -eq 2 ]; then
78 # cmp reported error
79 exit 99
80 fi
81 exit $success