Whamcloud - gitweb
tests: clean up $DEBUGFS_EXE usage in scripts
[tools/e2fsprogs.git] / tests / m_minrootdir / script
1 test_description="create fs image from dir, then minimize it"
2 if ! test -x $RESIZE2FS_EXE -o ! -x $DEBUGFS_EXE; then
3         echo "$test_name: $test_description: skipped (no debugfs/resize2fs)"
4         return 0
5 fi
6
7 MKFS_DIR=$TMPFILE.dir
8 OUT=$test_name.log
9 EXP=$test_dir/expect
10
11 rm -rf $MKFS_DIR
12 mkdir -p $MKFS_DIR
13 mkdir $MKFS_DIR/dir
14 mkdir $MKFS_DIR/emptydir
15 dd if=/dev/zero of=$MKFS_DIR/bigzerofile bs=1 count=1 seek=1073741824 2> /dev/null
16 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1024 2> /dev/null
17 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=524288 conv=notrunc 2> /dev/null
18 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1048576 conv=notrunc 2> /dev/null
19 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=536870912 conv=notrunc 2> /dev/null
20 echo "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1073741824 conv=notrunc 2> /dev/null
21 dd if=/dev/zero bs=1024 count=32 2> /dev/null | tr '\0' 'a' > $MKFS_DIR/bigfile
22 touch $MKFS_DIR/emptyfile
23 echo "Test me" > $MKFS_DIR/dir/file
24
25 echo "create fs" > $OUT
26 $MKE2FS -q -F -o Linux -T ext4 -O ^has_journal,metadata_csum,64bit,^resize_inode -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 >> $OUT 2>&1
27
28 $DUMPE2FS $TMPFILE >> $OUT 2>&1
29 cat > $TMPFILE.cmd << ENDL
30 stat /emptyfile
31 stat /bigfile
32 stat /sparsefile
33 stat /bigzerofile
34 stat /fifo
35 stat /emptydir
36 stat /dir
37 stat /dir/file
38 ENDL
39 $DEBUGFS -f $TMPFILE.cmd $TMPFILE 2>&1 | egrep "(stat|Size:|Type:)" | sed -f $test_dir/output.sed >> $OUT
40
41 cat > $TMPFILE.cmd << ENDL
42 ex /emptyfile
43 ex /bigfile
44 ex /sparsefile
45 ex /bigzerofile
46 ex /dir
47 ex /dir/file
48 ENDL
49 $DEBUGFS -f $TMPFILE.cmd $TMPFILE 2>&1 | sed -f $test_dir/output.sed >> $OUT
50 $FSCK -f -n $TMPFILE >> $OUT 2>&1
51
52 echo "minify fs" >> $OUT
53 $TUNE2FS -m 0 $TMPFILE >> $OUT 2>&1
54 $RESIZE2FS -M $TMPFILE >> $OUT 2>&1
55 $DUMPE2FS $TMPFILE >> $OUT 2>&1
56 $FSCK -f -n $TMPFILE >> $OUT 2>&1
57
58 echo "minify fs (2)" >> $OUT
59 $TUNE2FS -m 0 $TMPFILE >> $OUT 2>&1
60 $RESIZE2FS -M $TMPFILE >> $OUT 2>&1
61 $DUMPE2FS $TMPFILE >> $OUT 2>&1
62 $FSCK -f -n $TMPFILE >> $OUT 2>&1
63
64 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" < $OUT > $OUT.tmp
65 mv $OUT.tmp $OUT
66
67 # Do the verification
68 cmp -s $OUT $EXP
69 status=$?
70
71 if [ "$status" = 0 ] ; then
72         echo "$test_name: $test_description: ok"
73         touch $test_name.ok
74 else
75         echo "$test_name: $test_description: failed"
76         diff $DIFF_OPTS $EXP $OUT > $test_name.failed
77 fi
78
79 rm -rf $TMPFILE.cmd $MKFS_DIR $OUT.sed
80 unset MKFS_DIR OUT EXP