From: Dan Fandrich Date: Wed, 5 Apr 2023 22:29:00 +0000 (-0700) Subject: tests: tighten up perl exports X-Git-Tag: curl-8_1_0~182 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=44677b65653c34af290a52fd8a08c68642cd02d3;p=thirdparty%2Fcurl.git tests: tighten up perl exports This reduces namespace pollution a little. Ref: #10818 --- diff --git a/tests/convsrctest.pl b/tests/convsrctest.pl index 34504bafd7..fad922823c 100755 --- a/tests/convsrctest.pl +++ b/tests/convsrctest.pl @@ -44,7 +44,11 @@ use strict; use warnings; -use getpart; +use getpart qw( + getpart + loadtest + fulltest + ); # Boilerplate code for test tool my $head = diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index fd87f8eb45..4a4fc7726b 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -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 ); diff --git a/tests/http-server.pl b/tests/http-server.pl index b96e7e9e48..153020300b 100755 --- a/tests/http-server.pl +++ b/tests/http-server.pl @@ -38,7 +38,7 @@ use serverhelp qw( server_logfilename ); -use sshhelp qw( +use pathhelp qw( exe_ext ); diff --git a/tests/keywords.pl b/tests/keywords.pl index b62eb95a63..eb9f86830b 100755 --- a/tests/keywords.pl +++ b/tests/keywords.pl @@ -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"; diff --git a/tests/pathhelp.pm b/tests/pathhelp.pm index 5f67d6431f..db7fdc2764 100644 --- a/tests/pathhelp.pm +++ b/tests/pathhelp.pm @@ -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 diff --git a/tests/rtspserver.pl b/tests/rtspserver.pl index 4e5d0a0f00..3282d9c231 100755 --- a/tests/rtspserver.pl +++ b/tests/rtspserver.pl @@ -36,7 +36,7 @@ use serverhelp qw( server_logfilename ); -use sshhelp qw( +use pathhelp qw( exe_ext ); diff --git a/tests/runtests.pl b/tests/runtests.pl index bad53736d9..b4af9e25ee 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -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 diff --git a/tests/serverhelp.pm b/tests/serverhelp.pm index e1b4ff690a..bc5439ce21 100644 --- a/tests/serverhelp.pm +++ b/tests/serverhelp.pm @@ -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 ); +} #*************************************************************************** diff --git a/tests/sshhelp.pm b/tests/sshhelp.pm index 43e8dd5d25..d6a32f5895 100644 --- a/tests/sshhelp.pm +++ b/tests/sshhelp.pm @@ -26,116 +26,83 @@ package sshhelp; use strict; use warnings; -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 +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; -#*************************************************************************** -# 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 # diff --git a/tests/tftpserver.pl b/tests/tftpserver.pl index e1a696b0a2..52ad01f0c2 100755 --- a/tests/tftpserver.pl +++ b/tests/tftpserver.pl @@ -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 );