]>
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/;
19 use if $^O
ne "VMS", 'File::Glob' => qw
/glob/;
20 use Module
::Load
::Conditional
qw(can_load);
22 my $TAP_Harness = can_load
(modules
=> { 'TAP::Harness' => undef })
23 ?
'TAP::Harness' : 'OpenSSL::TAP::Harness';
25 my $srctop = $ENV{SRCTOP
} || $ENV{TOP
};
26 my $bldtop = $ENV{BLDTOP
} || $ENV{TOP
};
27 my $recipesdir = catdir
($srctop, "test", "recipes");
28 my $testlib = catdir
($srctop, "test", "testlib");
29 my $utillib = catdir
($srctop, "util");
32 ( verbosity
=> $ENV{VERBOSE
} || $ENV{V
} || $ENV{HARNESS_VERBOSE
} ?
1 : 0,
33 lib
=> [ $testlib, $utillib ],
38 my @alltests = find_matching_tests
("*");
42 foreach my $arg (@ARGV ?
@ARGV : ('alltests')) {
45 (my $x = basename
($_)) =~ s
|^[0-9][0-9]-(.*)\
.t
$|$1|;
50 if ($arg eq 'alltests') {
51 warn "'alltests' encountered, ignoring everything before that...\n"
53 %tests = map { $_ => 1 } @alltests;
54 } elsif ($arg =~ m/^(-?)(.*)/) {
57 my @matches = find_matching_tests
($test);
59 # If '-foo' is the first arg, it's short for 'alltests -foo'
60 if ($sign eq '-' && $initial_arg) {
61 %tests = map { $_ => 1 } @alltests;
64 if (scalar @matches == 0) {
65 warn "Test $test found no match, skipping ",
66 ($sign eq '-' ?
"removal" : "addition"),
69 foreach $test (@matches) {
78 warn "I don't know what '$arg' is about, ignoring...\n";
84 my $harness = $TAP_Harness->new(\
%tapargs);
85 my $ret = $harness->runtests(map { abs2rel
($_, rel2abs
(curdir
())); }
88 # $ret->has_errors may be any number, not just 0 or 1. On VMS, numbers
89 # from 2 and on are used as is as VMS statuses, which has severity encoded
90 # in the lower 3 bits. 0 and 1, on the other hand, generate SUCCESS and
91 # FAILURE, so for currect reporting on all platforms, we make sure the only
92 # exit codes are 0 and 1. Double-bang is the trick to do so.
93 exit !!$ret->has_errors if (ref($ret) eq "TAP::Parser::Aggregator");
95 # If this isn't a TAP::Parser::Aggregator, it's the pre-TAP test harness,
96 # which simply dies at the end if any test failed, so we don't need to bother
97 # with any exit code in that case.
99 sub find_matching_tests
{
102 if ($glob =~ m
|^[\d\
[\
]\?\
-]+$|) {
103 return glob(catfile
($recipesdir,"$glob-*.t"));
105 return glob(catfile
($recipesdir,"*-$glob.t"));
109 # Fake TAP::Harness in case it's not loaded
111 package OpenSSL
::TAP
::Harness
;
115 my %args = %{ shift() };
117 return bless { %args }, $class;
124 if ($self->{switches
}) {
125 push @switches, $self->{switches
};
128 foreach (@
{$self->{lib
}}) {
131 # It seems that $switches is getting interpreted with 'eval' or
132 # something like that, and that we need to take care of backslashes
133 # or they will disappear along the way.
134 $l =~ s
|\\|\\\\|g
if $^O
eq "MSWin32";
135 push @switches, "-I$l";
139 $Test::Harness
::switches
= join(' ', @switches);
140 Test
::Harness
::runtests
(@_);