[PATCH pve-storage v1 42/54] test: parse volname: move VM disk test creation into separate block

Max R. Carrara
2026-04-22T11:19:41Z

For future organizational purposes, move the loop that adds more
test cases for VM images into its own block.

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

diff --git a/src/test/parse_volname_test.pm b/src/test/parse_volname_test.pm
index ea07c56b..3777e6e8 100644
--- a/src/test/parse_volname_test.pm
+++ b/src/test/parse_volname_test.pm
@@ -226,40 +226,49 @@ my $tests = [
},
];

-# create more test cases for VM disk images matches
-my $disk_suffix = ['raw', 'qcow2', 'vmdk'];
-for my $s ($disk_suffix->@*) {
- my @arr = (
- {
- description => "VM disk image, $s",
- volname => "$vmid/vm-$vmid-disk-1.$s",
- expected => [
- 'images', "vm-$vmid-disk-1.$s", "$vmid", undef, undef, undef, "$s",
- ],
- },
- {
- description => "VM disk image, linked, $s",
- volname => "$vmid/base-$vmid-disk-0.$s/$vmid/vm-$vmid-disk-0.$s",
- expected => [
- 'images',
- "vm-$vmid-disk-0.$s",
- "$vmid",
- "base-$vmid-disk-0.$s",
- "$vmid",
- undef,
- "$s",
- ],
- },
- {
- description => "VM disk image, base, $s",
- volname => "$vmid/base-$vmid-disk-0.$s",
- expected => [
- 'images', "base-$vmid-disk-0.$s", "$vmid", undef, undef, 'base-', "$s",
- ],
- },
- );
+# Additional test cases for VM disk images
+{
+ my $disk_suffixes = ['raw', 'qcow2', 'vmdk'];

- push($tests->@*, @arr);
+ for my $suffix ($disk_suffixes->@*) {
+ my @extra_tests = (
+ {
+ description => "VM disk image, $suffix",
+ volname => "$vmid/vm-$vmid-disk-1.$suffix",
+ expected => [
+ 'images', "vm-$vmid-disk-1.$suffix", "$vmid", undef, undef, undef, $suffix,
+ ],
+ },
+ {
+ description => "VM disk image, linked, $suffix",
+ volname => "$vmid/base-$vmid-disk-0.$suffix/$vmid/vm-$vmid-disk-0.$suffix",
+ expected => [
+ 'images',
+ "vm-$vmid-disk-0.$suffix",
+ "$vmid",
+ "base-$vmid-disk-0.$suffix",
+ "$vmid",
+ undef,
+ $suffix,
+ ],
+ },
+ {
+ description => "VM disk image, base, $suffix",
+ volname => "$vmid/base-$vmid-disk-0.$suffix",
+ expected => [
+ 'images',
+ "base-$vmid-disk-0.$suffix",
+ "$vmid",
+ undef,
+ undef,
+ 'base-',
+ $suffix,
+ ],
+ },
+ );
+
+ push($tests->@*, @extra_tests);
+ }
}

# create more test cases for backup files matches
--
2.47.3