2 # Common settings and functions for the various resize_ffs tests.
5 # called from atf_init_test_cases
9 TDBASE64
=$
(atf_get_srcdir
)/testdata.
tar.gz.base64
10 GOODMD5
=$
(atf_get_srcdir
)/testdata.md5
11 # set BYTESWAP to opposite-endian.
12 if [ $
(sysctl
-n hw.byteorder
) = "1234" ]; then
19 # test_case() taken from the tests/ipf/h_common.sh
20 # Used to declare the atf goop for a test.
23 local name
="${1}"; shift
24 local check_function
="${1}"; shift
26 atf_test_case
"${name}" cleanup
27 eval "${name}_head() { \
28 atf_set "require.user
" "root
" ; \
29 atf_set "require.progs
" "rump_ffs
" ; \
31 eval "${name}_body() { \
32 ${check_function} " "${@}" "; \
34 eval "${name}_cleanup() { \
40 # Used to declare the atf goop for a test expected to fail.
43 local name
="${1}"; shift
44 local reason
="${1}"; shift
45 local check_function
="${1}"; shift
47 atf_test_case
"${name}" cleanup
48 eval "${name}_head() { \
49 atf_set "require.user
" "root
" ; \
51 eval "${name}_body() { \
52 atf_expect_fail "${reason}" ; \
53 ${check_function} " "${@}" "; \
55 eval "${name}_cleanup() { \
61 # copy_data requires the mount already done; makes one copy of the test data
64 uudecode -p ${TDBASE64} |
(cd mnt
; tar xzf
- -s/testdata
/TD
$1/)
70 for i
in $
(seq $1); do
75 # remove_data removes one directory worth of test data; the purpose
76 # is to ensure data exists near the end of the fs under test.
85 for i
in $
(seq $1); do
90 # verify that the data in a particular directory is still OK
91 # generated md5 file doesn't need explicit cleanup thanks to ATF
94 (cd mnt
/TD
$1 && md5
*) > TD
$1.md5
95 atf_check
diff -u ${GOODMD5} TD
$1.md5
98 # supply begin and end arguments
102 for i
in $
(seq $1 $2); do
110 echo "in resize_ffs:" ${@}
119 echo "bs is ${bs} numdata is ${numdata}"
120 echo "****resizing fs with blocksize ${bs}"
122 # we want no more than 16K/inode to allow test files to copy.
123 local fpi
=$
((fragsz
* 4))
125 if [ $fpi -gt 16384 ]; then
128 if [ x
$swap != x
]; then
129 newfs
-B ${BYTESWAP} -O${fslevel} -b ${bs} -f ${fragsz} \
130 -s ${osize} ${i} -F ${IMG}
132 newfs
-O${fslevel} -b ${bs} -f ${fragsz} -s ${osize} ${i} \
136 # we're specifying relative paths, so rump_ffs warns - ignore.
137 atf_check
-s exit:0 -e ignore rump_ffs
${IMG} mnt
138 copy_multiple
${numdata}
140 if [ ${nsize} -lt ${osize} ]; then
141 # how much data to remove so fs can be shrunk
142 local remove
=$
((numdata-numdata
*nsize
/osize
))
143 local dataleft
=$
((numdata-remove
))
144 echo remove is
$remove dataleft is
$dataleft
145 remove_multiple
${remove}
149 # Check that resize needed
150 atf_check
-s exit:0 -o ignore resize_ffs
-c -y -s ${nsize} ${IMG}
151 atf_check
-s exit:0 -o ignore resize_ffs
-y -s ${nsize} ${IMG}
152 atf_check
-s exit:0 -o ignore fsck_ffs
-f -n -F ${IMG}
153 atf_check
-s exit:0 -e ignore rump_ffs
${IMG} mnt
154 if [ ${nsize} -lt ${osize} ]; then
155 check_data_range $
((remove
+ 1)) ${numdata}
157 # checking everything because we don't delete on grow
158 check_data_range
1 ${numdata}
160 # Check that no resize needed
161 atf_check
-s exit:1 -o ignore resize_ffs
-c -y -s ${nsize} ${IMG}