[PATCH pve-storage v1 43/54] test: parse volname: move backup file test creation into sep. block

Max R. Carrara
2026-04-22T11:18:20Z

Similar to the previous commit, move the code that adds additional
tests for backup file volnames into a separate block, for future
organizational purposes.

Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
src/test/parse_volname_test.pm | 88 +++++++++++++++++-----------------
1 file changed, 45 insertions(+), 43 deletions(-)

diff --git a/src/test/parse_volname_test.pm b/src/test/parse_volname_test.pm
index 3777e6e8..fb300ad5 100644
--- a/src/test/parse_volname_test.pm
+++ b/src/test/parse_volname_test.pm
@@ -271,54 +271,56 @@ my $tests = [
}
}

-# create more test cases for backup files matches
-my $bkp_suffix = {
- qemu => ['vma', 'vma.gz', 'vma.lzo', 'vma.zst'],
- lxc => ['tar', 'tgz', 'tar.gz', 'tar.lzo', 'tar.zst', 'tar.bz2'],
- openvz => ['tar', 'tgz', 'tar.gz', 'tar.lzo', 'tar.zst'],
-};
+# Additional tests for backup files
+{
+ my $bkp_suffixes = {
+ qemu => ['vma', 'vma.gz', 'vma.lzo', 'vma.zst'],
+ lxc => ['tar', 'tgz', 'tar.gz', 'tar.lzo', 'tar.zst', 'tar.bz2'],
+ openvz => ['tar', 'tgz', 'tar.gz', 'tar.lzo', 'tar.zst'],
+ };

-for my $virt (keys $bkp_suffix->%*) {
- my $suffix = $bkp_suffix->{$virt};
- for my $s ($suffix->@*) {
- my @arr = (
- {
- description => "Backup archive, $virt, $s",
- volname => "backup/vzdump-$virt-$vmid-2020_03_30-21_12_40.$s",
- expected => [
- 'backup',
- "vzdump-$virt-$vmid-2020_03_30-21_12_40.$s",
- "$vmid",
- undef,
- undef,
- undef,
- 'raw',
- ],
- },
- );
+ for my $virt (keys $bkp_suffixes->%*) {
+ my $suffixes = $bkp_suffixes->{$virt};
+ for my $suffix ($suffixes->@*) {
+ my @extra_tests = (
+ {
+ description => "Backup archive, $virt, $suffix",
+ volname => "backup/vzdump-$virt-$vmid-2020_03_30-21_12_40.$suffix",
+ expected => [
+ 'backup',
+ "vzdump-$virt-$vmid-2020_03_30-21_12_40.$suffix",
+ "$vmid",
+ undef,
+ undef,
+ undef,
+ 'raw',
+ ],
+ },
+ );

- push($tests->@*, @arr);
+ push($tests->@*, @extra_tests);
+ }
}
-}

-# create more test cases for failed backup files matches
-my $non_bkp_suffix = {
- qemu => ['vms.gz', 'vma.xz'],
- lxc => ['zip.gz', 'tgz.lzo'],
-};
-for my $virt (keys $non_bkp_suffix->%*) {
- my $suffix = $non_bkp_suffix->{$virt};
- for my $s ($suffix->@*) {
- my @arr = (
- {
- description => "Failed match: Backup archive, $virt, $s",
- volname => "backup/vzdump-$virt-$vmid-2020_03_30-21_12_40.$s",
- expected =>
- "unable to parse directory volume name 'backup/vzdump-$virt-$vmid-2020_03_30-21_12_40.$s'\n",
- },
- );
+ # Failed tests
+ my $non_bkp_suffixes = {
+ qemu => ['vms.gz', 'vma.xz'],
+ lxc => ['zip.gz', 'tgz.lzo'],
+ };
+ for my $virt (keys $non_bkp_suffixes->%*) {
+ my $suffixes = $non_bkp_suffixes->{$virt};
+ for my $suffix ($suffixes->@*) {
+ my @extra_tests = (
+ {
+ description => "Failed match: Backup archive, $virt, $suffix",
+ volname => "backup/vzdump-$virt-$vmid-2020_03_30-21_12_40.$suffix",
+ expected =>
+ "unable to parse directory volume name 'backup/vzdump-$virt-$vmid-2020_03_30-21_12_40.$suffix'\n",
+ },
+ );

- push($tests->@*, @arr);
+ push($tests->@*, @extra_tests);
+ }
}
}

--
2.47.3