20-test_provider.t 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /usr/bin/env perl
  2. # Copyright 2019-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. use strict;
  9. use warnings;
  10. use OpenSSL::Test;
  11. setup("test_provider");
  12. plan tests => 9;
  13. SKIP: {
  14. skip "No default provider?", 6
  15. unless ok(run(app([qw(openssl provider default)])),
  16. "try running 'openssl provider default'");
  17. my $prev = 2; # The amount of lines from -v
  18. my @checks = qw( -v -vv -vvv );
  19. my %op = ( -v => '==',
  20. -vv => '>',
  21. -vvv => '>' );
  22. my $i = 0;
  23. foreach (@checks) {
  24. my @cmd = ('openssl', 'provider', $_, 'default');
  25. my @lines = ( map { (my $x = $_) =~ s|\R$||; $x }
  26. run(app([@cmd]), capture => 1) );
  27. my $curr = scalar @lines;
  28. my $cmp = "$curr $op{$_} $prev";
  29. ok(eval $cmp,
  30. "'openssl provider $_ default' line count $op{$_} $prev");
  31. ok($lines[0] eq '[ default ]',
  32. "'openssl provider -v default' first line is '[ default ]'");
  33. $prev = $curr;
  34. }
  35. }
  36. SKIP: {
  37. skip "No null provider?", 1
  38. unless ok(run(app([qw(openssl provider null)])),
  39. "try running 'openssl provider null'");
  40. my @cmd = ('openssl', 'provider', '-vvv', 'null');
  41. my @lines = ( map { (my $x = $_) =~ s|\R$||; $x }
  42. run(app([@cmd]), capture => 1) );
  43. my $curr = scalar @lines;
  44. my $cmp = "$curr == 1";
  45. ok(eval $cmp,
  46. "'openssl provider $_ default' line count == 1");
  47. }