xref: /aosp_15_r20/external/e2fsprogs/tests/u_direct_io/script (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1DESCRIPTION="direct I/O in unix_io"
2OUT=$test_name.log
3if test "$(id -u)" -ne 0 ; then
4    echo "$test_name: $DESCRIPTION: skipped (not root)"
5elif ! command -v losetup >/dev/null ; then
6    echo "$test_name: $DESCRIPTION: skipped (no losetup)"
7elif test ! -x $DEBUGFS_EXE; then
8    echo "$test_name: $DESCRIPTION: skipped (no debugfs)"
9else
10    dd if=/dev/zero of=$TMPFILE bs=1M count=128 > /dev/null 2>&1
11    LOOP=$(losetup --show --sector-size 4096 -f $TMPFILE)
12    if [ ! -b "$LOOP" ]; then
13        echo "$test_name: $DESCRIPTION: skipped (no loop devices)"
14        rm -f $TMPFILE
15        exit 0
16    fi
17    echo mke2fs -F -o Linux -t ext4 -O ^metadata_csum,^uninit_bg -D \$LOOP > $OUT
18    $MKE2FS -F -o Linux -t ext4 -O ^metadata_csum,^uninit_bg -D $LOOP 2>&1 | \
19	sed -f $cmd_dir/filter.sed >> $OUT
20
21    echo debugfs -D -R stats \$LOOP >> $OUT
22    $DEBUGFS -D -R stats $LOOP 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT
23
24    echo e2fsck -fn -N test_filesys \$LOOP > $OUT.new
25    $FSCK -fn -N test_filesys $LOOP >> $OUT.new 2>&1
26    echo Exit status is $? >> $OUT.new
27    sed -f $cmd_dir/filter.sed $OUT.new >> $OUT
28    rm -f $OUT.new
29
30    losetup -d $LOOP
31
32    echo e2fsck -fn -N test_filesys \$TMPFILE > $OUT.new
33    $FSCK -fn -N test_filesys $TMPFILE >> $OUT.new 2>&1
34    echo Exit status is $? >> $OUT.new
35    sed -f $cmd_dir/filter.sed $OUT.new >> $OUT
36    rm -f $OUT.new
37
38    cmp -s $test_name.log $test_dir/expect
39
40    if [ "$?" -eq 0 ]; then
41	echo "$test_name: $DESCRIPTION: ok"
42	touch $test_name.ok
43    else
44	echo "$test_name: $DESCRIPTION: failed"
45	diff $DIFF_OPTS $test_dir/expect $test_name.log >> $test_name.failed
46    fi
47fi
48
49unset LOOP
50