tests: tighten up perl exports

This reduces namespace pollution a little.

Ref: #10818
This commit is contained in:
Dan Fandrich 2023-04-05 15:29:00 -07:00
parent efbaa612f7
commit 44677b6565
10 changed files with 125 additions and 164 deletions

View File

@ -44,7 +44,11 @@
use strict;
use warnings;
use getpart;
use getpart qw(
getpart
loadtest
fulltest
);
# Boilerplate code for test tool
my $head =

View File

@ -59,7 +59,13 @@ use Digest::MD5;
use File::Basename;
use directories;
use getpart;
use getpart qw(
getpartattr
getpart
loadtest
);
use processhelp;
use serverhelp qw(
@ -72,7 +78,7 @@ use serverhelp qw(
datasockf_logfilename
);
use sshhelp qw(
use pathhelp qw(
exe_ext
);

View File

@ -38,7 +38,7 @@ use serverhelp qw(
server_logfilename
);
use sshhelp qw(
use pathhelp qw(
exe_ext
);

View File

@ -29,7 +29,10 @@ use warnings;
push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'});
push(@INC, ".");
use getpart; # array functions
use getpart qw(
getpart
loadtest
);
my $srcdir = $ENV{'srcdir'} || '.';
my $TESTDIR="$srcdir/data";

View File

@ -61,6 +61,7 @@ BEGIN {
our @EXPORT = qw(
sys_native_abs_path
sys_native_path
exe_ext
);
our @EXPORT_OK = qw(
@ -779,5 +780,22 @@ sub simple_transform_win32_to_unix {
$path = '/cygdrive' . $path if(drives_mounted_on_cygdrive());
return $path;
}
#
#***************************************************************************
# Return file extension for executable files on this operating system
#
sub exe_ext {
my ($component, @arr) = @_;
if ($ENV{'CURL_TEST_EXE_EXT'}) {
return $ENV{'CURL_TEST_EXE_EXT'};
}
if ($ENV{'CURL_TEST_EXE_EXT_'.$component}) {
return $ENV{'CURL_TEST_EXE_EXT_'.$component};
}
if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys' ||
$^O eq 'dos' || $^O eq 'os2') {
return '.exe';
}
}
1; # End of module

View File

@ -36,7 +36,7 @@ use serverhelp qw(
server_logfilename
);
use sshhelp qw(
use pathhelp qw(
exe_ext
);

View File

@ -98,22 +98,16 @@ use serverhelp qw(
use sshhelp qw(
$hstpubmd5f
$hstpubsha256f
$sshdexe
$sshexe
$sftpexe
$sshconfig
$sftpconfig
$sshdlog
$sshlog
$sftplog
$sftpcmds
display_sshdconfig
display_sshconfig
display_sftpconfig
display_sshdlog
display_sshlog
display_sftplog
exe_ext
find_sshd
find_ssh
find_sftp

View File

@ -27,39 +27,26 @@ package serverhelp;
use strict;
use warnings;
#***************************************************************************
# Global symbols allowed without explicit package name
#
use vars qw(
@EXPORT_OK
);
#***************************************************************************
# Inherit Exporter's capabilities
#
use base qw(Exporter);
#***************************************************************************
# Global symbols this module will export upon request
#
@EXPORT_OK = qw(
serverfactors
servername_id
servername_str
servername_canon
server_pidfilename
server_portfilename
server_logfilename
server_cmdfilename
server_inputfilename
server_outputfilename
mainsockf_pidfilename
mainsockf_logfilename
datasockf_pidfilename
datasockf_logfilename
BEGIN {
use base qw(Exporter);
our @EXPORT_OK = qw(
serverfactors
servername_id
servername_str
servername_canon
server_pidfilename
server_portfilename
server_logfilename
server_cmdfilename
server_inputfilename
server_outputfilename
mainsockf_pidfilename
mainsockf_logfilename
datasockf_pidfilename
datasockf_logfilename
);
}
#***************************************************************************

View File

@ -26,116 +26,83 @@ package sshhelp;
use strict;
use warnings;
BEGIN {
use base qw(Exporter);
our @EXPORT_OK = qw(
$sshdexe
$sshexe
$sftpsrvexe
$sftpexe
$sshkeygenexe
$sshdconfig
$sshconfig
$sftpconfig
$knownhosts
$sshdlog
$sshlog
$sftplog
$sftpcmds
$hstprvkeyf
$hstpubkeyf
$hstpubmd5f
$hstpubsha256f
$cliprvkeyf
$clipubkeyf
display_sshdconfig
display_sshconfig
display_sftpconfig
display_sshdlog
display_sshlog
display_sftplog
dump_array
find_sshd
find_ssh
find_sftpsrv
find_sftp
find_sshkeygen
find_httptlssrv
logmsg
sshversioninfo
);
}
use File::Spec;
#***************************************************************************
# Global symbols allowed without explicit package name
#
use vars qw(
@EXPORT_OK
$sshdexe
$sshexe
$sftpsrvexe
$sftpexe
$sshkeygenexe
$httptlssrvexe
$sshdconfig
$sshconfig
$sftpconfig
$knownhosts
$sshdlog
$sshlog
$sftplog
$sftpcmds
$hstprvkeyf
$hstpubkeyf
$hstpubmd5f
$hstpubsha256f
$cliprvkeyf
$clipubkeyf
@sftppath
@httptlssrvpath
);
#***************************************************************************
# Inherit Exporter's capabilities
#
use base qw(Exporter);
#***************************************************************************
# Global symbols this module will export upon request
#
@EXPORT_OK = qw(
$sshdexe
$sshexe
$sftpsrvexe
$sftpexe
$sshkeygenexe
$sshdconfig
$sshconfig
$sftpconfig
$knownhosts
$sshdlog
$sshlog
$sftplog
$sftpcmds
$hstprvkeyf
$hstpubkeyf
$hstpubmd5f
$hstpubsha256f
$cliprvkeyf
$clipubkeyf
display_sshdconfig
display_sshconfig
display_sftpconfig
display_sshdlog
display_sshlog
display_sftplog
dump_array
use pathhelp qw(
exe_ext
find_sshd
find_ssh
find_sftpsrv
find_sftp
find_sshkeygen
find_httptlssrv
logmsg
sshversioninfo
);
#***************************************************************************
# Global variables initialization
#
$sshdexe = 'sshd' .exe_ext('SSH'); # base name and ext of ssh daemon
$sshexe = 'ssh' .exe_ext('SSH'); # base name and ext of ssh client
$sftpsrvexe = 'sftp-server' .exe_ext('SSH'); # base name and ext of sftp-server
$sftpexe = 'sftp' .exe_ext('SSH'); # base name and ext of sftp client
$sshkeygenexe = 'ssh-keygen' .exe_ext('SSH'); # base name and ext of ssh-keygen
$httptlssrvexe = 'gnutls-serv' .exe_ext('SSH'); # base name and ext of gnutls-serv
$sshdconfig = 'curl_sshd_config'; # ssh daemon config file
$sshconfig = 'curl_ssh_config'; # ssh client config file
$sftpconfig = 'curl_sftp_config'; # sftp client config file
$sshdlog = undef; # ssh daemon log file
$sshlog = undef; # ssh client log file
$sftplog = undef; # sftp client log file
$sftpcmds = 'curl_sftp_cmds'; # sftp client commands batch file
$knownhosts = 'curl_client_knownhosts'; # ssh knownhosts file
$hstprvkeyf = 'curl_host_rsa_key'; # host private key file
$hstpubkeyf = 'curl_host_rsa_key.pub'; # host public key file
$hstpubmd5f = 'curl_host_rsa_key.pub_md5'; # md5 hash of host public key
$hstpubsha256f = 'curl_host_rsa_key.pub_sha256'; # sha256 hash of host public key
$cliprvkeyf = 'curl_client_key'; # client private key file
$clipubkeyf = 'curl_client_key.pub'; # client public key file
our $sshdexe = 'sshd' .exe_ext('SSH'); # base name and ext of ssh daemon
our $sshexe = 'ssh' .exe_ext('SSH'); # base name and ext of ssh client
our $sftpsrvexe = 'sftp-server' .exe_ext('SSH'); # base name and ext of sftp-server
our $sftpexe = 'sftp' .exe_ext('SSH'); # base name and ext of sftp client
our $sshkeygenexe = 'ssh-keygen' .exe_ext('SSH'); # base name and ext of ssh-keygen
our $httptlssrvexe = 'gnutls-serv' .exe_ext('SSH'); # base name and ext of gnutls-serv
our $sshdconfig = 'curl_sshd_config'; # ssh daemon config file
our $sshconfig = 'curl_ssh_config'; # ssh client config file
our $sftpconfig = 'curl_sftp_config'; # sftp client config file
our $sshdlog = undef; # ssh daemon log file
our $sshlog = undef; # ssh client log file
our $sftplog = undef; # sftp client log file
our $sftpcmds = 'curl_sftp_cmds'; # sftp client commands batch file
our $knownhosts = 'curl_client_knownhosts'; # ssh knownhosts file
our $hstprvkeyf = 'curl_host_rsa_key'; # host private key file
our $hstpubkeyf = 'curl_host_rsa_key.pub'; # host public key file
our $hstpubmd5f = 'curl_host_rsa_key.pub_md5'; # md5 hash of host public key
our $hstpubsha256f = 'curl_host_rsa_key.pub_sha256'; # sha256 hash of host public key
our $cliprvkeyf = 'curl_client_key'; # client private key file
our $clipubkeyf = 'curl_client_key.pub'; # client public key file
#***************************************************************************
# Absolute paths where to look for sftp-server plugin, when not in PATH
#
@sftppath = qw(
our @sftppath = qw(
/usr/lib/openssh
/usr/libexec/openssh
/usr/libexec
@ -161,7 +128,7 @@ $clipubkeyf = 'curl_client_key.pub'; # client public key file
#***************************************************************************
# Absolute paths where to look for httptlssrv (gnutls-serv), when not in PATH
#
@httptlssrvpath = qw(
our @httptlssrvpath = qw(
/usr/sbin
/usr/libexec
/usr/lib
@ -182,24 +149,6 @@ $clipubkeyf = 'curl_client_key.pub'; # client public key file
);
#***************************************************************************
# Return file extension for executable files on this operating system
#
sub exe_ext {
my ($component, @arr) = @_;
if ($ENV{'CURL_TEST_EXE_EXT'}) {
return $ENV{'CURL_TEST_EXE_EXT'};
}
if ($ENV{'CURL_TEST_EXE_EXT_'.$component}) {
return $ENV{'CURL_TEST_EXE_EXT_'.$component};
}
if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys' ||
$^O eq 'dos' || $^O eq 'os2') {
return '.exe';
}
}
#***************************************************************************
# Create or overwrite the given file with lines from an array of strings
#

View File

@ -23,20 +23,20 @@
#
#***************************************************************************
use strict;
use warnings;
BEGIN {
push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'});
push(@INC, ".");
}
use strict;
use warnings;
use serverhelp qw(
server_pidfilename
server_logfilename
);
use sshhelp qw(
use pathhelp qw(
exe_ext
);