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