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 <c.heiss@proxmox.com>
This commit is contained in:
Christoph Heiss 2024-05-16 15:39:31 +02:00 committed by Thomas Lamprecht
parent 368a3215b6
commit a2c01db295

View File

@ -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);
}