[pve-devel] [PATCH installer 1/6] test: ui2-stdio: fix multi-process testing

Christoph Heiss c.heiss at proxmox.com
Thu May 16 15:39:31 CEST 2024


Previously, if something failed in the child, the overall test would
still be successful and exit with `0`.

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 test/ui2-stdio.pl | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/test/ui2-stdio.pl b/test/ui2-stdio.pl
index ae29b79..01f323d 100755
--- a/test/ui2-stdio.pl
+++ b/test/ui2-stdio.pl
@@ -4,7 +4,6 @@ use strict;
 use warnings;
 
 use JSON qw(from_json);
-use Test::More;
 
 use Proxmox::Log;
 use Proxmox::UI;
@@ -16,10 +15,11 @@ $parent_writer->autoflush(1);
 $child_writer->autoflush(1);
 $child_reader->autoflush(1);
 
-
 my $child_pid = fork() // die "fork failed - $!\n";
 
 if ($child_pid) {
+    eval 'use Test::More tests => 3;';
+
     # parent, the hypothetical low-level installer
     close($parent_reader);
     close($parent_writer);
@@ -45,8 +45,11 @@ if ($child_pid) {
     Proxmox::UI::progress(1, 0, 1, 'done');
 
     waitpid($child_pid, 0);
+    is($?, 0); # check child exit status
     done_testing();
 } else {
+    eval 'use Test::More tests => 10;';
+
     # child, e.g. the TUI
     close($child_reader);
     close($child_writer);
@@ -90,6 +93,5 @@ if ($child_pid) {
 	'should get 100% done progress message');
 
     done_testing();
-    exit(0);
 }
 
-- 
2.44.0





More information about the pve-devel mailing list