tests: always make bundles, adapt build and tests

Make test bundles the default. Drop non-bundle build mode.
Also do all the optimizations and tidy-ups this allows, simpler builds,
less bundle exceptions, streamlined build mechanics.

Also rework the init/deinit macro magic for unit tests. The new method
allows using unique init/deinit function names, and calling them with
arguments. This is in turn makes it possible to reduce the use of global
variables.

Note this drop existing build options `-DCURL_TEST_BUNDLES=` from cmake
and `--enable-test-bundles` / `--disable-test-bundles` from autotools.

Also:
- rename test entry functions to have unique names: `test_<testname>`
  This removes the last exception that was handled in the generator.
- fix `make dist` to not miss test sources with test bundles enabled.
- sync and merge `tests/mk-bundle.pl` into `scripts/mk-unity.pl`.
- mk-unity.pl: add `--embed` option and use it when `CURL_CLANG_TIDY=ON`
  to ensure that `clang-tidy` does not miss external test C sources.
  (because `clang-tidy` ignores code that's #included.)
- tests/unit: drop no-op setup/stop functions.
- tests: reduce symbol scopes, global macros, other fixes and tidy-ups.
- tool1621: fix to run, also fix it to pass.
- sockfilt: fix Windows compiler warning in certain unity include order,
  by explicitly including `warnless.h`.

Follow-up to 6897aeb105 #17468

Closes #17590
This commit is contained in:
Viktor Szakats 2025-06-11 11:31:14 +02:00
parent 1cdac95e2e
commit 2c27a67daa
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
386 changed files with 2996 additions and 4164 deletions

View file

@ -40,24 +40,17 @@
#include "memdebug.h" /* LAST include file */
static struct Curl_easy *t1305_easy;
static struct Curl_dnscache hp;
static char *data_key;
static struct Curl_dns_entry *data_node;
static CURLcode unit_setup(void)
static CURLcode t1305_setup(void)
{
t1305_easy = curl_easy_init();
if(!t1305_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
Curl_dnscache_init(&hp, 7);
return CURLE_OK;
}
static void unit_stop(void)
static void t1305_stop(void)
{
if(data_node) {
Curl_freeaddrinfo(data_node->addr);
@ -65,15 +58,12 @@ static void unit_stop(void)
}
free(data_key);
Curl_dnscache_destroy(&hp);
curl_easy_cleanup(t1305_easy);
curl_global_cleanup();
}
static struct Curl_addrinfo *fake_ai(void)
{
static struct Curl_addrinfo *ai;
static const char dummy[]="dummy";
static const char dummy[] = "dummy";
size_t namelen = sizeof(dummy); /* including the null-terminator */
ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_in) +
@ -109,14 +99,15 @@ static CURLcode create_node(void)
return CURLE_OK;
}
UNITTEST_START
static CURLcode test_unit1305(char *arg)
{
UNITTEST_BEGIN(t1305_setup())
struct Curl_dns_entry *nodep;
size_t key_len;
/* Test 1305 exits without adding anything to the hash */
if(strcmp(arg, "1305") != 0) {
if(testnum == 1306) {
CURLcode rc = create_node();
abort_unless(rc == CURLE_OK, "data node creation failed");
key_len = strlen(data_key);
@ -128,4 +119,5 @@ UNITTEST_START
data_node = NULL;
}
UNITTEST_STOP
UNITTEST_END(t1305_stop())
}