]>
Commit | Line | Data |
---|---|---|
b987d748 | 1 | #! /usr/bin/env perl |
4af14b7b | 2 | # Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. |
b987d748 | 3 | # |
909f1a2e | 4 | # Licensed under the Apache License 2.0 (the "License"). You may not use |
b987d748 MC |
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 | ||
9afc2b92 | 9 | use OpenSSL::Test qw/:DEFAULT srctop_dir bldtop_dir/; |
b987d748 | 10 | use OpenSSL::Test::Utils; |
88d57bf8 | 11 | use File::Temp qw(tempfile); |
b987d748 MC |
12 | |
13 | #Load configdata.pm | |
14 | ||
15 | BEGIN { | |
16 | setup("test_shlibload"); | |
17 | } | |
9afc2b92 | 18 | use lib srctop_dir('Configurations'); |
b987d748 | 19 | use lib bldtop_dir('.'); |
9afc2b92 | 20 | use platform; |
b987d748 MC |
21 | |
22 | plan skip_all => "Test only supported in a shared build" if disabled("shared"); | |
bd3d8c12 | 23 | plan skip_all => "Test is disabled on AIX" if config('target') =~ m|^aix|; |
08073700 | 24 | plan skip_all => "Test is disabled on NonStop" if config('target') =~ m|^nonstop|; |
522b11e9 | 25 | plan skip_all => "Test only supported in a dso build" if disabled("dso"); |
b987d748 | 26 | |
88d57bf8 | 27 | plan tests => 10; |
b987d748 | 28 | |
9afc2b92 RL |
29 | my $libcrypto = platform->sharedlib('libcrypto'); |
30 | my $libssl = platform->sharedlib('libssl'); | |
62dd3351 | 31 | |
88d57bf8 MC |
32 | (my $fh, my $filename) = tempfile(); |
33 | ok(run(test(["shlibloadtest", "-crypto_first", $libcrypto, $libssl, $filename])), | |
34 | "running shlibloadtest -crypto_first $filename"); | |
35 | ok(check_atexit($fh)); | |
36 | unlink $filename; | |
37 | ($fh, $filename) = tempfile(); | |
38 | ok(run(test(["shlibloadtest", "-ssl_first", $libcrypto, $libssl, $filename])), | |
39 | "running shlibloadtest -ssl_first $filename"); | |
40 | ok(check_atexit($fh)); | |
41 | unlink $filename; | |
42 | ($fh, $filename) = tempfile(); | |
43 | ok(run(test(["shlibloadtest", "-just_crypto", $libcrypto, $libssl, $filename])), | |
44 | "running shlibloadtest -just_crypto $filename"); | |
45 | ok(check_atexit($fh)); | |
46 | unlink $filename; | |
47 | ($fh, $filename) = tempfile(); | |
48 | ok(run(test(["shlibloadtest", "-dso_ref", $libcrypto, $libssl, $filename])), | |
49 | "running shlibloadtest -dso_ref $filename"); | |
50 | ok(check_atexit($fh)); | |
51 | unlink $filename; | |
52 | ($fh, $filename) = tempfile(); | |
53 | ok(run(test(["shlibloadtest", "-no_atexit", $libcrypto, $libssl, $filename])), | |
54 | "running shlibloadtest -no_atexit $filename"); | |
55 | ok(!check_atexit($fh)); | |
56 | unlink $filename; | |
b987d748 | 57 | |
88d57bf8 MC |
58 | sub check_atexit { |
59 | my $fh = shift; | |
60 | my $data = <$fh>; | |
61 | ||
62 | return 1 if (defined $data && $data =~ m/atexit\(\) run/); | |
63 | ||
64 | return 0; | |
65 | } |