Fix tests: sh/dash compatibility, error messages, e2fsck on a fresh ext2

master
Vitaliy Filippov 2014-01-15 14:23:39 +00:00
parent c683b16f7e
commit ae5c125cd4
3 changed files with 26 additions and 22 deletions

View File

@ -14,12 +14,13 @@ mkdir -p dir
mount -o loop $FILE dir
# For block moving test: create a sparse file with many extents
dd if=/dev/urandom of=dir/f_random bs=1k count=1
for i in {1..2500}; do
for i in $(seq 1 2500); do
dd if=dir/f_random of=dir/f_sparse bs=1k count=1 seek=$((2400-i*2)) conv=notrunc 2>/dev/null
done
# For inode moving test: create 1201 1kb sized files
dd if=/dev/zero of=dir/f_zero bs=1k count=1
for i in {1..1200}; do
for i in $(seq 1 1200); do
cp dir/f_zero dir/f$i
done
sleep 1
umount dir

View File

@ -21,34 +21,34 @@ for (@$tests)
{
my ($name, $file, $inodes, $patch) = @$_;
print "\n*** $name ***\n\n";
system("cp $file.img test.img") && last;
system("cp $file.img test.img") && err("Failed to copy $file.img to test.img: $!");
if ($patch)
{
unlink("test.img.patch");
unlink("test.img.backup");
last if -e "test.img.patch";
last if -e "test.img.backup";
system("./realloc-inodes --patch test.img.patch test.img $inodes") && last;
system("diff $file.img test.img") && last;
system("./e2patch backup test.img test.img.patch test.img.backup") && last;
system("./e2patch apply test.img test.img.patch") && last;
system("/sbin/e2fsck -f test.img") && last;
system("cp $file.img test.img") && last;
system("./e2patch apply test.img test.img.patch") && last;
system("diff $file.img test.img") || last;
system("./e2patch apply test.img test.img.backup") && last;
system("diff $file.img test.img") && last;
err("Failed to remove test.img.patch") if -e "test.img.patch";
err("Failed to remove test.img.backup") if -e "test.img.backup";
system("./realloc-inodes --patch test.img.patch test.img $inodes") && err("realloc-inodes failed with code $?");
system("diff $file.img test.img") && err("patch I/O has modified $file.img (it differs from test.img)");
system("./e2patch backup test.img test.img.patch test.img.backup") && err("e2patch backup failed with code $?");
system("./e2patch apply test.img test.img.patch") && err("e2patch apply failed with code $?");
system("/sbin/e2fsck -f test.img") && err("filesystem is modified by e2fsck after applying realloc patch");
system("cp $file.img test.img") && err("failed to copy $file.img to test.img");
system("./e2patch apply test.img test.img.patch") && err("e2patch apply failed with code $?");
system("diff $file.img test.img") || err("$file.img does not differ from test.img after patching");
system("./e2patch apply test.img test.img.backup") && err("e2patch restore backup failed with code $?");
system("diff $file.img test.img") && err("$file.img differs from test.img after restoring backup");
}
system("./realloc-inodes test.img $inodes") && last;
system("/sbin/e2fsck -f test.img") && last;
system("./realloc-inodes test.img $inodes") && err("realloc-inodes failed with code $?");
system("/sbin/e2fsck -f test.img") && err("filesystem is modified by e2fsck after realloc");
$ok++;
}
if ($ok < @$tests)
sub err
{
print "\n!!! FAILED !!!\n";
print "Error: ", @_, "\n";
exit(1);
}
else
{
print "\n*** All tests OK ***\n";
}
print "\n*** All tests OK ***\n";

View File

@ -3,6 +3,9 @@
# Basic ext2 test
FS=ext2 FILE=test-ext2.img sh mkimage.sh
# ??? e2fsck rehashes dir indexes on a fresh ext2 O_o
e2fsck -f test-ext2.img
# Basic ext4 test
FS=ext4 FILE=test-ext4.img sh mkimage.sh