1e1051a39Sopenharmony_ci#! /usr/bin/env perl 2e1051a39Sopenharmony_ci# Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci# 4e1051a39Sopenharmony_ci# Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci# this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci# in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci# https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ciuse OpenSSL::Test::Simple; 11e1051a39Sopenharmony_ciuse OpenSSL::Test qw/:DEFAULT srctop_file srctop_dir bldtop_dir bldtop_file data_dir/; 12e1051a39Sopenharmony_ciuse OpenSSL::Test::Utils; 13e1051a39Sopenharmony_ciuse Cwd qw(abs_path); 14e1051a39Sopenharmony_ci 15e1051a39Sopenharmony_ciBEGIN { 16e1051a39Sopenharmony_cisetup("test_threads"); 17e1051a39Sopenharmony_ci} 18e1051a39Sopenharmony_ci 19e1051a39Sopenharmony_ciuse lib srctop_dir('Configurations'); 20e1051a39Sopenharmony_ciuse lib bldtop_dir('.'); 21e1051a39Sopenharmony_ci 22e1051a39Sopenharmony_cimy $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0); 23e1051a39Sopenharmony_cimy $config_path = abs_path(srctop_file("test", $no_fips ? "default.cnf" 24e1051a39Sopenharmony_ci : "default-and-fips.cnf")); 25e1051a39Sopenharmony_ci 26e1051a39Sopenharmony_ciplan tests => 2; 27e1051a39Sopenharmony_ci 28e1051a39Sopenharmony_ciif ($no_fips) { 29e1051a39Sopenharmony_ci ok(run(test(["threadstest", "-config", $config_path, data_dir()])), 30e1051a39Sopenharmony_ci "running test_threads"); 31e1051a39Sopenharmony_ci} else { 32e1051a39Sopenharmony_ci ok(run(test(["threadstest", "-fips", "-config", $config_path, data_dir()])), 33e1051a39Sopenharmony_ci "running test_threads with FIPS"); 34e1051a39Sopenharmony_ci} 35e1051a39Sopenharmony_ci 36e1051a39Sopenharmony_ci# Merge the configuration files into one filtering the contents so the failure 37e1051a39Sopenharmony_ci# condition is reproducable. A working FIPS configuration without the install 38e1051a39Sopenharmony_ci# status is required. 39e1051a39Sopenharmony_ci 40e1051a39Sopenharmony_ciopen CFGBASE, '<', $config_path; 41e1051a39Sopenharmony_ciopen CFGINC, '<', bldtop_file('/test/fipsmodule.cnf'); 42e1051a39Sopenharmony_ciopen CFGOUT, '>', 'thread.cnf'; 43e1051a39Sopenharmony_ci 44e1051a39Sopenharmony_ciwhile (<CFGBASE>) { 45e1051a39Sopenharmony_ci print CFGOUT unless m/^[.]include/; 46e1051a39Sopenharmony_ci} 47e1051a39Sopenharmony_ciclose CFGBASE; 48e1051a39Sopenharmony_ciprint CFGOUT "\n\n"; 49e1051a39Sopenharmony_ciwhile (<CFGINC>) { 50e1051a39Sopenharmony_ci print CFGOUT unless m/^install-status/; 51e1051a39Sopenharmony_ci} 52e1051a39Sopenharmony_ciclose CFGINC; 53e1051a39Sopenharmony_ciclose CFGOUT; 54e1051a39Sopenharmony_ci 55e1051a39Sopenharmony_ci$ENV{OPENSSL_CONF} = 'thread.cnf'; 56e1051a39Sopenharmony_ciok(run(test(["threadstest_fips"])), "running test_threads_fips"); 57