diff mbox series

[2/2] btrfs-progs: fix misc-test/029 provide device for mount

Message ID 1585125129-11224-2-git-send-email-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series [1/2] btrfs-progs: fix fsck-test/037 skip corrupt FREE_SPACE_BITMAP | expand

Commit Message

Anand Jain March 25, 2020, 8:32 a.m. UTC
The mount fails with 'file exists' error. Fix it by providing the device
name.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/misc-tests/029-send-p-different-mountpoints/test.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

David Sterba March 26, 2020, 3:46 p.m. UTC | #1
On Wed, Mar 25, 2020 at 04:32:09PM +0800, Anand Jain wrote:
> The mount fails with 'file exists' error. Fix it by providing the device
> name.

Can you be more specific about the environment where it fails? The test
passes for me.

> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  tests/misc-tests/029-send-p-different-mountpoints/test.sh | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/misc-tests/029-send-p-different-mountpoints/test.sh b/tests/misc-tests/029-send-p-different-mountpoints/test.sh
> index a478b3d26495..e34402d9ec06 100755
> --- a/tests/misc-tests/029-send-p-different-mountpoints/test.sh
> +++ b/tests/misc-tests/029-send-p-different-mountpoints/test.sh
> @@ -19,8 +19,10 @@ run_mayfail $SUDO_HELPER mkdir -p "$SUBVOL_MNT" ||
>  run_check_mkfs_test_dev
>  run_check_mount_test_dev
>  
> +# The sed part is to replace double forward-slash with single forward-slash
> +lodev=$(losetup  | grep $(echo $TEST_DEV | sed 's/\/\//\//') | awk '{print $1}')

There's a simpler way to canonicalize a path, eg using readlink or
realpath.

And I don't see why would two slashes appear in a path. IIRC a path
starting with two slashes is standardized as a network path and
recognized by VFS but why this is a concern for the testsuite?
Anand Jain March 27, 2020, 4:15 a.m. UTC | #2
On 3/26/20 11:46 PM, David Sterba wrote:
> On Wed, Mar 25, 2020 at 04:32:09PM +0800, Anand Jain wrote:
>> The mount fails with 'file exists' error. Fix it by providing the device
>> name.
> 
> Can you be more specific about the environment where it fails? The test
> passes for me.
> 

I am running it as

/btrfs-progs$ make TEST=029\* test-misc
     [TEST]   misc-tests.sh
     [TEST/misc]   029-send-p-different-mountpoints
failed: mount -t btrfs -o subvol=subv1 /btrfs-progs/tests//test.img 
/btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
test failed for case 029-send-p-different-mountpoints
make: *** [test-misc] Error 1

OR

make test

I wonder if there is any other/better way to run them?


>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   tests/misc-tests/029-send-p-different-mountpoints/test.sh | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/misc-tests/029-send-p-different-mountpoints/test.sh b/tests/misc-tests/029-send-p-different-mountpoints/test.sh
>> index a478b3d26495..e34402d9ec06 100755
>> --- a/tests/misc-tests/029-send-p-different-mountpoints/test.sh
>> +++ b/tests/misc-tests/029-send-p-different-mountpoints/test.sh
>> @@ -19,8 +19,10 @@ run_mayfail $SUDO_HELPER mkdir -p "$SUBVOL_MNT" ||
>>   run_check_mkfs_test_dev
>>   run_check_mount_test_dev
>>   
>> +# The sed part is to replace double forward-slash with single forward-slash
>> +lodev=$(losetup  | grep $(echo $TEST_DEV | sed 's/\/\//\//') | awk '{print $1}')
> 
> There's a simpler way to canonicalize a path, eg using readlink or
> realpath.
> 

  Err. yep. I will fix.

> And I don't see why would two slashes appear in a path. IIRC a path
> starting with two slashes is standardized as a network path and
> recognized by VFS but why this is a concern for the testsuite?
> 

The mount finds the path given is an image file and tries to add another
loop device to it (as I understand the above error), now I wonder
it should fail in your environment as well. If my understand is only
true.

