2
0

90-test_threads.t 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. use OpenSSL::Test::Simple;
  9. use OpenSSL::Test qw/:DEFAULT srctop_file srctop_dir bldtop_dir bldtop_file data_dir/;
  10. use OpenSSL::Test::Utils;
  11. use Cwd qw(abs_path);
  12. BEGIN {
  13. setup("test_threads");
  14. }
  15. use lib srctop_dir('Configurations');
  16. use lib bldtop_dir('.');
  17. my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
  18. my $config_path = abs_path(srctop_file("test", $no_fips ? "default.cnf"
  19. : "default-and-fips.cnf"));
  20. plan tests => 2;
  21. if ($no_fips) {
  22. ok(run(test(["threadstest", "-config", $config_path, data_dir()])),
  23. "running test_threads");
  24. } else {
  25. ok(run(test(["threadstest", "-fips", "-config", $config_path, data_dir()])),
  26. "running test_threads with FIPS");
  27. }
  28. # Merge the configuration files into one filtering the contents so the failure
  29. # condition is reproducible. A working FIPS configuration without the install
  30. # status is required.
  31. open CFGBASE, '<', $config_path;
  32. open CFGINC, '<', bldtop_file('/test/fipsmodule.cnf');
  33. open CFGOUT, '>', 'thread.cnf';
  34. while (<CFGBASE>) {
  35. print CFGOUT unless m/^[.]include/;
  36. }
  37. close CFGBASE;
  38. print CFGOUT "\n\n";
  39. while (<CFGINC>) {
  40. print CFGOUT unless m/^install-status/;
  41. }
  42. close CFGINC;
  43. close CFGOUT;
  44. $ENV{OPENSSL_CONF} = 'thread.cnf';
  45. ok(run(test(["threadstest_fips"])), "running test_threads_fips");