Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d79b67

Browse files
committed
Make SSL regression test suite more portable by avoiding cp.
Use perl 'glob' and File::Copy instead of "cp". This takes us one step closer to running the suite on Windows. Michael Paquier
1 parent 0fb256d commit 5d79b67

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/test/ssl/ServerSetup.pm

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,29 @@ package ServerSetup;
1919
use strict;
2020
use warnings;
2121
use TestLib;
22+
use File::Basename;
23+
use File::Copy;
2224
use Test::More;
2325

2426
use Exporter 'import';
2527
our @EXPORT = qw(
2628
configure_test_server_for_ssl switch_server_cert
2729
);
2830

31+
# Copy a set of files, taking into account wildcards
32+
sub copy_files
33+
{
34+
my $orig = shift;
35+
my $dest = shift;
36+
37+
my @orig_files = glob $orig;
38+
foreach my $orig_file (@orig_files)
39+
{
40+
my $base_file = basename($orig_file);
41+
copy($orig_file, "$dest/$base_file") or die "Could not copy $orig_file to $dest";
42+
}
43+
}
44+
2945
sub configure_test_server_for_ssl
3046
{
3147
my $tempdir = $_[0];
@@ -48,13 +64,12 @@ sub configure_test_server_for_ssl
4864

4965
close CONF;
5066

51-
5267
# Copy all server certificates and keys, and client root cert, to the data dir
53-
system_or_bail "cp ssl/server-*.crt '$tempdir'/pgdata";
54-
system_or_bail "cp ssl/server-*.key '$tempdir'/pgdata";
68+
copy_files("ssl/server-*.crt", "$tempdir/pgdata");
69+
copy_files("ssl/server-*.key", "$tempdir/pgdata");
5570
system_or_bail "chmod 0600 '$tempdir'/pgdata/server-*.key";
56-
system_or_bail "cp ssl/root+client_ca.crt '$tempdir'/pgdata";
57-
system_or_bail "cp ssl/root+client.crl '$tempdir'/pgdata";
71+
copy_files("ssl/root+client_ca.crt", "$tempdir/pgdata");
72+
copy_files("ssl/root+client.crl", "$tempdir/pgdata");
5873

5974
# Only accept SSL connections from localhost. Our tests don't depend on this
6075
# but seems best to keep it as narrow as possible for security reasons.

0 commit comments

Comments
 (0)