#!/usr/bin/perl use strict; my $tests = [ [ 'Basic ext2 test - grow', 'test-ext2', 8192 ], [ 'Basic ext2 test - shrink', 'test-ext2', 1920 ], [ 'Basic ext3 test - grow', 'test-ext3', 16384 ], [ 'Basic ext3 test - shrink', 'test-ext3', 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 ], [ 'Patch I/O, big flex_bg - extend', 'test-biggroup', 40000, 1 ], # FAILS! [ 'Patch I/O, 4k block, shrink, non-optimal inode count', 'test-ext4-4k', 1928, 1 ], ]; if (@ARGV) { @$tests = @$tests[@ARGV]; } my $ok = 0; for (@$tests) { my ($name, $file, $inodes, $patch) = @$_; print "\n*** $name ***\n\n"; 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"); 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") && err("realloc-inodes failed with code $?"); system("/sbin/e2fsck -f test.img") && err("filesystem is modified by e2fsck after realloc"); $ok++; } sub err { print "\n!!! FAILED !!!\n"; print "Error: ", @_, "\n"; exit(1); } print "\n*** All tests OK ***\n";