80-test_cmp_http.t: Simplify and prevent hangs on server not launching/behaving correctly

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15642)
This commit is contained in:
Dr. David von Oheimb 2021-06-07 11:44:23 +02:00 committed by Dr. David von Oheimb
parent f8ab78f6c2
commit ee1d1db824

View File

@ -276,28 +276,19 @@ sub start_mock_server {
my $pid = open($server_fh, "$cmd|") or die "Trying to $cmd";
print "Pid is: $pid\n";
if ($server_port == 0) {
# Clear it first
$server_port = undef;
# Find out the actual server port
while (<$server_fh>) {
print;
print "Server output: $_";
next if m/using section/;
s/\R$//; # Better chomp
next unless (/^ACCEPT/);
# $1 may be undefined, which is OK to assign to $server_port,
# as that gets detected further down.
/^ACCEPT\s.*:(\d+)$/;
$server_port = $1;
last;
}
unless (defined $server_port) {
stop_mock_server($pid);
return 0;
$server_port = $1 if /^ACCEPT\s.*:(\d+)$/;
last; # Do not loop further to prevent hangs on server misbehavior
}
}
unless ($server_port > 0) {
stop_mock_server($pid);
return 0;
}
$server_tls = $kur_port = $pbm_port = $server_port;
return $pid;
}