From a2c01db29574ac24c3e93b216e8d80567eeccd5c Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Thu, 16 May 2024 15:39:31 +0200 Subject: [PATCH] test: ui2-stdio: fix multi-process testing Previously, if something failed in the child, the overall test would still be successful and exit with `0`. Signed-off-by: Christoph Heiss --- 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); }