mirror of
https://github.com/curl/curl.git
synced 2026-08-25 02:23:31 +03:00
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:
parent
1cdac95e2e
commit
2c27a67daa
386 changed files with 2996 additions and 4164 deletions
|
|
@ -21,9 +21,6 @@
|
|||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "test.h"
|
||||
#include "first.h"
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
# include <locale.h> /* for setlocale() */
|
||||
#endif
|
||||
|
|
@ -120,9 +117,10 @@ int main(int argc, char **argv)
|
|||
{
|
||||
char *URL;
|
||||
CURLcode result;
|
||||
int basearg;
|
||||
test_func_t test_func;
|
||||
entry_func_t entry_func;
|
||||
char *entry_name;
|
||||
char *env;
|
||||
size_t tmp;
|
||||
|
||||
CURL_SET_BINMODE(stdout);
|
||||
|
||||
|
|
@ -137,61 +135,38 @@ int main(int argc, char **argv)
|
|||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
test_argc = argc;
|
||||
test_argv = argv;
|
||||
test_argc = argc - 1;
|
||||
test_argv = argv + 1;
|
||||
|
||||
#ifdef CURLTESTS_BUNDLED
|
||||
{
|
||||
char *test_name;
|
||||
|
||||
--test_argc;
|
||||
++test_argv;
|
||||
|
||||
basearg = 2;
|
||||
|
||||
if(argc < (basearg + 1)) {
|
||||
curl_mfprintf(stderr, "Pass testname and URL as arguments please\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
test_name = argv[basearg - 1];
|
||||
test_func = NULL;
|
||||
{
|
||||
size_t tmp;
|
||||
for(tmp = 0; tmp < CURL_ARRAYSIZE(s_tests); ++tmp) {
|
||||
if(strcmp(test_name, s_tests[tmp].name) == 0) {
|
||||
test_func = s_tests[tmp].ptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!test_func) {
|
||||
curl_mfprintf(stderr, "Test '%s' not found.\n", test_name);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
basearg = 1;
|
||||
|
||||
if(argc < (basearg + 1)) {
|
||||
curl_mfprintf(stderr, "Pass URL as argument please\n");
|
||||
if(argc < 3) {
|
||||
curl_mfprintf(stderr, "Pass testname and URL as arguments please\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
test_func = test;
|
||||
#endif
|
||||
entry_name = argv[1];
|
||||
entry_func = NULL;
|
||||
for(tmp = 0; tmp < CURL_ARRAYSIZE(s_entries); ++tmp) {
|
||||
if(strcmp(entry_name, s_entries[tmp].name) == 0) {
|
||||
entry_func = s_entries[tmp].ptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(argc > (basearg + 1))
|
||||
libtest_arg2 = argv[basearg + 1];
|
||||
if(!entry_func) {
|
||||
curl_mfprintf(stderr, "Test '%s' not found.\n", entry_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(argc > (basearg + 2))
|
||||
libtest_arg3 = argv[basearg + 2];
|
||||
if(argc > 3)
|
||||
libtest_arg2 = argv[3];
|
||||
|
||||
if(argc > (basearg + 2))
|
||||
libtest_arg4 = argv[basearg + 3];
|
||||
if(argc > 4)
|
||||
libtest_arg3 = argv[4];
|
||||
|
||||
URL = argv[basearg]; /* provide this to the rest */
|
||||
if(argc > 5)
|
||||
libtest_arg4 = argv[5];
|
||||
|
||||
URL = argv[2]; /* provide this to the rest */
|
||||
|
||||
env = getenv("CURL_TESTNUM");
|
||||
if(env)
|
||||
|
|
@ -201,7 +176,7 @@ int main(int argc, char **argv)
|
|||
|
||||
curl_mfprintf(stderr, "URL: %s\n", URL);
|
||||
|
||||
result = test_func(URL);
|
||||
result = entry_func(URL);
|
||||
curl_mfprintf(stderr, "Test ended with result %d\n", result);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue