summaryrefslogtreecommitdiffstats
path: root/test/recipes
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2018-11-15 17:41:06 +0000
committerMatt Caswell <matt@openssl.org>2019-01-04 13:19:39 +0000
commit88d57bf83fe32b2c8ceb1264562fdd028de504bf (patch)
tree90fab9f8dd79c5560789851047dbe414ae5aa19c /test/recipes
parentd0f2f202c5aa6365d3c13e18a0b9e26837c290a0 (diff)
Test atexit handlers
Test that atexit handlers get called properly at process exit, unless we have explicitly asked for them not to be. Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7647)
Diffstat (limited to 'test/recipes')
-rw-r--r--test/recipes/90-test_shlibload.t45
1 files changed, 36 insertions, 9 deletions
diff --git a/test/recipes/90-test_shlibload.t b/test/recipes/90-test_shlibload.t
index bb7fab079c..ea8aeeb7d5 100644
--- a/test/recipes/90-test_shlibload.t
+++ b/test/recipes/90-test_shlibload.t
@@ -8,6 +8,7 @@
use OpenSSL::Test qw/:DEFAULT bldtop_dir bldtop_file/;
use OpenSSL::Test::Utils;
+use File::Temp qw(tempfile);
#Load configdata.pm
@@ -20,7 +21,7 @@ use configdata;
plan skip_all => "Test only supported in a shared build" if disabled("shared");
plan skip_all => "Test is disabled on AIX" if config('target') =~ m|^aix|;
-plan tests => 4;
+plan tests => 10;
# When libssl and libcrypto are compiled on Linux with "-rpath", but not
# "--enable-new-dtags", the RPATH takes precedence over LD_LIBRARY_PATH,
@@ -30,14 +31,31 @@ plan tests => 4;
my $libcrypto = bldtop_file(shlib('libcrypto'));
my $libssl = bldtop_file(shlib('libssl'));
-ok(run(test(["shlibloadtest", "-crypto_first", $libcrypto, $libssl])),
- "running shlibloadtest -crypto_first");
-ok(run(test(["shlibloadtest", "-ssl_first", $libcrypto, $libssl])),
- "running shlibloadtest -ssl_first");
-ok(run(test(["shlibloadtest", "-just_crypto", $libcrypto, $libssl])),
- "running shlibloadtest -just_crypto");
-ok(run(test(["shlibloadtest", "-dso_ref", $libcrypto, $libssl])),
- "running shlibloadtest -dso_ref");
+(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;
sub shlib {
my $lib = shift;
@@ -49,3 +67,12 @@ sub shlib {
$lib =~ s|\.\$\(SHLIB_VERSION_NUMBER\)|.$config{shlib_version}|;
return $lib;
}
+
+sub check_atexit {
+ my $fh = shift;
+ my $data = <$fh>;
+
+ return 1 if (defined $data && $data =~ m/atexit\(\) run/);
+
+ return 0;
+}