Skip to content

tests/server: support bundle binary #15000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Sep 22, 2024

Extend existing --enable-test-bundles and -DCURL_TEST_BUNDLES=ON
options to also bundle test server programs into a single binary. With
autotools, also bundle auxiliary libcurl sources for a "unity"-style
build.

It saves almost 10 minutes per run, across all CI jobs.
On average it makes build tests steps 25% faster.

With CMake, it brings down testdeps build steps to 32 to 37, from
45 to 64 before this patch, with unity. Without unity it brings it down
from 400-420 to 280-300. For comparison, without unity and bundles,
the number of build steps is around 1850.

With autotools the gain is possibly larger because this patch does unity
and bundle for test servers.

The total reduction of build steps / log lines is 12000. It's 44% of
reduction on average across all CI jobs.

Follow-up to 77401af #16695
Follow-up to 71cf0d1 #14772

Comparison of 'build tests' targets in S(econds) and L(ines/steps),
between before and after this patch:

CI job BefS AftS Gain BefL AftL Gain Comments
GHA/windows
Cygwin AM 110 95 15 237 88 149 l(ines)
Cygwin CM 34 27 7 63 36 27 s(teps, with Ninja)
msys2, AM x86_64 !proxy 35 21 14 255 108 147 l
msys2, AM x86_64 default 35 22 13 255 108 147 l
msys2, CM x86_64 default 14 11 3 63 36 27 s
msys2, AM x86_64 default R 41 29 12 245 96 149 l
mingw, AM x86_64 default 69 33 36 331 156 175 l
mingw, AM x86_64 c-ares U 69 33 36 331 156 175 l
mingw, CM x86_64 schannel c-ares U 32 24 8 63 36 27 s
mingw, CM clang-x86_64 gnutls 9 6 3 63 36 27 s
mingw, CM ucrt-x86_64 schannel R TrackMem 43 35 8 64 37 27 s
mingw, CM clang-x86_64 openssl 20 18 2 63 36 27 s
mingw, CM ucrt-x86_64 schannel uwp 36 34 2 47 34 13 s
mingw, CM x86_64 schannel dev debug 32 24 8 64 37 27 s
mingw, CM i686 schannel R 38 37 1 47 34 13 s
dl-mingw, CM 9.5.0-x86_64 schan 102 94 8 63 36 27 s
dl-mingw, CM 7.3.0-x86_64 schan mbedtls U 32 24 8 94 60 34 l
dl-mingw, CM 6.4.0-i686 schannel !unity 42 31 11 427 297 130 l (no unity, yes bundle)
linux-mingw, AM gcc - - - -
linux-mingw, CM gcc 12 10 2 46 33 13 s
mingw32ce, AM 4.4.0-arm schannel - - - -
mingw32ce, CM 4.4.0-arm schannel 30 31 -1 81 61 20 l
msvc, CM x64-uwp openssl +examples 13 10 3 102 68 34 l
msvc, CM x64-windows openssl 13 10 3 102 68 34 l
msvc, CM x64-windows schannel MultiSSL U 13 10 3 102 68 34 l
msvc, CM x64-windows libressl 14 13 1 102 68 34 l
msvc, CM x64-windows boringssl 11 11 0 84 64 20 l
msvc, CM x64-windows wolfssl +examples 13 10 3 102 68 34 l
msvc, CM x64-windows mbedtls libssh 14 10 4 102 68 34 l
GHA/old-linux:
linux (cmake & autoconf) AM 14 11 3 217 75 142 l
linux (cmake & autoconf) CM 15 13 2 545 380 165 l
GHA/non-native:
AmigaOS, AM gcc AmiSSL m68k - - - -
AmigaOS, CM gcc AmiSSL m68k 8 7 1 78 58 20 l
Android 21, AM openssl arm64 7 5 2 222 80 142 l
Android 21, CM openssl arm64 4 5 -1 81 61 20 l
Android 35, AM openssl arm64 7 5 2 222 80 142 l
Android 35, CM boringssl !zstd arm64 4 3 1 81 61 20 l
Android 35, CM openssl arm64 5 4 1 81 61 20 l
FreeBSD, AM clang openssl arm64 - - - -
FreeBSD, AM clang openssl x86_64 7 3 4 513 133 380 l
FreeBSD, CM clang openssl !unity !bundle.. 49 47 2 1841 1841 s (no unity, no bundle)
FreeBSD, CM clang openssl arm64 - - - -
MS-DOS, AM djgpp openssl i586 - - - -
MS-DOS, CM djgpp openssl i586 6 7 -1 45 32 13 s
NetBSD, CM clang openssl x86_64 15 13 2 62 35 27 s
OmniOS, AM gcc openssl amd64 20 11 9 216 74 142 l
OpenBSD, CM clang libressl x86_64 9 7 2 62 35 27 s
iOS, AM libressl arm64 6 3 3 217 68 149 l
iOS, CM libressl arm64 10 10 0 236 175 61 l
iOS, CM-Xcode libressl arm64 13 8 5 899 627 272 l
GHA/linux:
AM bearssl 9 8 1 258 111 147 l
AM bearssl clang 6 4 2 258 111 147 l
AM libressl heimdal 11 8 3 267 120 147 l
CM libressl heimdal valgrind 8 5 3 62 35 27 s
AM libressl clang 7 4 3 258 111 147 l
AM wolfssl-all 11 8 3 258 111 147 l
AM wolfssl-opensslextra valgrind 11 7 4 258 111 147 l
AM mbedtls valgrind 10 7 3 258 111 147 l
AM mbedtls clang 6 3 3 258 111 147 l
CM mbedtls 7 6 1 62 35 27 s
CM mbedtls-pkg 7 7 0 62 35 27 s
CM mbedtls-pkg !pc - - - -
AM msh3 10 7 3 258 111 147 l
CM msh3 7 7 0 62 35 27 s
AM awslc 18 15 3 247 98 149 l
CM awslc 13 11 2 400 277 123 s (no unity, yes bundle)
AM openssl default 10 7 3 258 111 147 l
AM openssl libssh2 sync-resolver valgrind 10 7 3 258 111 147 l
AM openssl 11 7 4 258 111 147 l
AM openssl -O3 valgrind 26 21 5 258 111 147 l
AM openssl clang krb5 7 3 4 265 118 147 l
CM openssl clang krb5 LTO - - - -
AM openssl !ipv6 !--libcurl 10 7 3 258 111 147 l
AM openssl https-only 11 8 3 258 111 147 l
CM openssl torture !FTP 7 6 1 62 35 27 s
CM openssl torture FTP 8 6 2 62 35 27 s
AM openssl i686 12 9 3 258 111 147 l
AM !ssl !http !smtp !imap 10 7 3 258 111 147 l
AM clang-tidy - - - -
AM scanbuild - - - -
AM address-sanitizer 10 6 4 258 111 147 l
AM thread-sanitizer 7 4 3 258 111 147 l
AM memory-sanitizer 10 6 4 258 111 147 l
AM event-based 10 7 3 253 106 147 l
AM duphandle 10 8 2 253 106 147 l
AM rustls valgrind 10 8 2 258 111 147 l
CM rustls 7 5 2 62 35 27 s
AM IntelC openssl 18 14 4 572 282 290 l
AM Slackware openssl gssapi gcc 17 14 3 252 103 149 l
AM Alpine MUSL https-rr 15 11 4 266 119 147 l
AM Alpine MUSL c-ares https-rr 15 11 4 266 119 147 l
GHA/linux-http3:
AM quictls 12 8 4 258 111 147 l
AM gnutls 11 8 3 257 110 147 l
AM wolfssl 11 9 2 257 110 147 l
CM wolfssl 8 7 1 62 35 27 s
AM openssl-quic 11 8 3 257 110 147 l
AM quiche 11 9 2 257 110 147 l
CM quiche 8 6 2 62 35 27 s
GHA/macos:
AM clang !ssl !debug brotli zstd 5 3 2 218 69 149 l
AM clang !ssl 4 5 -1 227 80 147 l
AM clang !ssl libssh2 AppleIDN 5 1 4 227 80 147 l
AM clang OpenSSL libssh c-ares 4 2 2 227 80 147 l
AM clang !ssl c-ares 4 5 -1 227 80 147 l
AM clang !ssl HTTP-only 4 2 2 222 75 147 l
AM clang SecureTransport libssh2 3 3 0 227 80 147 l
AM clang SecureTransport libssh2 10.12 4 2 2 227 80 147 l
AM clang LibreSSL +examples 5 2 3 227 80 147 l
AM clang OpenSSL 6 1 5 227 80 147 l
AM clang OpenSSL event-based 5 3 2 227 80 147 l
AM clang quictls libssh2 !ldap 10.15 4 2 2 227 80 147 l
CM clang OpenSSL gsasl rtmp AppleIDN 2 2 0 45 32 13 s
CM clang OpenSSL AppleIDN clang-tidy +e 150 76 74 400 277 123 s (clang-tidy)
CM clang quictls +static libssh +examples 2 2 0 45 32 13 s
CM clang SecureTransport debug 2 2 0 62 35 27 s
CM clang LibreSSL !ldap heimdal c-ares +e 4 2 2 45 32 13 s
CM clang wolfSSL !ldap brotli zstd 1 2 -1 45 32 13 s
CM clang mbedTLS openldap brotli zstd 1 2 -1 45 32 13 s
CM clang GnuTLS !ldap krb5 0 1 0 45 32 13 s
CM clang OpenSSL torture !FTP 2 1 1 61 34 27 s
CM clang OpenSSL torture FTP 2 1 1 61 34 27 s
AM llvm@15 OpenSSL libssh 5 4 1 227 80 147 l
CM llvm@15 OpenSSL gsasl rtmp AppleIDN 3 2 1 45 32 13 s
CM llvm@15 quictls +static libssh +e 2 2 0 45 32 13 s
CM llvm@15 SecureTransport debug 3 2 1 62 35 27 s
CM llvm@15 LibreSSL !ldap heimdal c-ares.. 3 1 2 45 32 13 s
CM llvm@15 wolfSSL !ldap brotli zstd 3 2 1 45 32 13 s
CM llvm@15 mbedTLS openldap brotli zstd 2 2 0 45 32 13 s
CM llvm@15 GnuTLS !ldap krb5 2 1 1 45 32 13 s
AM gcc-12 !ssl !debug 18 12 6 218 69 149 l
AM gcc-12 SecureTransport libssh2 13 6 7 227 80 147 l
CM gcc-12 OpenSSL gsasl rtmp AppleIDN 7 5 2 45 32 13 s
CM gcc-12 quictls +static libssh +e 8 6 2 45 32 13 s
CM gcc-12 SecureTransport debug 8 6 2 62 35 27 s
CM gcc-12 LibreSSL !ldap heimdal c-ares... 7 6 1 45 32 13 s
CM gcc-12 wolfSSL !ldap brotli zstd 16 6 10 45 32 13 s
CM gcc-12 mbedTLS openldap brotli zstd 11 6 5 45 32 13 s
CM gcc-12 GnuTLS !ldap krb5 7 5 2 45 32 13 s
AppVeyor:
VS2008 D x86 OpenSSL + Schannel SH +e 56 39 17 21 14 7 s (VCBuild)
VS2010 D x64 Schannel SH +e 14 12 2 105 78 27 l
VS2012 R x86 OpenSSL + Schannel SH 23 21 2 84 64 20 l
VS2013 D x64 OpenSSL SH Build-only - - - - (no build tests)
VS2015 D x64 OpenSSL ST Build-only - - - - (no build tests)
VS2017 D x64 OpenSSL SH Build-only - - - - (no build tests)
VS2019 D x64 OpenSSL + Schannel SH 33 26 7 81 61 20 l
VS2022 D x64 !SSL ST 32 25 7 79 59 20 l
VS2022 D x64 !SSL ST HTTP-only 33 22 11 79 59 20 l
VS2022 R arm64 Schannel ST 74 69 5 79 59 20 l
VS2022 R x64 Schannel SH U DBGBLD !CURLDBG 66 61 5 78 58 20 l
VS2022 D x64 Schannel ST U 34 25 9 79 59 20 l
VS2022 D x64 Schannel ST U clang-cl +e 42 34 8 53 40 13 l
VS2022 R x64 OpenSSL SH 60 58 2 83 63 20 l
Total 2394 1807 -587 26k 14k -12k
in % -24% -45%
in minutes 9m47

Before:
GHA/windows: https://github.com/curl/curl/actions/runs/13854983424
GHA/old-linux: https://github.com/curl/curl/actions/runs/13854983399
GHA/non-native: https://github.com/curl/curl/actions/runs/13854983427
GHA/linux-http3: https://github.com/curl/curl/actions/runs/13854983409
GHA/linux: https://github.com/curl/curl/actions/runs/13854983406
GHA/macos: https://github.com/curl/curl/actions/runs/13854983401
Appveyor: https://ci.appveyor.com/project/curlorg/curl/builds/51703551

After:
GHA/windows: https://github.com/curl/curl/actions/runs/13860433850?pr=15000
GHA/old-linux: https://github.com/curl/curl/actions/runs/13860433809?pr=15000
GHA/non-native: https://github.com/curl/curl/actions/runs/13860433828?pr=15000
GHA/linux-http3: https://github.com/curl/curl/actions/runs/13860433806?pr=15000
GHA/linux: https://github.com/curl/curl/actions/runs/13860433848?pr=15000
GHA/macos: https://github.com/curl/curl/actions/runs/13860433835?pr=15000
Appveyor: https://ci.appveyor.com/project/curlorg/curl/builds/51704222


  • autotools: include MEMDEBUG sources in unity for non-CURLDEBUG builds. Ref: autotools: use CURLDEBUG to exclude TrackMemory code from unity #16723
  • test with test bundles disabled, fix fallouts.
  • figure out why the bundled server binary is broken. (infinite? loops, timing issues)
  • inet missing.
  • dupe declarations.
  • fail to detect $bundle and skipping.
  • mis-detects $bundle and wants to run bundle tests.
  • replace runtests.pl -bundle option with something automatic? This would allow running it directly without having to add -bundle manually to match such build. [SKIP for now] → runtests: auto-detect test bundle builds #16750
  • merge mk-bundle.pl, mk-bundle-server.pl? and perhaps mk-unity.pl? [SKIP]
  • consider dropping mk-bundle.pl and just make it a manual server.c that includes all sources? Thus fixing up unity by default, regardless of build-system? also simplifying combinations and ensuring no symbol collision regressions by default? [SKIP, this bundler also does "unity" for autotools builds, which would be impractical the manual way.]

test/server cleanup plans:

@vszakats vszakats marked this pull request as draft September 22, 2024 08:58
@vszakats vszakats added the build label Sep 22, 2024
@vszakats vszakats force-pushed the server-bundle branch 2 times, most recently from 602937c to 5dd6751 Compare September 22, 2024 16:52
@vszakats vszakats force-pushed the server-bundle branch 2 times, most recently from d23bcb2 to 1f94bfa Compare October 2, 2024 20:08
@vszakats vszakats marked this pull request as ready for review October 2, 2024 22:33
@vszakats vszakats marked this pull request as draft October 2, 2024 22:37
@vszakats vszakats force-pushed the server-bundle branch 4 times, most recently from 4bd2924 to fffba0b Compare October 3, 2024 19:47
@vszakats vszakats force-pushed the server-bundle branch 2 times, most recently from a380749 to fb2905b Compare December 21, 2024 12:37
@vszakats vszakats force-pushed the server-bundle branch 4 times, most recently from 575bb18 to 46b8f5f Compare January 26, 2025 20:49
@vszakats vszakats force-pushed the server-bundle branch 2 times, most recently from c7c9937 to 0d1e3a8 Compare February 16, 2025 02:33
vszakats added a commit to vszakats/curl that referenced this pull request Feb 24, 2025
Support multi-target cmake builds via `CURL_DIRSUFFIX` env. Drop using
using `-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_*=` as a workaround in CI.

Also:
- replace `resolve` references in tests with a new `%RESOLVE` variable.
- fix `-c` option format in manual.
- fix some whitespace.

Ref: curl#15000
Cherry-picked from curl#16394
vszakats added a commit that referenced this pull request Feb 24, 2025
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
@vszakats vszakats force-pushed the server-bundle branch 4 times, most recently from 5897da9 to 5162525 Compare March 14, 2025 10:33
@vszakats vszakats removed cmdline tool CI Continuous Integration labels Mar 14, 2025
@vszakats vszakats marked this pull request as ready for review March 14, 2025 10:41
vszakats added a commit that referenced this pull request Mar 14, 2025
It seems unnecessary and possibly unexpected to build test servers with
debug-enabled features and memory tracking whenever the tested curl is
built like that (which is a requirement for some tests, so curl is
mostly built like that when running tests.) It also makes building
servers a little bit faster with cmake for the most common cases.

You can apply debug options to `tests/server` with these new options:
- `./configure`: `--enable-server-debug`.
- cmake: `-DENABLE_SERVER_DEBUG`.

Also sync the way we pass these macros in autotools, with CMake builds.
Before this patch, autotools passed them via `curl_config.h`. After this
patch it passes them on the command-line, like cmake builds do.

This patch also make these option no longer passed to examples and
`http/client` in cmake builds, where they were no-ops anyway.

