From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9288268900 for ; Wed, 10 Feb 2021 11:19:17 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 76BBE83D8 for ; Wed, 10 Feb 2021 11:18:47 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id EACE583CF for ; Wed, 10 Feb 2021 11:18:46 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B20944415E for ; Wed, 10 Feb 2021 11:18:46 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 10 Feb 2021 11:18:42 +0100 Message-Id: <20210210101842.16482-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -1.154 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [diskmanage.pm] Subject: [pve-devel] [PATCH storage] Diskmanage: replace check for zpool binary with a function and mock it X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2021 10:19:17 -0000 so the test still works when it's not installed. Signed-off-by: Fabian Ebner --- 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