2016-04-22 19:21:51 +08:00
|
|
|
#! /usr/bin/env perl
|
2021-01-28 20:54:57 +08:00
|
|
|
# Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2016-04-22 19:21:51 +08:00
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-04-22 19:21:51 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2015-10-26 00:43:55 +08:00
|
|
|
|
|
|
|
use OpenSSL::Test::Simple;
|
2021-01-26 21:30:06 +08:00
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_file srctop_dir bldtop_dir bldtop_file data_dir/;
|
2020-12-10 23:39:58 +08:00
|
|
|
use OpenSSL::Test::Utils;
|
|
|
|
use Cwd qw(abs_path);
|
2015-10-26 00:43:55 +08:00
|
|
|
|
2020-12-10 23:39:58 +08:00
|
|
|
BEGIN {
|
|
|
|
setup("test_threads");
|
|
|
|
}
|
|
|
|
|
|
|
|
use lib srctop_dir('Configurations');
|
|
|
|
use lib bldtop_dir('.');
|
|
|
|
|
|
|
|
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
|
2021-05-13 08:34:42 +08:00
|
|
|
my $config_path = abs_path(srctop_file("test", $no_fips ? "default.cnf"
|
|
|
|
: "default-and-fips.cnf"));
|
2020-12-10 23:39:58 +08:00
|
|
|
|
2021-05-14 13:41:14 +08:00
|
|
|
plan tests => 2;
|
2020-12-10 23:39:58 +08:00
|
|
|
|
|
|
|
if ($no_fips) {
|
2021-05-13 08:34:42 +08:00
|
|
|
ok(run(test(["threadstest", "-config", $config_path, data_dir()])),
|
|
|
|
"running test_threads");
|
2020-12-10 23:39:58 +08:00
|
|
|
} else {
|
2021-05-13 08:34:42 +08:00
|
|
|
ok(run(test(["threadstest", "-fips", "-config", $config_path, data_dir()])),
|
|
|
|
"running test_threads with FIPS");
|
2020-12-10 23:39:58 +08:00
|
|
|
}
|
2021-05-14 13:41:14 +08:00
|
|
|
|
|
|
|
# Merge the configuration files into one filtering the contents so the failure
|
|
|
|
# condition is reproducable. A working FIPS configuration without the install
|
|
|
|
# status is required.
|
|
|
|
|
|
|
|
open CFGBASE, '<', $config_path;
|
|
|
|
open CFGINC, '<', bldtop_file('/providers/fipsmodule.cnf');
|
|
|
|
open CFGOUT, '>', 'thread.cnf';
|
|
|
|
|
|
|
|
while (<CFGBASE>) {
|
|
|
|
print CFGOUT unless m/^[.]include/;
|
|
|
|
}
|
|
|
|
close CFGBASE;
|
|
|
|
print CFGOUT "\n\n";
|
|
|
|
while (<CFGINC>) {
|
|
|
|
print CFGOUT unless m/^install-status/;
|
|
|
|
}
|
|
|
|
close CFGINC;
|
|
|
|
close CFGOUT;
|
|
|
|
|
|
|
|
$ENV{OPENSSL_CONF} = 'thread.cnf';
|
|
|
|
ok(run(test(["threadstest_fips"])), "running test_threads_fips");
|