Whamcloud - gitweb
1a8d84635ab02c2a32edc4bf6788e56b1de2fa2b
[tools/e2fsprogs.git] / tests / m_assume_storage_prezeroed / script
1 test_description="test prezeroed storage metadata allocation"
2 FILE_SIZE=16M
3
4 LOG=$test_name.log
5 OUT=$test_name.out
6 EXP=$test_dir/expect
7
8 if test "$(id -u)" -ne 0 ; then
9     echo "$test_name: $test_description: skipped (not root)"
10 elif ! command -v losetup >/dev/null ; then
11     echo "$test_name: $test_description: skipped (no losetup)"
12 else
13     dd if=/dev/zero of=$TMPFILE.1 bs=1 count=0 seek=$FILE_SIZE >> $LOG 2>&1
14     dd if=/dev/zero of=$TMPFILE.2 bs=1 count=0 seek=$FILE_SIZE >> $LOG 2>&1
15
16     LOOP1=$(losetup --show --sector-size 4096 -f $TMPFILE.1)
17     if [ ! -b "$LOOP1" ]; then
18         echo "$test_name: $DESCRIPTION: skipped (no loop devices)"
19         rm -f $TMPFILE.1 $TMPFILE.2
20         exit 0
21     fi
22     LOOP2=$(losetup --show --sector-size 4096 -f $TMPFILE.2)
23     if [ ! -b "$LOOP2" ]; then
24         echo "$test_name: $DESCRIPTION: skipped (no loop devices)"
25         rm -f $TMPFILE.1 $TMPFILE.2
26         losetup -d $LOOP1
27         exit 0
28     fi
29
30     echo $MKE2FS -o Linux -t ext4 $LOOP1 >> $LOG 2>&1
31     $MKE2FS -o Linux -t ext4 $LOOP1 >> $LOG 2>&1
32     sync
33     stat $TMPFILE.1 >> $LOG 2>&1
34     SZ=$(stat -c "%b" $TMPFILE.1)
35     if test $SZ -gt 10000 ; then
36         echo "> 10000" > $OUT
37     else
38         echo "$SZ" > $OUT
39     fi
40
41     echo $MKE2FS -o Linux -t ext4 -E assume_storage_prezeroed=1 $LOOP2 >> $LOG 2>&1
42     $MKE2FS -o Linux -t ext4 -E assume_storage_prezeroed=1 $LOOP2 >> $LOG 2>&1
43     sync
44     stat $TMPFILE.2 >> $LOG 2>&1
45     stat -c "%b" $TMPFILE.2 >> $OUT
46
47     losetup -d $LOOP1
48     losetup -d $LOOP2
49     rm -f $TMPFILE.1 $TMPFILE.2
50
51     cmp -s $OUT $EXP
52     status=$?
53
54     if [ "$status" = 0 ] ; then
55         echo "$test_name: $test_description: ok"
56         touch $test_name.ok
57     else
58         echo "$test_name: $test_description: failed"
59         cat $LOG > $test_name.failed
60         diff $EXP $OUT >> $test_name.failed
61     fi
62 fi
63 unset LOG OUT EXP FILE_SIZE LOOP1 LOOP2