2016-10-18 21:16:35 +08:00
|
|
|
#! /usr/bin/env perl
|
2018-03-20 01:37:46 +08:00
|
|
|
# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2016-10-18 21:16:35 +08:00
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-10-18 21:16:35 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2018-10-23 21:42:46 +08:00
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_dir bldtop_dir/;
|
2016-10-18 21:16:35 +08:00
|
|
|
use OpenSSL::Test::Utils;
|
2018-11-16 01:41:06 +08:00
|
|
|
use File::Temp qw(tempfile);
|
2016-10-18 21:16:35 +08:00
|
|
|
|
|
|
|
#Load configdata.pm
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
setup("test_shlibload");
|
|
|
|
}
|
2018-10-23 21:42:46 +08:00
|
|
|
use lib srctop_dir('Configurations');
|
2016-10-18 21:16:35 +08:00
|
|
|
use lib bldtop_dir('.');
|
2018-10-23 21:42:46 +08:00
|
|
|
use platform;
|
2016-10-18 21:16:35 +08:00
|
|
|
|
|
|
|
plan skip_all => "Test only supported in a shared build" if disabled("shared");
|
2018-06-15 21:41:07 +08:00
|
|
|
plan skip_all => "Test is disabled on AIX" if config('target') =~ m|^aix|;
|
2020-09-07 05:37:47 +08:00
|
|
|
plan skip_all => "Test is disabled on NonStop" if config('target') =~ m|^nonstop|;
|
2019-01-29 19:41:32 +08:00
|
|
|
plan skip_all => "Test only supported in a dso build" if disabled("dso");
|
2016-10-18 21:16:35 +08:00
|
|
|
|
2018-11-16 01:41:06 +08:00
|
|
|
plan tests => 10;
|
2016-10-18 21:16:35 +08:00
|
|
|
|
2018-10-23 21:42:46 +08:00
|
|
|
my $libcrypto = platform->sharedlib('libcrypto');
|
|
|
|
my $libssl = platform->sharedlib('libssl');
|
2016-11-04 01:48:23 +08:00
|
|
|
|
2018-11-16 01:41:06 +08:00
|
|
|
(my $fh, my $filename) = tempfile();
|
|
|
|
ok(run(test(["shlibloadtest", "-crypto_first", $libcrypto, $libssl, $filename])),
|
|
|
|
"running shlibloadtest -crypto_first $filename");
|
|
|
|
ok(check_atexit($fh));
|
|
|
|
unlink $filename;
|
|
|
|
($fh, $filename) = tempfile();
|
|
|
|
ok(run(test(["shlibloadtest", "-ssl_first", $libcrypto, $libssl, $filename])),
|
|
|
|
"running shlibloadtest -ssl_first $filename");
|
|
|
|
ok(check_atexit($fh));
|
|
|
|
unlink $filename;
|
|
|
|
($fh, $filename) = tempfile();
|
|
|
|
ok(run(test(["shlibloadtest", "-just_crypto", $libcrypto, $libssl, $filename])),
|
|
|
|
"running shlibloadtest -just_crypto $filename");
|
|
|
|
ok(check_atexit($fh));
|
|
|
|
unlink $filename;
|
|
|
|
($fh, $filename) = tempfile();
|
|
|
|
ok(run(test(["shlibloadtest", "-dso_ref", $libcrypto, $libssl, $filename])),
|
|
|
|
"running shlibloadtest -dso_ref $filename");
|
|
|
|
ok(check_atexit($fh));
|
|
|
|
unlink $filename;
|
|
|
|
($fh, $filename) = tempfile();
|
|
|
|
ok(run(test(["shlibloadtest", "-no_atexit", $libcrypto, $libssl, $filename])),
|
|
|
|
"running shlibloadtest -no_atexit $filename");
|
|
|
|
ok(!check_atexit($fh));
|
|
|
|
unlink $filename;
|
2016-10-18 21:16:35 +08:00
|
|
|
|
2018-11-16 01:41:06 +08:00
|
|
|
sub check_atexit {
|
|
|
|
my $fh = shift;
|
|
|
|
my $data = <$fh>;
|
|
|
|
|
|
|
|
return 1 if (defined $data && $data =~ m/atexit\(\) run/);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|