]> git.proxmox.com Git - pve-storage.git/commitdiff
Diskmanage: replace check for zpool binary with a function and mock it
authorFabian Ebner <f.ebner@proxmox.com>
Wed, 10 Feb 2021 10:18:42 +0000 (11:18 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 19 Feb 2021 14:29:04 +0000 (15:29 +0100)
so the test still works when it's not installed.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Diskmanage.pm
test/disklist_test.pm

index e356fb3a317a7f17d186bd90ad17cdadc3aa3030..64bb813fdfa59acbb3a1cc5513d8597492ca363d 100644 (file)
@@ -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
index bfce1ea27352c83024c1f1cbb373185feccad921..7f0e0be86e73ae8159c344eb60f1a587ca92acac 100644 (file)
@@ -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");