-# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@EXPORT_OK = (@Test::More::EXPORT_OK, qw(bldtop_dir bldtop_file
srctop_dir srctop_file
data_file
- pipe with cmdstr quotify));
+ pipe with cmdstr quotify
+ openssl_versions));
=head1 NAME
# exit_checker is used by run() directly after completion of a command.
# it receives the exit code from that command and is expected to return
# 1 (for success) or 0 (for failure). This is the status value that run()
- # will give back (through the |statusvar| referens and as returned value
+ # will give back (through the |statusvar| reference and as returned value
# when capture => 1 doesn't apply).
exit_checker => sub { return shift == 0 ? 1 : 0 },
}
close $pipe;
} else {
+ $ENV{HARNESS_OSSL_PREFIX} = "# ";
system("$prefix$cmd");
+ delete $ENV{HARNESS_OSSL_PREFIX};
}
$e = ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8);
$r = $hooks{exit_checker}->($e);
=item B<with HASHREF, CODEREF>
-C<with> will temporarly install hooks given by the HASHREF and then execute
+C<with> will temporarily install hooks given by the HASHREF and then execute
the given CODEREF. Hooks are usually expected to have a coderef as value.
The currently available hoosk are:
C<cmdstr> takes a CODEREF from C<app> or C<test> and simply returns the
command as a string.
-C<cmdstr> takes some additiona options OPTS that affect the string returned:
+C<cmdstr> takes some additional options OPTS that affect the string returned:
=over 4
sub quotify {
# Unix setup (default if nothing else is mentioned)
my $arg_formatter =
- sub { $_ = shift; /\s|[\{\}\\\$\[\]\*\?\|\&:;<>]/ ? "'$_'" : $_ };
+ sub { $_ = shift;
+ ($_ eq '' || /\s|[\{\}\\\$\[\]\*\?\|\&:;<>]/) ? "'$_'" : $_ };
if ( $^O eq "VMS") { # VMS setup
$arg_formatter = sub {
$_ = shift;
- if (/\s|["[:upper:]]/) {
+ if ($_ eq '' || /\s|["[:upper:]]/) {
s/"/""/g;
'"'.$_.'"';
} else {
} elsif ( $^O eq "MSWin32") { # MSWin setup
$arg_formatter = sub {
$_ = shift;
- if (/\s|["\|\&\*\;<>]/) {
+ if ($_ eq '' || /\s|["\|\&\*\;<>]/) {
s/(["\\])/\\$1/g;
'"'.$_.'"';
} else {
return map { $arg_formatter->($_) } @_;
}
+=over 4
+
+=item B<openssl_versions>
+
+Returns a list of two numbers, the first representing the build version,
+the second representing the library version. See opensslv.h for more
+information on those numbers.
+
+= back
+
+=cut
+
+my @versions = ();
+sub openssl_versions {
+ unless (@versions) {
+ my %lines =
+ map { s/\R$//;
+ /^(.*): (0x[[:xdigit:]]{8})$/;
+ die "Weird line: $_" unless defined $1;
+ $1 => hex($2) }
+ run(test(['versions']), capture => 1);
+ @versions = ( $lines{'Build version'}, $lines{'Library version'} );
+ }
+ return @versions;
+}
+
######################################################################
# private functions. These are never exported.
my $e = pop || "";
my $f = pop;
- $f = catfile($directories{BLDTEST},@_,$f . $e);
- $f = catfile($directories{SRCTEST},@_,$f) unless -f $f;
- return $f;
+ my $out = catfile($directories{BLDTEST},@_,$f . $e);
+ $out = catfile($directories{SRCTEST},@_,$f) unless -f $out;
+ return $out;
}
sub __apps_file {
my $e = pop || "";
my $f = pop;
- $f = catfile($directories{BLDAPPS},@_,$f . $e);
- $f = catfile($directories{SRCAPPS},@_,$f) unless -f $f;
- return $f;
+ my $out = catfile($directories{BLDAPPS},@_,$f . $e);
+ $out = catfile($directories{SRCAPPS},@_,$f) unless -f $out;
+ return $out;
}
sub __fuzz_file {
my $e = pop || "";
my $f = pop;
- $f = catfile($directories{BLDFUZZ},@_,$f . $e);
- $f = catfile($directories{SRCFUZZ},@_,$f) unless -f $f;
- return $f;
+ my $out = catfile($directories{BLDFUZZ},@_,$f . $e);
+ $out = catfile($directories{SRCFUZZ},@_,$f) unless -f $out;
+ return $out;
}
sub __data_file {
}
# We put back new values carefully. Doing the obvious
- # %directories = ( %tmp_irectories )
+ # %directories = ( %tmp_directories )
# will clear out any value that happens to be an absolute path
foreach (keys %tmp_directories) {
$directories{$_} = $tmp_directories{$_};
$prefix = ($prog =~ /^(?:[\$a-z0-9_]+:)?[<\[]/i ? "mcr " : "mcr []");
}
- # We test if the program to use exists.
- if ( ! -x $prog ) {
- $prog = undef;
- }
-
if (defined($prog)) {
# Make sure to quotify the program file on platforms that may
# have spaces or similar in their path name.
=head1 AUTHORS
-Richard Levitte E<lt>levitte@openssl.orgE<gt> with assitance and
+Richard Levitte E<lt>levitte@openssl.orgE<gt> with assistance and
inspiration from Andy Polyakov E<lt>appro@openssl.org<gt>.
=cut