diff mbox series

btrfs-progs: tests: Add test for missing device delete error value

Message ID 20180903100257.5789-1-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: tests: Add test for missing device delete error value | expand

Commit Message

Nikolay Borisov Sept. 3, 2018, 10:02 a.m. UTC
Add a test which ensures the kernel returns the correct error value
when missing device removal is requested. This test verifies that kernel
refactoring didn't broken the return value.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 tests/misc-tests/011-delete-missing-device/test.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

David Sterba Sept. 10, 2018, 5:57 p.m. UTC | #1
On Mon, Sep 03, 2018 at 01:02:57PM +0300, Nikolay Borisov wrote:
> Add a test which ensures the kernel returns the correct error value
> when missing device removal is requested. This test verifies that kernel
> refactoring didn't broken the return value.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  tests/misc-tests/011-delete-missing-device/test.sh | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/tests/misc-tests/011-delete-missing-device/test.sh b/tests/misc-tests/011-delete-missing-device/test.sh
> index 4c976421c091..b799a25c201d 100755
> --- a/tests/misc-tests/011-delete-missing-device/test.sh
> +++ b/tests/misc-tests/011-delete-missing-device/test.sh
> @@ -44,6 +44,21 @@ test_delete_missing()
>  	run_check_umount_test_dev
>  }
>  
> +test_missing_error()
> +{
> +	run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
> +	run_check_mount_test_dev
> +	local out
> +	out=$(run_mustfail_stdout "Unexpected success" \

Which would become:

  unexpected success: Unexpected success

You'd win the error message of the year :) The text is supposed to be
more specific what was not expected, eg. "missing device removed".
David Sterba Sept. 11, 2018, 2:31 p.m. UTC | #2
On Mon, Sep 10, 2018 at 07:57:20PM +0200, David Sterba wrote:
> On Mon, Sep 03, 2018 at 01:02:57PM +0300, Nikolay Borisov wrote:
> > Add a test which ensures the kernel returns the correct error value
> > when missing device removal is requested. This test verifies that kernel
> > refactoring didn't broken the return value.
> > 
> > Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> > ---
> >  tests/misc-tests/011-delete-missing-device/test.sh | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> > 
> > diff --git a/tests/misc-tests/011-delete-missing-device/test.sh b/tests/misc-tests/011-delete-missing-device/test.sh
> > index 4c976421c091..b799a25c201d 100755
> > --- a/tests/misc-tests/011-delete-missing-device/test.sh
> > +++ b/tests/misc-tests/011-delete-missing-device/test.sh
> > @@ -44,6 +44,21 @@ test_delete_missing()
> >  	run_check_umount_test_dev
> >  }
> >  
> > +test_missing_error()
> > +{
> > +	run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
> > +	run_check_mount_test_dev
> > +	local out
> > +	out=$(run_mustfail_stdout "Unexpected success" \
> 
> Which would become:
> 
>   unexpected success: Unexpected success
> 
> You'd win the error message of the year :) The text is supposed to be
> more specific what was not expected, eg. "missing device removed".

Updated and applied, thanks.
diff mbox series

Patch

diff --git a/tests/misc-tests/011-delete-missing-device/test.sh b/tests/misc-tests/011-delete-missing-device/test.sh
index 4c976421c091..b799a25c201d 100755
--- a/tests/misc-tests/011-delete-missing-device/test.sh
+++ b/tests/misc-tests/011-delete-missing-device/test.sh
@@ -44,6 +44,21 @@  test_delete_missing()
 	run_check_umount_test_dev
 }
 
+test_missing_error()
+{
+	run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
+	run_check_mount_test_dev
+	local out
+	out=$(run_mustfail_stdout "Unexpected success" \
+		$SUDO_HELPER "$TOP/btrfs" device remove missing "$TEST_MNT")
+
+	if ! echo "$out" | grep -q "no missing devices found to remove"; then
+		_fail "IOCTL returned unexpected error value"
+	fi
+
+	run_check_umount_test_dev
+}
+
 setup_loopdevs 4
 prepare_loopdevs
 dev1=${loopdevs[1]}
@@ -53,5 +68,7 @@  TEST_DEV=$dev1
 test_do_mkfs -m raid1 -d raid1
 test_wipefs
 test_delete_missing
+test_missing_error
+
 
 cleanup_loopdevs