Fix tests: sh/dash compatibility, error messages, e2fsck on a fresh ext2
parent
c683b16f7e
commit
ae5c125cd4
|
@ -14,12 +14,13 @@ mkdir -p dir
|
||||||
mount -o loop $FILE dir
|
mount -o loop $FILE dir
|
||||||
# For block moving test: create a sparse file with many extents
|
# For block moving test: create a sparse file with many extents
|
||||||
dd if=/dev/urandom of=dir/f_random bs=1k count=1
|
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
|
dd if=dir/f_random of=dir/f_sparse bs=1k count=1 seek=$((2400-i*2)) conv=notrunc 2>/dev/null
|
||||||
done
|
done
|
||||||
# For inode moving test: create 1201 1kb sized files
|
# For inode moving test: create 1201 1kb sized files
|
||||||
dd if=/dev/zero of=dir/f_zero bs=1k count=1
|
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
|
cp dir/f_zero dir/f$i
|
||||||
done
|
done
|
||||||
|
sleep 1
|
||||||
umount dir
|
umount dir
|
||||||
|
|
38
run-tests.pl
38
run-tests.pl
|
@ -21,34 +21,34 @@ for (@$tests)
|
||||||
{
|
{
|
||||||
my ($name, $file, $inodes, $patch) = @$_;
|
my ($name, $file, $inodes, $patch) = @$_;
|
||||||
print "\n*** $name ***\n\n";
|
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)
|
if ($patch)
|
||||||
{
|
{
|
||||||
unlink("test.img.patch");
|
unlink("test.img.patch");
|
||||||
unlink("test.img.backup");
|
unlink("test.img.backup");
|
||||||
last if -e "test.img.patch";
|
err("Failed to remove test.img.patch") if -e "test.img.patch";
|
||||||
last if -e "test.img.backup";
|
err("Failed to remove test.img.backup") if -e "test.img.backup";
|
||||||
system("./realloc-inodes --patch test.img.patch test.img $inodes") && last;
|
system("./realloc-inodes --patch test.img.patch test.img $inodes") && err("realloc-inodes failed with code $?");
|
||||||
system("diff $file.img test.img") && last;
|
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") && last;
|
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") && last;
|
system("./e2patch apply test.img test.img.patch") && err("e2patch apply failed with code $?");
|
||||||
system("/sbin/e2fsck -f test.img") && last;
|
system("/sbin/e2fsck -f test.img") && err("filesystem is modified by e2fsck after applying realloc patch");
|
||||||
system("cp $file.img test.img") && last;
|
system("cp $file.img test.img") && err("failed to copy $file.img to test.img");
|
||||||
system("./e2patch apply test.img test.img.patch") && last;
|
system("./e2patch apply test.img test.img.patch") && err("e2patch apply failed with code $?");
|
||||||
system("diff $file.img test.img") || last;
|
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") && last;
|
system("./e2patch apply test.img test.img.backup") && err("e2patch restore backup failed with code $?");
|
||||||
system("diff $file.img test.img") && last;
|
system("diff $file.img test.img") && err("$file.img differs from test.img after restoring backup");
|
||||||
}
|
}
|
||||||
system("./realloc-inodes test.img $inodes") && last;
|
system("./realloc-inodes test.img $inodes") && err("realloc-inodes failed with code $?");
|
||||||
system("/sbin/e2fsck -f test.img") && last;
|
system("/sbin/e2fsck -f test.img") && err("filesystem is modified by e2fsck after realloc");
|
||||||
$ok++;
|
$ok++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ok < @$tests)
|
sub err
|
||||||
{
|
{
|
||||||
print "\n!!! FAILED !!!\n";
|
print "\n!!! FAILED !!!\n";
|
||||||
|
print "Error: ", @_, "\n";
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
print "\n*** All tests OK ***\n";
|
print "\n*** All tests OK ***\n";
|
||||||
}
|
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
# Basic ext2 test
|
# Basic ext2 test
|
||||||
FS=ext2 FILE=test-ext2.img sh mkimage.sh
|
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
|
# Basic ext4 test
|
||||||
FS=ext4 FILE=test-ext4.img sh mkimage.sh
|
FS=ext4 FILE=test-ext4.img sh mkimage.sh
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue