From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <c.heiss@proxmox.com>
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 52FACA08D5
 for <pve-devel@lists.proxmox.com>; Thu,  9 Nov 2023 10:48:04 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 356D112D51
 for <pve-devel@lists.proxmox.com>; Thu,  9 Nov 2023 10:48:04 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (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
 for <pve-devel@lists.proxmox.com>; Thu,  9 Nov 2023 10:48:03 +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 5555747585
 for <pve-devel@lists.proxmox.com>; Thu,  9 Nov 2023 10:48:03 +0100 (CET)
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Thu,  9 Nov 2023 10:47:56 +0100
Message-ID: <20231109094758.335216-1-c.heiss@proxmox.com>
X-Mailer: git-send-email 2.42.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.014 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 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
 T_SCC_BODY_TEXT_LINE    -0.01 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [proxmox.com]
Subject: [pve-devel] [PATCH installer v2] low level: testmode: take path to
 disk image instead of using /dev/null
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 09 Nov 2023 09:48:04 -0000

.. in exactly the same way GUI and TUI installer do, streamlining them.

Up until now, testing the TUI installer often involved hand-editing the
`run-env-info.json` to put some proper disk sizes > 0 in place. This
makes this process a lot easier.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
v1: https://lists.proxmox.com/pipermail/pve-devel/2023-October/059311.html

Changes v1 -> v2:
  * rebased on latest master

 Makefile                    | 15 ++++++++++-----
 proxmox-low-level-installer |  8 ++++----
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 5e94c29..6f64c4e 100644
--- a/Makefile
+++ b/Makefile
@@ -139,26 +139,31 @@ cd-info.test:

 check-pve: prepare-check-env test.img
 	rm -f cd-info.test; $(MAKE) cd-info.test
-	./proxmox-low-level-installer dump-env -t
+	./proxmox-low-level-installer dump-env -t test.img
 	G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img

 check-pve-multidisks: prepare-check-env test.img test2.img test3.img test4.img test5.big.img
 	rm -f cd-info.test; $(MAKE) cd-info.test
-	./proxmox-low-level-installer dump-env -t
+	./proxmox-low-level-installer dump-env -t test.img,test2.img,test3.img,test4.img,test5.big.img
 	G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img,test2.img,test3.img,test4.img,test5.big.img

 check-pve-tui: prepare-check-env test.img
 	rm -f cd-info.test; $(MAKE) cd-info.test
-	./proxmox-low-level-installer dump-env -t
+	./proxmox-low-level-installer dump-env -t test.img
 	testdir/usr/bin/proxmox-tui-installer -t test.img 2>testdir/run/stderr

+check-pve-tui-multidisks: prepare-check-env test.img test2.img test3.img test4.img test5.big.img
+	rm -f cd-info.test; $(MAKE) cd-info.test
+	./proxmox-low-level-installer dump-env -t test.img,test2.img,test3.img,test4.img,test5.big.img
+	testdir/usr/bin/proxmox-tui-installer -t test.img,test2.img,test3.img,test4.img,test5.big.img
+
 prepare-check-pmg: prepare-check-env test.img
 	rm -f cd-info.test; $(MAKE) \
 	    PRODUCT=pmg \
 	    PRODUCTLONG="Proxmox Mail Gateway" \
 	    ISONAME='proxmox-mail-gateway' \
 	    cd-info.test
-	./proxmox-low-level-installer dump-env -t
+	./proxmox-low-level-installer dump-env -t test.img

 check-pmg: prepare-check-pmg
 	G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img
@@ -172,7 +177,7 @@ prepare-check-pbs: prepare-check-env test.img
 	    PRODUCTLONG='Proxmox Backup Server' \
 	    ISONAME='proxmox-backup-server' \
 	    cd-info.test
-	./proxmox-low-level-installer dump-env -t
+	./proxmox-low-level-installer dump-env -t test.img

 check-pbs: prepare-check-pbs
 	G_SLICE=always-malloc perl -I testdir/usr/share/perl5 testdir/usr/bin/proxinstall -t test.img
diff --git a/proxmox-low-level-installer b/proxmox-low-level-installer
index 814961e..0f2bf4f 100755
--- a/proxmox-low-level-installer
+++ b/proxmox-low-level-installer
@@ -11,14 +11,14 @@ use JSON;
 use Time::HiRes qw(usleep);

 {
-    my $test_mode;
+    my $test_image;
     GetOptions(
-	'test-mode|t' => \$test_mode
+	'test-image|t=s' => \$test_image
     ) or die "usage error\n";

-    # FIXME: use cleaner approach for setting tet mode?
-    Proxmox::Install::ISOEnv::set_test_image('/dev/null') if $test_mode;
+    Proxmox::Install::ISOEnv::set_test_image($test_image) if $test_image;
 }
+
 use Proxmox::Install::ISOEnv;
 use Proxmox::Install::RunEnv;

--
2.42.0