- add variable for the null device filename and use that in Perl code.
- initialize this variable with `NUL` on native Windows.
- add `%DEV_NULL` variable and use it in tests.
Fixes `The system cannot find the path specified.` messages seen when
running `runtests.pl` with native Windows Perl.
Also adjust code to not break mcedit syntax highlighting.
Cherry-picked from #14949
Closes #15098
- `%CLIENTIP` - IPv4 address of the client running curl
- `%CURL` - Path to the curl executable
- `%DATE` - current YYYY-MM-DD date
+- `%DEV_NULL` - Null device (e.g. /dev/null)
- `%FILE_PWD` - Current directory, on Windows prefixed with a slash
- `%FTP6PORT` - IPv6 port number of the FTP server
- `%FTPPORT` - Port number of the FTP server
HTTP RFC1867-formpost a file from stdin with "faked" filename
</name>
<command>
-http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F field1=contents1 -F "fileupload=@-;filename=/dev/null;type=text/x-null;format=x-curl"
+http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F field1=contents1 -F "fileupload=@-;filename=%DEV_NULL;type=text/x-null;format=x-curl"
</command>
<stdin>
\r
contents1\r
------------------------------5dbea401cd8c\r
-Content-Disposition: form-data; name="fileupload"; filename="/dev/null"\r
+Content-Disposition: form-data; name="fileupload"; filename="%DEV_NULL"\r
Content-Type: text/x-null;format=x-curl\r
\r
line1
HTTP GET -w num_headers with redirected fetch (2 connects)
</name>
<command>
-http://%HOSTIP:%HTTPPORT/%TESTNUMBER -w "%{num_headers}\n" -L -o/dev/null
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER -w "%{num_headers}\n" -L -o%DEV_NULL
</command>
</client>
# Initialize @protocols from the curl binary under test
#
sub init_protocols {
- for (`$CURL -V 2>/dev/null`) {
+ for (`$CURL -V 2>$dev_null`) {
if(m/^Protocols: (.*)$/) {
parseprotocols($1);
}
%keywords
@protocols
$bundle
+ $dev_null
);
}
use pathhelp qw(exe_ext);
our $memanalyze="$perl $srcdir/memanalyze.pl";
our $valgrind; # path to valgrind, or empty if disabled
our $bundle = 0; # use bundled server, libtest, unit binaries
+our $dev_null = ($^O eq 'MSWin32' ? 'NUL' : '/dev/null');
# paths in $LOGDIR
our $LOCKDIR = "lock"; # root of the server directory with lock files
my $connect = "127.0.0.1,8990";
my $conf = "nghttpx.conf";
my $cert = "Server-localhost-sv";
+my $dev_null = ($^O eq 'MSWin32' ? 'NUL' : '/dev/null');
#***************************************************************************
# Process command line options
"--errorlog-file=$logfile ".
"$keyfile $certfile";
print "RUN: $cmdline\n" if($verbose);
-exec("exec $cmdline 2>/dev/null");
+exec("exec $cmdline 2>$dev_null");
my $connect = "127.0.0.1,8990";
my $cert = "Server-localhost-sv";
my $conf = "nghttpx.conf";
+my $dev_null = ($^O eq 'MSWin32' ? 'NUL' : '/dev/null');
#***************************************************************************
# Process command line options
"--conf=$conf ".
"$keyfile $certfile";
print "RUN: $cmdline\n" if($verbose);
-exec("exec $cmdline 2>/dev/null");
+exec("exec $cmdline 2>$dev_null");
}
}
+my $dev_null = ($^O eq 'MSWin32' ? 'NUL' : '/dev/null');
+
my $use_cygpath; # Only for Windows:
# undef - autodetect
# 0 - do not use cygpath
sub should_use_cygpath {
return $use_cygpath if defined $use_cygpath;
if(os_is_win()) {
- $use_cygpath = (qx{cygpath -u '.\\' 2>/dev/null} eq "./\n" && $? == 0);
+ $use_cygpath = (qx{cygpath -u '.\\' 2>$dev_null} eq "./\n" && $? == 0);
} else {
$use_cygpath = 0;
}
while(1) {
if(-d $check_path) {
my $res =
- `(cd "$check_path" && cmd /c "echo %__CD__%") 2>/dev/null`;
+ `(cd "$check_path" && cmd /c "echo %__CD__%") 2>$dev_null`;
if($? == 0 && substr($path, 0, 1) ne '%') {
# Remove both '\r' and '\n'.
$res =~ s{\n|\r}{}g;
$ENV{"NGHTTPX"} = checktestcmd("nghttpx");
}
if ($ENV{"NGHTTPX"}) {
- my $nghttpx_version=join(' ', `"$ENV{'NGHTTPX'}" -v 2>/dev/null`);
+ my $cmd = "\"$ENV{'NGHTTPX'}\" -v 2>$dev_null";
+ my $nghttpx_version=join(' ', `$cmd`);
$nghttpx_h3 = $nghttpx_version =~ /nghttp3\//;
chomp $nghttpx_h3;
}
print $temp "\n";
}
close($temp) || die "Failure writing diff file";
- my @out = `diff -u $file2 $file1 2>/dev/null`;
+ my @out = `diff -u $file2 $file1 2>$dev_null`;
if(!$out[0]) {
- @out = `diff -c $file2 $file1 2>/dev/null`;
+ @out = `diff -c $file2 $file1 2>$dev_null`;
}
return @out;
# seed of the month. December 2019 becomes 201912
$randseed = ($year+1900)*100 + $mon+1;
print "Using curl: $CURL\n";
- open(my $curlvh, "-|", shell_quote($CURL) . " --version 2>/dev/null") ||
+ open(my $curlvh, "-|", shell_quote($CURL) . " --version 2>$dev_null") ||
die "could not get curl version!";
my @c = <$curlvh>;
close($curlvh) || die "could not get curl version!";
# we have found valgrind on the host, use it
# verify that we can invoke it fine
- my $code = runclient("valgrind >/dev/null 2>&1");
+ my $code = runclient("valgrind >$dev_null 2>&1");
if(($code>>8) != 1) {
#logmsg "Valgrind failure, disable it\n";
# use it, if it is supported by the version installed on the system
# (this happened in 2003, so we could probably don't need to care about
# that old version any longer and just delete this check)
- runclient("valgrind --help 2>&1 | grep -- --tool > /dev/null 2>&1");
+ runclient("valgrind --help 2>&1 | grep -- --tool >$dev_null 2>&1");
if (($? >> 8)) {
$valgrind_tool="";
}
$$thing =~ s/${prefix}SSH_PWD/$ssh_pwd/g;
$$thing =~ s/${prefix}SRCDIR/$srcdir/g;
$$thing =~ s/${prefix}USER/$USER/g;
+ $$thing =~ s/${prefix}DEV_NULL/$dev_null/g;
$$thing =~ s/${prefix}SSHSRVMD5/$SSHSRVMD5/g;
$$thing =~ s/${prefix}SSHSRVSHA256/$SSHSRVSHA256/g;
use globalconfig qw(
$torture
$verbose
+ $dev_null
);
my $logfunc; # optional reference to function for logging
#
sub runclientoutput {
my ($cmd)=@_;
- return `$cmd 2>/dev/null`;
+ return `$cmd 2>$dev_null`;
# This is one way to test curl on a remote machine
# my @out = `ssh $CLIENTIP cd \'$pwd\' \\; \'$cmd\'`;