public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage] Diskmanage: replace check for zpool binary with a function and mock it
@ 2021-02-10 10:18 Fabian Ebner
  2021-02-19 14:32 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Ebner @ 2021-02-10 10:18 UTC (permalink / raw)
  To: pve-devel

so the test still works when it's not installed.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 PVE/Diskmanage.pm     | 8 +++++++-
 test/disklist_test.pm | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index e356fb3..64bb813 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -19,6 +19,12 @@ my $PVS = "/sbin/pvs";
 my $LVS = "/sbin/lvs";
 my $LSBLK = "/bin/lsblk";
 
+sub check_bin {
+    my ($path) = @_;
+
+    return -x $path;
+}
+
 sub verify_blockdev_path {
     my ($rel_path) = @_;
 
@@ -201,7 +207,7 @@ sub get_zfs_devices {
     my ($lsblk_info) = @_;
     my $res = {};
 
-    return {} if ! -x $ZPOOL;
+    return {} if !check_bin($ZPOOL);
 
     # use zpool and parttype uuid,
     # because log and cache do not have
diff --git a/test/disklist_test.pm b/test/disklist_test.pm
index bfce1ea..7f0e0be 100644
--- a/test/disklist_test.pm
+++ b/test/disklist_test.pm
@@ -244,6 +244,8 @@ $diskmanage_module->mock('dir_is_empty' => sub {
 	return 1;
     });
 print("\tMocked dir_is_empty\n");
+$diskmanage_module->mock('check_bin' => sub { return 1; });
+print("\tMocked check_bin\n");
 my $tools_module= new Test::MockModule('PVE::ProcFSTools', no_auto => 1);
 $tools_module->mock('parse_proc_mounts' => \&mocked_parse_proc_mounts);
 print("\tMocked parse_proc_mounts\n");
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH storage] Diskmanage: replace check for zpool binary with a function and mock it
  2021-02-10 10:18 [pve-devel] [PATCH storage] Diskmanage: replace check for zpool binary with a function and mock it Fabian Ebner
@ 2021-02-19 14:32 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-02-19 14:32 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Ebner

On 10.02.21 11:18, Fabian Ebner wrote:
> so the test still works when it's not installed.
> 
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>  PVE/Diskmanage.pm     | 8 +++++++-
>  test/disklist_test.pm | 2 ++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-19 14:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 10:18 [pve-devel] [PATCH storage] Diskmanage: replace check for zpool binary with a function and mock it Fabian Ebner
2021-02-19 14:32 ` [pve-devel] applied: " Thomas Lamprecht

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