00-check_testexes.t 1.5 KB
Newer Older
1 2 3 4 5
#! /usr/bin/perl

use strict;

use File::Spec::Functions;
6
use File::Basename;
7 8 9 10
use OpenSSL::Test qw/:DEFAULT top_file/;

setup("check_testexes");

R
Richard Levitte 已提交
11 12 13 14 15 16 17 18
my $OpenSSL_ver = "";
my $Makefile = top_file("Makefile");
if (open(FH, $Makefile)) {
    $OpenSSL_ver =
	(map { chomp; s/^VERSION=([^\s]*)\s*$//; $1 } grep { /^VERSION=/ } <FH>)[0];
    close FH;
}

19 20
my $MINFO = top_file("MINFO");

21 22 23
plan skip_all => "because MINFO not found. If you want this test to run, please do 'perl util/mkfiles.pl > MINFO'"
    unless open(FH,$MINFO);

R
Richard Levitte 已提交
24 25
my $MINFO_ver = "";

26 27
while(<FH>) {
    chomp;
R
Richard Levitte 已提交
28 29 30
    if (/^VERSION=([^\s]*)\s*$/) {
	$MINFO_ver = $1;
    }
31 32 33 34 35 36 37 38
    last if /^RELATIVE_DIRECTORY=test$/;
}
while(<FH>) {
    chomp;
    last if /^EXE=/;
}
close FH;

R
Richard Levitte 已提交
39 40 41
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'"
    unless $OpenSSL_ver eq $MINFO_ver;

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
s/^EXE=\s*//;
s/\s*$//;
my @expected_tests =
    map { s/\..*$//;		# Remove extension
	  s/_?test$//;		# Remove 'test', possibly prefixed with '_'
	  s/(sha\d+)t/$1/;	# sha comes with no t at the end
	  $_; } split(/\s+/, $_);

plan tests => scalar @expected_tests;

my @found_tests =
    map { basename($_) } glob(top_file("test", "recipes", "*.t"));

foreach my $test (sort @expected_tests) {
    ok(scalar(grep(/^[0-9][0-9]-test_$test\.t$/, @found_tests)),
       "check that a test for $test exists")
	|| diag("Expected to find something matching '[0-9][0-9]-test_$test.t'");
59
}