Makefile revision 1.2 1 ## Notes:
2 ## This set of tests creates a dummy directory tree in /tmp and
3 ## populates it with several files. The test requires around 1100
4 ## inodes and 6.8MB.
5 ##
6 ## This test verifies that newfs can create filesystems in both bytes
7 ## orders. For each byte order it is checked that:
8 ## - the kernel understands both filesystems created
9 ## - fsck_ffs can convert them from one byte order to the other
10 ## - dump handles properly the 'nodump' flag, an that restore can
11 ## properly restore the filesystem.
12 ##
13 ## This is derived from work done by Brian Grayson, submitted in PR 6706.
14
15 TMPL=/tmp/ffstemplate
16 TMPMP=/tmp/ffsregresstest_mount
17 TMPIM=/var/tmp/ffsregresstest.im
18 TMPREST=/tmp/restoreregress
19 EN?= be
20 DIGITS=0 1 2 3 4 5 6 7 8 9
21
22 VND?= vnd0
23 BVND= /dev/${VND}
24 CVND= /dev/r${VND}
25 MPART?= a
26 .if (${MACHINE_ARCH} == "i386")
27 RPART?= d
28 .else
29 RPART?= c
30 .endif
31
32 # As make is called recusively, and we may cd to ${OBJDIR}, we need to call make
33 # with some variables propagated.
34 SRCDIR?= ${.CURDIR}
35 MAKECMD= ${MAKE} -f ${SRCDIR}/Makefile SRCDIR=${SRCDIR} EN=${EN} VND=${VND} MPART=${MPART} RPART=${RPART}
36
37 regress: template
38 ${MAKECMD} EN=be makeregress
39 ${MAKECMD} clean-tmpfs
40 ${MAKECMD} EN=le makeregress
41 ${MAKECMD} clean
42
43 makeregress: tmpfs
44 ${MAKECMD} dump
45 ${MAKECMD} fsck
46 ${MAKECMD} clean-dump;
47
48 clean: clean-tmpfs clean-template clean-dump
49 clean-dump:
50 @echo "*** Cleaning up ${TMPREST}."
51 -rm -rf ${TMPREST}
52 clean-tmpfs:
53 @echo "*** Cleaning up ${TMPMP}."
54 -umount ${TMPMP}
55 -vnconfig -u ${BVND}${RPART}
56 -rm -rf ${TMPMP} ${TMPIM}
57 clean-template:
58 @echo "*** Cleaning up ${TMPL}."
59 -rm -rf ${TMPL}
60
61 cmp:
62 diff -r -q ${TMPL} ${TMPMP}
63
64 dump:
65 @echo "*** Testing dump nodump flag support."
66 @# First of all, estimate the size of a dump of just the tmpfs.
67 sh ${SRCDIR}/estimatecompare 2572 -S -h9 -0 ${CVND}${MPART}
68
69 @# Now estimate the size, after honoring the nodump flag.
70 sh ${SRCDIR}/estimatecompare 347 -S -h0 -0 ${CVND}${MPART}
71 @echo "*** Testing dump/restore support"
72 mkdir ${TMPREST}
73 dump -0 -h9 -B10000 -f - ${CVND}${MPART} | \
74 (cd ${TMPREST}; restore -rf -)
75 @#restore should have created a restoresymtable file
76 rm ${TMPREST}/restoresymtable
77 diff -r -q ${TMPL} ${TMPREST}
78
79 fsck:
80 @echo "*** checking fsck_ffs endian conversion."
81 umount ${BVND}${MPART}
82 .if (${EN} == le)
83 fsck_ffs -B be -y ${CVND}${MPART}
84 mount -o async ${BVND}${MPART} ${TMPMP}
85 ${MAKECMD} cmp
86 umount ${BVND}${MPART}
87 fsck_ffs -B le -y ${CVND}${MPART}
88 mount -o async ${BVND}${MPART} ${TMPMP}
89 ${MAKECMD} cmp
90 .else
91 fsck_ffs -B le -y ${CVND}${MPART}
92 mount -o async ${BVND}${MPART} ${TMPMP}
93 ${MAKECMD} cmp
94 umount ${BVND}${MPART}
95 fsck_ffs -B be -y ${CVND}${MPART}
96 mount -o async ${BVND}${MPART} ${TMPMP}
97 ${MAKECMD} cmp
98 .endif
99
100 tmpfs:
101 @echo "*** Creating a dummy directory tree at ${TMPMP} monted on" \
102 "${TMPIM}, ${EN} byte order."
103 dd if=/dev/zero of=${TMPIM} count=5860
104 vnconfig -v ${BVND}${RPART} ${TMPIM}
105 disklabel -rw ${VND} floppy288
106 newfs -B ${EN} -i 500 -b 8192 -f 1024 ${CVND}${MPART}
107 mkdir ${TMPMP}
108 mount -o async ${BVND}${MPART} ${TMPMP}
109 # Arg, cp will give an error if the symlink is copied before its target
110 -cp -Rp ${TMPL}/* ${TMPMP}
111 ${MAKECMD} cmp
112
113 template:
114 mkdir ${TMPL}
115 @# Create a directory with a 10K file, with the file marked nodump.
116 mkdir ${TMPL}/nodumpfile
117 jot -r -c -s '' -n 10240 > ${TMPL}/nodumpfile/10k
118 chflags nodump ${TMPL}/nodumpfile/10k
119 @# And some ordinary 10k files.
120 mkdir ${TMPL}/dumpfile
121 TMPFS_DUMP=${TMPL}/dumpfile/dumpfile.10k; \
122 for f in ${DIGITS}; do \
123 jot -r -c -s '' -n 10240 > $$TMPFS_DUMP.$$f; done;
124 @# A subdir with a short and a long symbolic link in it
125 mkdir ${TMPL}/dumpfile/subdir
126 ln -s ../dumpfile.10k.0 ${TMPL}/dumpfile/subdir/link;
127 ln -s ../dumpfile.10k.1 ${TMPL}/dumpfile/subdir/really_really_really_really_really_really_long_name_to_use_up_space.link;
128 @# And now the same files, but in a dir marked nodump:
129 mkdir ${TMPL}/nodumpdir
130 chflags nodump ${TMPL}/nodumpdir
131 TMPFS_1=${TMPL}/nodumpdir/10k; \
132 for f in ${DIGITS}; do \
133 jot -r -c -s '' -n 10240 > $$TMPFS_1.$$f; \
134 done
135
136 @# Also create a large directory that uses more than one direct block
137 @# (so it has to be larger than 8K).
138 @# Make sure one entry is for a deleted file, also.
139 mkdir ${TMPL}/2blkdir
140 TMPFS_1=${TMPL}/2blkdir; \
141 jot -r -c -s '' -n 10 > $$TMPFS_1/10b; \
142 for f in ${DIGITS}; do for g in ${DIGITS}; do \
143 jot -r -c -s '' -n 10 > \
144 $$TMPFS_1/really_really_really_really_really_really_long_name_to_use_up_space_$$f$$g ;\
145 done; done; \
146 rm $$TMPFS_1/10b
147
148 @# Now create a directory with at least one indirect block.
149 @# On a FS with 8K blocks, we need at least 1 + 12*8192 bytes, or
150 @# 98305 bytes, in the directory. 1000 files does the trick,
151 @# with the long filename below.
152 mkdir ${TMPL}/indirblk
153 chflags nodump ${TMPL}/indirblk
154 TMPFS_1=${TMPL}/indirblk; \
155 jot -r -c -s '' -n 10 > $$TMPFS_1/10b; \
156 for e in 0; do\
157 for f in ${DIGITS}; do for g in ${DIGITS}; do for h in ${DIGITS}; do \
158 jot -r -c -s '' -n 10 > \
159 $$TMPFS_1/really_really_really_really_really_really_long_name_to_use_up_dir_entry_space$$e$$f$$g$$h ;\
160 done; done; done; done; \
161 rm $$TMPFS_1/10b
162 @# ^--- As before, make sure at least one direntry is a deleted file.
163