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