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