Skip to contentSkip to conversation

btrfs: add validation of compression options to btrfs/048

PATCH Superseded Johannes Thumshirn 2 participants 5 messages Jun 6, 2019 – Jun 7, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: add validation of compression options to btrfs/048

The current btrfs/048 test-case did not check the behavior of properties with options like compression and with the compression level supplied.

Add test cases for compression with compression level as well so we can be sure we don't regress there.

---
 tests/btrfs/048     | 15 +++++++++++++++
 tests/btrfs/048.out | 12 ++++++++++++
 2 files changed, 27 insertions(+)
tests/btrfs/048 +15 -0
index 8bb10a904bc9..af2d4ff34414 100755
@@ -226,5 +226,20 @@ $BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lz' 2>&1 | _filter_scrat
 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT
 $BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | grep '^generation'
 
+echo -e "\nTesting argument validation with options"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lzo:9' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zlib:3' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zstd:0' 2>&1 | _filter_scratch
+echo "***"
+
+echo -e "\nTesting invalid argument validation with options, should fail"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lz:9' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zli:0' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zst:3' 2>&1 | _filter_scratch
+
 status=0
 exit
tests/btrfs/048.out +12 -0
index 16a785a642f7..016eba265b01 100644
@@ -92,3 +92,15 @@ Testing generation is unchanged after failed validation
 generation		7
 ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
 generation		7
+
+Testing argument validation with options
+***
+***
+***
+
+Testing invalid argument validation with options, should fail
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
+***
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
+***
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
Signature · 1 line
2.16.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Johannes Thumshirn

The current btrfs/048 test-case did not check the behavior of properties with options like compression and with the compression level supplied.

Add test cases for compression with compression level as well so we can be sure we don't regress there.

---
 tests/btrfs/048     | 15 +++++++++++++++
 tests/btrfs/048.out | 12 ++++++++++++
 2 files changed, 27 insertions(+)
tests/btrfs/048 +0 -0
index 8bb10a904bc9..af2d4ff34414 100755

tests/btrfs/048 $BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lz' 2>&1 | _filter_scrat · line 235

Quoted 10 lines
tests/btrfs/048 +7 -0
@@ -226,5 +226,20 @@ $BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lz' 2>&1 | _filter_scrat
 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT
 $BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | grep '^generation'
 
+echo -e "\nTesting argument validation with options"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lzo:9' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zlib:3' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zstd:0' 2>&1 | _filter_scratch
+echo "***"

For those 3 cases, there's no need to "2>&1 | _filter_scratch", since we don't expect any output from the commands in the golden output.

Other than that, looks good to me, thanks.

Quoted 33 lines
tests/btrfs/048 +8 -0
+
+echo -e "\nTesting invalid argument validation with options, should fail"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lz:9' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zli:0' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zst:3' 2>&1 | _filter_scratch
+
 status=0
 exit
tests/btrfs/048.out +12 -1
index 16a785a642f7..016eba265b01 100644
@@ -92,3 +92,15 @@ Testing generation is unchanged after failed validation
 generation             7
 ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
 generation             7
+
+Testing argument validation with options
+***
+***
+***
+
+Testing invalid argument validation with options, should fail
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
+***
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
+***
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
--

2.16.4

Signature · 3 lines
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”
#2 lore raw

PATCH v2 1/1 btrfs: add validation of compression options to btrfs/048

The current btrfs/048 test-case did not check the behavior of properties with options like compression and with the compression level supplied.

Add test cases for compression with compression level as well so we can be sure we don't regress there.

---
Changes to v1:
- Removed output redirection and filtering for the cases we don't expect any actual output (Filipe)

---
 tests/btrfs/048     | 15 +++++++++++++++
 tests/btrfs/048.out | 12 ++++++++++++
 2 files changed, 27 insertions(+)
tests/btrfs/048 +15 -0
index 8bb10a904bc9..04df3ed98ff7 100755
@@ -226,5 +226,20 @@ $BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lz' 2>&1 | _filter_scrat
 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT
 $BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | grep '^generation'
 
+echo -e "\nTesting argument validation with options"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lzo:9'
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zlib:3'
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zstd:0'
+echo "***"
+
+echo -e "\nTesting invalid argument validation with options, should fail"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lz:9' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zli:0' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zst:3' 2>&1 | _filter_scratch
+
 status=0
 exit
tests/btrfs/048.out +12 -0
index 16a785a642f7..016eba265b01 100644
@@ -92,3 +92,15 @@ Testing generation is unchanged after failed validation
 generation		7
 ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
 generation		7
+
+Testing argument validation with options
+***
+***
+***
+
+Testing invalid argument validation with options, should fail
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
+***
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
+***
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
Signature · 1 line
2.16.4
#3 lore raw

On Thu, Jun 06, 2019 at 01:39:07PM +0200, Johannes Thumshirn wrote:
[...]

Quoted 2 lines

+echo -e "\nTesting argument validation with options" +$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lzo:9'

Please don't take this patch yet, setting lzo with a compression level should fail but doesn't. I'll be addressing this soon (and update the test accordingly)

Thanks,
Johannes

Signature · 6 lines
Johannes Thumshirn                            SUSE Labs Filesystems
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#4 lore raw

PATCH v3 1/1 btrfs: add validation of compression options to btrfs/048

The current btrfs/048 test-case did not check the behavior of properties with options like compression and with the compression level supplied.

Add test cases for compression with compression level as well so we can be sure we don't regress there.

---
Changes to v2:
- Remove validation of lzo compression with option, lzo doesn't have compression levels

Changes to v1:
- Removed output redirection and filtering for the cases we don't expect any actual output (Filipe)

---
 tests/btrfs/048     | 13 +++++++++++++
 tests/btrfs/048.out | 11 +++++++++++
 2 files changed, 24 insertions(+)
tests/btrfs/048 +13 -0
index 8bb10a904bc9..7294f231e4ed 100755
@@ -226,5 +226,18 @@ $BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lz' 2>&1 | _filter_scrat
 $BTRFS_UTIL_PROG filesystem sync $SCRATCH_MNT
 $BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV | grep '^generation'
 
+echo -e "\nTesting argument validation with options"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zlib:3'
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zstd:0'
+echo "***"
+
+echo -e "\nTesting invalid argument validation with options, should fail"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zl:9' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zli:0' 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'zst:3' 2>&1 | _filter_scratch
+
 status=0
 exit
tests/btrfs/048.out +11 -0
index 16a785a642f7..0923b00c01ed 100644
@@ -92,3 +92,14 @@ Testing generation is unchanged after failed validation
 generation		7
 ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
 generation		7
+
+Testing argument validation with options
+***
+***
+
+Testing invalid argument validation with options, should fail
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
+***
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
+***
+ERROR: failed to set compression for SCRATCH_MNT: Invalid argument
Signature · 1 line
2.16.4