Fix append_ia5 function to not assume NUL terminated strings
[openssl.git] / test / generate_ssl_tests.pl
index 8cfc451fbba80178084d917642ae591db4b3870e..9ff556c0a931a493a2f3c280dccc90832f4fc4f1 100644 (file)
@@ -1,5 +1,5 @@
 #! /usr/bin/env perl
-# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2016-2021 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
 use strict;
 use warnings;
 
+use Cwd qw/abs_path/;
 use File::Basename;
 use File::Spec::Functions;
 
 use OpenSSL::Test qw/srctop_dir srctop_file/;
 use OpenSSL::Test::Utils;
 
-# This block needs to run before 'use lib srctop_dir' directives.
-BEGIN {
-    OpenSSL::Test::setup("no_test_here", quiet => 1);
-}
-
 use FindBin;
 use lib "$FindBin::Bin/../util/perl";
 use OpenSSL::fallback "$FindBin::Bin/../external/perl/MODULES.txt";
 use Text::Template 1.46;
 
+my $input_file;
+my $provider;
+
+BEGIN {
+    #Input file may be relative to cwd, but setup below changes the cwd, so
+    #figure out the absolute path first
+    $input_file = abs_path(shift);
+    $provider = shift // '';
+
+    OpenSSL::Test::setup("no_test_here", quiet => 1);
+}
+
 use lib "$FindBin::Bin/ssl-tests";
 
 use vars qw/@ISA/;
@@ -127,6 +135,11 @@ sub print_templates {
 # Shamelessly copied from Configure.
 sub read_config {
     my $fname = shift;
+    my $provider = shift;
+    local $ssltests::fips_mode = $provider eq "fips";
+    local $ssltests::no_deflt_libctx =
+        $provider eq "default" || $provider eq "fips";
+
     open(INPUT, "< $fname") or die "Can't open input file '$fname'!\n";
     local $/ = undef;
     my $content = <INPUT>;
@@ -135,9 +148,8 @@ sub read_config {
     warn $@ if $@;
 }
 
-my $input_file = shift;
 # Reads the tests into ssltests::tests.
-read_config($input_file);
+read_config($input_file, $provider);
 print_templates();
 
 1;