123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- use strict;
- use warnings;
- BEGIN {
- $ENV{HARNESS_VERBOSE} = "yes" if $ENV{VERBOSE} || $ENV{V};
- }
- use File::Spec::Functions qw/catdir catfile curdir abs2rel rel2abs/;
- use File::Basename;
- use FindBin;
- use lib "$FindBin::Bin/../util/perl";
- use OpenSSL::Glob;
- my $TAP_Harness = eval { require TAP::Harness } ? "TAP::Harness"
- : "OpenSSL::TAP::Harness";
- my $srctop = $ENV{SRCTOP} || $ENV{TOP};
- my $bldtop = $ENV{BLDTOP} || $ENV{TOP};
- my $recipesdir = catdir($srctop, "test", "recipes");
- my $libdir = rel2abs(catdir($srctop, "util", "perl"));
- $ENV{OPENSSL_CONF} = catdir($srctop, "apps", "openssl.cnf");
- my %tapargs =
- ( verbosity => $ENV{VERBOSE} || $ENV{V} || $ENV{HARNESS_VERBOSE} ? 1 : 0,
- lib => [ $libdir ],
- switches => '-w',
- merge => 1
- );
- my @alltests = find_matching_tests("*");
- my %tests = ();
- my $initial_arg = 1;
- foreach my $arg (@ARGV ? @ARGV : ('alltests')) {
- if ($arg eq 'list') {
- foreach (@alltests) {
- (my $x = basename($_)) =~ s|^[0-9][0-9]-(.*)\.t$|$1|;
- print $x,"\n";
- }
- exit 0;
- }
- if ($arg eq 'alltests') {
- warn "'alltests' encountered, ignoring everything before that...\n"
- unless $initial_arg;
- %tests = map { $_ => 1 } @alltests;
- } elsif ($arg =~ m/^(-?)(.*)/) {
- my $sign = $1;
- my $test = $2;
- my @matches = find_matching_tests($test);
-
- if ($sign eq '-' && $initial_arg) {
- %tests = map { $_ => 1 } @alltests;
- }
- if (scalar @matches == 0) {
- warn "Test $test found no match, skipping ",
- ($sign eq '-' ? "removal" : "addition"),
- "...\n";
- } else {
- foreach $test (@matches) {
- if ($sign eq '-') {
- delete $tests{$test};
- } else {
- $tests{$test} = 1;
- }
- }
- }
- } else {
- warn "I don't know what '$arg' is about, ignoring...\n";
- }
- $initial_arg = 0;
- }
- my $harness = $TAP_Harness->new(\%tapargs);
- my $ret = $harness->runtests(map { abs2rel($_, rel2abs(curdir())); }
- sort keys %tests);
- exit !!$ret->has_errors if (ref($ret) eq "TAP::Parser::Aggregator");
- sub find_matching_tests {
- my ($glob) = @_;
- if ($glob =~ m|^[\d\[\]\?\-]+$|) {
- return glob(catfile($recipesdir,"$glob-*.t"));
- }
- return glob(catfile($recipesdir,"*-$glob.t"));
- }
- use Test::Harness;
- package OpenSSL::TAP::Harness;
- sub new {
- my $class = shift;
- my %args = %{ shift() };
- return bless { %args }, $class;
- }
- sub runtests {
- my $self = shift;
- my @switches = ();
- if ($self->{switches}) {
- push @switches, $self->{switches};
- }
- if ($self->{lib}) {
- foreach (@{$self->{lib}}) {
- my $l = $_;
-
-
-
- $l =~ s|\\|\\\\|g if $^O eq "MSWin32";
- push @switches, "-I$l";
- }
- }
- $Test::Harness::switches = join(' ', @switches);
- Test::Harness::runtests(@_);
- }
|