90-test_shlibload.t 2.0 KB

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