mirror of
https://github.com/curl/curl.git
synced 2026-08-24 17:03:32 +03:00
tests: constify, make consts static
- lib509: constify an input string. - add `static` to const data, where missing. - tool1394: fix indentation. Closes #17736
This commit is contained in:
parent
db512ee267
commit
1ec0da0149
14 changed files with 33 additions and 32 deletions
|
|
@ -1900,7 +1900,7 @@ static char bigpart[120000];
|
||||||
*/
|
*/
|
||||||
static int huge(void)
|
static int huge(void)
|
||||||
{
|
{
|
||||||
const char *smallpart = "c";
|
static const char *smallpart = "c";
|
||||||
int i;
|
int i;
|
||||||
CURLU *urlp = curl_url();
|
CURLU *urlp = curl_url();
|
||||||
CURLUcode rc;
|
CURLUcode rc;
|
||||||
|
|
@ -1954,7 +1954,7 @@ static int huge(void)
|
||||||
|
|
||||||
static int urldup(void)
|
static int urldup(void)
|
||||||
{
|
{
|
||||||
const char *url[] = {
|
static const char *url[] = {
|
||||||
"http://"
|
"http://"
|
||||||
"user:pwd@"
|
"user:pwd@"
|
||||||
"[2a04:4e42:e00::347%25eth0]"
|
"[2a04:4e42:e00::347%25eth0]"
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ static CURLcode test_lib1948(char *URL)
|
||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
const char *testput = "This is test PUT data\n";
|
static const char *testput = "This is test PUT data\n";
|
||||||
put_buffer pbuf;
|
put_buffer pbuf;
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ static bool is_chain_in_order(struct curl_certinfo *cert_info)
|
||||||
|
|
||||||
/* Find the certificate issuer and subject by enumerating each field */
|
/* Find the certificate issuer and subject by enumerating each field */
|
||||||
for(; slist && (!issuer || !subject); slist = slist->next) {
|
for(; slist && (!issuer || !subject); slist = slist->next) {
|
||||||
const char issuer_prefix[] = "Issuer:";
|
static const char issuer_prefix[] = "Issuer:";
|
||||||
const char subject_prefix[] = "Subject:";
|
static const char subject_prefix[] = "Subject:";
|
||||||
|
|
||||||
if(!strncmp(slist->data, issuer_prefix, sizeof(issuer_prefix)-1)) {
|
if(!strncmp(slist->data, issuer_prefix, sizeof(issuer_prefix)-1)) {
|
||||||
issuer = slist->data + sizeof(issuer_prefix)-1;
|
issuer = slist->data + sizeof(issuer_prefix)-1;
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,9 @@ static CURLcode test_lib505(char *URL)
|
||||||
struct curl_slist *hl;
|
struct curl_slist *hl;
|
||||||
|
|
||||||
struct curl_slist *headerlist = NULL;
|
struct curl_slist *headerlist = NULL;
|
||||||
const char *buf_1 = "RNFR 505";
|
|
||||||
const char *buf_2 = "RNTO 505-forreal";
|
static const char *buf_1 = "RNFR 505";
|
||||||
|
static const char *buf_2 = "RNTO 505-forreal";
|
||||||
|
|
||||||
if(!libtest_arg2) {
|
if(!libtest_arg2) {
|
||||||
curl_mfprintf(stderr, "Usage: <url> <file-to-upload>\n");
|
curl_mfprintf(stderr, "Usage: <url> <file-to-upload>\n");
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,8 @@ static void custom_free(void *ptr)
|
||||||
|
|
||||||
static CURLcode test_lib509(char *URL)
|
static CURLcode test_lib509(char *URL)
|
||||||
{
|
{
|
||||||
unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
static const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||||
0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7};
|
0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7};
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
int asize;
|
int asize;
|
||||||
|
|
@ -98,7 +98,7 @@ static CURLcode test_lib509(char *URL)
|
||||||
test_setopt(curl, CURLOPT_USERAGENT, "test509"); /* uses strdup() */
|
test_setopt(curl, CURLOPT_USERAGENT, "test509"); /* uses strdup() */
|
||||||
|
|
||||||
asize = (int)sizeof(a);
|
asize = (int)sizeof(a);
|
||||||
str = curl_easy_escape(curl, (char *)a, asize); /* uses realloc() */
|
str = curl_easy_escape(curl, (const char *)a, asize); /* uses realloc() */
|
||||||
|
|
||||||
if(seen)
|
if(seen)
|
||||||
curl_mprintf("Callbacks were invoked!\n");
|
curl_mprintf("Callbacks were invoked!\n");
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ again:
|
||||||
|
|
||||||
if(!res) {
|
if(!res) {
|
||||||
/* we are connected, now get an HTTP document the raw way */
|
/* we are connected, now get an HTTP document the raw way */
|
||||||
const char *request =
|
static const char *request =
|
||||||
"GET /556 HTTP/1.1\r\n"
|
"GET /556 HTTP/1.1\r\n"
|
||||||
"Host: ninja\r\n\r\n";
|
"Host: ninja\r\n\r\n";
|
||||||
const char *sbuf = request;
|
const char *sbuf = request;
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,7 @@ OM_uint32 gss_display_status(OM_uint32 *min,
|
||||||
OM_uint32 *message_context,
|
OM_uint32 *message_context,
|
||||||
gss_buffer_t status_string)
|
gss_buffer_t status_string)
|
||||||
{
|
{
|
||||||
const char maj_str[] = "Stub GSS error";
|
static const char maj_str[] = "Stub GSS error";
|
||||||
(void)mech_type;
|
(void)mech_type;
|
||||||
if(min)
|
if(min)
|
||||||
*min = 0;
|
*min = 0;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ static CURLcode test_tool1394(char *arg)
|
||||||
{
|
{
|
||||||
UNITTEST_BEGIN_SIMPLE
|
UNITTEST_BEGIN_SIMPLE
|
||||||
|
|
||||||
const char *values[] = {
|
static const char *values[] = {
|
||||||
/* -E parameter */ /* exp. cert name */ /* exp. passphrase */
|
/* -E parameter */ /* exp. cert name */ /* exp. passphrase */
|
||||||
"foo:bar:baz", "foo", "bar:baz",
|
"foo:bar:baz", "foo", "bar:baz",
|
||||||
"foo\\:bar:baz", "foo:bar", "baz",
|
"foo\\:bar:baz", "foo:bar", "baz",
|
||||||
|
|
@ -74,20 +74,20 @@ static CURLcode test_tool1394(char *arg)
|
||||||
if(certname) {
|
if(certname) {
|
||||||
if(strcmp(p[1], certname)) {
|
if(strcmp(p[1], certname)) {
|
||||||
printf("expected certname '%s' but got '%s' "
|
printf("expected certname '%s' but got '%s' "
|
||||||
"for -E param '%s'\n", p[1], certname, p[0]);
|
"for -E param '%s'\n", p[1], certname, p[0]);
|
||||||
fail("assertion failure");
|
fail("assertion failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("expected certname '%s' but got NULL "
|
printf("expected certname '%s' but got NULL "
|
||||||
"for -E param '%s'\n", p[1], p[0]);
|
"for -E param '%s'\n", p[1], p[0]);
|
||||||
fail("assertion failure");
|
fail("assertion failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(certname) {
|
if(certname) {
|
||||||
printf("expected certname NULL but got '%s' "
|
printf("expected certname NULL but got '%s' "
|
||||||
"for -E param '%s'\n", certname, p[0]);
|
"for -E param '%s'\n", certname, p[0]);
|
||||||
fail("assertion failure");
|
fail("assertion failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -95,20 +95,20 @@ static CURLcode test_tool1394(char *arg)
|
||||||
if(passphrase) {
|
if(passphrase) {
|
||||||
if(strcmp(p[2], passphrase)) {
|
if(strcmp(p[2], passphrase)) {
|
||||||
printf("expected passphrase '%s' but got '%s'"
|
printf("expected passphrase '%s' but got '%s'"
|
||||||
"for -E param '%s'\n", p[2], passphrase, p[0]);
|
"for -E param '%s'\n", p[2], passphrase, p[0]);
|
||||||
fail("assertion failure");
|
fail("assertion failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("expected passphrase '%s' but got NULL "
|
printf("expected passphrase '%s' but got NULL "
|
||||||
"for -E param '%s'\n", p[2], p[0]);
|
"for -E param '%s'\n", p[2], p[0]);
|
||||||
fail("assertion failure");
|
fail("assertion failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(passphrase) {
|
if(passphrase) {
|
||||||
printf("expected passphrase NULL but got '%s' "
|
printf("expected passphrase NULL but got '%s' "
|
||||||
"for -E param '%s'\n", passphrase, p[0]);
|
"for -E param '%s'\n", passphrase, p[0]);
|
||||||
fail("assertion failure");
|
fail("assertion failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ static CURLcode test_unit1398(char *arg)
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
char buf[3] = {'b', 'u', 'g'};
|
char buf[3] = {'b', 'u', 'g'};
|
||||||
const char *str = "bug";
|
static const char *str = "bug";
|
||||||
int width = 3;
|
int width = 3;
|
||||||
char output[130];
|
char output[130];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ static CURLcode test_unit1601(char *arg)
|
||||||
#if (defined(USE_CURL_NTLM_CORE) && !defined(USE_WINDOWS_SSPI)) \
|
#if (defined(USE_CURL_NTLM_CORE) && !defined(USE_WINDOWS_SSPI)) \
|
||||||
|| !defined(CURL_DISABLE_DIGEST_AUTH)
|
|| !defined(CURL_DISABLE_DIGEST_AUTH)
|
||||||
|
|
||||||
const char string1[] = "1";
|
static const char string1[] = "1";
|
||||||
const char string2[] = "hello-you-fool";
|
static const char string2[] = "hello-you-fool";
|
||||||
unsigned char output[MD5_DIGEST_LEN];
|
unsigned char output[MD5_DIGEST_LEN];
|
||||||
unsigned char *testp = output;
|
unsigned char *testp = output;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ static CURLcode test_unit1610(char *arg)
|
||||||
#if !defined(CURL_DISABLE_AWS) || !defined(CURL_DISABLE_DIGEST_AUTH) \
|
#if !defined(CURL_DISABLE_AWS) || !defined(CURL_DISABLE_DIGEST_AUTH) \
|
||||||
|| defined(USE_LIBSSH2)
|
|| defined(USE_LIBSSH2)
|
||||||
|
|
||||||
const char string1[] = "1";
|
static const char string1[] = "1";
|
||||||
const char string2[] = "hello-you-fool";
|
static const char string2[] = "hello-you-fool";
|
||||||
unsigned char output[CURL_SHA256_DIGEST_LENGTH];
|
unsigned char output[CURL_SHA256_DIGEST_LENGTH];
|
||||||
unsigned char *testp = output;
|
unsigned char *testp = output;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ static CURLcode test_unit1611(char *arg)
|
||||||
UNITTEST_BEGIN_SIMPLE
|
UNITTEST_BEGIN_SIMPLE
|
||||||
|
|
||||||
#ifdef USE_CURL_NTLM_CORE
|
#ifdef USE_CURL_NTLM_CORE
|
||||||
const char string1[] = "1";
|
static const char string1[] = "1";
|
||||||
const char string2[] = "hello-you-fool";
|
static const char string2[] = "hello-you-fool";
|
||||||
unsigned char output[MD4_DIGEST_LENGTH];
|
unsigned char output[MD4_DIGEST_LENGTH];
|
||||||
unsigned char *testp = output;
|
unsigned char *testp = output;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ static CURLcode test_unit1612(char *arg)
|
||||||
#if (defined(USE_CURL_NTLM_CORE) && !defined(USE_WINDOWS_SSPI)) \
|
#if (defined(USE_CURL_NTLM_CORE) && !defined(USE_WINDOWS_SSPI)) \
|
||||||
|| !defined(CURL_DISABLE_DIGEST_AUTH)
|
|| !defined(CURL_DISABLE_DIGEST_AUTH)
|
||||||
|
|
||||||
const char password[] = "Pa55worD";
|
static const char password[] = "Pa55worD";
|
||||||
const char string1[] = "1";
|
static const char string1[] = "1";
|
||||||
const char string2[] = "hello-you-fool";
|
static const char string2[] = "hello-you-fool";
|
||||||
unsigned char output[HMAC_MD5_LENGTH];
|
unsigned char output[HMAC_MD5_LENGTH];
|
||||||
unsigned char *testp = output;
|
unsigned char *testp = output;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,9 +135,9 @@ static CURLcode test_unit1655(char *arg)
|
||||||
const size_t buflen = sizeof(buffer);
|
const size_t buflen = sizeof(buffer);
|
||||||
const size_t magic1 = 9765;
|
const size_t magic1 = 9765;
|
||||||
size_t olen1 = magic1;
|
size_t olen1 = magic1;
|
||||||
const char *sunshine1 = "a.com";
|
static const char *sunshine1 = "a.com";
|
||||||
const char *dotshine1 = "a.com.";
|
static const char *dotshine1 = "a.com.";
|
||||||
const char *sunshine2 = "aa.com";
|
static const char *sunshine2 = "aa.com";
|
||||||
size_t olen2;
|
size_t olen2;
|
||||||
DOHcode ret2;
|
DOHcode ret2;
|
||||||
size_t olen;
|
size_t olen;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue