Whamcloud - gitweb
ChangeLog, expect, name, script:
authorTheodore Ts'o <tytso@mit.edu>
Sat, 5 May 2001 16:21:48 +0000 (16:21 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 5 May 2001 16:21:48 +0000 (16:21 +0000)
  d_loaddump: New test which verifies debugfs's dump and load routines.
dirblock.c:
  Fix misc. gcc -Wall errors

lib/ext2fs/dirblock.c
tests/ChangeLog
tests/d_loaddump/expect [new file with mode: 0644]
tests/d_loaddump/name [new file with mode: 0644]
tests/d_loaddump/script [new file with mode: 0644]

index dd9fe5f..0101a5e 100644 (file)
@@ -41,7 +41,7 @@ errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
        p = (char *) buf;
        end = (char *) buf + fs->blocksize;
        while (p < end-8) {
-               dirent = (struct ext2_dir_entry_2 *) p;
+               dirent = (struct ext2_dir_entry *) p;
                if (do_swap) {
                        dirent->inode = ext2fs_swab32(dirent->inode);
                        dirent->rec_len = ext2fs_swab16(dirent->rec_len);
@@ -52,7 +52,7 @@ errcode_t ext2fs_read_dir_block(ext2_filsys fs, blk_t block,
                        rec_len = 8;
                        retval = EXT2_ET_DIR_CORRUPTED;
                }
-               dirent2 = dirent;
+               dirent2 = (struct ext2_dir_entry_2 *) dirent;
                if ((dirent2->name_len +8) > dirent2->rec_len)
                        retval = EXT2_ET_DIR_CORRUPTED;
                p += rec_len;
index 2803954..b657b9f 100644 (file)
@@ -1,3 +1,8 @@
+2001-05-05  Theodore Tso  <tytso@valinux.com>
+
+       * d_loaddump: New test which verifies debugfs's dump and load
+               routines.
+
 2000-10-24    <tytso@snap.thunk.org>
 
        * f_journal: Update to take into account new printing by the
diff --git a/tests/d_loaddump/expect b/tests/d_loaddump/expect
new file mode 100644 (file)
index 0000000..14d6a20
--- /dev/null
@@ -0,0 +1,18 @@
+debugfs load/dump test
+mke2fs -Fq ./test.img 512
+Exit status is 0
+debugfs -R ''write test.data test_data'' -w ./test.img
+Allocated inode: 12
+Exit status is 0
+e2fsck -yf -N test_filesys
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 12/64 files (0.0% non-contiguous), 156/512 blocks
+Exit status is 0
+debugfs -R ''dump test_data test.verify'' ./test.img
+Exit status is 0
+cmp test.data test.verify
+Exit status is 0
diff --git a/tests/d_loaddump/name b/tests/d_loaddump/name
new file mode 100644 (file)
index 0000000..025ec3b
--- /dev/null
@@ -0,0 +1 @@
+debugfs load/dump test
diff --git a/tests/d_loaddump/script b/tests/d_loaddump/script
new file mode 100644 (file)
index 0000000..a030b89
--- /dev/null
@@ -0,0 +1,61 @@
+OUT=$test_name.log
+EXP=$test_dir/expect
+VERIFY_FSCK_OPT=-yf
+
+TEST_DATA=test.data
+VERIFY_DATA=test.verify
+
+echo "debugfs load/dump test" > $OUT
+
+dd if=/dev/zero of=$TMPFILE bs=1k count=512 >& /dev/null
+
+echo "mke2fs -Fq $TMPFILE 512" >> $OUT
+
+$MKE2FS -Fq $TMPFILE 512 >& /dev/null
+status=$?
+echo Exit status is $status >> $OUT
+
+dd if=$DEBUGFS of=$TEST_DATA bs=1k count=128 >& /dev/null
+echo "file fragment odd size" >> $TEST_DATA
+
+echo "debugfs -R ''write $TEST_DATA test_data'' -w $TMPFILE" > $OUT.new
+$DEBUGFS -R "write $TEST_DATA test_data" -w $TMPFILE >> $OUT.new 2>&1
+status=$?
+echo Exit status is $status >> $OUT.new
+sed -e '2d' $OUT.new >> $OUT
+
+echo e2fsck $VERIFY_FSCK_OPT -N test_filesys > $OUT.new
+$FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
+status=$?
+echo Exit status is $status >> $OUT.new
+sed -e '2d' $OUT.new >> $OUT
+
+echo "debugfs -R ''dump test_data $VERIFY_DATA'' $TMPFILE" > $OUT.new
+$DEBUGFS -R "dump test_data $VERIFY_DATA" $TMPFILE >> $OUT.new 2>&1
+status=$?
+echo Exit status is $status >> $OUT.new
+sed -e '2d' $OUT.new >> $OUT
+
+echo "cmp $TEST_DATA $VERIFY_DATA" >> $OUT
+cmp $TEST_DATA $VERIFY_DATA >>$OUT
+status=$?
+echo Exit status is $status >> $OUT
+
+#
+# Do the verification
+#
+
+rm -f $test_name.ok $test_name.failed $VERIFY_DATA $TEST_DATA $TMPFILE
+cmp -s $OUT $EXP
+status=$?
+
+if [ "$status" = 0 ] ; then
+       echo "ok"
+       touch $test_name.ok
+else
+       echo "failed"
+       diff -c $EXP $OUT > $test_name.failed
+fi
+
+unset VERIFY_FSCK_OPT NATIVE_FSCK_OPT OUT EXP TEST_DATA VERIFY_DATA
+