Some tests

master
Vitaliy Filippov 2014-01-12 12:43:19 +00:00
parent f2e0275c7e
commit 6d7094fd3d
4 changed files with 77 additions and 1 deletions

View File

@ -3,3 +3,9 @@ realloc-inodes: realloc-inodes.c bmove.c bmove.h check_uninit.c check_uninit.h M
gcc -g -Wsign-compare -Wall -o realloc-inodes -lcom_err -lext2fs realloc-inodes.c bmove.c patch_io.c patch.c check_uninit.c
e2patch: e2patch.c patch.c patch.h
gcc -g -Wsign-compare -Wall -o e2patch -lcom_err -lext2fs e2patch.c patch.c
test-ext2.img:
UID=$(shell id -u)
sudo sh test-mkimages.sh
sudo chown $(UID) *.img
test: test-ext2.img realloc-inodes e2patch
perl run-tests.pl

View File

@ -21,7 +21,7 @@
*/
/**
* TODO write some tests
* TODO try to not fragment the journal while moving
*
* The theory isn't that hard:
* 1) Determine where we want to move the inode tables:

54
run-tests.pl Normal file
View File

@ -0,0 +1,54 @@
#!/usr/bin/perl
use strict;
my $tests = [
[ 'Basic ext2 test - grow', 'test-ext2', 8192 ],
[ 'Basic ext2 test - shrink', 'test-ext2', 1920 ],
[ 'Basic ext4 test - grow', 'test-ext4', 8192 ],
[ 'Basic ext4 test - shrink', 'test-ext4', 1920 ],
[ 'Big flex_bg - grow', 'test-biggroup', 33280 ],
[ 'Big flex_bg - shrink', 'test-biggroup', 8192 ],
[ 'Block and journal moving between groups', 'test-ext4-25m', 8192 ],
[ '> 1 flex_bg - shrink', 'test-ext4-25m', 1920 ],
[ 'Bigalloc - grow', 'test-ext4-bigalloc', 8192 ],
[ 'Bigalloc - shrink, not on a cluster boundary', 'test-ext4-bigalloc', 1984 ],
[ 'Patch I/O, big flex_bg - shrink', 'test-biggroup', 8192, 1 ],
];
my $ok = 0;
for (@$tests)
{
my ($name, $file, $inodes, $patch) = @$_;
print "\n*** $name ***\n\n";
system("cp $file.img test.img") && last;
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;
}
system("./realloc-inodes test.img $inodes") && last;
system("/sbin/e2fsck -f test.img") && last;
$ok++;
}
if ($ok < @$tests)
{
print "\n!!! FAILED !!!\n";
}
else
{
print "\n*** All tests OK ***\n";
}

16
test-mkimages.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/sh
# Basic ext2 test
FS=ext2 FILE=test-ext2.img sh mkimage.sh
# Basic ext4 test
FS=ext4 FILE=test-ext4.img sh mkimage.sh
# Big flex_bg, inode tables don't fit in a single block group
FS=ext4 FILE=test-biggroup.img SIZE=131072 OPTS='-b 1024 -I 256 -g 2048 -G 64 -N 32768' sh mkimage.sh
# Journal moving, reallocation in FS with > 1 flex_bg, moving blocks between groups
FS=ext4 FILE=test-ext4-25m.img SIZE=25000 OPTS='-b 1024 -g 2048 -N 2048 -G 4' sh mkimage.sh
# bigalloc
FS=ext4 FILE=test-ext4-bigalloc.img SIZE=32768 OPTS='-C 2048 -O bigalloc,^resize_inode -b 1024 -g 2048 -N 2048' sh mkimage.sh