mirror of
https://github.com/curl/curl.git
synced 2026-08-25 22:23:53 +03:00
unittests: cleanups
- make sure all UNITTEST prototypes mark in which unit test they are used, with "@unittest" markup - make sure all UNITTEST functions do not use Curl_ prefix, as that is a prefix we use for global private functions and these functions are static and therefore not global and the prefix is wrong - drop UNITTEST for functions not used in unit tests - make the extract-unit-protos script highlight the above issues if found - extract-unit-protos now also outputs the unit test number for all the generated protos in lib/unitprotos.h to aid readers. It also adds the source file and line number where the proto originates from. - extract-unit-protos now exits with a non-zero value if any of the above warnings are triggered - cf-dns: Curl_cf_dns_result => static cf_dns_result - hostip: Curl_ipv6works => static ipv6works - url: remove Curl_setup_conn() - not used anymore - connect: Curl_timeleft_now_ms => UNITTEST timeleft_now_ms Closes #21330
This commit is contained in:
parent
94f14c54b0
commit
7fd35f4c34
36 changed files with 248 additions and 216 deletions
|
|
@ -487,7 +487,7 @@ CURLcode Curl_cf_dns_insert_after(struct Curl_cfilter *cf_at,
|
|||
/* Return the resolv result from the first "resolv" filter, starting
|
||||
* the given filter `cf` downwards.
|
||||
*/
|
||||
CURLcode Curl_cf_dns_result(struct Curl_cfilter *cf)
|
||||
static CURLcode cf_dns_result(struct Curl_cfilter *cf)
|
||||
{
|
||||
for(; cf; cf = cf->next) {
|
||||
if(cf->cft == &Curl_cft_dns) {
|
||||
|
|
@ -509,7 +509,7 @@ CURLcode Curl_cf_dns_result(struct Curl_cfilter *cf)
|
|||
*/
|
||||
CURLcode Curl_conn_dns_result(struct connectdata *conn, int sockindex)
|
||||
{
|
||||
return Curl_cf_dns_result(conn->cfilter[sockindex]);
|
||||
return cf_dns_result(conn->cfilter[sockindex]);
|
||||
}
|
||||
|
||||
static const struct Curl_addrinfo *cf_dns_get_nth_ai(
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ CURLcode Curl_cf_dns_insert_after(struct Curl_cfilter *cf_at,
|
|||
bool complete_resolve);
|
||||
|
||||
CURLcode Curl_conn_dns_result(struct connectdata *conn, int sockindex);
|
||||
CURLcode Curl_cf_dns_result(struct Curl_cfilter *cf);
|
||||
|
||||
/* Returns TRUE if any addressinfo is available via
|
||||
* `Curl_conn_dns_get_ai()`. */
|
||||
|
|
|
|||
|
|
@ -92,10 +92,10 @@ static cf_ip_connect_create *get_cf_create(uint8_t transport)
|
|||
}
|
||||
|
||||
#ifdef UNITTESTS
|
||||
/* used by unit2600.c */
|
||||
UNITTEST void Curl_debug_set_transport_provider(
|
||||
/* @unittest 2600 */
|
||||
UNITTEST void debug_set_transport_provider(
|
||||
uint8_t transport, cf_ip_connect_create *cf_create);
|
||||
UNITTEST void Curl_debug_set_transport_provider(
|
||||
UNITTEST void debug_set_transport_provider(
|
||||
uint8_t transport, cf_ip_connect_create *cf_create)
|
||||
{
|
||||
size_t i;
|
||||
|
|
|
|||
|
|
@ -34,11 +34,9 @@
|
|||
#include "curlx/strparse.h"
|
||||
|
||||
#ifdef UNITTESTS
|
||||
/* used by unit2600.c */
|
||||
UNITTEST void Curl_cf_def_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data);
|
||||
UNITTEST void Curl_cf_def_close(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
/* @unittest 2600 */
|
||||
UNITTEST void cf_def_close(struct Curl_cfilter *cf, struct Curl_easy *data);
|
||||
UNITTEST void cf_def_close(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
{
|
||||
cf->connected = FALSE;
|
||||
if(cf->next)
|
||||
|
|
|
|||
|
|
@ -97,14 +97,17 @@ enum alpnid Curl_str2alpnid(const struct Curl_str *cstr)
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Curl_timeleft_ms() returns the amount of milliseconds left allowed for the
|
||||
* timeleft_now_ms() returns the amount of milliseconds left allowed for the
|
||||
* transfer/connection. If the value is 0, there is no timeout (ie there is
|
||||
* infinite time left). If the value is negative, the timeout time has already
|
||||
* elapsed.
|
||||
* @unittest: 1303
|
||||
*
|
||||
* @unittest 1303
|
||||
*/
|
||||
timediff_t Curl_timeleft_now_ms(struct Curl_easy *data,
|
||||
const struct curltime *pnow)
|
||||
UNITTEST timediff_t timeleft_now_ms(struct Curl_easy *data,
|
||||
const struct curltime *pnow);
|
||||
UNITTEST timediff_t timeleft_now_ms(struct Curl_easy *data,
|
||||
const struct curltime *pnow)
|
||||
{
|
||||
timediff_t timeleft_ms = 0;
|
||||
timediff_t ctimeleft_ms = 0;
|
||||
|
|
@ -139,7 +142,7 @@ timediff_t Curl_timeleft_now_ms(struct Curl_easy *data,
|
|||
|
||||
timediff_t Curl_timeleft_ms(struct Curl_easy *data)
|
||||
{
|
||||
return Curl_timeleft_now_ms(data, Curl_pgrs_now(data));
|
||||
return timeleft_now_ms(data, Curl_pgrs_now(data));
|
||||
}
|
||||
|
||||
void Curl_shutdown_start(struct Curl_easy *data, int sockindex,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
***************************************************************************/
|
||||
#include "curl_setup.h"
|
||||
|
||||
#include "hostip.h"
|
||||
#include "curlx/timeval.h"
|
||||
|
||||
struct Curl_dns_entry;
|
||||
|
|
@ -37,8 +38,6 @@ enum alpnid Curl_str2alpnid(const struct Curl_str *cstr);
|
|||
/* generic function that returns how much time there is left to run, according
|
||||
to the timeouts set */
|
||||
timediff_t Curl_timeleft_ms(struct Curl_easy *data);
|
||||
timediff_t Curl_timeleft_now_ms(struct Curl_easy *data,
|
||||
const struct curltime *pnow);
|
||||
|
||||
#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
|
||||
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ static int num_addresses(const struct Curl_addrinfo *addr)
|
|||
}
|
||||
|
||||
/*
|
||||
* Curl_shuffle_addr() shuffles the order of addresses in a 'Curl_addrinfo'
|
||||
* dns_shuffle_addr() shuffles the order of addresses in a 'Curl_addrinfo'
|
||||
* struct by re-linking its linked list.
|
||||
*
|
||||
* The addr argument should be the address of a pointer to the head node of a
|
||||
|
|
@ -339,12 +339,12 @@ static int num_addresses(const struct Curl_addrinfo *addr)
|
|||
*
|
||||
* Not declared static only to make it easy to use in a unit test!
|
||||
*
|
||||
* @unittest: 1608
|
||||
* @unittest 1608
|
||||
*/
|
||||
UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
||||
struct Curl_addrinfo **addr);
|
||||
UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
||||
struct Curl_addrinfo **addr)
|
||||
UNITTEST CURLcode dns_shuffle_addr(struct Curl_easy *data,
|
||||
struct Curl_addrinfo **addr);
|
||||
UNITTEST CURLcode dns_shuffle_addr(struct Curl_easy *data,
|
||||
struct Curl_addrinfo **addr)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
const int num_addrs = num_addresses(*addr);
|
||||
|
|
@ -464,7 +464,7 @@ static struct Curl_dns_entry *dnscache_entry_create(
|
|||
#ifndef CURL_DISABLE_SHUFFLE_DNS
|
||||
/* shuffle addresses if requested */
|
||||
if(data->set.dns_shuffle_addresses && dns->addr) {
|
||||
CURLcode result = Curl_shuffle_addr(data, &dns->addr);
|
||||
CURLcode result = dns_shuffle_addr(data, &dns->addr);
|
||||
if(result) {
|
||||
/* free without lock, we are the sole owner */
|
||||
dnscache_entry_free(dns);
|
||||
|
|
|
|||
10
lib/doh.c
10
lib/doh.c
|
|
@ -714,6 +714,7 @@ static DOHcode doh_rdata(const unsigned char *doh,
|
|||
return DOH_OK;
|
||||
}
|
||||
|
||||
/* @unittest 1655 */
|
||||
UNITTEST void de_init(struct dohentry *de);
|
||||
UNITTEST void de_init(struct dohentry *de)
|
||||
{
|
||||
|
|
@ -724,6 +725,7 @@ UNITTEST void de_init(struct dohentry *de)
|
|||
curlx_dyn_init(&de->cname[i], DYN_DOH_CNAME);
|
||||
}
|
||||
|
||||
/* @unittest 1655 */
|
||||
UNITTEST DOHcode doh_resp_decode(const unsigned char *doh,
|
||||
size_t dohlen,
|
||||
DNStype dnstype,
|
||||
|
|
@ -1045,6 +1047,7 @@ static const char *doh_type2name(DNStype dnstype)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* @unittest 1655 */
|
||||
UNITTEST void de_cleanup(struct dohentry *d);
|
||||
UNITTEST void de_cleanup(struct dohentry *d)
|
||||
{
|
||||
|
|
@ -1177,11 +1180,8 @@ err:
|
|||
}
|
||||
|
||||
#if defined(DEBUGBUILD) && defined(CURLVERBOSE)
|
||||
UNITTEST void doh_print_httpsrr(struct Curl_easy *data,
|
||||
struct Curl_https_rrinfo *hrr);
|
||||
|
||||
UNITTEST void doh_print_httpsrr(struct Curl_easy *data,
|
||||
struct Curl_https_rrinfo *hrr)
|
||||
static void doh_print_httpsrr(struct Curl_easy *data,
|
||||
struct Curl_https_rrinfo *hrr)
|
||||
{
|
||||
DEBUGASSERT(hrr);
|
||||
infof(data, "HTTPS RR: priority %d, target: %s", hrr->priority, hrr->target);
|
||||
|
|
|
|||
68
lib/dynhds.c
68
lib/dynhds.c
|
|
@ -220,33 +220,36 @@ CURLcode Curl_dynhds_h1_cadd_line(struct dynhds *dynhds, const char *line)
|
|||
}
|
||||
|
||||
#ifdef UNITTESTS
|
||||
/* used by unit2602.c */
|
||||
/* @unittest 2602 */
|
||||
|
||||
/**
|
||||
* Return TRUE iff one or more headers with the given name exist.
|
||||
*/
|
||||
UNITTEST bool Curl_dynhds_contains(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen);
|
||||
UNITTEST bool Curl_dynhds_contains(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen)
|
||||
UNITTEST bool dynhds_contains(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen);
|
||||
UNITTEST bool dynhds_contains(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen)
|
||||
{
|
||||
return !!Curl_dynhds_get(dynhds, name, namelen);
|
||||
}
|
||||
|
||||
UNITTEST bool Curl_dynhds_ccontains(struct dynhds *dynhds, const char *name);
|
||||
UNITTEST bool Curl_dynhds_ccontains(struct dynhds *dynhds, const char *name)
|
||||
/* @unittest 2602 */
|
||||
UNITTEST bool dynhds_ccontains(struct dynhds *dynhds, const char *name);
|
||||
UNITTEST bool dynhds_ccontains(struct dynhds *dynhds, const char *name)
|
||||
{
|
||||
return Curl_dynhds_contains(dynhds, name, strlen(name));
|
||||
return dynhds_contains(dynhds, name, strlen(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how often the given name appears in `dynhds`.
|
||||
* Names are case-insensitive.
|
||||
*
|
||||
* @unittest 2602
|
||||
*/
|
||||
UNITTEST size_t Curl_dynhds_count_name(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen);
|
||||
UNITTEST size_t Curl_dynhds_count_name(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen)
|
||||
UNITTEST size_t dynhds_count_name(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen);
|
||||
UNITTEST size_t dynhds_count_name(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen)
|
||||
{
|
||||
size_t n = 0;
|
||||
if(dynhds->hds_len) {
|
||||
|
|
@ -263,23 +266,27 @@ UNITTEST size_t Curl_dynhds_count_name(struct dynhds *dynhds,
|
|||
/**
|
||||
* Return how often the given null-terminated name appears in `dynhds`.
|
||||
* Names are case-insensitive.
|
||||
*
|
||||
* @unittest 2602
|
||||
*/
|
||||
UNITTEST size_t Curl_dynhds_ccount_name(struct dynhds *dynhds,
|
||||
UNITTEST size_t dynhds_ccount_name(struct dynhds *dynhds,
|
||||
const char *name);
|
||||
UNITTEST size_t Curl_dynhds_ccount_name(struct dynhds *dynhds,
|
||||
UNITTEST size_t dynhds_ccount_name(struct dynhds *dynhds,
|
||||
const char *name)
|
||||
{
|
||||
return Curl_dynhds_count_name(dynhds, name, strlen(name));
|
||||
return dynhds_count_name(dynhds, name, strlen(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all entries with the given name.
|
||||
* Returns number of entries removed.
|
||||
*
|
||||
* @unittest 2602
|
||||
*/
|
||||
UNITTEST size_t Curl_dynhds_remove(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen);
|
||||
UNITTEST size_t Curl_dynhds_remove(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen)
|
||||
UNITTEST size_t dynhds_remove(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen);
|
||||
UNITTEST size_t dynhds_remove(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen)
|
||||
{
|
||||
size_t n = 0;
|
||||
if(dynhds->hds_len) {
|
||||
|
|
@ -308,22 +315,25 @@ UNITTEST size_t Curl_dynhds_remove(struct dynhds *dynhds,
|
|||
* Set the give header name and value, replacing any entries with
|
||||
* the same name. The header is added at the end of all (remaining)
|
||||
* entries.
|
||||
*
|
||||
* @unittest 2602
|
||||
*/
|
||||
UNITTEST CURLcode Curl_dynhds_set(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen,
|
||||
const char *value, size_t valuelen);
|
||||
UNITTEST CURLcode Curl_dynhds_set(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen,
|
||||
const char *value, size_t valuelen)
|
||||
UNITTEST CURLcode dynhds_set(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen,
|
||||
const char *value, size_t valuelen);
|
||||
UNITTEST CURLcode dynhds_set(struct dynhds *dynhds,
|
||||
const char *name, size_t namelen,
|
||||
const char *value, size_t valuelen)
|
||||
{
|
||||
Curl_dynhds_remove(dynhds, name, namelen);
|
||||
dynhds_remove(dynhds, name, namelen);
|
||||
return Curl_dynhds_add(dynhds, name, namelen, value, valuelen);
|
||||
}
|
||||
|
||||
UNITTEST size_t Curl_dynhds_cremove(struct dynhds *dynhds, const char *name);
|
||||
UNITTEST size_t Curl_dynhds_cremove(struct dynhds *dynhds, const char *name)
|
||||
/* @unittest 2602 */
|
||||
UNITTEST size_t dynhds_cremove(struct dynhds *dynhds, const char *name);
|
||||
UNITTEST size_t dynhds_cremove(struct dynhds *dynhds, const char *name)
|
||||
{
|
||||
return Curl_dynhds_remove(dynhds, name, strlen(name));
|
||||
return dynhds_remove(dynhds, name, strlen(name));
|
||||
}
|
||||
|
||||
#endif /* UNITTESTS */
|
||||
|
|
|
|||
|
|
@ -2505,7 +2505,7 @@ static bool twodigit(const char *p, int *val)
|
|||
}
|
||||
|
||||
/*
|
||||
* Unittest @1668
|
||||
* @unittest 1668
|
||||
*/
|
||||
UNITTEST bool ftp_213_date(const char *p, int *year, int *month, int *day,
|
||||
int *hour, int *minute, int *second);
|
||||
|
|
|
|||
17
lib/hostip.c
17
lib/hostip.c
|
|
@ -74,6 +74,15 @@
|
|||
|
||||
#define MAX_DNS_CACHE_SIZE 29999
|
||||
|
||||
/*
|
||||
* ipv6works() returns TRUE if IPv6 seems to work.
|
||||
*/
|
||||
#ifdef USE_IPV6
|
||||
static bool ipv6works(struct Curl_easy *data);
|
||||
#else
|
||||
#define ipv6works(x) FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* hostip.c explained
|
||||
* ==================
|
||||
|
|
@ -120,7 +129,7 @@ uint8_t Curl_resolv_dns_queries(struct Curl_easy *data, uint8_t ip_version)
|
|||
case CURL_IPRESOLVE_V4:
|
||||
return CURL_DNSQ_A;
|
||||
default:
|
||||
if(Curl_ipv6works(data))
|
||||
if(ipv6works(data))
|
||||
return (CURL_DNSQ_A | CURL_DNSQ_AAAA);
|
||||
else
|
||||
return CURL_DNSQ_A;
|
||||
|
|
@ -292,9 +301,9 @@ CURLcode Curl_probeipv6(struct Curl_multi *multi)
|
|||
}
|
||||
|
||||
/*
|
||||
* Curl_ipv6works() returns TRUE if IPv6 seems to work.
|
||||
* ipv6works() returns TRUE if IPv6 seems to work.
|
||||
*/
|
||||
bool Curl_ipv6works(struct Curl_easy *data)
|
||||
static bool ipv6works(struct Curl_easy *data)
|
||||
{
|
||||
DEBUGASSERT(data);
|
||||
DEBUGASSERT(data->multi);
|
||||
|
|
@ -334,7 +343,7 @@ static bool can_resolve_dns_queries(struct Curl_easy *data,
|
|||
uint8_t dns_queries)
|
||||
{
|
||||
(void)data;
|
||||
if((CURL_DNSQ_IP(dns_queries) == CURL_DNSQ_AAAA) && !Curl_ipv6works(data))
|
||||
if((CURL_DNSQ_IP(dns_queries) == CURL_DNSQ_AAAA) && !ipv6works(data))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,16 +71,10 @@ enum alpnid {
|
|||
bool Curl_host_is_ipnum(const char *hostname);
|
||||
|
||||
#ifdef USE_IPV6
|
||||
|
||||
/* probe if it seems to work */
|
||||
CURLcode Curl_probeipv6(struct Curl_multi *multi);
|
||||
/*
|
||||
* Curl_ipv6works() returns TRUE if IPv6 seems to work.
|
||||
*/
|
||||
bool Curl_ipv6works(struct Curl_easy *data);
|
||||
#else
|
||||
#define Curl_probeipv6(x) CURLE_OK
|
||||
#define Curl_ipv6works(x) FALSE
|
||||
#endif
|
||||
|
||||
/* IPv4 thread-safe resolve function used for synch and asynch builds */
|
||||
|
|
|
|||
|
|
@ -679,6 +679,7 @@ static int compare_func(const void *a, const void *b)
|
|||
return compare;
|
||||
}
|
||||
|
||||
/* @unittest 1979 */
|
||||
UNITTEST CURLcode canon_path(const char *q, size_t len,
|
||||
struct dynbuf *new_path,
|
||||
bool do_uri_encode);
|
||||
|
|
@ -708,6 +709,7 @@ UNITTEST CURLcode canon_path(const char *q, size_t len,
|
|||
return result;
|
||||
}
|
||||
|
||||
/* @unittest 1980 */
|
||||
UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq);
|
||||
UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq)
|
||||
{
|
||||
|
|
|
|||
38
lib/llist.c
38
lib/llist.c
|
|
@ -40,7 +40,7 @@ static struct Curl_llist_node *verifynode(struct Curl_llist_node *n)
|
|||
#define VERIFYNODE(x) x
|
||||
#endif
|
||||
/*
|
||||
* @unittest: 1300
|
||||
* @unittest 1300
|
||||
*/
|
||||
void Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
|
||||
{
|
||||
|
|
@ -62,7 +62,7 @@ void Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
|
|||
*
|
||||
* The 'ne' argument should be a pointer into the object to store.
|
||||
*
|
||||
* @unittest: 1300
|
||||
* @unittest 1300
|
||||
*/
|
||||
void Curl_llist_insert_next(struct Curl_llist *list,
|
||||
struct Curl_llist_node *e, /* may be NULL */
|
||||
|
|
@ -112,7 +112,7 @@ void Curl_llist_insert_next(struct Curl_llist *list,
|
|||
*
|
||||
* The 'ne' argument should be a pointer into the object to store.
|
||||
*
|
||||
* @unittest: 1300
|
||||
* @unittest 1300
|
||||
*/
|
||||
void Curl_llist_append(struct Curl_llist *list, const void *p,
|
||||
struct Curl_llist_node *ne)
|
||||
|
|
@ -168,11 +168,7 @@ void *Curl_node_take_elem(struct Curl_llist_node *e)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unittest: 1300
|
||||
*/
|
||||
UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user);
|
||||
UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user)
|
||||
static void node_uremove(struct Curl_llist_node *e, void *user)
|
||||
{
|
||||
struct Curl_llist *list;
|
||||
void *ptr;
|
||||
|
|
@ -190,7 +186,7 @@ UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user)
|
|||
|
||||
void Curl_node_remove(struct Curl_llist_node *e)
|
||||
{
|
||||
Curl_node_uremove(e, NULL);
|
||||
node_uremove(e, NULL);
|
||||
}
|
||||
|
||||
void Curl_llist_destroy(struct Curl_llist *list, void *user)
|
||||
|
|
@ -198,7 +194,7 @@ void Curl_llist_destroy(struct Curl_llist *list, void *user)
|
|||
if(list) {
|
||||
DEBUGASSERT(list->_init == LLISTINIT);
|
||||
while(list->_size > 0)
|
||||
Curl_node_uremove(list->_tail, user);
|
||||
node_uremove(list->_tail, user);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,10 +208,13 @@ struct Curl_llist_node *Curl_llist_head(struct Curl_llist *list)
|
|||
}
|
||||
|
||||
#ifdef UNITTESTS
|
||||
/* Curl_llist_tail() returns the last 'struct Curl_llist_node *', which
|
||||
might be NULL */
|
||||
UNITTEST struct Curl_llist_node *Curl_llist_tail(struct Curl_llist *list);
|
||||
UNITTEST struct Curl_llist_node *Curl_llist_tail(struct Curl_llist *list)
|
||||
/* llist_tail() returns the last 'struct Curl_llist_node *', which might be
|
||||
NULL
|
||||
|
||||
@unittest 1300
|
||||
*/
|
||||
UNITTEST struct Curl_llist_node *llist_tail(struct Curl_llist *list);
|
||||
UNITTEST struct Curl_llist_node *llist_tail(struct Curl_llist *list)
|
||||
{
|
||||
DEBUGASSERT(list);
|
||||
DEBUGASSERT(list->_init == LLISTINIT);
|
||||
|
|
@ -249,10 +248,13 @@ struct Curl_llist_node *Curl_node_next(struct Curl_llist_node *n)
|
|||
}
|
||||
|
||||
#ifdef UNITTESTS
|
||||
/* Curl_node_prev() returns the previous element in a list from a given
|
||||
Curl_llist_node */
|
||||
UNITTEST struct Curl_llist_node *Curl_node_prev(struct Curl_llist_node *n);
|
||||
UNITTEST struct Curl_llist_node *Curl_node_prev(struct Curl_llist_node *n)
|
||||
/* llist_node_prev() returns the previous element in a list from a given
|
||||
Curl_llist_node
|
||||
|
||||
@unittest 1300
|
||||
*/
|
||||
UNITTEST struct Curl_llist_node *llist_node_prev(struct Curl_llist_node *n);
|
||||
UNITTEST struct Curl_llist_node *llist_node_prev(struct Curl_llist_node *n)
|
||||
{
|
||||
DEBUGASSERT(n);
|
||||
DEBUGASSERT(n->_init == NODEINIT);
|
||||
|
|
|
|||
|
|
@ -304,10 +304,8 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
|
|||
goto error;
|
||||
#endif
|
||||
|
||||
#ifdef USE_IPV6
|
||||
if(Curl_probeipv6(multi))
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
#ifdef USE_RESOLV_THREADED
|
||||
if(xfer_table_size < CURL_XFER_TABLE_SIZE) { /* easy multi */
|
||||
|
|
|
|||
|
|
@ -38,15 +38,17 @@
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Curl_cidr4_match() returns TRUE if the given IPv4 address is within the
|
||||
* cidr4_match() returns TRUE if the given IPv4 address is within the
|
||||
* specified CIDR address range.
|
||||
*
|
||||
* @unittest 1614
|
||||
*/
|
||||
UNITTEST bool Curl_cidr4_match(const char *ipv4, /* 1.2.3.4 address */
|
||||
const char *network, /* 1.2.3.4 address */
|
||||
unsigned int bits);
|
||||
UNITTEST bool Curl_cidr4_match(const char *ipv4, /* 1.2.3.4 address */
|
||||
const char *network, /* 1.2.3.4 address */
|
||||
unsigned int bits)
|
||||
UNITTEST bool cidr4_match(const char *ipv4, /* 1.2.3.4 address */
|
||||
const char *network, /* 1.2.3.4 address */
|
||||
unsigned int bits);
|
||||
UNITTEST bool cidr4_match(const char *ipv4, /* 1.2.3.4 address */
|
||||
const char *network, /* 1.2.3.4 address */
|
||||
unsigned int bits)
|
||||
{
|
||||
unsigned int address = 0;
|
||||
unsigned int check = 0;
|
||||
|
|
@ -77,12 +79,11 @@ UNITTEST bool Curl_cidr4_match(const char *ipv4, /* 1.2.3.4 address */
|
|||
return address == check;
|
||||
}
|
||||
|
||||
UNITTEST bool Curl_cidr6_match(const char *ipv6,
|
||||
const char *network,
|
||||
unsigned int bits);
|
||||
UNITTEST bool Curl_cidr6_match(const char *ipv6,
|
||||
const char *network,
|
||||
unsigned int bits)
|
||||
/* @unittest 1614 */
|
||||
UNITTEST bool cidr6_match(const char *ipv6, const char *network,
|
||||
unsigned int bits);
|
||||
UNITTEST bool cidr6_match(const char *ipv6, const char *network,
|
||||
unsigned int bits)
|
||||
{
|
||||
#ifdef USE_IPV6
|
||||
unsigned int bytes;
|
||||
|
|
@ -176,9 +177,9 @@ static bool match_ip(int type, const char *token, size_t tokenlen,
|
|||
*slash = 0; /* null-terminate there */
|
||||
}
|
||||
if(type == TYPE_IPV6)
|
||||
return Curl_cidr6_match(name, checkip, bits);
|
||||
return cidr6_match(name, checkip, bits);
|
||||
else
|
||||
return Curl_cidr4_match(name, checkip, bits);
|
||||
return cidr4_match(name, checkip, bits);
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#ifndef CURL_DISABLE_PROGRESS_METER
|
||||
/* Provide a string that is 7 letters long (plus the zero byte).
|
||||
|
||||
Unit test 1636.
|
||||
@unittest 1636
|
||||
*/
|
||||
UNITTEST void time2str(char *r, size_t rsize, curl_off_t seconds);
|
||||
UNITTEST void time2str(char *r, size_t rsize, curl_off_t seconds)
|
||||
|
|
@ -83,7 +83,7 @@ UNITTEST void time2str(char *r, size_t rsize, curl_off_t seconds)
|
|||
but never longer than 6 columns (+ one zero byte).
|
||||
Add suffix k, M, G when suitable...
|
||||
|
||||
Unit test 1636
|
||||
@unittest 1636
|
||||
*/
|
||||
UNITTEST char *max6out(curl_off_t bytes, char *max6, size_t mlen);
|
||||
UNITTEST char *max6out(curl_off_t bytes, char *max6, size_t mlen)
|
||||
|
|
@ -127,7 +127,7 @@ static void pgrs_speedinit(struct Curl_easy *data)
|
|||
}
|
||||
|
||||
/*
|
||||
* @unittest: 1606
|
||||
* @unittest 1606
|
||||
*/
|
||||
UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data,
|
||||
const struct curltime *pnow);
|
||||
|
|
|
|||
|
|
@ -68,8 +68,9 @@ void Curl_uint32_bset_destroy(struct uint32_bset *bset)
|
|||
}
|
||||
|
||||
#ifdef UNITTESTS
|
||||
UNITTEST uint32_t Curl_uint32_bset_capacity(struct uint32_bset *bset);
|
||||
UNITTEST uint32_t Curl_uint32_bset_capacity(struct uint32_bset *bset)
|
||||
/* @unittest 3211 */
|
||||
UNITTEST uint32_t uint32_bset_capacity(struct uint32_bset *bset);
|
||||
UNITTEST uint32_t uint32_bset_capacity(struct uint32_bset *bset)
|
||||
{
|
||||
return bset->nslots * 64;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ void *Curl_uint32_hash_get(struct uint_hash *h, uint32_t id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* @unittest 1616 */
|
||||
UNITTEST void uint_hash_clear(struct uint_hash *h);
|
||||
UNITTEST void uint_hash_clear(struct uint_hash *h)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,9 +38,12 @@ void Curl_uint32_spbset_init(struct uint32_spbset *bset)
|
|||
#endif
|
||||
}
|
||||
|
||||
/* Clear the bitset, making it empty. */
|
||||
UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset);
|
||||
UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset)
|
||||
/* Clear the bitset, making it empty.
|
||||
|
||||
@unittest 3213
|
||||
*/
|
||||
UNITTEST void uint32_spbset_clear(struct uint32_spbset *bset);
|
||||
UNITTEST void uint32_spbset_clear(struct uint32_spbset *bset)
|
||||
{
|
||||
struct uint32_spbset_chunk *next, *chunk;
|
||||
|
||||
|
|
@ -54,7 +57,7 @@ UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset)
|
|||
void Curl_uint32_spbset_destroy(struct uint32_spbset *bset)
|
||||
{
|
||||
DEBUGASSERT(bset->init == CURL_UINT32_SPBSET_MAGIC);
|
||||
Curl_uint32_spbset_clear(bset);
|
||||
uint32_spbset_clear(bset);
|
||||
}
|
||||
|
||||
uint32_t Curl_uint32_spbset_count(struct uint32_spbset *bset)
|
||||
|
|
|
|||
|
|
@ -79,9 +79,12 @@ CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows)
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/* Clear the table, making it empty. */
|
||||
UNITTEST void Curl_uint32_tbl_clear(struct uint32_tbl *tbl);
|
||||
UNITTEST void Curl_uint32_tbl_clear(struct uint32_tbl *tbl)
|
||||
/* Clear the table, making it empty.
|
||||
|
||||
@unittest 3212
|
||||
*/
|
||||
UNITTEST void uint32_tbl_clear(struct uint32_tbl *tbl);
|
||||
UNITTEST void uint32_tbl_clear(struct uint32_tbl *tbl)
|
||||
{
|
||||
DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
|
||||
uint32_tbl_clear_rows(tbl, 0, tbl->nrows);
|
||||
|
|
@ -92,7 +95,7 @@ UNITTEST void Curl_uint32_tbl_clear(struct uint32_tbl *tbl)
|
|||
void Curl_uint32_tbl_destroy(struct uint32_tbl *tbl)
|
||||
{
|
||||
DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
|
||||
Curl_uint32_tbl_clear(tbl);
|
||||
uint32_tbl_clear(tbl);
|
||||
curlx_free(tbl->rows);
|
||||
memset(tbl, 0, sizeof(*tbl));
|
||||
}
|
||||
|
|
|
|||
25
lib/url.c
25
lib/url.c
|
|
@ -3418,29 +3418,6 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
/* Curl_setup_conn() is called after the name resolve initiated in
|
||||
* create_conn() is all done.
|
||||
*
|
||||
* Curl_setup_conn() also handles reused connections
|
||||
*/
|
||||
CURLcode Curl_setup_conn(struct Curl_easy *data,
|
||||
struct Curl_dns_entry *dns,
|
||||
bool *protocol_done)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
struct connectdata *conn = data->conn;
|
||||
|
||||
if(!conn->bits.reuse)
|
||||
result = Curl_conn_setup(data, conn, FIRSTSOCKET, dns,
|
||||
CURL_CF_SSL_DEFAULT);
|
||||
if(!result)
|
||||
result = Curl_headers_init(data);
|
||||
|
||||
/* not sure we need this flag to be passed around any more */
|
||||
*protocol_done = FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
CURLcode Curl_connect(struct Curl_easy *data, bool *pconnected)
|
||||
{
|
||||
CURLcode result;
|
||||
|
|
@ -3474,7 +3451,7 @@ CURLcode Curl_connect(struct Curl_easy *data, bool *pconnected)
|
|||
CURL_CF_SSL_DEFAULT);
|
||||
if(!result)
|
||||
result = Curl_headers_init(data);
|
||||
CURL_TRC_M(data, "Curl_setup_conn() -> %d", result);
|
||||
CURL_TRC_M(data, "Curl_conn_setup() -> %d", result);
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@ void Curl_freeset(struct Curl_easy *data);
|
|||
CURLcode Curl_uc_to_curlcode(CURLUcode uc);
|
||||
CURLcode Curl_close(struct Curl_easy **datap); /* opposite of Curl_open() */
|
||||
CURLcode Curl_connect(struct Curl_easy *data, bool *pconnected);
|
||||
CURLcode Curl_setup_conn(struct Curl_easy *data,
|
||||
struct Curl_dns_entry *dns,
|
||||
bool *protocol_done);
|
||||
void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn);
|
||||
CURLcode Curl_parse_login_details(const char *login, const size_t len,
|
||||
char **userp, char **passwdp,
|
||||
|
|
|
|||
28
lib/urlapi.c
28
lib/urlapi.c
|
|
@ -118,7 +118,7 @@ static const char *find_host_sep(const char *url)
|
|||
* 'query' tells if it is a query part or not, or if it is allowed to
|
||||
* "transition" into a query part with a question mark.
|
||||
*
|
||||
* @unittest: 1675
|
||||
* @unittest 1675
|
||||
*/
|
||||
UNITTEST CURLUcode urlencode_str(struct dynbuf *o, const char *url,
|
||||
size_t len, bool relative,
|
||||
|
|
@ -341,10 +341,11 @@ out:
|
|||
return ures;
|
||||
}
|
||||
|
||||
UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host,
|
||||
bool has_scheme);
|
||||
UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host,
|
||||
bool has_scheme)
|
||||
/* @unittest 1653 */
|
||||
UNITTEST CURLUcode parse_port(struct Curl_URL *u, struct dynbuf *host,
|
||||
bool has_scheme);
|
||||
UNITTEST CURLUcode parse_port(struct Curl_URL *u, struct dynbuf *host,
|
||||
bool has_scheme)
|
||||
{
|
||||
const char *portptr;
|
||||
const char *hostname = curlx_dyn_ptr(host);
|
||||
|
|
@ -400,7 +401,7 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host,
|
|||
/* This function assumes 'hostname' now starts with [. It trims 'hostname' in
|
||||
* place and it sets u->zoneid if present.
|
||||
*
|
||||
* @unittest: 1675
|
||||
* @unittest 1675
|
||||
*/
|
||||
UNITTEST CURLUcode ipv6_parse(struct Curl_URL *u, char *hostname,
|
||||
size_t hlen);
|
||||
|
|
@ -458,10 +459,8 @@ UNITTEST CURLUcode ipv6_parse(struct Curl_URL *u, char *hostname,
|
|||
return CURLUE_OK;
|
||||
}
|
||||
|
||||
UNITTEST CURLUcode hostname_check(struct Curl_URL *u, char *hostname,
|
||||
size_t hlen);
|
||||
UNITTEST CURLUcode hostname_check(struct Curl_URL *u, char *hostname,
|
||||
size_t hlen) /* length of hostname */
|
||||
static CURLUcode hostname_check(struct Curl_URL *u, char *hostname,
|
||||
size_t hlen) /* length of hostname */
|
||||
{
|
||||
size_t len;
|
||||
DEBUGASSERT(hostname);
|
||||
|
|
@ -492,7 +491,7 @@ UNITTEST CURLUcode hostname_check(struct Curl_URL *u, char *hostname,
|
|||
*
|
||||
* Returns the host type.
|
||||
*
|
||||
* @unittest: 1675
|
||||
* @unittest 1675
|
||||
*/
|
||||
|
||||
UNITTEST int ipv4_normalize(struct dynbuf *host);
|
||||
|
|
@ -640,7 +639,7 @@ static CURLUcode parse_authority(struct Curl_URL *u,
|
|||
goto out;
|
||||
}
|
||||
|
||||
uc = Curl_parse_port(u, host, has_scheme);
|
||||
uc = parse_port(u, host, has_scheme);
|
||||
if(uc)
|
||||
goto out;
|
||||
|
||||
|
|
@ -716,7 +715,6 @@ static bool is_dot(const char **str, size_t *clen)
|
|||
|
||||
/*
|
||||
* dedotdotify()
|
||||
* @unittest: 1395
|
||||
*
|
||||
* This function gets a null-terminated path with dot and dotdot sequences
|
||||
* passed in and strips them off according to the rules in RFC 3986 section
|
||||
|
|
@ -727,6 +725,8 @@ static bool is_dot(const char **str, size_t *clen)
|
|||
* RETURNS
|
||||
*
|
||||
* Zero for success and 'out' set to an allocated dedotdotified string.
|
||||
*
|
||||
* @unittest 1395
|
||||
*/
|
||||
UNITTEST int dedotdotify(const char *input, size_t clen, char **outp);
|
||||
UNITTEST int dedotdotify(const char *input, size_t clen, char **outp)
|
||||
|
|
@ -835,7 +835,7 @@ end:
|
|||
}
|
||||
|
||||
/*
|
||||
* @unittest: 1675
|
||||
* @unittest 1675
|
||||
*/
|
||||
UNITTEST CURLUcode parse_file(const char *url, size_t urllen, CURLU *u,
|
||||
const char **pathp, size_t *pathlenp);
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ static const char *getASN1Element_(struct Curl_asn1Element *elem,
|
|||
}
|
||||
|
||||
/*
|
||||
* unit test @1657
|
||||
* @unittest 1657
|
||||
*/
|
||||
UNITTEST const char *getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end);
|
||||
|
|
@ -490,7 +490,7 @@ static CURLcode OID2str(struct dynbuf *store,
|
|||
}
|
||||
|
||||
/*
|
||||
* Unit test @1656
|
||||
* @unittest 1656
|
||||
*/
|
||||
UNITTEST CURLcode GTime2str(struct dynbuf *store,
|
||||
const char *beg, const char *end);
|
||||
|
|
@ -617,6 +617,8 @@ static CURLcode UTime2str(struct dynbuf *store,
|
|||
* Convert an ASN.1 element to a printable string.
|
||||
*
|
||||
* Return error
|
||||
*
|
||||
* @unittest 1667
|
||||
*/
|
||||
UNITTEST CURLcode ASN1tostr(struct dynbuf *store,
|
||||
struct Curl_asn1Element *elem);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue