mirror of
https://github.com/curl/curl.git
synced 2026-07-26 13:57:57 +03:00
tests: separate tunit tests from unit tests more
- unit tests need no tool code as they are libcurl unit tests - unit test 1621 is now tunit test 1621 instead, as it tests tool code - build unit tests with BUILDING_LIBCURL as they pretent to be libcurl Closes #17259
This commit is contained in:
parent
2e49965126
commit
220eda34cd
7 changed files with 12 additions and 9 deletions
|
|
@ -39,6 +39,9 @@ if(CURL_TEST_BUNDLES)
|
|||
set(units_SOURCES "unit_bundle.c")
|
||||
endif()
|
||||
|
||||
# unit tests are small pretend-libcurl-programs
|
||||
list(APPEND CURL_DEBUG_MACROS "BUILDING_LIBCURL")
|
||||
|
||||
foreach(_target IN LISTS UNITPROGS)
|
||||
set(_target_name "${_target}")
|
||||
add_executable(${_target_name} EXCLUDE_FROM_ALL ${${_target}_SOURCES})
|
||||
|
|
|
|||
|
|
@ -46,11 +46,10 @@ CFLAGS += @CURL_CFLAG_EXTRAS@
|
|||
# Prevent LIBS from being used for all link targets
|
||||
LIBS = $(BLANK_AT_MAKETIME)
|
||||
|
||||
LDADD = $(top_builddir)/src/libcurltool.la \
|
||||
$(top_builddir)/lib/libcurlu.la \
|
||||
LDADD = $(top_builddir)/lib/libcurlu.la \
|
||||
@LIBCURL_PC_LDFLAGS_PRIVATE@ @LIBCURL_PC_LIBS_PRIVATE@
|
||||
|
||||
AM_CPPFLAGS += -DCURL_STATICLIB -DUNITTESTS
|
||||
AM_CPPFLAGS += -DCURL_STATICLIB -DUNITTESTS -DBUILDING_LIBCURL
|
||||
if DEBUGBUILD
|
||||
AM_CPPFLAGS += -DDEBUGBUILD
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ UNITPROGS = unit1300 unit1302 unit1303 unit1304 unit1305 unit1307 \
|
|||
unit1399 \
|
||||
unit1600 unit1601 unit1602 unit1603 unit1605 unit1606 unit1607 \
|
||||
unit1608 unit1609 unit1610 unit1611 unit1612 unit1614 unit1615 unit1616 \
|
||||
unit1620 unit1621 \
|
||||
unit1620 \
|
||||
unit1650 unit1651 unit1652 unit1653 unit1654 unit1655 unit1656 unit1657 \
|
||||
unit1658 \
|
||||
unit1660 unit1661 unit1663 unit1664 \
|
||||
|
|
@ -106,8 +106,6 @@ unit1616_SOURCES = unit1616.c $(UNITFILES)
|
|||
|
||||
unit1620_SOURCES = unit1620.c $(UNITFILES)
|
||||
|
||||
unit1621_SOURCES = unit1621.c $(UNITFILES)
|
||||
|
||||
unit1650_SOURCES = unit1650.c $(UNITFILES)
|
||||
|
||||
unit1651_SOURCES = unit1651.c $(UNITFILES)
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "url.h"
|
||||
|
||||
#include "memdebug.h" /* LAST include file */
|
||||
|
||||
static CURLcode unit_setup(void)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static void unit_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__) || \
|
||||
(!defined(HAVE_FSETXATTR) && \
|
||||
(!defined(__FreeBSD_version) || (__FreeBSD_version < 500000)))
|
||||
UNITTEST_START
|
||||
UNITTEST_STOP
|
||||
#else
|
||||
|
||||
char *stripcredentials(const char *url);
|
||||
|
||||
struct checkthis {
|
||||
const char *input;
|
||||
const char *output;
|
||||
};
|
||||
|
||||
static const struct checkthis tests[] = {
|
||||
{ "ninja://foo@example.com", "ninja://foo@example.com" },
|
||||
{ "https://foo@example.com", "https://example.com/" },
|
||||
{ "https://localhost:45", "https://localhost:45/" },
|
||||
{ "https://foo@localhost:45", "https://localhost:45/" },
|
||||
{ "http://daniel:password@localhost", "http://localhost/" },
|
||||
{ "http://daniel@localhost", "http://localhost/" },
|
||||
{ "http://localhost/", "http://localhost/" },
|
||||
{ NULL, NULL } /* end marker */
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; tests[i].input; i++) {
|
||||
const char *url = tests[i].input;
|
||||
char *stripped = stripcredentials(url);
|
||||
printf("Test %u got input \"%s\", output: \"%s\"\n",
|
||||
i, tests[i].input, stripped);
|
||||
|
||||
fail_if(stripped && strcmp(tests[i].output, stripped),
|
||||
tests[i].output);
|
||||
curl_free(stripped);
|
||||
}
|
||||
}
|
||||
UNITTEST_STOP
|
||||
#endif
|
||||
|
|
@ -22,8 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "curlcheck.h"
|
||||
/* disable the curlx_get_line redefinitions for this unit test */
|
||||
#define BUILDING_LIBCURL
|
||||
#include "curl_get_line.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue