4fc9e1b3afc48205bd3315355ef37abc3542e137
[openssl.git] / test / recipes / 00-check_testexes.t
1 #! /usr/bin/perl
2
3 use strict;
4
5 use File::Spec::Functions;
6 use OpenSSL::Test qw/:DEFAULT top_file/;
7
8 setup("check_testexes");
9
10 my $MINFO = top_file("MINFO");
11
12  SKIP: {
13      my %foundfiles;
14      my $numtests = 1;
15
16      if (open(FH,$MINFO)) {
17          while(<FH>) {
18              chomp;
19              last if /^RELATIVE_DIRECTORY=test$/;
20          }
21          while(<FH>) {
22              chomp;
23              last if /^EXE=/;
24          }
25          close FH;
26
27          my $pathfix = sub { return shift; }; # noop
28          if ($^O eq "MSWin32") {
29              # Experience has shown that glob needs the backslashes escaped
30              # to handle the glob glob() gets served.  Otherwise, it sometimes
31              # considers the backslash an escape of the next character, most
32              # notably the [.
33              # (if the single backslash is followed by a *, however, the *
34              # doesn't seem to be considered escaped...  go figure...)
35              $pathfix = sub { shift; s/\\/\\\\/g; return $_; };
36          }
37          s/^EXE=\s*//;
38          s/\s*$//;
39          %foundfiles =
40              map {
41                  my $key = $_;
42                  s/_?test$//;
43                  s/(sha\d+)t/$1/;
44                  $key =>
45                      $pathfix->(top_file("test", "recipes",
46                                          "[0-9][0-9]-test_$_.t")); } split(/\s+/, $_);
47          $numtests = scalar keys %foundfiles;
48      }
49
50      plan tests => $numtests;
51
52      skip "because $MINFO not found. If you want this test to run, please do 'perl util/mkfiles.pl > $MINFO'", 1
53          unless %foundfiles;
54
55      foreach (sort keys %foundfiles) {
56          my @check = glob($foundfiles{$_});
57          ok(scalar @check, "check that a test for $_ exists")
58              || diag("Expected to find something matching $foundfiles{$_}");
59      }
60 }