runtests: support multi-target cmake, drop workarounds from CI

Support multi-target cmake builds via `CURL_DIRSUFFIX` env. For example:
`export CURL_DIRSUFFIX=Debug/`.

Multi-target generators place their output to `src/<subdir>/`,
`lib/<subdir>/`, `tests/server/<subdir>`, `tests/libtest/<subdir>` and
`tests/unit/<subdir>/` by default. Before this patch, `runtests.pl`
couldn't run on such builds because it expected the binaries under the
their `<subdir>`-less directories. This patch allows to set such subdir
and make `runtests.pl` find the binaries. In CI we use multi-target
builds with tests for MSVC. It also helps Xcode-generator builds, though
in CI we don't have such job running tests.

There may be better solutions to configure this, but passing a custom
value to `runtests.pl` including its subprocesses is somewhat tricky.
The reason the configuration value expects the slash at the end is
because MSYS is automagically expanding the env to a (wrong) absolute
path if the slash is in the front.

Also:
- drop the `-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_*=` workaround from CI.
- replace `resolve` references in tests with a new `%RESOLVE` variable.
  It didn't use a filename extension before. After this patch it uses
  `exe_ext('TOOL')`. I'm not sure if this is the correct choice vs.
  `exe_ext('SRV')`.
- fix `-c` option format in manual.
- fix some whitespace.

Note, in CI we still tweak `CMAKE_RUNTIME_OUTPUT_DIRECTORY_*` in jobs
which share steps between `./configure` and cmake. It's easier that way.

Ref: #15000
Cherry-picked from #16394

Closes #16452
This commit is contained in:
Viktor Szakats 2025-02-24 15:27:35 +01:00
parent db2fd7c3de
commit 3585796049
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
16 changed files with 69 additions and 56 deletions

View file

@ -126,7 +126,6 @@ our $tortalloc;
# local variables
my %oldenv; # environment variables before test is started
my $UNITDIR="./unit";
my $CURLLOG="$LOGDIR/commands.log"; # all command lines run
my $defserverlogslocktimeout = 5; # timeout to await server logs lock removal
my $defpostcommanddelay = 0; # delay between command and postcheck sections
@ -263,7 +262,7 @@ sub event_loop {
#
sub checktestcmd {
my ($cmd)=@_;
my @testpaths=("$LIBDIR/.libs", "$LIBDIR");
my @testpaths=($LIBDIR . ".libs", "$LIBDIR");
return checkcmd($cmd, @testpaths);
}
@ -922,18 +921,18 @@ sub singletest_run {
if($tool =~ /^lib/) {
if($bundle) {
$CMDLINE="$LIBDIR/libtests";
$CMDLINE=$LIBDIR . "libtests";
}
else {
$CMDLINE="$LIBDIR/$tool";
$CMDLINE=$LIBDIR . $tool;
}
}
elsif($tool =~ /^unit/) {
if($bundle) {
$CMDLINE="$UNITDIR/units";
$CMDLINE=$UNITDIR . "units";
}
else {
$CMDLINE="$UNITDIR/$tool";
$CMDLINE=$UNITDIR . $tool;
}
}
@ -1035,12 +1034,12 @@ sub singletest_run {
if ($torture) {
$cmdres = torture($CMDLINE,
$testnum,
"$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " -x $LOGDIR/gdbcmd");
"$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " -x $LOGDIR" . "gdbcmd");
}
elsif($gdbthis == 1) {
# gdb
my $GDBW = ($gdbxwin) ? "-w" : "";
runclient("$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " $GDBW -x $LOGDIR/gdbcmd");
runclient("$gdb --directory $LIBDIR " . shell_quote($DBGCURL) . " $GDBW -x $LOGDIR" . "gdbcmd");
$cmdres=0; # makes it always continue after a debugged run
}
elsif($gdbthis == 2) {