btrfs/339: test receive dump stream for different user
PATCH v2 1/1 btrfs/339: test receive dump stream for different user
Test receive to dump stream file from different user.
This is a regression test for the btrfs-progs commit cd933616d485 ("btrfs-progs: receive: don't use O_NOATIME to open stream for dumping").
---
v2:
- forward to $seqres.full rather than -q
- use $tmp for stream file
--- tests/btrfs/339 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/btrfs/339.out | 2 ++ 2 files changed, 42 insertions(+) create mode 100755 tests/btrfs/339 create mode 100644 tests/btrfs/339.out
tests/btrfs/339 new file +40 -0
@@ -0,0 +1,40 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Sidong Yang. All Rights Reserved. +# +# FS QA Test 339 +# +# Test btrfs receive dump stream from different user +# +. ./common/preamble +_begin_fstest auto quick send snapshot + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* +} + +. ./common/filter +. ./common/quota + +_require_scratch +_require_user + +_fixed_by_git_commit btrfs-progs cd933616d485 \ + "btrfs-progs: receive: don't use O_NOATIME to open stream for dumping" + +_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed" +_scratch_mount + +stream=$tmp.fsv.ss + +$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap >> $seqres.full +$BTRFS_UTIL_PROG send -f $stream $SCRATCH_MNT/snap >> $seqres.full 2>&1 || _fail "send failed" +chmod a+r $stream +_su $qa_user -c "$BTRFS_UTIL_PROG receive --dump -f $stream" >> $seqres.full + +# success, all done +echo "Silence is golden" +_exit 0
tests/btrfs/339.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 339 +Silence is golden
Signature · 1 line
2.43.0
Quoted 32 lines · Sidong Yang
Test receive to dump stream file from different user.
This is a regression test for the btrfs-progs commit
cd933616d485("btrfs-progs: receive: don't useO_NOATIMEto open stream for dumping").Signed-off-by Sidong Yang <[email protected]>---
v2:
- forward to $seqres.full rather than -q
- use $tmp for stream file--- tests/btrfs/339 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/btrfs/339.out | 2 ++ 2 files changed, 42 insertions(+) create mode 100755 tests/btrfs/339 create mode 100644 tests/btrfs/339.outtests/btrfs/339 new file +7
-0@@ -0,0 +1,40 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Sidong Yang. All Rights Reserved. +# +# FS QA Test 339 +# +# Test btrfs receive dump stream from different user
tests/btrfs/339 line 17
Quoted 10 lines
tests/btrfs/339 new file +10
-0+# +. ./common/preamble +_begin_fstest auto quick send snapshot + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* +}
This does the same as the default _cleanup function, so there's no need to have it, just remove it.
tests/btrfs/339 line 20
Quoted 3 lines
tests/btrfs/339 new file +3
-0+ +. ./common/filter +. ./common/quota
Why include the quota file? It's not needed, the test doesn't use anything from it, just remove it.
tests/btrfs/339 line 33
Quoted 13 lines
tests/btrfs/339 new file +13
-0+ +_require_scratch +_require_user + +_fixed_by_git_commit btrfs-progs cd933616d485 \ + "btrfs-progs: receive: don't use O_NOATIME to open stream for dumping" + +_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed" +_scratch_mount + +stream=$tmp.fsv.ss + +$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap >> $seqres.full
Nowadays we use _btrfs, it's shorter and does the same (including the stdout redirection):
_btrfs subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap
tests/btrfs/339 line 34
Quoted 1 line
tests/btrfs/339 new file +1
-0+$BTRFS_UTIL_PROG send -f $stream $SCRATCH_MNT/snap >> $seqres.full 2>&1 || _fail "send failed"
And here:
_btrfs send -f $stream $SCRATCH_MNT/snap
There's no need to: || _fail "send failed"
That is generally discouraged in fstests. A failure will just cause a mismatch with the golden output and make the test fail.
But _btrfs already calls _fail and redirects to the .full file anyway.
Otherwise it looks good, thanks.
Quoted 18 lines
tests/btrfs/339 new file +6
-0+chmod a+r $stream +_su $qa_user -c "$BTRFS_UTIL_PROG receive --dump -f $stream" >> $seqres.full + +# success, all done +echo "Silence is golden" +_exit 0tests/btrfs/339.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 339 +Silence is golden --2.43.0
Quoted 38 lines · Filipe Manana
Quoted 37 lines · Sidong Yang
Test receive to dump stream file from different user.
This is a regression test for the btrfs-progs commit
cd933616d485("btrfs-progs: receive: don't useO_NOATIMEto open stream for dumping").Signed-off-by Sidong Yang <[email protected]>---
v2:
- forward to $seqres.full rather than -q
- use $tmp for stream file--- tests/btrfs/339 | 40 ++++++++++++++++++++++++++++++++++++++++ tests/btrfs/339.out | 2 ++ 2 files changed, 42 insertions(+) create mode 100755 tests/btrfs/339 create mode 100644 tests/btrfs/339.outtests/btrfs/339 new file +12
-0@@ -0,0 +1,40 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Sidong Yang. All Rights Reserved. +# +# FS QA Test 339 +# +# Test btrfs receive dump stream from different user +# +. ./common/preamble +_begin_fstest auto quick send snapshot + +# Override the default cleanup function.
Quoted 8 lines
tests/btrfs/339 line 17
Quoted 5 lines
tests/btrfs/339 new file +5
-0+_cleanup() +{ + cd / + rm -r -f $tmp.* +}This does the same as the default
_cleanupfunction, so there's no need to have it, just remove it.
I see, Thanks
Quoted 7 lines
tests/btrfs/339 line 20
Quoted 4 lines
tests/btrfs/339 new file +3
-0+ +. ./common/filter +. ./common/quotaWhy include the quota file? It's not needed, the test doesn't use anything from it, just remove it.
I don't need it. Removed.
Quoted 26 lines
Quoted 4 lines
tests/btrfs/339 new file +3
-0+ +_require_scratch +_require_usertests/btrfs/339 line 33
Quoted 10 lines
tests/btrfs/339 new file +10
-0+ +_fixed_by_git_commit btrfs-progs cd933616d485 \ + "btrfs-progs: receive: don't use O_NOATIME to open stream for dumping" + +_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed" +_scratch_mount + +stream=$tmp.fsv.ss + +$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snap >> $seqres.fullNowadays we use
_btrfs, it's shorter and does the same (including the stdout redirection):
_btrfssubvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/snaptests/btrfs/339 line 34
Quoted 1 line
tests/btrfs/339 new file +1
-0+$BTRFS_UTIL_PROG send -f $stream $SCRATCH_MNT/snap >> $seqres.full 2>&1 || _fail "send failed"And here:
_btrfssend -f $stream $SCRATCH_MNT/snap
Quoted 7 lines
There's no need to: ||
_fail"send failed"
That is generally discouraged in fstests. A failure will just cause a mismatch with the golden output and make the test fail.But
_btrfsalready calls_failand redirects to the .full file anyway.Otherwise it looks good, thanks.
Thanks, I'll send a new version right away.
Thanks,
Sidong
Quoted 21 lines
Quoted 21 lines
tests/btrfs/339 new file +6
-0+chmod a+r $stream +_su $qa_user -c "$BTRFS_UTIL_PROG receive --dump -f $stream" >> $seqres.full + +# success, all done +echo "Silence is golden" +_exit 0tests/btrfs/339.out new file +2
-1@@ -0,0 +1,2 @@ +QA output created by 339 +Silence is golden --2.43.0