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