/* 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) {
*/
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(
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()`. */
}
#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;
#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)
#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;
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,
***************************************************************************/
#include "curl_setup.h"
+#include "hostip.h"
#include "curlx/timeval.h"
struct Curl_dns_entry;
/* 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 */
}
/*
- * 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
*
* 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);
#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);
return DOH_OK;
}
+/* @unittest 1655 */
UNITTEST void de_init(struct dohentry *de);
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,
}
#endif
+/* @unittest 1655 */
UNITTEST void de_cleanup(struct dohentry *d);
UNITTEST void de_cleanup(struct dohentry *d)
{
}
#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);
}
#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) {
/**
* 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) {
* 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 */
}
/*
- * Unittest @1668
+ * @unittest 1668
*/
UNITTEST bool ftp_213_date(const char *p, int *year, int *month, int *day,
int *hour, int *minute, int *second);
#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
* ==================
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;
}
/*
- * 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);
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;
}
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 */
return compare;
}
+/* @unittest 1979 */
UNITTEST CURLcode canon_path(const char *q, size_t len,
struct dynbuf *new_path,
bool do_uri_encode);
return result;
}
+/* @unittest 1980 */
UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq);
UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq)
{
#define VERIFYNODE(x) x
#endif
/*
- * @unittest: 1300
+ * @unittest 1300
*/
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 */
*
* 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)
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;
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)
if(list) {
DEBUGASSERT(list->_init == LLISTINIT);
while(list->_size > 0)
- Curl_node_uremove(list->_tail, user);
+ node_uremove(list->_tail, user);
}
}
}
#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);
}
#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);
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 */
#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;
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;
*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);
}
/****************************************************************
#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)
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)
}
/*
- * @unittest: 1606
+ * @unittest 1606
*/
UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data,
const struct curltime *pnow);
}
#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;
}
return NULL;
}
+/* @unittest 1616 */
UNITTEST void uint_hash_clear(struct uint_hash *h);
UNITTEST void uint_hash_clear(struct uint_hash *h)
{
#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;
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)
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);
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));
}
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;
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:
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,
* '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,
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);
/* 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);
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);
*
* Returns the host type.
*
- * @unittest: 1675
+ * @unittest 1675
*/
UNITTEST int ipv4_normalize(struct dynbuf *host);
goto out;
}
- uc = Curl_parse_port(u, host, has_scheme);
+ uc = parse_port(u, host, has_scheme);
if(uc)
goto out;
/*
* 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
* 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)
}
/*
- * @unittest: 1675
+ * @unittest 1675
*/
UNITTEST CURLUcode parse_file(const char *url, size_t urllen, CURLU *u,
const char **pathp, size_t *pathlenp);
}
/*
- * unit test @1657
+ * @unittest 1657
*/
UNITTEST const char *getASN1Element(struct Curl_asn1Element *elem,
const char *beg, const char *end);
}
/*
- * Unit test @1656
+ * @unittest 1656
*/
UNITTEST CURLcode GTime2str(struct dynbuf *store,
const char *beg, const char *end);
* Convert an ASN.1 element to a printable string.
*
* Return error
+ *
+ * @unittest 1667
*/
UNITTEST CURLcode ASN1tostr(struct dynbuf *store,
struct Curl_asn1Element *elem);
my @proto;
my %func;
my %inc;
+my %test;
+my %from;
+my $error;
sub scanfile {
my ($file) = @_;
open(F, "<$file") || die "$file failed";
my $unit = 0;
+ my $line = 0;
+ my $unitref = 0;
+ my $unittest = 0;
while(<F>) {
+ $line++;
+ my $full = $_;
+ if($_ =~ /\@unittest (\d+)/) {
+ $unittest = $1;
+ $unitref = $line; # store line number
+ }
if($_ =~ /^UNITTEST .*[* ]([a-z0-9_]+)\(/i) {
my $n = $1;
if($func{$n}) {
# already prototyped, this is now the function itself
}
else {
+ if($n =~ /^Curl_/) {
+ print STDERR "$file:$line:1: warn: $n is Curl_ prefixed?\n";
+ $error++;
+ }
+ if(($line - $unitref) > 10) {
+ print STDERR "$file:$line:1: warn: Missing \@unittest reference?\n";
+ $error++;
+ }
+ else {
+ $test{$full} = $unittest;
+ $from{$full} = "$file:$line";
+ }
+
$func{$n} = 1;
push @proto, $_;
$inc{$file} = 1;
scanfile($f);
}
+if($error) {
+ exit 1;
+}
+
print <<HEAD
#ifndef UNITTESTPROTOS_H
#define UNITTESTPROTOS_H
}
for my $p (@proto) {
+ if($test{$p}) {
+ printf "\n/* for unit test %d from %s */\n",
+ $test{$p}, $from{$p};
+ }
print $p;
}
"list initial size should be zero");
fail_unless(Curl_llist_head(&llist) == NULL,
"list head should initiate to NULL");
- fail_unless(Curl_llist_tail(&llist) == NULL,
+ fail_unless(llist_tail(&llist) == NULL,
"list tail should initiate to NULL");
/**
fail_unless(Curl_node_elem(Curl_llist_head(&llist)) == &unusedData_case1,
"head ptr should be first entry");
/* same goes for the list tail */
- fail_unless(Curl_llist_tail(&llist) == Curl_llist_head(&llist),
+ fail_unless(llist_tail(&llist) == Curl_llist_head(&llist),
"tail and head should be the same");
/**
fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) ==
&unusedData_case3,
"the node next to head is not getting set correctly");
- fail_unless(Curl_node_elem(Curl_llist_tail(&llist)) == &unusedData_case3,
+ fail_unless(Curl_node_elem(llist_tail(&llist)) == &unusedData_case3,
"the list tail is not getting set correctly");
/**
&unusedData_case2,
"the node next to head is not getting set correctly");
/* better safe than sorry, check that the tail is not corrupted */
- fail_unless(Curl_node_elem(Curl_llist_tail(&llist)) != &unusedData_case2,
+ fail_unless(Curl_node_elem(llist_tail(&llist)) != &unusedData_case2,
"the list tail is not getting set correctly");
/* unit tests for Curl_node_remove */
fail_unless(Curl_llist_head(&llist) == element_next,
"llist new head not modified properly");
abort_unless(Curl_llist_head(&llist), "llist.head is NULL");
- fail_unless(Curl_node_prev(Curl_llist_head(&llist)) == NULL,
+ fail_unless(llist_node_prev(Curl_llist_head(&llist)) == NULL,
"new head previous not set to null");
/**
to_remove = Curl_node_next(Curl_llist_head(&llist));
abort_unless(to_remove, "to_remove is NULL");
element_next = Curl_node_next(to_remove);
- element_prev = Curl_node_prev(to_remove);
- Curl_node_uremove(to_remove, NULL);
+ element_prev = llist_node_prev(to_remove);
+ Curl_node_remove(to_remove);
fail_unless(Curl_node_next(element_prev) == element_next,
"element previous->next is not being adjusted");
abort_unless(element_next, "element_next is NULL");
- fail_unless(Curl_node_prev(element_next) == element_prev,
+ fail_unless(llist_node_prev(element_next) == element_prev,
"element next->previous is not being adjusted");
/**
* 4: list->tail will be tail->previous
*/
- to_remove = Curl_llist_tail(&llist);
- element_prev = Curl_node_prev(to_remove);
+ to_remove = llist_tail(&llist);
+ element_prev = llist_node_prev(to_remove);
Curl_node_remove(to_remove);
- fail_unless(Curl_llist_tail(&llist) == element_prev,
+ fail_unless(llist_tail(&llist) == element_prev,
"llist tail is not being adjusted when removing tail");
/**
Curl_node_remove(to_remove);
fail_unless(Curl_llist_head(&llist) == NULL,
"llist head is not NULL while the llist is empty");
- fail_unless(Curl_llist_tail(&llist) == NULL,
+ fail_unless(llist_tail(&llist) == NULL,
"llist tail is not NULL while the llist is empty");
/**
fail_unless(Curl_node_elem(Curl_llist_head(&llist)) == &unusedData_case1,
"head ptr should be first entry");
/* same goes for the list tail */
- fail_unless(Curl_llist_tail(&llist) == Curl_llist_head(&llist),
+ fail_unless(llist_tail(&llist) == Curl_llist_head(&llist),
"tail and head should be the same");
/**
fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) ==
&unusedData_case2,
"the node next to head is not getting set correctly");
- fail_unless(Curl_node_elem(Curl_llist_tail(&llist)) == &unusedData_case2,
+ fail_unless(Curl_node_elem(llist_tail(&llist)) == &unusedData_case2,
"the list tail is not getting set correctly");
/**
fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) ==
&unusedData_case2,
"the node next to head did not stay the same");
- fail_unless(Curl_node_elem(Curl_llist_tail(&llist)) == &unusedData_case3,
+ fail_unless(Curl_node_elem(llist_tail(&llist)) == &unusedData_case3,
"the list tail is not getting set correctly");
Curl_llist_destroy(&llist, NULL);
TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
easy->progress.now = now;
easy->mstate = run[i].connecting ? MSTATE_INIT : MSTATE_DO;
- timeout = Curl_timeleft_now_ms(easy, &now);
+ timeout = timeleft_now_ms(easy, &now);
if(timeout != run[i].result)
fail(run[i].comment);
}
/* Shuffle repeatedly and make sure that the list changes */
for(i = 0; i < 10; i++) {
- if(CURLE_OK != Curl_shuffle_addr(easy, &addrhead))
+ if(CURLE_OK != dns_shuffle_addr(easy, &addrhead))
break;
if(addrhead != addrs)
break;
{ NULL, NULL, FALSE }
};
for(i = 0; list4[i].a; i++) {
- bool match = Curl_cidr4_match(list4[i].a, list4[i].n, list4[i].bits);
+ bool match = cidr4_match(list4[i].a, list4[i].n, list4[i].bits);
if(match != list4[i].match) {
curl_mfprintf(stderr, "%s in %s/%u should %smatch\n",
list4[i].a, list4[i].n, list4[i].bits,
}
#ifdef USE_IPV6
for(i = 0; list6[i].a; i++) {
- bool match = Curl_cidr6_match(list6[i].a, list6[i].n, list6[i].bits);
+ bool match = cidr6_match(list6[i].a, list6[i].n, list6[i].bits);
if(match != list6[i].match) {
curl_mfprintf(stderr, "%s in %s/%u should %smatch\n",
list6[i].a, list6[i].n, list6[i].bits,
#include "curl/urlapi.h"
#include "urlapi-int.h"
-static CURLUcode parse_port(CURLU *url, const char *h, bool has_scheme)
+static CURLUcode my_parse_port(CURLU *url, const char *h, bool has_scheme)
{
struct dynbuf host;
CURLUcode ret;
curlx_dyn_init(&host, 10000);
if(curlx_dyn_add(&host, h))
return CURLUE_OUT_OF_MEMORY;
- ret = Curl_parse_port(url, &host, has_scheme);
+ ret = parse_port(url, &host, has_scheme);
curlx_dyn_free(&host);
return ret;
}
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "parse_port returned error");
ret = curl_url_get(u, CURLUPART_PORT, &portnum, CURLU_NO_DEFAULT_PORT);
fail_unless(ret != CURLUE_OK, "curl_url_get portnum returned something");
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15|");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret != CURLUE_OK, "parse_port true on error");
curlx_safefree(ipv6port);
curl_url_cleanup(u);
ipv6port = curlx_strdup("[fe80::250:56ff;fea7:da15]:808");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "parse_port returned error");
ret = curl_url_get(u, CURLUPART_PORT, &portnum, 0);
fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error");
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%25eth3]:80");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "parse_port returned error");
ret = curl_url_get(u, CURLUPART_PORT, &portnum, 0);
fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error");
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%25eth3]");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "parse_port returned error");
curlx_safefree(ipv6port);
curl_url_cleanup(u);
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]:81");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "parse_port returned error");
ret = curl_url_get(u, CURLUPART_PORT, &portnum, 0);
fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error");
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15];81");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret != CURLUE_OK, "parse_port true on error");
curlx_safefree(ipv6port);
curl_url_cleanup(u);
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]80");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret != CURLUE_OK, "parse_port true on error");
curlx_safefree(ipv6port);
curl_url_cleanup(u);
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]:");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, TRUE);
+ ret = my_parse_port(u, ipv6port, TRUE);
fail_unless(ret == CURLUE_OK, "parse_port returned error");
curlx_safefree(ipv6port);
curl_url_cleanup(u);
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15!25eth3]:180");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "parse_port returned error");
ret = curl_url_get(u, CURLUPART_PORT, &portnum, 0);
fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error");
ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%eth3]:80");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "parse_port returned error");
curlx_safefree(ipv6port);
curl_url_cleanup(u);
"aaaaaaaaaaaaaaaaaaaaaa:");
if(!ipv6port)
goto fail;
- ret = parse_port(u, ipv6port, FALSE);
+ ret = my_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_BAD_PORT_NUMBER, "parse_port did wrong");
fail:
curlx_free(ipv6port);
CURL_LOG_LVL_NONE,
cf_test_destroy,
cf_test_connect,
- Curl_cf_def_close,
+ cf_def_close,
Curl_cf_def_shutdown,
cf_test_adjust_pollset,
Curl_cf_def_data_pending,
struct test_result tr;
struct curl_slist *list = NULL;
- Curl_debug_set_transport_provider(TRNSPRT_TCP, cf_test_create);
+ debug_set_transport_provider(TRNSPRT_TCP, cf_test_create);
current_tc = tc;
current_tr = &tr;
fail_if(Curl_dynhds_add(&hds, "test2", 5, "456", 3), "add failed");
/* remove and add without exceeding limits */
for(i = 0; i < 100; ++i) {
- if(Curl_dynhds_remove(&hds, "test2", 5) != 1) {
+ if(dynhds_remove(&hds, "test2", 5) != 1) {
fail_if(TRUE, "should");
break;
}
fail_unless(Curl_dynhds_count(&hds) == 2, "should hold 2");
/* set, replacing previous entry without exceeding limits */
for(i = 0; i < 100; ++i) {
- if(Curl_dynhds_set(&hds, "test2", 5, "456", 3)) {
+ if(dynhds_set(&hds, "test2", 5, "456", 3)) {
fail_if(TRUE, "add failed");
break;
}
result = Curl_dynhds_add(&hds, "test3", 5, "789", 3);
fail_unless(result, "add should have failed");
- fail_unless(Curl_dynhds_count_name(&hds, "test", 4) == 0, "false positive");
- fail_unless(Curl_dynhds_count_name(&hds, "test1", 4) == 0, "false positive");
+ fail_unless(dynhds_count_name(&hds, "test", 4) == 0, "false positive");
+ fail_unless(dynhds_count_name(&hds, "test1", 4) == 0, "false positive");
fail_if(Curl_dynhds_get(&hds, "test1", 4), "false positive");
fail_unless(Curl_dynhds_get(&hds, "test1", 5), "false negative");
- fail_unless(Curl_dynhds_count_name(&hds, "test1", 5) == 1, "should");
- fail_unless(Curl_dynhds_ccount_name(&hds, "test2") == 1, "should");
+ fail_unless(dynhds_count_name(&hds, "test1", 5) == 1, "should");
+ fail_unless(dynhds_ccount_name(&hds, "test2") == 1, "should");
fail_unless(Curl_dynhds_cget(&hds, "test2"), "should");
- fail_unless(Curl_dynhds_ccount_name(&hds, "TEST2") == 1, "should");
- fail_unless(Curl_dynhds_ccontains(&hds, "TesT2"), "should");
- fail_unless(Curl_dynhds_contains(&hds, "TeSt2", 5), "should");
+ fail_unless(dynhds_ccount_name(&hds, "TEST2") == 1, "should");
+ fail_unless(dynhds_ccontains(&hds, "TesT2"), "should");
+ fail_unless(dynhds_contains(&hds, "TeSt2", 5), "should");
Curl_dynhds_free(&hds);
/* add header exceeding max overall length */
fail_if(Curl_dynhds_add(&hds, "test1", 5, "123", 3), "add failed");
fail_if(Curl_dynhds_cadd(&hds, "blablabla", "thingies"), "add failed");
fail_if(Curl_dynhds_h1_cadd_line(&hds, "blablabla: thingies"), "add failed");
- fail_unless(Curl_dynhds_ccount_name(&hds, "blablabla") == 2, "should");
- fail_unless(Curl_dynhds_cremove(&hds, "blablabla") == 2, "should");
- fail_if(Curl_dynhds_ccontains(&hds, "blablabla"), "should not");
+ fail_unless(dynhds_ccount_name(&hds, "blablabla") == 2, "should");
+ fail_unless(dynhds_cremove(&hds, "blablabla") == 2, "should");
+ fail_if(dynhds_ccontains(&hds, "blablabla"), "should not");
result = Curl_dynhds_h1_cadd_line(&hds, "blablabla thingies");
fail_unless(result, "add should have failed");
if(!result) {
- fail_unless(Curl_dynhds_ccount_name(&hds, "bLABlaBlA") == 0, "should");
+ fail_unless(dynhds_ccount_name(&hds, "bLABlaBlA") == 0, "should");
fail_if(Curl_dynhds_cadd(&hds, "Bla-Bla", "thingies"), "add failed");
curlx_dyn_init(&dbuf, 32 * 1024);
name, capacity, slen);
Curl_uint32_bset_init(&bset);
fail_unless(!Curl_uint32_bset_resize(&bset, capacity), "bset resize failed");
- c = Curl_uint32_bset_capacity(&bset);
+ c = uint32_bset_capacity(&bset);
fail_unless(c == (((capacity + 63) / 64) * 64), "wrong capacity");
Curl_uint32_bset_clear(&bset);
}
/* Adding capacity number does not work (0 - capacity-1) */
- c = Curl_uint32_bset_capacity(&bset);
+ c = uint32_bset_capacity(&bset);
fail_unless(!Curl_uint32_bset_add(&bset, c), "add out of range worked");
/* The count it correct */
c = Curl_uint32_bset_count(&bset);
fail_unless(!Curl_uint32_bset_resize(&bset, capacity / 2),
"resize half failed");
/* halved the size, what numbers remain in set? */
- c = Curl_uint32_bset_capacity(&bset);
+ c = uint32_bset_capacity(&bset);
n = 0;
for(i = 0; i < slen; ++i) {
if(s[i] < c)
"does not contain dummy");
}
/* clear */
- Curl_uint32_tbl_clear(&tbl);
+ uint32_tbl_clear(&tbl);
fail_unless(!Curl_uint32_tbl_count(&tbl), "count not 0 after clear");
for(i = 0; i < TBL_SIZE / 2; ++i) {
fail_unless(!Curl_uint32_tbl_contains(&tbl, i),
fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add");
fail_unless(key == 1, "unexpected key assigned");
/* clear, fill, remove one, add, should get the removed key again */
- Curl_uint32_tbl_clear(&tbl);
+ uint32_tbl_clear(&tbl);
for(i = 0; i < Curl_uint32_tbl_capacity(&tbl); ++i)
fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add");
fail_unless(!Curl_uint32_tbl_add(&tbl, &dummy, &key), "add on full");
Curl_uint32_spbset_init(&bset);
- Curl_uint32_spbset_clear(&bset);
+ uint32_spbset_clear(&bset);
c = Curl_uint32_spbset_count(&bset);
fail_unless(c == 0, "set count is not 0");
c = Curl_uint32_spbset_count(&bset);
fail_unless(c == slen / 2, "set count is wrong");
- Curl_uint32_spbset_clear(&bset);
+ uint32_spbset_clear(&bset);
c = Curl_uint32_spbset_count(&bset);
fail_unless(c == 0, "set count is not 0");
for(i = 0; i < slen; i++) { /* none present any longer */