summaryrefslogtreecommitdiffstats
path: root/test/testlib
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2017-04-19 10:34:54 +0200
committerRichard Levitte <levitte@openssl.org>2017-04-25 15:43:04 +0200
commit208d721a004026b128dc66300e32e65a9dc7df1d (patch)
treecd95d9de87063bb4040ce438414d77518467a2f8 /test/testlib
parent65d62488b8c808350f440d2276034f5223b391ad (diff)
TAPify testutil
With the perl test framework comes the output format TAP (Test Anything Protocol, see http://testanything.org/) with extra extension for subtests. This change extends that same output format to any test program using testutil. In this implementation, each test program is seen as a full test that can be used as a subtest. The perl framework passes on the subtest level to the test programs with the environment variable HARNESS_OSSL_LEVEL. Furthermore, and series of tests added with ADD_ALL_TESTS is regarded as another subtest level. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3296)
Diffstat (limited to 'test/testlib')
-rw-r--r--test/testlib/OpenSSL/Test.pm14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/testlib/OpenSSL/Test.pm b/test/testlib/OpenSSL/Test.pm
index c4799e8648..f8fcbe906d 100644
--- a/test/testlib/OpenSSL/Test.pm
+++ b/test/testlib/OpenSSL/Test.pm
@@ -17,7 +17,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = "0.8";
@ISA = qw(Exporter);
@EXPORT = (@Test::More::EXPORT, qw(setup run indir cmd app fuzz test
- perlapp perltest));
+ perlapp perltest subtest));
@EXPORT_OK = (@Test::More::EXPORT_OK, qw(bldtop_dir bldtop_file
srctop_dir srctop_file
data_file
@@ -65,6 +65,7 @@ use File::Spec::Functions qw/file_name_is_absolute curdir canonpath splitdir
use File::Path 2.00 qw/rmtree mkpath/;
use File::Basename;
+my $level = 0;
# The name of the test. This is set by setup() and is used in the other
# functions to verify that setup() has been used.
@@ -454,6 +455,8 @@ sub run {
open STDERR, ">", devnull();
}
+ $ENV{HARNESS_OSSL_LEVEL} = $level + 1;
+
# The dance we do with $? is the same dance the Unix shells appear to
# do. For example, a program that gets aborted (and therefore signals
# SIGABRT = 6) will appear to exit with the code 134. We mimic this
@@ -1153,4 +1156,13 @@ inspiration from Andy Polyakov E<lt>appro@openssl.org<gt>.
=cut
+no warnings 'redefine';
+sub subtest {
+ $level++;
+
+ Test::More::subtest @_;
+
+ $level--;
+};
+
1;