]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/run_tests.pl
2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (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
12 # Recognise VERBOSE and V which is common on other projects.
14 $ENV{HARNESS_VERBOSE
} = "yes" if $ENV{VERBOSE
} || $ENV{V
};
17 use File
::Spec
::Functions qw
/catdir catfile curdir abs2rel rel2abs/;
20 use lib
"$FindBin::Bin/../util/perl";
22 use Module
::Load
::Conditional
qw(can_load);
24 my $TAP_Harness = can_load
(modules
=> { 'TAP::Harness' => undef })
25 ?
'TAP::Harness' : 'OpenSSL::TAP::Harness';
27 my $srctop = $ENV{SRCTOP
} || $ENV{TOP
};
28 my $bldtop = $ENV{BLDTOP
} || $ENV{TOP
};
29 my $recipesdir = catdir
($srctop, "test", "recipes");
30 my $libdir = rel2abs
(catdir
($srctop, "util", "perl"));
33 ( verbosity
=> $ENV{VERBOSE
} || $ENV{V
} || $ENV{HARNESS_VERBOSE
} ?
1 : 0,
39 my @alltests = find_matching_tests
("*");
43 foreach my $arg (@ARGV ?
@ARGV : ('alltests')) {
46 (my $x = basename
($_)) =~ s
|^[0-9][0-9]-(.*)\
.t
$|$1|;
51 if ($arg eq 'alltests') {
52 warn "'alltests' encountered, ignoring everything before that...\n"
54 %tests = map { $_ => 1 } @alltests;
55 } elsif ($arg =~ m/^(-?)(.*)/) {
58 my @matches = find_matching_tests
($test);
60 # If '-foo' is the first arg, it's short for 'alltests -foo'
61 if ($sign eq '-' && $initial_arg) {
62 %tests = map { $_ => 1 } @alltests;
65 if (scalar @matches == 0) {
66 warn "Test $test found no match, skipping ",
67 ($sign eq '-' ?
"removal" : "addition"),
70 foreach $test (@matches) {
79 warn "I don't know what '$arg' is about, ignoring...\n";
85 my $harness = $TAP_Harness->new(\
%tapargs);
86 my $ret = $harness->runtests(map { abs2rel
($_, rel2abs
(curdir
())); }
89 # $ret->has_errors may be any number, not just 0 or 1. On VMS, numbers
90 # from 2 and on are used as is as VMS statuses, which has severity encoded
91 # in the lower 3 bits. 0 and 1, on the other hand, generate SUCCESS and
92 # FAILURE, so for currect reporting on all platforms, we make sure the only
93 # exit codes are 0 and 1. Double-bang is the trick to do so.
94 exit !!$ret->has_errors if (ref($ret) eq "TAP::Parser::Aggregator");
96 # If this isn't a TAP::Parser::Aggregator, it's the pre-TAP test harness,
97 # which simply dies at the end if any test failed, so we don't need to bother
98 # with any exit code in that case.
100 sub find_matching_tests
{
103 if ($glob =~ m
|^[\d\
[\
]\?\
-]+$|) {
104 return glob(catfile
($recipesdir,"$glob-*.t"));
106 return glob(catfile
($recipesdir,"*-$glob.t"));
110 # Fake TAP::Harness in case it's not loaded
112 package OpenSSL
::TAP
::Harness
;
116 my %args = %{ shift() };
118 return bless { %args }, $class;
125 if ($self->{switches
}) {
126 push @switches, $self->{switches
};
129 foreach (@
{$self->{lib
}}) {
132 # It seems that $switches is getting interpreted with 'eval' or
133 # something like that, and that we need to take care of backslashes
134 # or they will disappear along the way.
135 $l =~ s
|\\|\\\\|g
if $^O
eq "MSWin32";
136 push @switches, "-I$l";
140 $Test::Harness
::switches
= join(' ', @switches);
141 Test
::Harness
::runtests
(@_);