Re: [PATCH 3/4] tests: add test for e2image -b option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jun 26, 2017, at 10:58 AM, Artem Blagodarenko <artem.blagodarenko@xxxxxxxxx> wrote:
> 
> From: Artem Blagodarenko <artem.blagodarenko@xxxxxxxxxxx>
> 
> The test makes raw image from partition with broken super block
> and executes e2fsck.

It's great to have a test case for this.

If possible, it is preferred to create new test cases by writing a script that formats a new filesystem and induces corruption via debugfs or dd or similar.  That makes it easier to see what is actually corrupted in the filesystem.

Cheers, Andreas

> Signed-off-by: Artem Blagodarenko <artem.blagodarenko@xxxxxxxxxxx>
> ---
> tests/i_zero_super/expect   |   22 ++++++++++++++++++++++
> tests/i_zero_super/image.gz |  Bin 0 -> 13262 bytes
> tests/i_zero_super/script   |   36 ++++++++++++++++++++++++++++++++++++
> 3 files changed, 58 insertions(+), 0 deletions(-)
> 
> diff --git a/tests/i_zero_super/expect b/tests/i_zero_super/expect
> new file mode 100644
> index 0000000..863d692
> --- /dev/null
> +++ b/tests/i_zero_super/expect
> @@ -0,0 +1,22 @@
> +test.img was not cleanly unmounted, check forced.

Shouldn't this report something about using the backup superblock?

> +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
> +Free blocks count wrong for group #0 (7987, counted=7982).
> +Fix? no
> +
> +Free blocks count wrong (11602, counted=11597).
> +Fix? no
> +
> +Free inodes count wrong for group #0 (1493, counted=1488).
> +Fix? no
> +
> +Free inodes count wrong (2997, counted=2992).
> +Fix? no
> +
> +
> +test.img: ********** WARNING: Filesystem still has errors **********
> +
> +test.img: 11/3008 files (0.0% non-contiguous), 398/12000 blocks
> diff --git a/tests/i_zero_super/image.gz b/tests/i_zero_super/image.gz
> new file mode 100644
> index 0000000000000000000000000000000000000000..eea9140194f4dd9ec9dc8bb7b9e2215b950587d2
> GIT binary patch
> literal 13262
> zcmeI&{WsH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super/script
> new file mode 100644
> index 0000000..5952c6f
> --- /dev/null
> +++ b/tests/i_zero_super/script
> @@ -0,0 +1,36 @@
> +if test -x $E2IMAGE_EXE; then
> +
> +IMAGE=$test_dir/image.gz
> +FSCK_OPT=-fy
> +OUT=$test_name.log
> +EXP=$test_dir/expect
> +
> +cp /dev/null $OUT

Truncating a file can be done directly by the shell, like: "> $OUT".

> +
> +gzip -d < $IMAGE > $TMPFILE
> +
> +$E2IMAGE_EXE -r -b 8193 $TMPFILE $TMPFILE.raw
> +$FSCK -n -b 8193 $TMPFILE.raw > $OUT.new 2>&1
> +sed -f $cmd_dir/filter.sed -e "s;$TMPFILE.raw;test.img;" $OUT.new >> $OUT

This could avoid a temp output file and filter the result directly, like:

$FSCK -n -b 8193 $TMPFILE.raw |
	sed -f $cmd_dir/filter.sed -e 's;$TMPFILE.raw;test.img;' > $OUT

> +
> +rm -f $TMPFILE
> +rm -f $TMPFILE.raw
> +rm -f $OUT.new

These can be a single "rm" command.

> +cmp -s $OUT $EXP
> +status=$?
> +
> +if [ "$status" = 0 ] ; then
> +	echo "$test_name: $test_description: ok"
> +	touch $test_name.ok
> +else
> +	echo "$test_name: $test_description: failed"
> +	diff $EXP $OUT > $test_name.failed
> +	rm -f $test_name.tmp
> +fi
> +
> +unset IMAGE FSCK_OPT OUT EXP
> +
> +else #if test -x $E2IMAGE_EXE; then

Not sure what the comment here is?  This should be the "if ! test -x" branch?

> +	echo "$test_name: $test_description: skipped"
> +fi
> --
> 1.7.1
> 


Cheers, Andreas





Attachment: signature.asc
Description: Message signed with OpenPGP


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux