Repository navigation
runtests: use temporary directory in checksystemfeatures - #23424
mihaigmarin wants to merge 1 commit into
Conversation
|
|
||
| my $curlverout = "$LOGDIR/curlverout.log"; | ||
| my $curlvererr = "$LOGDIR/curlvererr.log"; | ||
| my $tmpdir = tempdir("logtmpXXXXXX", DIR => ".", CLEANUP => 1); |
There was a problem hiding this comment.
Wouldn't this mean that an interrupted or broken test may
now leave orphan files in the system temp directory? It's the
first use tempdir() in runtests, other files are all created
within $LOGDIR, easy to clean or start afresh without littering.
Is there perhaps a better place for this under the tests/log
directory? Also what issue is this TODO fixing?
There was a problem hiding this comment.
I think an interrupted test will leave orphan files, but they will be cleared on the next run. Only the created temporary directory is cleaned when the process is interrupted because it has the CLEANUP option.
The issue from what I have understood was that using for example $ ./runtests.pl -l resulted in the deleting of the entire log directory.
There was a problem hiding this comment.
Thanks. I wonder if CLEANUP really works e.g. on Windows, which
has a weird filesystem with special needs (it depends on how CLEANUP
is implemented.)
I'm still unconvinced that the test should start writing outside the tests
directory. Why not %LOGDIR/temp for example?
There was a problem hiding this comment.
I think the idea is to separate the curlverout.log and curlvererr.log outside of $LOGDIR. In this way when running $ runtests.pl -l the $LOGDIR doesn't need to be recreated because the curlverout.log and curlvererr.log are not depending on that path.
There was a problem hiding this comment.
I made #23442 that avoids creating these disk files. This may
make it easier to deal with the creation/deletion of the log
dir, since it's no longer necessary for curl version detection.
There was a problem hiding this comment.
I've merged your changes into this pull request.
I found out that when running $ ./runtests.pl 1 and the log directory doesn't exists I get this warnings:
./runtests.pl 1
Using curl: ../src/curl
fopen() failed with error (2) No such file or directory
Error opening file 'log/sws.log'
Msg not logged: 10:01:22.217642 ========> sws quits
fopen() failed with error (2) No such file or directory
Error opening file 'log/sockfilt.log'
Msg not logged: 10:01:22.221369 ========> sockfilt quits
fopen() failed with error (2) No such file or directory
Error opening file 'log/sws.log'
Msg not logged: 10:01:22.225062 ========> sws quitsOne way to not have this is to redirect stderr to /dev/null:
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 91f303cd6f..3f4b08a9b0 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -765,7 +765,7 @@ sub checksystemfeatures {
# client has IPv6 support
# check if the HTTP server has it!
- my $cmd = server_exe('sws')." --version";
+ my $cmd = server_exe('sws')." --version 2>$dev_null";
my @sws = qx($cmd);
if($sws[0] =~ /IPv6/) {
# HTTP server has IPv6 support!
@@ -773,7 +773,7 @@ sub checksystemfeatures {
}
# check if the FTP server has it!
- $cmd = server_exe('sockfilt')." --version";
+ $cmd = server_exe('sockfilt')." --version 2>$dev_null";
@sws = qx($cmd);
if($sws[0] =~ /IPv6/) {
# FTP server has IPv6 support!
@@ -783,7 +783,7 @@ sub checksystemfeatures {
if($feature{"UnixSockets"}) {
# client has Unix sockets support, check whether the HTTP server has it
- my $cmd = server_exe('sws')." --version";
+ my $cmd = server_exe('sws')." --version 2>$dev_null";
my @sws = qx($cmd);
$http_unix = 1 if($sws[0] =~ /unix/);
}
Any suggestions?
There was a problem hiding this comment.
Good catch, more log dir users! Trying #23449 to avoid them.
There was a problem hiding this comment.
I have rebased on upstream/master and keep only one commit with changed description in order to better reflect what this pull request does.
There was a problem hiding this comment.
I wonder if this code has ever worked. This file was previously deleted at line 523 so I would expect this code path to display nothing.
There was a problem hiding this comment.
I think this code is executed only when curl executable is not found, on line 753
| die "Could not get curl's version"; | ||
| } | ||
| unlink($curlverout, $curlvererr); | ||
| rmdir($tmpdir); |
There was a problem hiding this comment.
Wouldn't this cause a race condition with tempdir()'s own cleanup? The directory is deleted here, but if a new directory with the same name is later created, tempdir's CLEANUP will delete this new, incorrect directory. This is mostly a theoretical problem, but perhaps this unlink/rmdir should just be dropped to allow tempdir to do it on program exit.
There was a problem hiding this comment.
Yes, this could be removed. I think the only benefit that it brings is that it will delete the tmpdir after the version check completes. Basically you don't have to wait until the program finishes in order for tmpdir to be removed.
Prior to this patch runtests was determining curl version and build details by saving stdout and stderr output to disk file and re-reading from there to parse and output to log. Simplify by reading stdout+ stderr directly into memory instead. Also avoids touching the disk, and no longer needs a `log` directory present. Also: - pass `--disable` alongside `--version` to prevent parsing `.curlrc` with potential extra output or side-effect. Ref: https://perldoc.perl.org/perlop#%60STRING%60 Ref: #23424 Follow-up to 93d5952 Closes #23442
To not need a log directory at this stage of the script. The log only received a 'quit' event; safe to discard. Reported-by: Mihai-Gabriel Marin Bug: #23424 (comment) Ref: #23424 Closes #23449
da69572 to
90aff19
Compare
Previously, runtests.pl cleared and created the main log directory early in the script solely because checksystemfeatures() needed somewhere to store temporary curl version output logs. This caused runs that only queried information (such as listing tests with -l) to wipe out the existing log directory from previous test runs. Currently checksystemfeatures() stores curl version output directly in memory. the creation of log directory is no longer needed for checksystemfeatures(). Solved the TODO by moving the creation of logdir insided createrunners when the tests are executed. Co-authored-by: Gemini <gemini@google.com> Signed-off-by: Mihai-Gabriel Marin <mihaigmarin@gmail.com>
90aff19 to
68f3e5b
Compare
Solved TODO regarding clearing and creating log directory.