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