]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - test/recipes/70-test_sslrecords.t
Raise an error on syscall failure in tls_retry_write_records
[thirdparty/openssl.git] / test / recipes / 70-test_sslrecords.t
index 2a4e64c50ece687313f2370797f37d6e408fd8cd..691db13b8a8e51208871c17dfab7f763e41ad1e2 100644 (file)
@@ -1,5 +1,5 @@
 #! /usr/bin/env perl
-# Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
 #
 # Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
@@ -26,53 +26,24 @@ plan skip_all => "$test_name needs the dynamic engine feature enabled"
 plan skip_all => "$test_name needs the sock feature enabled"
     if disabled("sock");
 
-my $testplanisset = 0;
 my $inject_recs_num = undef;
 my $content_type = undef;
 my $boundary_test_type = undef;
 my $fatal_alert = undef; # set by filters at expected fatal alerts
 my $sslv2testtype = undef;
 my $proxy_start_success = 0;
-my $dtlsproxy = undef;
-my $tlsproxy = undef;
-
-my $dummyproxy = TLSProxy::Proxy->new(
-    \&add_empty_recs_filter,
-    cmdstr(app([ "openssl" ]), display => 1),
-    srctop_file("apps", "server.pem"),
-    (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
-);
-
-# Avoid failures with tls1_3 disabled builds
-# TLSProxy defaults to use tls1_3 and tls1_2 is required by the tests so
-# set it here and check that a simple proxy works before running the tests
-$dummyproxy->serverflags("-tls1_2");
-$dummyproxy->clientflags("-no_tls1_3");
-
-$dummyproxy->start() or plan skip_all => "Unable to start up Proxy for tests";
+
 plan tests => 42;
 
 SKIP: {
     skip "TLS 1.2 is disabled", 21 if disabled("tls1_2");
     # Run tests with TLS
-    $tlsproxy = TLSProxy::Proxy->new(
-        \&add_empty_recs_filter,
-        cmdstr(app([ "openssl" ]), display => 1),
-        srctop_file("apps", "server.pem"),
-        (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
-    );
     run_tests(0);
 }
 
 SKIP: {
     skip "DTLS 1.2 is disabled", 21 if disabled("dtls1_2");
-    # Run tests with DTLS
-    $dtlsproxy = TLSProxy::Proxy->new_dtls(
-        \&add_empty_recs_filter,
-        cmdstr(app([ "openssl" ]), display => 1),
-        srctop_file("apps", "server.pem"),
-        (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
-    );
+    skip "DTLSProxy does not work on Windows", 21 if $^O =~ /^(MSWin32)$/;
     run_tests(1);
 }
 
@@ -82,9 +53,19 @@ sub run_tests
 
     my $proxy;
     if ($run_test_as_dtls == 1) {
-        $proxy = $dtlsproxy;
+        $proxy = TLSProxy::Proxy->new_dtls(
+            \&add_empty_recs_filter,
+            cmdstr(app([ "openssl" ]), display => 1),
+            srctop_file("apps", "server.pem"),
+            (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
+        );
     } else {
-        $proxy = $tlsproxy;
+        $proxy = TLSProxy::Proxy->new(
+            \&add_empty_recs_filter,
+            cmdstr(app([ "openssl" ]), display => 1),
+            srctop_file("apps", "server.pem"),
+            (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
+        );
     }
 
     $fatal_alert = 0; # set by filters at expected fatal alerts
@@ -97,10 +78,13 @@ sub run_tests
         $fatal_alert = 0;
         $proxy->serverflags("-tls1_2");
         $proxy->clientflags("-no_tls1_3");
-        $proxy->start();
+        $proxy_start_success = $proxy->start();
         ok($fatal_alert, "Out of context empty records test");
     }
 
+    skip "TLSProxy did not start correctly", 21 if $proxy_start_success == 0
+                                                   && $run_test_as_dtls == 0;
+
     #Test 2: Injecting in context empty records should succeed
     $proxy->clear();
     $content_type = TLSProxy::Record::RT_HANDSHAKE;
@@ -112,6 +96,10 @@ sub run_tests
         $proxy->clientflags("-no_tls1_3");
     }
     $proxy_start_success = $proxy->start();
+
+    skip "TLSProxy did not start correctly", 20 if $proxy_start_success == 0
+                                                   && $run_test_as_dtls == 1;
+
     ok($proxy_start_success && TLSProxy::Message->success(),
        "In context empty records test".($run_test_as_dtls == 1) ? " for DTLS" : " for TLS");