public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server v2 7/8] tests: cfg2cmd: improve mocking File::stat
Date: Fri, 25 Jul 2025 12:50:54 +0200	[thread overview]
Message-ID: <20250725105109.54093-8-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250725105109.54093-1-f.ebner@proxmox.com>

Stat-ing /dev/null worked, because the check in the blockdev module is
for block and character devices and then decides based on the
'media=cdrom' flag whether to use the host_cdrom or host_device
driver. But the result should actually be mocked to represent a block
device rather than a character device.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

New in v2.

 src/test/run_config2command_tests.pl | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/test/run_config2command_tests.pl b/src/test/run_config2command_tests.pl
index 7156c2e9..0623b5c1 100755
--- a/src/test/run_config2command_tests.pl
+++ b/src/test/run_config2command_tests.pl
@@ -317,11 +317,9 @@ my $file_stat_module = Test::MockModule->new("File::stat");
 $file_stat_module->mock(
     stat => sub {
         my ($path) = @_;
-        if ($path =~ m!/dev/!) {
-            return $file_stat_module->original('stat')->('/dev/null');
-        } else {
-            return $file_stat_module->original('stat')->('./run_config2command_tests.pl');
-        }
+        my $st = $file_stat_module->original('stat')->('./run_config2command_tests.pl');
+        $st->[2] = 25008 if $path =~ m!/dev/!; # block device
+        return $st;
     },
 );
 
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-07-25 10:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 10:50 [pve-devel] [PATCH-SERIES qemu-server v2 0/8] blockdev and snapshot-as-volume-chain on LVM fixes Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 1/8] blockdev: helper to add common options Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 2/8] blockdev: fix discard Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 3/8] tests: image convert: avoid hard-coded VM ID in result Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 4/8] tests: image convert: properly set snapshot-as-volume-chain option Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 5/8] tests: image convert: add tests where storages with 'snapshot-as-volume-chain' are the target Fiona Ebner
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 6/8] fix #6543: use qcow2 'discard-no-unref' option when using snapshot-as-volume-chain Fiona Ebner
2025-07-25 10:50 ` Fiona Ebner [this message]
2025-07-25 10:50 ` [pve-devel] [PATCH qemu-server v2 8/8] image convert: re-use generate_drive_blockdev() Fiona Ebner
2025-07-25 12:15 ` [pve-devel] applied-series: [PATCH-SERIES qemu-server v2 0/8] blockdev and snapshot-as-volume-chain on LVM fixes Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250725105109.54093-8-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal