[openssl] master update

Richard Levitte levitte at openssl.org
Sun Jun 6 05:36:39 UTC 2021


The branch master has been updated
       via  97cf9b05fa1cdb8e4e7f60016aa95ae0e976e8c3 (commit)
       via  d00be9f38760b5f143a7cdecf6c61ad6316f4cc8 (commit)
      from  0ebef5b5098e5d15cf2e7f48a78b22cced41f352 (commit)


- Log -----------------------------------------------------------------
commit 97cf9b05fa1cdb8e4e7f60016aa95ae0e976e8c3
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Jun 2 21:19:18 2021 +0200

    test/recipes/80-test_cmp_http.t: Don't trust $server_port in start_mock_server()
    
    Even if $server_port isn't touched, it's still a number coming from
    configuration.  It's therefore not trustable as an indicator that the
    ACCEPT line delivered a port number or an error indication.
    
    $accept_msg is used instead to capture the port if there is one, and
    be a better indicator of error.
    
    Fixes #15557
    Fixes #15571
    
    Reviewed-by: David von Oheimb <david.von.oheimb at siemens.com>
    (Merged from https://github.com/openssl/openssl/pull/15580)

commit d00be9f38760b5f143a7cdecf6c61ad6316f4cc8
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Jun 2 08:14:08 2021 +0200

    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 at siemens.com>
    (Merged from https://github.com/openssl/openssl/pull/15580)

-----------------------------------------------------------------------

Summary of changes:
 test/recipes/80-test_cmp_http.t | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/test/recipes/80-test_cmp_http.t b/test/recipes/80-test_cmp_http.t
index 910c751eec..9c99226721 100644
--- a/test/recipes/80-test_cmp_http.t
+++ b/test/recipes/80-test_cmp_http.t
@@ -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 {
@@ -278,19 +276,30 @@ 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;
             s/\R$//;                # Better chomp
             next unless (/^ACCEPT/);
-            $server_port = $server_tls = $kur_port = $pbm_port = $1
-                if m/^ACCEPT\s.*?:(\d+)$/;
+
+            # $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;
+        }
     }
-    return $pid if $server_port =~ m/^(\d+)$/;
-    stop_mock_server($pid);
-    return 0;
+    $server_tls = $kur_port = $pbm_port = $server_port;
+    return $pid;
 }
 
 sub stop_mock_server {


More information about the openssl-commits mailing list