In templates, output_on() must be used the same way as output_off()
[openssl.git] / test / recipes / 00-check_testexes.t
1 #! /usr/bin/perl
2
3 use strict;
4
5 use File::Spec::Functions;
6 use File::Basename;
7 use OpenSSL::Test qw/:DEFAULT bldtop_file/;
8
9 setup("check_testexes");
10
11 my $OpenSSL_ver = "";
12 my $Makefile = bldtop_file("Makefile");
13 if (open(FH, $Makefile)) {
14     $OpenSSL_ver =
15         (map { s/\R//; s/^VERSION=([^\s]*)\s*$//; $1 } grep { /^VERSION=/ } <FH>)[0];
16     close FH;
17 }
18
19 my $MINFO = bldtop_file("MINFO");
20
21 plan skip_all => "because MINFO not found. If you want this test to run, please do 'perl util/mkfiles.pl > MINFO'"
22     unless open(FH,$MINFO);
23
24 my $MINFO_ver = "";
25
26 while(<FH>) {
27     s/\R//;     # chomp;
28     if (/^VERSION=([^\s]*)\s*$/) {
29         $MINFO_ver = $1;
30     }
31     last if /^RELATIVE_DIRECTORY=test$/;
32 }
33 while(<FH>) {
34     s/\R//;     # chomp;
35     last if /^EXE=/;
36 }
37 close FH;
38
39 plan skip_all => "because MINFO is not from this OpenSSL version. If you want this test to run, please do 'perl util/mkfiles.pl > MINFO'"
40     unless $OpenSSL_ver eq $MINFO_ver;
41
42 s/^EXE=\s*//;
43 s/\s*$//;
44 my @expected_tests =
45     map { s/\..*$//;            # Remove extension
46           s/_?test$//;          # Remove 'test', possibly prefixed with '_'
47           s/(sha\d+)t/$1/;      # sha comes with no t at the end
48           $_; } split(/\s+/, $_);
49
50 plan tests => scalar @expected_tests;
51
52 my @found_tests =
53     map { basename($_) } glob(bldtop_file("test", "recipes", "*.t"));
54
55 foreach my $test (sort @expected_tests) {
56     ok(scalar(grep(/^[0-9][0-9]-test_$test\.t$/, @found_tests)),
57        "check that a test for $test exists")
58         || diag("Expected to find something matching '[0-9][0-9]-test_$test.t'");
59 }