Skip to content

runtests: use temporary directory in checksystemfeatures - #23424

Open
mihaigmarin wants to merge 1 commit into
curl:masterfrom
mihaigmarin:feature/log-dir
Open

mihaigmarin wants to merge 1 commit into
curl:masterfrom
mihaigmarin:feature/log-dir

Conversation

@mihaigmarin

Copy link
Copy Markdown
Contributor

Solved TODO regarding clearing and creating log directory.

@github-actions github-actions Bot added the tests label Oct 15, 2026
Comment thread tests/runtests.pl Outdated

my $curlverout = "$LOGDIR/curlverout.log";
my $curlvererr = "$LOGDIR/curlvererr.log";
my $tmpdir = tempdir("logtmpXXXXXX", DIR => ".", CLEANUP => 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vszakats vszakats Oct 16, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vszakats vszakats Oct 16, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 quits

One 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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, more log dir users! Trying #23449 to avoid them.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged #23449.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, merged #23449 into #23424

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rebased on upstream/master and keep only one commit with changed description in order to better reflect what this pull request does.

Comment thread tests/runtests.pl Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code is executed only when curl executable is not found, on line 753

Comment thread tests/runtests.pl Outdated
die "Could not get curl's version";
}
unlink($curlverout, $curlvererr);
rmdir($tmpdir);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

vszakats added a commit that referenced this pull request Oct 17, 2026
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
vszakats added a commit that referenced this pull request Oct 17, 2026
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
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants