Makefile revision 1.2
11.1Sbouyer##  Notes:
21.1Sbouyer##    This set of tests creates a dummy directory tree in /tmp and
31.1Sbouyer##    populates it with several files.  The test requires around 1100
41.1Sbouyer##    inodes and 6.8MB.
51.1Sbouyer##
61.1Sbouyer##    This test verifies that newfs can create filesystems in both bytes
71.1Sbouyer##    orders. For each byte order it is checked that:
81.1Sbouyer##      - the kernel understands both filesystems created
91.1Sbouyer##      - fsck_ffs can convert them from one byte order to the other
101.1Sbouyer##      - dump handles properly the 'nodump' flag, an that restore can
111.1Sbouyer##        properly restore the filesystem.
121.1Sbouyer##
131.2Sbouyer##    This is derived from work done by Brian Grayson, submitted in PR 6706.
141.1Sbouyer
151.1SbouyerTMPL=/tmp/ffstemplate
161.1SbouyerTMPMP=/tmp/ffsregresstest_mount
171.1SbouyerTMPIM=/var/tmp/ffsregresstest.im
181.1SbouyerTMPREST=/tmp/restoreregress
191.1SbouyerEN?= be
201.1SbouyerDIGITS=0 1 2 3 4 5 6 7 8 9
211.1Sbouyer
221.1SbouyerVND?= vnd0
231.1SbouyerBVND= /dev/${VND}
241.1SbouyerCVND= /dev/r${VND}
251.1SbouyerMPART?= a
261.1Sbouyer.if (${MACHINE_ARCH} == "i386")
271.1SbouyerRPART?= d
281.1Sbouyer.else
291.1SbouyerRPART?= c
301.1Sbouyer.endif
311.1Sbouyer
321.1Sbouyer# As make is called recusively, and we may cd to ${OBJDIR}, we need to call make
331.1Sbouyer# with some variables propagated.
341.1SbouyerSRCDIR?= ${.CURDIR}
351.1SbouyerMAKECMD= ${MAKE} -f ${SRCDIR}/Makefile SRCDIR=${SRCDIR} EN=${EN} VND=${VND} MPART=${MPART} RPART=${RPART}
361.1Sbouyer
371.1Sbouyerregress: template
381.1Sbouyer	${MAKECMD} EN=be makeregress
391.1Sbouyer	${MAKECMD} clean-tmpfs
401.1Sbouyer	${MAKECMD} EN=le makeregress
411.1Sbouyer	${MAKECMD} clean
421.1Sbouyer
431.1Sbouyermakeregress: tmpfs
441.1Sbouyer	${MAKECMD} dump
451.1Sbouyer	${MAKECMD} fsck
461.1Sbouyer	${MAKECMD} clean-dump;
471.1Sbouyer
481.1Sbouyerclean: clean-tmpfs clean-template clean-dump
491.1Sbouyerclean-dump:
501.1Sbouyer	@echo "***  Cleaning up ${TMPREST}."
511.1Sbouyer	-rm -rf ${TMPREST}
521.1Sbouyerclean-tmpfs:
531.1Sbouyer	@echo "***  Cleaning up ${TMPMP}."
541.1Sbouyer	-umount ${TMPMP}
551.1Sbouyer	-vnconfig -u ${BVND}${RPART}
561.1Sbouyer	-rm -rf ${TMPMP} ${TMPIM}
571.1Sbouyerclean-template:
581.1Sbouyer	@echo "***  Cleaning up ${TMPL}."
591.1Sbouyer	-rm -rf ${TMPL}
601.1Sbouyer
611.1Sbouyercmp:
621.1Sbouyer	diff -r -q ${TMPL} ${TMPMP}
631.1Sbouyer
641.1Sbouyerdump:
651.1Sbouyer	@echo "***  Testing dump nodump flag support."
661.1Sbouyer	@#  First of all, estimate the size of a dump of just the tmpfs.
671.1Sbouyer	sh ${SRCDIR}/estimatecompare 2572 -S -h9 -0 ${CVND}${MPART}
681.1Sbouyer
691.1Sbouyer	@#  Now estimate the size, after honoring the nodump flag.
701.1Sbouyer	sh ${SRCDIR}/estimatecompare 347  -S -h0 -0 ${CVND}${MPART}
711.1Sbouyer	@echo "***  Testing dump/restore support"
721.1Sbouyer	mkdir ${TMPREST}
731.1Sbouyer	dump -0 -h9 -B10000 -f - ${CVND}${MPART} | \
741.1Sbouyer	    (cd ${TMPREST}; restore -rf -)
751.1Sbouyer	@#restore should have created a restoresymtable file
761.1Sbouyer	rm ${TMPREST}/restoresymtable
771.1Sbouyer	diff -r -q ${TMPL} ${TMPREST}
781.1Sbouyer
791.1Sbouyerfsck:
801.1Sbouyer	@echo "*** checking fsck_ffs endian conversion."
811.1Sbouyer	umount ${BVND}${MPART}
821.1Sbouyer.if (${EN} == le)
831.1Sbouyer	fsck_ffs -B be -y ${CVND}${MPART}
841.1Sbouyer	mount -o async ${BVND}${MPART} ${TMPMP}
851.1Sbouyer	${MAKECMD} cmp
861.1Sbouyer	umount ${BVND}${MPART}
871.1Sbouyer	fsck_ffs -B le -y ${CVND}${MPART}
881.1Sbouyer	mount -o async ${BVND}${MPART} ${TMPMP}
891.1Sbouyer	${MAKECMD} cmp
901.1Sbouyer.else
911.1Sbouyer	fsck_ffs -B le -y ${CVND}${MPART}
921.1Sbouyer	mount -o async ${BVND}${MPART} ${TMPMP}
931.1Sbouyer	${MAKECMD} cmp
941.1Sbouyer	umount ${BVND}${MPART}
951.1Sbouyer	fsck_ffs -B be -y ${CVND}${MPART}
961.1Sbouyer	mount -o async ${BVND}${MPART} ${TMPMP}
971.1Sbouyer	${MAKECMD} cmp
981.1Sbouyer.endif
991.1Sbouyer
1001.1Sbouyertmpfs:
1011.1Sbouyer	@echo "***  Creating a dummy directory tree at ${TMPMP} monted on" \
1021.1Sbouyer	    "${TMPIM}, ${EN} byte order."
1031.1Sbouyer	dd if=/dev/zero of=${TMPIM} count=5860
1041.1Sbouyer	vnconfig -v ${BVND}${RPART} ${TMPIM}
1051.1Sbouyer	disklabel -rw ${VND} floppy288
1061.1Sbouyer	newfs -B ${EN} -i 500 -b 8192 -f 1024 ${CVND}${MPART}
1071.1Sbouyer	mkdir ${TMPMP}
1081.1Sbouyer	mount -o async ${BVND}${MPART} ${TMPMP}
1091.1Sbouyer	# Arg, cp will give an error if the symlink is copied before its target
1101.1Sbouyer	-cp -Rp ${TMPL}/* ${TMPMP}
1111.1Sbouyer	${MAKECMD} cmp
1121.1Sbouyer
1131.1Sbouyertemplate:
1141.1Sbouyer	mkdir ${TMPL}
1151.1Sbouyer	@# Create a directory with a 10K file, with the file marked nodump.
1161.1Sbouyer	mkdir ${TMPL}/nodumpfile
1171.1Sbouyer	jot -r -c -s '' -n 10240 > ${TMPL}/nodumpfile/10k 
1181.1Sbouyer	chflags nodump ${TMPL}/nodumpfile/10k
1191.1Sbouyer	@# And some ordinary 10k files.
1201.1Sbouyer	mkdir ${TMPL}/dumpfile
1211.1Sbouyer	TMPFS_DUMP=${TMPL}/dumpfile/dumpfile.10k; \
1221.1Sbouyer	for f in ${DIGITS}; do \
1231.1Sbouyer	  jot -r -c -s '' -n 10240 > $$TMPFS_DUMP.$$f; done;
1241.1Sbouyer	@# A subdir with a short and a long symbolic link in it
1251.1Sbouyer	mkdir ${TMPL}/dumpfile/subdir
1261.1Sbouyer	ln -s ../dumpfile.10k.0 ${TMPL}/dumpfile/subdir/link;
1271.1Sbouyer	ln -s ../dumpfile.10k.1 ${TMPL}/dumpfile/subdir/really_really_really_really_really_really_long_name_to_use_up_space.link;
1281.1Sbouyer	@# And now the same files, but in a dir marked nodump:
1291.1Sbouyer	mkdir ${TMPL}/nodumpdir
1301.1Sbouyer	chflags nodump ${TMPL}/nodumpdir
1311.1Sbouyer	TMPFS_1=${TMPL}/nodumpdir/10k; \
1321.1Sbouyer	  for f in ${DIGITS}; do  \
1331.1Sbouyer	      jot -r -c -s '' -n 10240 > $$TMPFS_1.$$f; \
1341.1Sbouyer	  done
1351.1Sbouyer	
1361.1Sbouyer	@# Also create a large directory that uses more than one direct block
1371.1Sbouyer	@# (so it has to be larger than 8K).
1381.1Sbouyer	@# Make sure one entry is for a deleted file, also.
1391.1Sbouyer	mkdir ${TMPL}/2blkdir
1401.1Sbouyer	TMPFS_1=${TMPL}/2blkdir; \
1411.1Sbouyer	  jot -r -c -s '' -n 10 > $$TMPFS_1/10b; \
1421.1Sbouyer	  for f in ${DIGITS}; do for g in ${DIGITS}; do \
1431.1Sbouyer	    jot -r -c -s '' -n 10 > \
1441.1Sbouyer	      $$TMPFS_1/really_really_really_really_really_really_long_name_to_use_up_space_$$f$$g ;\
1451.1Sbouyer	    done; done; \
1461.1Sbouyer	  rm $$TMPFS_1/10b
1471.1Sbouyer
1481.1Sbouyer	@# Now create a directory with at least one indirect block.
1491.1Sbouyer	@# On a FS with 8K blocks, we need at least 1 + 12*8192 bytes, or
1501.1Sbouyer	@#   98305 bytes, in the directory.  1000 files does the trick,
1511.1Sbouyer	@#   with the long filename below.
1521.1Sbouyer	mkdir ${TMPL}/indirblk
1531.1Sbouyer	chflags nodump ${TMPL}/indirblk
1541.1Sbouyer	TMPFS_1=${TMPL}/indirblk; \
1551.1Sbouyer	  jot -r -c -s '' -n 10 >  $$TMPFS_1/10b; \
1561.1Sbouyer	  for e in 0; do\
1571.1Sbouyer	  for f in ${DIGITS}; do for g in ${DIGITS}; do for h in ${DIGITS}; do \
1581.1Sbouyer	    jot -r -c -s '' -n 10 >  \
1591.1Sbouyer	      $$TMPFS_1/really_really_really_really_really_really_long_name_to_use_up_dir_entry_space$$e$$f$$g$$h ;\
1601.1Sbouyer	    done; done; done; done; \
1611.1Sbouyer	  rm $$TMPFS_1/10b
1621.1Sbouyer	@# ^---  As before, make sure at least one direntry is a deleted file.
163