Add EVP_KDF-X942 to the fips module
[openssl.git] / test / recipes / 90-test_shlibload.t
1 #! /usr/bin/env perl
2 # Copyright 2016-2020 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 use OpenSSL::Test qw/:DEFAULT srctop_dir bldtop_dir/;
10 use OpenSSL::Test::Utils;
11 use File::Temp qw(tempfile);
12
13 #Load configdata.pm
14
15 BEGIN {
16     setup("test_shlibload");
17 }
18 use lib srctop_dir('Configurations');
19 use lib bldtop_dir('.');
20 use platform;
21
22 plan skip_all => "Test only supported in a shared build" if disabled("shared");
23 plan skip_all => "Test is disabled on AIX" if config('target') =~ m|^aix|;
24 plan skip_all => "Test is disabled on NonStop" if config('target') =~ m|^nonstop|;
25 plan skip_all => "Test only supported in a dso build" if disabled("dso");
26 plan skip_all => "Test is disabled in an address sanitizer build" unless disabled("asan");
27
28 plan tests => 10;
29
30 my $libcrypto = platform->sharedlib('libcrypto');
31 my $libssl = platform->sharedlib('libssl');
32
33 (my $fh, my $filename) = tempfile();
34 ok(run(test(["shlibloadtest", "-crypto_first", $libcrypto, $libssl, $filename])),
35    "running shlibloadtest -crypto_first $filename");
36 ok(check_atexit($fh));
37 unlink $filename;
38 ($fh, $filename) = tempfile();
39 ok(run(test(["shlibloadtest", "-ssl_first", $libcrypto, $libssl, $filename])),
40    "running shlibloadtest -ssl_first $filename");
41 ok(check_atexit($fh));
42 unlink $filename;
43 ($fh, $filename) = tempfile();
44 ok(run(test(["shlibloadtest", "-just_crypto", $libcrypto, $libssl, $filename])),
45    "running shlibloadtest -just_crypto $filename");
46 ok(check_atexit($fh));
47 unlink $filename;
48 ($fh, $filename) = tempfile();
49 ok(run(test(["shlibloadtest", "-dso_ref", $libcrypto, $libssl, $filename])),
50    "running shlibloadtest -dso_ref $filename");
51 ok(check_atexit($fh));
52 unlink $filename;
53 ($fh, $filename) = tempfile();
54 ok(run(test(["shlibloadtest", "-no_atexit", $libcrypto, $libssl, $filename])),
55    "running shlibloadtest -no_atexit $filename");
56 ok(!check_atexit($fh));
57 unlink $filename;
58
59 sub check_atexit {
60     my $fh = shift;
61     my $data = <$fh>;
62
63     return 1 if (defined $data && $data =~ m/atexit\(\) run/);
64
65     return 0;
66 }