Thanks, Anand
David Sterba April 1, 2020, 6:35 p.m. UTC | #3
On Fri, Mar 27, 2020 at 12:15:45PM +0800, Anand Jain wrote:
> 
> 
> On 3/26/20 11:46 PM, David Sterba wrote:
> > On Wed, Mar 25, 2020 at 04:32:09PM +0800, Anand Jain wrote:
> >> The mount fails with 'file exists' error. Fix it by providing the device
> >> name.
> > 
> > Can you be more specific about the environment where it fails? The test
> > passes for me.
> > 
> 
> I am running it as
> 
> /btrfs-progs$ make TEST=029\* test-misc
>      [TEST]   misc-tests.sh
>      [TEST/misc]   029-send-p-different-mountpoints
> failed: mount -t btrfs -o subvol=subv1 /btrfs-progs/tests//test.img 
> /btrfs-progs/tests/misc-tests/029-send-p-different-mountpoints/subvol_mnt
> test failed for case 029-send-p-different-mountpoints
> make: *** [test-misc] Error 1

That command works fine and the path of image has double slashes too:

$ make TEST=029\* test-misc
    [TEST]   misc-tests.sh
    [TEST/misc]   029-send-p-different-mountpoints

From the log, the first run of mount:

RUN CHECK root_helper mount -t btrfs -o loop /btrfs-progs/tests//test.img /btrfs-progs/tests//mnt

> >> --- a/tests/misc-tests/029-send-p-different-mountpoints/test.sh
> >> +++ b/tests/misc-tests/029-send-p-different-mountpoints/test.sh
> >> @@ -19,8 +19,10 @@ run_mayfail $SUDO_HELPER mkdir -p "$SUBVOL_MNT" ||
> >>   run_check_mkfs_test_dev
> >>   run_check_mount_test_dev
> >>   
> >> +# The sed part is to replace double forward-slash with single forward-slash
> >> +lodev=$(losetup  | grep $(echo $TEST_DEV | sed 's/\/\//\//') | awk '{print $1}')
> > 
> > There's a simpler way to canonicalize a path, eg using readlink or
> > realpath.
> 
>   Err. yep. I will fix.
> 
> > And I don't see why would two slashes appear in a path. IIRC a path
> > starting with two slashes is standardized as a network path and
> > recognized by VFS but why this is a concern for the testsuite?
> 
> The mount finds the path given is an image file and tries to add another
> loop device to it (as I understand the above error), now I wonder
> it should fail in your environment as well. If my understand is only
> true.

Instead of patching the tests, the path to TEST_DEV should be
canonicalized in prepare_test_dev or initialization of TEST_DEV should
not put the slash at the end in the test driver scripts.

tests/misc-tests.sh:
...
TEST_TOP="$TOP/tests/"
diff mbox series

Patch

diff --git a/tests/misc-tests/029-send-p-different-mountpoints/test.sh b/tests/misc-tests/029-send-p-different-mountpoints/test.sh
index a478b3d26495..e34402d9ec06 100755
--- a/tests/misc-tests/029-send-p-different-mountpoints/test.sh
+++ b/tests/misc-tests/029-send-p-different-mountpoints/test.sh
@@ -19,8 +19,10 @@  run_mayfail $SUDO_HELPER mkdir -p "$SUBVOL_MNT" ||
 run_check_mkfs_test_dev
 run_check_mount_test_dev
 
+# The sed part is to replace double forward-slash with single forward-slash
+lodev=$(losetup  | grep $(echo $TEST_DEV | sed 's/\/\//\//') | awk '{print $1}')
 run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
-run_check $SUDO_HELPER mount -t btrfs -o subvol=subv1 "$TEST_DEV" "$SUBVOL_MNT"
+run_check $SUDO_HELPER mount -t btrfs -o subvol=subv1 "$lodev" "$SUBVOL_MNT"
 
 run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/test-subvol"
 run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r \