Ref: #15000
Closes #16705
mk-bundle.pl: add .c extension if missing
fixup socket_domain differently, drop unused enum type'
mk-bundle.pl: drop deduped macros/variables/functions
mk-bundle.pl: improve readability of generated code
move script to server
mk-bundle.pl: add support for raw curl source (to support autotools "unity")
mk-bundle: make p_mains static
reshuffle first.c use
first: make p_mains static
When non-bundled, the server source is included last. This is important
for unity builds because server global variables cannot shadow libcurl
function parameters and local variables.

Keep this order when doing bundles to avoid triggering more -Wshadow
warnings than otherwise.

Makefile.inc: move CURLDEBUG-dependent sources to MEMDEBUG
Makefile.inc: fixup for non-bundle builds
cm: move CURLDEBUG-dependent sources to MEMDEBUG
cm: make p_mains static
add first.c, first.h to dist
keep resolve tool out of servers

Reason is that it's called from data/test* modules where conditionally
executing either `server/servers disabled` or `server/disabled`
depending on build settings would be problematic.

do not checksrc generated bundle source
am: keep the origin order of sources
Makefile.am: do unity when doing bundle
Makefile.am: move first.c last as in cmake
am: make p_mains static
Makefile.am: add FIRSTFILES to distro
@vszakats
Copy link
Member Author

vszakats commented Mar 15, 2025

I plan to merge this tomorrow if no objections (and if I finish in time
with the performance gain table.)

It's extending the existing test bundle feature, that is disabled by
default. The patch touches the non-bundle build path minimally, for
the test targets.

@vszakats vszakats closed this in f4f2550 Mar 16, 2025
@vszakats vszakats deleted the server-bundle branch March 16, 2025 13:04
vszakats added a commit to vszakats/curl that referenced this pull request Mar 17, 2025
If libtests, units and servers binaries are all present, auto-enable
bundle mode.

Drop manual runtests option.

Also fix to append executable extension to `libtests` and `units`
executables when launching them.

Follow-up to f4f2550 curl#15000
Follow-up to 71cf0d1 curl#14772
vszakats added a commit to vszakats/curl that referenced this pull request Mar 17, 2025
If libtests, units and servers binaries are all present, auto-enable
bundle mode.

Drop manual runtests option.

Also fix to append executable extension to `libtests` and `units`
executables when launching them.

Follow-up to f4f2550 curl#15000
Follow-up to 71cf0d1 curl#14772
vszakats added a commit to vszakats/curl that referenced this pull request Mar 17, 2025
If libtests, units and servers binaries are all present, auto-enable
bundle mode.

Drop manual runtests option.

Also fix to append executable extension to `libtests` and `units`
executables when launching them.

Follow-up to f4f2550 curl#15000
Follow-up to 71cf0d1 curl#14772
vszakats added a commit to vszakats/curl that referenced this pull request Mar 17, 2025
If libtests, units and servers binaries are all present, auto-enable
bundle mode.

Drop manual runtests option.

Also fix to append executable extension to `libtests` and `units`
executables when launching them.

Follow-up to f4f2550 curl#15000
Follow-up to 71cf0d1 curl#14772
@vszakats
Copy link
Member Author

Here are two CI run with and without test bundles enabled:

without: https://github.com/curl/curl/actions/runs/13909934284
with: https://github.com/curl/curl/actions/runs/13909397643

Some examples:

Cygwin AM: 10m1 vs 1m32 (6.5x)
Cygwin CM: 1m27 vs 28s
mingw, CM clang-x86_64 gnutls: 1m4 vs 6s
dl-mingw, CM R Ninja: 3m33 vs 1m36
dl-mingw, CM R Make: 1m47 vs 25
dl-mingw, CM D Make !unity: 2m41 vs 30s
linux-mingw CM: 1m2s 10s
MSVC CM: 3m32 vs 11s (20x)

For MSVC it's a 20x reduction, others are also pretty good.

vszakats added a commit that referenced this pull request Mar 18, 2025
If libtests, units and servers binaries are all present, auto-enable
bundle mode.

Drop manual runtests option.

Note: Make sure to "make clean" before changing the test bundle build
setting.

Also fix to append executable extension to all libtest and unit test
executables when launching them. This should make it a tiny bit faster
on Windows.

Follow-up to f4f2550 #15000
Follow-up to 71cf0d1 #14772

Closes #16750
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant