test/recipes/80-test_cmp_http.t: Simplify test_cmp_http()

test_cmp_http() made some assumptions about what values that exit_checker
could get that aren't quite right.

Furthermore, the expected result isn't about exit codes, but about
true or false.  This is better served by getting the value from
OpenSSL::Test::run(), and checking that value against $expected_result
with Test::More::is().

Fixes #15557
Fixes #15571

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/15580)
This commit is contained in:
Richard Levitte 2021-06-02 08:14:08 +02:00
parent 0ebef5b509
commit d00be9f387

View File

@ -12,7 +12,7 @@ use strict;
use warnings;
use POSIX;
use OpenSSL::Test qw/:DEFAULT with data_file data_dir srctop_dir bldtop_dir result_dir/;
use OpenSSL::Test qw/:DEFAULT data_file data_dir srctop_dir bldtop_dir result_dir/;
use OpenSSL::Test::Utils;
BEGIN {
@ -133,19 +133,17 @@ sub test_cmp_http {
$params = [ '-server', "127.0.0.1:$server_port", @$params ]
unless grep { $_ eq '-server' } @$params;
with({ exit_checker => sub {
my $actual_result = shift == 0;
my $OK = $actual_result == $expected_result;
if ($faillog && !$OK) {
unless (is(my $actual_result = run(cmd([$path_app, @$params,])),
$expected_result,
$title)) {
if ($faillog) {
my $quote_spc_empty = sub { $_ eq "" ? '""' : $_ =~ m/ / ? '"'.$_.'"' : $_ };
my $invocation = "$path_app ".join(' ', map $quote_spc_empty->($_), @$params);
print $faillog "$server_name $aspect \"$title\" ($i/$n)".
" expected=$expected_result actual=$actual_result\n";
print $faillog "$invocation\n\n";
}
return $OK; } },
sub { ok(run(cmd([$path_app, @$params,])),
$title); });
}
}
sub test_cmp_http_aspect {