mirror of
https://github.com/curl/curl.git
synced 2026-07-23 18:17:15 +03:00
lib: move all UNITTEST prototypes to C files
- make extract-unit-protos handle multi-line prototypes - but they need
to be above the implementation
- Prototypes for static functions we use in unit tests should not be in
header files. We generate lib/unitprotos.h for this purpose
- Removed some function wrappers written for unit tests and make them
use UNITTEST function directly.
- Renamed time2str() in the tool to timebuf() since we have the same
name in lib/ and in unit tests they can both be used non-static in a
build.
This reverts commit f95fadd116.
Follow-up to #21010
Closes #21014
This commit is contained in:
parent
7242cea7f6
commit
98d8e82c74
42 changed files with 109 additions and 149 deletions
11
lib/doh.c
11
lib/doh.c
|
|
@ -69,6 +69,11 @@ static const char *doh_strerror(DOHcode code)
|
|||
|
||||
/* @unittest 1655
|
||||
*/
|
||||
UNITTEST DOHcode doh_req_encode(const char *host,
|
||||
DNStype dnstype,
|
||||
unsigned char *dnsp, /* buffer */
|
||||
size_t len, /* buffer size */
|
||||
size_t *olen); /* output length */
|
||||
UNITTEST DOHcode doh_req_encode(const char *host,
|
||||
DNStype dnstype,
|
||||
unsigned char *dnsp, /* buffer */
|
||||
|
|
@ -699,6 +704,7 @@ static DOHcode doh_rdata(const unsigned char *doh,
|
|||
return DOH_OK;
|
||||
}
|
||||
|
||||
UNITTEST void de_init(struct dohentry *d);
|
||||
UNITTEST void de_init(struct dohentry *de)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -708,6 +714,10 @@ UNITTEST void de_init(struct dohentry *de)
|
|||
curlx_dyn_init(&de->cname[i], DYN_DOH_CNAME);
|
||||
}
|
||||
|
||||
UNITTEST DOHcode doh_resp_decode(const unsigned char *doh,
|
||||
size_t dohlen,
|
||||
DNStype dnstype,
|
||||
struct dohentry *d);
|
||||
UNITTEST DOHcode doh_resp_decode(const unsigned char *doh,
|
||||
size_t dohlen,
|
||||
DNStype dnstype,
|
||||
|
|
@ -1025,6 +1035,7 @@ static const char *doh_type2name(DNStype dnstype)
|
|||
}
|
||||
#endif
|
||||
|
||||
UNITTEST void de_cleanup(struct dohentry *d);
|
||||
UNITTEST void de_cleanup(struct dohentry *d)
|
||||
{
|
||||
int i = 0;
|
||||
|
|
|
|||
22
lib/doh.h
22
lib/doh.h
|
|
@ -25,7 +25,8 @@
|
|||
***************************************************************************/
|
||||
#include "urldata.h"
|
||||
|
||||
#ifndef CURL_DISABLE_DOH
|
||||
/* enums outside of the #ifdef to make the types work in unitprotos.h even on
|
||||
builds without DoH support */
|
||||
|
||||
typedef enum {
|
||||
DOH_OK,
|
||||
|
|
@ -53,6 +54,10 @@ typedef enum {
|
|||
CURL_DNS_TYPE_HTTPS = 65
|
||||
} DNStype;
|
||||
|
||||
struct dohentry; /* forward-declare for non-DoH builds */
|
||||
|
||||
#ifndef CURL_DISABLE_DOH
|
||||
|
||||
enum doh_slot_num {
|
||||
/* Explicit values for first two symbols so as to match hard-coded
|
||||
* constants in existing code
|
||||
|
|
@ -158,21 +163,6 @@ struct dohentry {
|
|||
void Curl_doh_close(struct Curl_easy *data);
|
||||
void Curl_doh_cleanup(struct Curl_easy *data);
|
||||
|
||||
#ifdef UNITTESTS
|
||||
UNITTEST DOHcode doh_req_encode(const char *host,
|
||||
DNStype dnstype,
|
||||
unsigned char *dnsp, /* buffer */
|
||||
size_t len, /* buffer size */
|
||||
size_t *olen); /* output length */
|
||||
UNITTEST DOHcode doh_resp_decode(const unsigned char *doh,
|
||||
size_t dohlen,
|
||||
DNStype dnstype,
|
||||
struct dohentry *d);
|
||||
|
||||
UNITTEST void de_init(struct dohentry *d);
|
||||
UNITTEST void de_cleanup(struct dohentry *d);
|
||||
#endif
|
||||
|
||||
#else /* CURL_DISABLE_DOH */
|
||||
#define Curl_doh(a, b, c, d, e) NULL
|
||||
#define Curl_doh_is_resolved(x, y) CURLE_COULDNT_RESOLVE_HOST
|
||||
|
|
|
|||
|
|
@ -679,6 +679,8 @@ static int compare_func(const void *a, const void *b)
|
|||
return compare;
|
||||
}
|
||||
|
||||
UNITTEST CURLcode canon_path(const char *q, size_t len,
|
||||
struct dynbuf *new_path, bool normalize);
|
||||
UNITTEST CURLcode canon_path(const char *q, size_t len,
|
||||
struct dynbuf *new_path,
|
||||
bool do_uri_encode)
|
||||
|
|
@ -705,6 +707,7 @@ UNITTEST CURLcode canon_path(const char *q, size_t len,
|
|||
return result;
|
||||
}
|
||||
|
||||
UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq);
|
||||
UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
|
|
|||
|
|
@ -31,10 +31,4 @@
|
|||
/* this is for creating aws_sigv4 header output */
|
||||
CURLcode Curl_output_aws_sigv4(struct Curl_easy *data);
|
||||
|
||||
#ifdef UNITTESTS
|
||||
UNITTEST CURLcode canon_path(const char *q, size_t len,
|
||||
struct dynbuf *new_path, bool normalize);
|
||||
UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq);
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CURL_HTTP_AWS_SIGV4_H */
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@
|
|||
* Curl_cidr4_match() returns TRUE if the given IPv4 address is within the
|
||||
* specified CIDR address range.
|
||||
*/
|
||||
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)
|
||||
|
|
@ -74,6 +77,9 @@ 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)
|
||||
|
|
|
|||
|
|
@ -26,17 +26,6 @@
|
|||
#include "curl_setup.h"
|
||||
|
||||
#ifndef CURL_DISABLE_PROXY
|
||||
|
||||
#ifdef UNITTESTS
|
||||
|
||||
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_cidr6_match(const char *ipv6,
|
||||
const char *network,
|
||||
unsigned int bits);
|
||||
#endif
|
||||
|
||||
bool Curl_check_noproxy(const char *name, const char *no_proxy);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ static void pgrs_speedinit(struct Curl_easy *data)
|
|||
/*
|
||||
* @unittest: 1606
|
||||
*/
|
||||
UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data,
|
||||
const struct curltime *pnow);
|
||||
UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data,
|
||||
const struct curltime *pnow)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,9 +82,4 @@ void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer,
|
|||
|
||||
void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent);
|
||||
|
||||
#ifdef UNITTESTS
|
||||
UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data,
|
||||
const struct curltime *pnow);
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CURL_PROGRESS_H */
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ 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)
|
||||
{
|
||||
return bset->nslots * 64;
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@ CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax);
|
|||
/* Destroy the bitset, freeing all resources. */
|
||||
void Curl_uint32_bset_destroy(struct uint32_bset *bset);
|
||||
|
||||
/* Get the bitset capacity, e.g. can hold numbers from 0 to capacity - 1. */
|
||||
uint32_t Curl_uint32_bset_capacity(struct uint32_bset *bset);
|
||||
|
||||
/* Get the cardinality of the bitset, e.g. numbers present in the set. */
|
||||
uint32_t Curl_uint32_bset_count(struct uint32_bset *bset);
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,8 @@ void *Curl_uint32_hash_get(struct uint_hash *h, uint32_t id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void uint_hash_clear(struct uint_hash *h)
|
||||
UNITTEST void uint_hash_clear(struct uint_hash *h);
|
||||
UNITTEST void uint_hash_clear(struct uint_hash *h)
|
||||
{
|
||||
if(h && h->table) {
|
||||
struct uint_hash_entry *he, **he_anchor;
|
||||
|
|
@ -198,13 +199,6 @@ static void uint_hash_clear(struct uint_hash *h)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef UNITTESTS
|
||||
UNITTEST void Curl_uint32_hash_clear(struct uint_hash *h)
|
||||
{
|
||||
uint_hash_clear(h);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Curl_uint32_hash_destroy(struct uint_hash *h)
|
||||
{
|
||||
DEBUGASSERT(h->init == CURL_UINT32_HASHINIT);
|
||||
|
|
|
|||
|
|
@ -44,8 +44,6 @@ void Curl_uint32_hash_init(struct uint_hash *h,
|
|||
uint32_t slots,
|
||||
Curl_uint32_hash_dtor *dtor);
|
||||
void Curl_uint32_hash_destroy(struct uint_hash *h);
|
||||
void Curl_uint32_hash_clear(struct uint_hash *h);
|
||||
|
||||
bool Curl_uint32_hash_set(struct uint_hash *h, uint32_t id, void *value);
|
||||
bool Curl_uint32_hash_remove(struct uint_hash *h, uint32_t id);
|
||||
void *Curl_uint32_hash_get(struct uint_hash *h, uint32_t id);
|
||||
|
|
|
|||
|
|
@ -32,11 +32,6 @@ CURLUcode Curl_url_set_authority(CURLU *u, const char *authority);
|
|||
|
||||
CURLUcode Curl_junkscan(const char *url, size_t *urllen, bool allowspace);
|
||||
|
||||
#ifdef UNITTESTS
|
||||
UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host,
|
||||
bool has_scheme);
|
||||
#endif
|
||||
|
||||
#define U_CURLU_URLDECODE (unsigned int)CURLU_URLDECODE
|
||||
#define U_CURLU_PATH_AS_IS (unsigned int)CURLU_PATH_AS_IS
|
||||
|
||||
|
|
|
|||
|
|
@ -332,6 +332,8 @@ out:
|
|||
return result;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -160,10 +160,6 @@ static const struct Curl_OID OIDtable[] = {
|
|||
* Please note there is no pretension here to rewrite a full SSL library.
|
||||
*/
|
||||
|
||||
static const char *getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end)
|
||||
WARN_UNUSED_RESULT;
|
||||
|
||||
#define CURL_ASN1_MAX_RECURSIONS 16
|
||||
|
||||
static const char *getASN1Element_(struct Curl_asn1Element *elem,
|
||||
|
|
@ -233,8 +229,13 @@ static const char *getASN1Element_(struct Curl_asn1Element *elem,
|
|||
return elem->end;
|
||||
}
|
||||
|
||||
static const char *getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end)
|
||||
/*
|
||||
* unit test @1657
|
||||
*/
|
||||
UNITTEST const char *getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end);
|
||||
UNITTEST const char *getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end)
|
||||
{
|
||||
return getASN1Element_(elem, beg, end, 0);
|
||||
}
|
||||
|
|
@ -255,17 +256,6 @@ static const struct Curl_OID *searchOID(const char *oid)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef UNITTESTS
|
||||
/* used by unit1657.c */
|
||||
CURLcode Curl_x509_getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end)
|
||||
{
|
||||
if(getASN1Element(elem, beg, end))
|
||||
return CURLE_OK;
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert an ASN.1 Boolean value into its string representation.
|
||||
*
|
||||
|
|
@ -427,6 +417,7 @@ static CURLcode utf8asn1str(struct dynbuf *to, int type, const char *from,
|
|||
*
|
||||
* @unittest 1666
|
||||
*/
|
||||
UNITTEST CURLcode encodeOID(struct dynbuf *buf, const char *b, const char *e);
|
||||
UNITTEST CURLcode encodeOID(struct dynbuf *store,
|
||||
const char *beg, const char *end)
|
||||
{
|
||||
|
|
@ -511,8 +502,13 @@ static CURLcode OID2str(struct dynbuf *store,
|
|||
return result;
|
||||
}
|
||||
|
||||
static CURLcode GTime2str(struct dynbuf *store,
|
||||
const char *beg, const char *end)
|
||||
/*
|
||||
* Unit test @1656
|
||||
*/
|
||||
UNITTEST CURLcode GTime2str(struct dynbuf *store,
|
||||
const char *beg, const char *end);
|
||||
UNITTEST CURLcode GTime2str(struct dynbuf *store,
|
||||
const char *beg, const char *end)
|
||||
{
|
||||
const char *tzp;
|
||||
const char *fracp;
|
||||
|
|
@ -589,15 +585,6 @@ static CURLcode GTime2str(struct dynbuf *store,
|
|||
sep, (int)tzl, tzp);
|
||||
}
|
||||
|
||||
#ifdef UNITTESTS
|
||||
/* used by unit1656.c */
|
||||
CURLcode Curl_x509_GTime2str(struct dynbuf *store,
|
||||
const char *beg, const char *end)
|
||||
{
|
||||
return GTime2str(store, beg, end);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert an ASN.1 UTC time to a printable string.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
***************************************************************************/
|
||||
#include "curl_setup.h"
|
||||
|
||||
struct Curl_asn1Element;
|
||||
|
||||
#if defined(USE_GNUTLS) || defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || \
|
||||
defined(USE_MBEDTLS) || defined(USE_RUSTLS)
|
||||
|
||||
|
|
@ -75,23 +77,6 @@ CURLcode Curl_extract_certinfo(struct Curl_easy *data, int certnum,
|
|||
const char *beg, const char *end);
|
||||
CURLcode Curl_verifyhost(struct Curl_cfilter *cf, struct Curl_easy *data,
|
||||
const char *beg, const char *end);
|
||||
|
||||
#ifdef UNITTESTS
|
||||
UNITTEST CURLcode encodeOID(struct dynbuf *store,
|
||||
const char *beg, const char *end);
|
||||
|
||||
#if defined(USE_GNUTLS) || defined(USE_SCHANNEL) || defined(USE_MBEDTLS) || \
|
||||
defined(USE_RUSTLS)
|
||||
|
||||
/* used by unit1656.c */
|
||||
CURLcode Curl_x509_GTime2str(struct dynbuf *store,
|
||||
const char *beg, const char *end);
|
||||
/* used by unit1657.c */
|
||||
CURLcode Curl_x509_getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end);
|
||||
#endif /* USE_GNUTLS || USE_SCHANNEL || USE_MBEDTLS || RUSTLS */
|
||||
#endif /* UNITTESTS */
|
||||
|
||||
#endif /* USE_GNUTLS || USE_WOLFSSL || USE_SCHANNEL || USE_MBEDTLS ||
|
||||
USE_RUSTLS */
|
||||
#endif /* HEADER_CURL_X509ASN1_H */
|
||||
|
|
|
|||
|
|
@ -27,15 +27,38 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
my @proto;
|
||||
my %func;
|
||||
my %inc;
|
||||
|
||||
sub scanfile {
|
||||
my ($file) = @_;
|
||||
open(F, "<$file") || die "$file failed";
|
||||
my $unit = 0;
|
||||
while(<F>) {
|
||||
if($_ =~ /^UNITTEST .*\);/) {
|
||||
push @proto, $_;
|
||||
$inc{$file} = 1;
|
||||
if($_ =~ /^UNITTEST .*[* ]([a-z0-9_]+)\(/i) {
|
||||
my $n = $1;
|
||||
if($func{$n}) {
|
||||
# already prototyped, this is now the function itself
|
||||
}
|
||||
else {
|
||||
$func{$n} = 1;
|
||||
push @proto, $_;
|
||||
$inc{$file} = 1;
|
||||
$unit = 1;
|
||||
}
|
||||
}
|
||||
if($unit) {
|
||||
if($unit != 1) {
|
||||
push @proto, $_;
|
||||
}
|
||||
if($_ =~ /\);/) {
|
||||
# end of proto
|
||||
$unit = 0;
|
||||
}
|
||||
else {
|
||||
# proto continues
|
||||
$unit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@
|
|||
|
||||
/* The point of this function would be to return a string of the input data,
|
||||
but never longer than 5 columns (+ one zero byte).
|
||||
Add suffix k, M, G when suitable... */
|
||||
Add suffix k, M, G when suitable...
|
||||
|
||||
Unit test @1622
|
||||
*/
|
||||
UNITTEST char *max5data(curl_off_t bytes, char *max5, size_t mlen)
|
||||
{
|
||||
/* a signed 64-bit value is 8192 petabytes maximum */
|
||||
|
|
@ -85,8 +88,11 @@ int xferinfo_cb(void *clientp,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Provide a time string that is 8 letters long (plus the zero byte) */
|
||||
UNITTEST void time2str(char *r, size_t rlen, curl_off_t seconds)
|
||||
/* Provide a time string that is 8 letters long (plus the zero byte)
|
||||
|
||||
Unit test @1622
|
||||
*/
|
||||
UNITTEST void timebuf(char *r, size_t rlen, curl_off_t seconds)
|
||||
{
|
||||
curl_off_t h;
|
||||
if(seconds <= 0) {
|
||||
|
|
@ -260,14 +266,14 @@ bool progress_meter(CURLM *multi, struct curltime *start, bool final)
|
|||
if(dlknown && speed) {
|
||||
curl_off_t est = all_dltotal / speed;
|
||||
curl_off_t left = (all_dltotal - all_dlnow) / speed;
|
||||
time2str(time_left, sizeof(time_left), left);
|
||||
time2str(time_total, sizeof(time_total), est);
|
||||
timebuf(time_left, sizeof(time_left), left);
|
||||
timebuf(time_total, sizeof(time_total), est);
|
||||
}
|
||||
else {
|
||||
time2str(time_left, sizeof(time_left), 0);
|
||||
time2str(time_total, sizeof(time_total), 0);
|
||||
timebuf(time_left, sizeof(time_left), 0);
|
||||
timebuf(time_total, sizeof(time_total), 0);
|
||||
}
|
||||
time2str(time_spent, sizeof(time_spent), spent);
|
||||
timebuf(time_spent, sizeof(time_spent), spent);
|
||||
|
||||
(void)curl_multi_get_offt(multi, CURLMINFO_XFERS_ADDED, &xfers_added);
|
||||
(void)curl_multi_get_offt(multi, CURLMINFO_XFERS_RUNNING, &xfers_running);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ void progress_finalize(struct per_transfer *per);
|
|||
|
||||
#ifdef UNITTESTS
|
||||
UNITTEST char *max5data(curl_off_t bytes, char *max5, size_t mlen);
|
||||
UNITTEST void time2str(char *r, size_t rlen, curl_off_t seconds);
|
||||
UNITTEST void timebuf(char *r, size_t rlen, curl_off_t seconds);
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CURL_TOOL_PROGRESS_H */
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ tool%TESTNUMBER
|
|||
|
||||
<verify>
|
||||
<stdout>
|
||||
time2str
|
||||
timebuf
|
||||
0 - %SP%SP%SP%SP%SP%SP%SP%SP
|
||||
1 - 00:00:01
|
||||
3 - 00:00:03
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<info>
|
||||
<keywords>
|
||||
unittest
|
||||
Curl_x509_GTime2str
|
||||
GTime2str
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ Curl_x509_GTime2str
|
|||
unittest
|
||||
</features>
|
||||
<name>
|
||||
Curl_x509_GTime2str unit tests
|
||||
GTime2str unit tests
|
||||
</name>
|
||||
</client>
|
||||
</testcase>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<info>
|
||||
<keywords>
|
||||
unittest
|
||||
Curl_x509_getASN1Element
|
||||
getASN1Element
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ Curl_x509_getASN1Element
|
|||
unittest
|
||||
</features>
|
||||
<name>
|
||||
Curl_x509_getASN1Element unit tests
|
||||
getASN1Element unit tests
|
||||
</name>
|
||||
</client>
|
||||
</testcase>
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ extern const struct entry_s s_entries[];
|
|||
|
||||
extern int unitfail; /* for unittests */
|
||||
|
||||
#ifdef UNITTESTS
|
||||
#include "unitprotos.h"
|
||||
#endif
|
||||
|
||||
#include "curlx/base64.h" /* for curlx_base64* */
|
||||
#include "curlx/dynbuf.h" /* for curlx_dyn_*() */
|
||||
#include "curlx/fopen.h" /* for curlx_f*() */
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ static CURLcode test_tool1622(const char *arg)
|
|||
0 /* end of list */
|
||||
};
|
||||
|
||||
puts("time2str");
|
||||
puts("timebuf");
|
||||
for(i = 0, secs = 0; i < 63; i++) {
|
||||
time2str(buffer, sizeof(buffer), secs);
|
||||
timebuf(buffer, sizeof(buffer), secs);
|
||||
curl_mprintf("%20" FMT_OFF_T " - %s\n", secs, buffer);
|
||||
if(strlen(buffer) != 8) {
|
||||
curl_mprintf("^^ was too long!\n");
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include "unitcheck.h"
|
||||
|
||||
#include "llist.h"
|
||||
#include "unitprotos.h"
|
||||
|
||||
static void test_Curl_llist_dtor(void *key, void *value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
#include "unitprotos.h"
|
||||
|
||||
static CURLcode test_unit1395(const char *arg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
|
||||
#include "progress.h"
|
||||
#include "urldata.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -24,13 +24,9 @@
|
|||
#include "unitcheck.h"
|
||||
|
||||
#ifndef CURL_DISABLE_SHUFFLE_DNS
|
||||
|
||||
#include "urldata.h"
|
||||
#include "curl_addrinfo.h"
|
||||
|
||||
CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
||||
struct Curl_addrinfo **addr);
|
||||
|
||||
static struct Curl_addrinfo addrs[8];
|
||||
|
||||
static CURLcode t1608_setup(void)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
|
||||
#include "uint-hash.h"
|
||||
|
||||
static void t1616_mydtor(uint32_t id, void *elem)
|
||||
|
|
@ -67,7 +66,7 @@ static CURLcode test_unit1616(const char *arg)
|
|||
abort_unless(v == value, "lookup present entry failed");
|
||||
v = Curl_uint32_hash_get(&hash, key2);
|
||||
abort_unless(!v, "lookup missing entry failed");
|
||||
Curl_uint32_hash_clear(&hash);
|
||||
uint_hash_clear(&hash);
|
||||
|
||||
/* Attempt to add another key/value pair */
|
||||
value2 = curlx_malloc(sizeof(int));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
#include "unitprotos.h"
|
||||
|
||||
static CURLcode test_unit1636(const char *arg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
|
||||
#include "doh.h"
|
||||
|
||||
static CURLcode test_unit1650(const char *arg)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "curl/urlapi.h"
|
||||
#include "urlapi-int.h"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
|
||||
#include "doh.h"
|
||||
|
||||
static CURLcode test_unit1655(const char *arg)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ static bool do_test(const struct test_spec *spec, size_t i,
|
|||
const char *in = spec->input;
|
||||
|
||||
curlx_dyn_reset(dbuf);
|
||||
result = Curl_x509_GTime2str(dbuf, in, in + strlen(in));
|
||||
result = GTime2str(dbuf, in, in + strlen(in));
|
||||
if(result != spec->result_exp) {
|
||||
curl_mfprintf(stderr, "test %zu: expect result %d, got %d\n",
|
||||
i, spec->result_exp, result);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ static bool do_test1657(const struct test1657_spec *spec, size_t i,
|
|||
CURLcode result;
|
||||
struct Curl_asn1Element elem;
|
||||
const char *in;
|
||||
const char *ptr;
|
||||
|
||||
memset(&elem, 0, sizeof(elem));
|
||||
curlx_dyn_reset(buf);
|
||||
|
|
@ -76,7 +77,8 @@ static bool do_test1657(const struct test1657_spec *spec, size_t i,
|
|||
return FALSE;
|
||||
}
|
||||
in = curlx_dyn_ptr(buf);
|
||||
result = Curl_x509_getASN1Element(&elem, in, in + curlx_dyn_len(buf));
|
||||
ptr = getASN1Element(&elem, in, in + curlx_dyn_len(buf));
|
||||
result = ptr ? CURLE_OK : CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
if(result != spec->result_exp) {
|
||||
curl_mfprintf(stderr, "test %zu: expect result %d, got %d\n",
|
||||
i, spec->result_exp, result);
|
||||
|
|
@ -104,7 +106,7 @@ static CURLcode test_unit1657(const char *arg)
|
|||
if(!do_test1657(&test1657_specs[i], i, &dbuf))
|
||||
all_ok = FALSE;
|
||||
}
|
||||
fail_unless(all_ok, "some tests of Curl_x509_getASN1Element() fails");
|
||||
fail_unless(all_ok, "some tests of getASN1Element() fails");
|
||||
|
||||
curlx_dyn_free(&dbuf);
|
||||
curl_global_cleanup();
|
||||
|
|
@ -117,7 +119,7 @@ static CURLcode test_unit1657(const char *arg)
|
|||
static CURLcode test_unit1657(const char *arg)
|
||||
{
|
||||
UNITTEST_BEGIN_SIMPLE
|
||||
puts("not tested since Curl_x509_getASN1Element() is not built in");
|
||||
puts("not tested since getASN1Element() is not built in");
|
||||
UNITTEST_END_SIMPLE
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,12 +36,6 @@ static CURLcode t1658_setup(void)
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
extern CURLcode doh_resp_decode_httpsrr(struct Curl_easy *data,
|
||||
const unsigned char *cp, size_t len,
|
||||
struct Curl_https_rrinfo **hrr);
|
||||
extern void doh_print_httpsrr(struct Curl_easy *data,
|
||||
struct Curl_https_rrinfo *hrr);
|
||||
|
||||
/*
|
||||
* The idea here is that we pass one DNS packet at the time to the decoder. we
|
||||
* then generate a string output with the results and compare if it matches
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#if defined(USE_GNUTLS) || defined(USE_SCHANNEL) || defined(USE_MBEDTLS) || \
|
||||
defined(USE_RUSTLS)
|
||||
|
||||
#include "vtls/x509asn1.h"
|
||||
#include "vtls/vtls.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
|
||||
#include "http_aws_sigv4.h"
|
||||
|
||||
static CURLcode test_unit1979(const char *arg)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
|
||||
#include "http_aws_sigv4.h"
|
||||
|
||||
static CURLcode test_unit1980(const char *arg)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
#include "unitcheck.h"
|
||||
|
||||
#include "urldata.h"
|
||||
#include "uint-bset.h"
|
||||
#include "curl_trc.h"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include "urldata.h"
|
||||
#include "uint-table.h"
|
||||
#include "curl_trc.h"
|
||||
#include "unitprotos.h"
|
||||
|
||||
#define TBL_SIZE 100
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include "urldata.h"
|
||||
#include "uint-spbset.h"
|
||||
#include "curl_trc.h"
|
||||
#include "unitprotos.h"
|
||||
|
||||
static void check_spbset(const char *name, const uint32_t *s, size_t slen)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue