From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 0D9361FF0AA for ; Tue, 17 Nov 2026 21:46:30 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2AD8B219AC; Tue, 17 Nov 2026 21:43:58 +0100 (CET) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v3 42/51] test: filesystem path: modernize code Date: Tue, 17 Nov 2026 21:39:14 +0100 Message-ID: <20261117203953.913035-43-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261117203953.913035-1-m.carrara@proxmox.com> References: <20261117203953.913035-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794948081678 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.242 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: FEQF6BAH6F2RAJHXRCQO2ALJXKOB7GUV X-Message-ID-Hash: FEQF6BAH6F2RAJHXRCQO2ALJXKOB7GUV X-MailFrom: m.carrara@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Wolfgang Bumiller X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Modernize the existing code in `filesystem_path_test.pm` while leaving the tests unchanged otherwise. In particular, - move the test execution code into its own subroutine - add and call a `main()` subroutine - declare `use v5.36;` instead of `use strict;` and `use warnings;` - rename / capitalize the sole constant - adapt the code style to fit our more modern style guide Signed-off-by: Max R. Carrara --- src/test/filesystem_path_test.pm | 62 +++++++++++++++++++------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/src/test/filesystem_path_test.pm b/src/test/filesystem_path_test.pm index dd7e4fa7..f5574c65 100644 --- a/src/test/filesystem_path_test.pm +++ b/src/test/filesystem_path_test.pm @@ -1,16 +1,16 @@ package PVE::Storage::TestFilesystemPath; -use strict; -use warnings; +use v5.36; use lib qw(..); use PVE::Storage; + use Test::More; -my $path = '/some/path'; +my $DEFAULT_STORAGE_DIR = '/some/path'; { package PVE::Storage::TestFilesystemPath::RootdirPlugin; @@ -30,87 +30,99 @@ my $path = '/some/path'; my $tests = [ { volname => '1234/vm-1234-disk-0.raw', snapname => undef, expected => [ - "$path/images/1234/vm-1234-disk-0.raw", '1234', 'vm-vol', + "$DEFAULT_STORAGE_DIR/images/1234/vm-1234-disk-0.raw", '1234', 'vm-vol', ], }, { volname => '1234/vm-1234-disk-0.raw', snapname => 'my_snap', expected => "can't snapshot this image format\n", }, { volname => '1234/vm-1234-disk-0.qcow2', snapname => undef, expected => [ - "$path/images/1234/vm-1234-disk-0.qcow2", '1234', 'vm-vol', + "$DEFAULT_STORAGE_DIR/images/1234/vm-1234-disk-0.qcow2", '1234', 'vm-vol', ], }, { volname => '1234/vm-1234-disk-0.qcow2', snapname => 'my_snap', expected => [ - "$path/images/1234/vm-1234-disk-0.qcow2", '1234', 'vm-vol', + "$DEFAULT_STORAGE_DIR/images/1234/vm-1234-disk-0.qcow2", '1234', 'vm-vol', ], }, { volname => '1234/vm-1234-state-my_snap.raw', snapname => undef, expected => [ - "$path/images/1234/vm-1234-state-my_snap.raw", '1234', 'vm-state', + "$DEFAULT_STORAGE_DIR/images/1234/vm-1234-state-my_snap.raw", '1234', 'vm-state', ], }, { volname => '1234/subvol-1234-disk-0.subvol', snapname => undef, expected => [ - "$path/images/1234/subvol-1234-disk-0.subvol", '1234', 'ct-vol', + "$DEFAULT_STORAGE_DIR/images/1234/subvol-1234-disk-0.subvol", '1234', 'ct-vol', ], }, { volname => 'iso/my-awesome-proxmox.iso', snapname => undef, expected => [ - "$path/template/iso/my-awesome-proxmox.iso", undef, 'iso', + "$DEFAULT_STORAGE_DIR/template/iso/my-awesome-proxmox.iso", undef, 'iso', ], }, { volname => "backup/vzdump-qemu-1234-2020_03_30-21_12_40.vma", snapname => undef, expected => [ - "$path/dump/vzdump-qemu-1234-2020_03_30-21_12_40.vma", 1234, 'backup', + "$DEFAULT_STORAGE_DIR/dump/vzdump-qemu-1234-2020_03_30-21_12_40.vma", 1234, + 'backup', ], }, # an external plugin may return 'rootdir', whose volumes are in 'private' instead of 'images' { plugin => 'PVE::Storage::TestFilesystemPath::RootdirPlugin', volname => 'subvol-1234-disk-0', snapname => undef, expected => [ - "$path/private/subvol-1234-disk-0", 1234, 'rootdir', + "$DEFAULT_STORAGE_DIR/private/subvol-1234-disk-0", 1234, 'rootdir', ], }, ]; -plan tests => scalar @$tests; +my sub run_tests($tests) { + for my $t ($tests->@*) { + my $volname = $t->{volname}; + my $snapname = $t->{snapname}; + my $expected = $t->{expected}; + my $plugin = $t->{plugin} // 'PVE::Storage::Plugin'; + my $scfg = { path => $DEFAULT_STORAGE_DIR }; + my $got; -foreach my $tt (@$tests) { - my $volname = $tt->{volname}; - my $snapname = $tt->{snapname}; - my $expected = $tt->{expected}; - my $plugin = $tt->{plugin} // 'PVE::Storage::Plugin'; - my $scfg = { path => $path }; - my $got; + eval { $got = [$plugin->filesystem_path($scfg, $volname, $snapname)]; }; + $got = $@ if $@; - eval { $got = [$plugin->filesystem_path($scfg, $volname, $snapname)]; }; - $got = $@ if $@; - - is_deeply($got, $expected, "wantarray: filesystem_path for $volname") - || diag(explain($got)); + is_deeply($got, $expected, "wantarray: filesystem_path for $volname") + || diag(explain($got)); + } + return; } -done_testing(); +my sub main() { + plan tests => scalar($tests->@*); + + run_tests($tests); + + done_testing(); + + return; +} + +main(); 1; -- 2.47.3