Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1594.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* Testing Retry-After header parser */
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
struct curl_slist *header = NULL;
curl_off_t retry;
CURL *curl = NULL;
int res = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
res = curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry);
if(res)
goto test_cleanup;
#ifdef LIB1596
/* we get a relative number of seconds, so add the number of seconds
we're at to make it a somewhat stable number. Then remove accuracy. */
retry += time(NULL);
retry /= 10000;
#endif
printf("Retry-After %" CURL_FORMAT_CURL_OFF_T "\n", retry);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_slist_free_all(header);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1508.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2020, Linus Nielsen Feltzing <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
int res = 0;
CURLM *m = NULL;
(void)URL;
global_init(CURL_GLOBAL_ALL);
multi_init(m);
test_cleanup:
/* proper cleanup sequence - type PB */
curl_multi_cleanup(m);
curl_global_cleanup();
printf("We are done\n");
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib586.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
#define THREADS 2
/* struct containing data of a thread */
struct Tdata {
CURLSH *share;
char *url;
};
struct userdata {
const char *text;
int counter;
};
/* lock callback */
static void my_lock(CURL *handle, curl_lock_data data,
curl_lock_access laccess, void *useptr)
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
(void)laccess;
switch(data) {
case CURL_LOCK_DATA_SHARE:
what = "share";
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
break;
case CURL_LOCK_DATA_SSL_SESSION:
what = "ssl_session";
break;
default:
fprintf(stderr, "lock: no such data: %d\n", (int)data);
return;
}
printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
}
/* unlock callback */
static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
(void)handle;
switch(data) {
case CURL_LOCK_DATA_SHARE:
what = "share";
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
break;
case CURL_LOCK_DATA_SSL_SESSION:
what = "ssl_session";
break;
default:
fprintf(stderr, "unlock: no such data: %d\n", (int)data);
return;
}
printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
}
/* the dummy thread function */
static void *fire(void *ptr)
{
CURLcode code;
struct Tdata *tdata = (struct Tdata*)ptr;
CURL *curl;
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
return NULL;
}
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_URL, tdata->url);
printf("CURLOPT_SHARE\n");
curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
printf("PERFORM\n");
code = curl_easy_perform(curl);
if(code != CURLE_OK) {
int i = 0;
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
tdata->url, i, (int)code);
}
printf("CLEANUP\n");
curl_easy_cleanup(curl);
return NULL;
}
/* test function */
int test(char *URL)
{
int res;
CURLSHcode scode = CURLSHE_OK;
char *url;
struct Tdata tdata;
CURL *curl;
CURLSH *share;
int i;
struct userdata user;
user.text = "Pigs in space";
user.counter = 0;
printf("GLOBAL_INIT\n");
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* prepare share */
printf("SHARE_INIT\n");
share = curl_share_init();
if(!share) {
fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_LOCKFUNC\n");
scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_UNLOCKFUNC\n");
scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_USERDATA\n");
scode = curl_share_setopt(share, CURLSHOPT_USERDATA, &user);
}
if(CURLSHE_OK == scode) {
printf("CURL_LOCK_DATA_SSL_SESSION\n");
scode = curl_share_setopt(share, CURLSHOPT_SHARE,
CURL_LOCK_DATA_SSL_SESSION);
}
if(CURLSHE_OK != scode) {
fprintf(stderr, "curl_share_setopt() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
res = 0;
/* start treads */
for(i = 1; i <= THREADS; i++) {
/* set thread data */
tdata.url = URL;
tdata.share = share;
/* simulate thread, direct call of "thread" function */
printf("*** run %d\n",i);
fire(&tdata);
}
/* fetch a another one */
printf("*** run %d\n", i);
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
url = URL;
test_setopt(curl, CURLOPT_URL, url);
printf("CURLOPT_SHARE\n");
test_setopt(curl, CURLOPT_SHARE, share);
printf("PERFORM\n");
curl_easy_perform(curl);
/* try to free share, expect to fail because share is in use*/
printf("try SHARE_CLEANUP...\n");
scode = curl_share_cleanup(share);
if(scode == CURLSHE_OK) {
fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL;
}
else {
printf("SHARE_CLEANUP failed, correct\n");
}
test_cleanup:
/* clean up last handle */
printf("CLEANUP\n");
curl_easy_cleanup(curl);
/* free share */
printf("SHARE_CLEANUP\n");
scode = curl_share_cleanup(share);
if(scode != CURLSHE_OK)
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode);
printf("GLOBAL_CLEANUP\n");
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib506.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static const char *HOSTHEADER = "Host: www.host.foo.com";
static const char *JAR = "log/jar506";
#define THREADS 2
/* struct containing data of a thread */
struct Tdata {
CURLSH *share;
char *url;
};
struct userdata {
const char *text;
int counter;
};
static int locks[3];
/* lock callback */
static void my_lock(CURL *handle, curl_lock_data data,
curl_lock_access laccess, void *useptr)
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
int locknum;
(void)handle;
(void)laccess;
switch(data) {
case CURL_LOCK_DATA_SHARE:
what = "share";
locknum = 0;
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
locknum = 1;
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
locknum = 2;
break;
default:
fprintf(stderr, "lock: no such data: %d\n", (int)data);
return;
}
/* detect locking of locked locks */
if(locks[locknum]) {
printf("lock: double locked %s\n", what);
return;
}
locks[locknum]++;
printf("lock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
}
/* unlock callback */
static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
{
const char *what;
struct userdata *user = (struct userdata *)useptr;
int locknum;
(void)handle;
switch(data) {
case CURL_LOCK_DATA_SHARE:
what = "share";
locknum = 0;
break;
case CURL_LOCK_DATA_DNS:
what = "dns";
locknum = 1;
break;
case CURL_LOCK_DATA_COOKIE:
what = "cookie";
locknum = 2;
break;
default:
fprintf(stderr, "unlock: no such data: %d\n", (int)data);
return;
}
/* detect unlocking of unlocked locks */
if(!locks[locknum]) {
printf("unlock: double unlocked %s\n", what);
return;
}
locks[locknum]--;
printf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter);
user->counter++;
}
/* build host entry */
static struct curl_slist *sethost(struct curl_slist *headers)
{
(void)headers;
return curl_slist_append(NULL, HOSTHEADER);
}
/* the dummy thread function */
static void *fire(void *ptr)
{
CURLcode code;
struct curl_slist *headers;
struct Tdata *tdata = (struct Tdata*)ptr;
CURL *curl;
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
return NULL;
}
headers = sethost(NULL);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, tdata->url);
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
printf("CURLOPT_SHARE\n");
curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share);
printf("PERFORM\n");
code = curl_easy_perform(curl);
if(code) {
int i = 0;
fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n",
tdata->url, i, (int)code);
}
printf("CLEANUP\n");
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
return NULL;
}
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
}
/* test function */
int test(char *URL)
{
int res;
CURLSHcode scode = CURLSHE_OK;
CURLcode code = CURLE_OK;
char *url = NULL;
struct Tdata tdata;
CURL *curl;
CURLSH *share;
struct curl_slist *headers = NULL;
struct curl_slist *cookies = NULL;
struct curl_slist *next_cookie = NULL;
int i;
struct userdata user;
user.text = "Pigs in space";
user.counter = 0;
printf("GLOBAL_INIT\n");
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* prepare share */
printf("SHARE_INIT\n");
share = curl_share_init();
if(!share) {
fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_LOCKFUNC\n");
scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock);
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_UNLOCKFUNC\n");
scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock);
}
if(CURLSHE_OK == scode) {
printf("CURLSHOPT_USERDATA\n");
scode = curl_share_setopt(share, CURLSHOPT_USERDATA, &user);
}
if(CURLSHE_OK == scode) {
printf("CURL_LOCK_DATA_COOKIE\n");
scode = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
}
if(CURLSHE_OK == scode) {
printf("CURL_LOCK_DATA_DNS\n");
scode = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
}
if(CURLSHE_OK != scode) {
fprintf(stderr, "curl_share_setopt() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* initial cookie manipulation */
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
printf("CURLOPT_SHARE\n");
test_setopt(curl, CURLOPT_SHARE, share);
printf("CURLOPT_COOKIELIST injected_and_clobbered\n");
test_setopt(curl, CURLOPT_COOKIELIST,
"Set-Cookie: injected_and_clobbered=yes; "
"domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030");
printf("CURLOPT_COOKIELIST ALL\n");
test_setopt(curl, CURLOPT_COOKIELIST, "ALL");
printf("CURLOPT_COOKIELIST session\n");
test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: session=elephants");
printf("CURLOPT_COOKIELIST injected\n");
test_setopt(curl, CURLOPT_COOKIELIST,
"Set-Cookie: injected=yes; domain=host.foo.com; "
"expires=Sat Feb 2 11:56:27 GMT 2030");
printf("CURLOPT_COOKIELIST SESS\n");
test_setopt(curl, CURLOPT_COOKIELIST, "SESS");
printf("CLEANUP\n");
curl_easy_cleanup(curl);
res = 0;
/* start treads */
for(i = 1; i <= THREADS; i++) {
/* set thread data */
tdata.url = suburl(URL, i); /* must be curl_free()d */
tdata.share = share;
/* simulate thread, direct call of "thread" function */
printf("*** run %d\n",i);
fire(&tdata);
curl_free(tdata.url);
}
/* fetch a another one and save cookies */
printf("*** run %d\n", i);
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
url = suburl(URL, i);
headers = sethost(NULL);
test_setopt(curl, CURLOPT_HTTPHEADER, headers);
test_setopt(curl, CURLOPT_URL, url);
printf("CURLOPT_SHARE\n");
test_setopt(curl, CURLOPT_SHARE, share);
printf("CURLOPT_COOKIEJAR\n");
test_setopt(curl, CURLOPT_COOKIEJAR, JAR);
printf("CURLOPT_COOKIELIST FLUSH\n");
test_setopt(curl, CURLOPT_COOKIELIST, "FLUSH");
printf("PERFORM\n");
curl_easy_perform(curl);
printf("CLEANUP\n");
curl_easy_cleanup(curl);
curl_free(url);
curl_slist_free_all(headers);
/* load cookies */
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
url = suburl(URL, i);
headers = sethost(NULL);
test_setopt(curl, CURLOPT_HTTPHEADER, headers);
test_setopt(curl, CURLOPT_URL, url);
printf("CURLOPT_SHARE\n");
test_setopt(curl, CURLOPT_SHARE, share);
printf("CURLOPT_COOKIELIST ALL\n");
test_setopt(curl, CURLOPT_COOKIELIST, "ALL");
printf("CURLOPT_COOKIEJAR\n");
test_setopt(curl, CURLOPT_COOKIEFILE, JAR);
printf("CURLOPT_COOKIELIST RELOAD\n");
test_setopt(curl, CURLOPT_COOKIELIST, "RELOAD");
code = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if(code != CURLE_OK) {
fprintf(stderr, "curl_easy_getinfo() failed\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
printf("loaded cookies:\n");
if(!cookies) {
fprintf(stderr, " reloading cookies from '%s' failed\n", JAR);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
printf("-----------------\n");
next_cookie = cookies;
while(next_cookie) {
printf(" %s\n", next_cookie->data);
next_cookie = next_cookie->next;
}
printf("-----------------\n");
curl_slist_free_all(cookies);
/* try to free share, expect to fail because share is in use*/
printf("try SHARE_CLEANUP...\n");
scode = curl_share_cleanup(share);
if(scode == CURLSHE_OK) {
fprintf(stderr, "curl_share_cleanup succeed but error expected\n");
share = NULL;
}
else {
printf("SHARE_CLEANUP failed, correct\n");
}
test_cleanup:
/* clean up last handle */
printf("CLEANUP\n");
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
curl_free(url);
/* free share */
printf("SHARE_CLEANUP\n");
scode = curl_share_cleanup(share);
if(scode != CURLSHE_OK)
fprintf(stderr, "curl_share_cleanup failed, code errno %d\n",
(int)scode);
printf("GLOBAL_CLEANUP\n");
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1552.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL *curls = NULL;
CURLM *multi = NULL;
int still_running;
int i = 0;
int res = 0;
CURLMsg *msg;
int counter = 3;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(curls);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
easy_setopt(curls, CURLOPT_VERBOSE, 1L);
easy_setopt(curls, CURLOPT_USERPWD, "u:s");
multi_add_handle(multi, curls);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running && counter--) {
int num;
res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
if(res != CURLM_OK) {
printf("curl_multi_wait() returned %d\n", res);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &still_running);
if(msg)
/* this should now contain a result code from the easy handle,
get it */
i = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/test1013.pl | #!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
###########################################################################
# Determine if curl-config --protocols/--features matches the
# curl --version protocols/features
if ( $#ARGV != 2 )
{
print "Usage: $0 curl-config-script curl-version-output-file features|protocols\n";
exit 3;
}
my $what=$ARGV[2];
# Read the output of curl --version
my $curl_protocols="";
open(CURL, "$ARGV[1]") || die "Can't get curl $what list\n";
while( <CURL> )
{
$curl_protocols = lc($_) if ( /$what:/i );
}
close CURL;
$curl_protocols =~ s/\r//;
$curl_protocols =~ /\w+: (.*)$/;
@curl = split / /,$1;
# These features are not supported by curl-config
@curl = grep(!/^(Debug|TrackMemory|CharConv)$/i, @curl);
@curl = sort @curl;
# Read the output of curl-config
my @curl_config;
open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config $what list\n";
while( <CURLCONFIG> )
{
chomp;
# ignore curl-config --features not in curl's feature list
push @curl_config, lc($_);
}
close CURLCONFIG;
@curl_config = sort @curl_config;
my $curlproto = join ' ', @curl;
my $curlconfigproto = join ' ', @curl_config;
my $different = $curlproto ne $curlconfigproto;
if ($different) {
print "Mismatch in $what lists:\n";
print "curl: $curlproto\n";
print "curl-config: $curlconfigproto\n";
}
exit $different;
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1553.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
static int xferinfo(void *p,
curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow)
{
(void)p;
(void)dlnow;
(void)dltotal;
(void)ulnow;
(void)ultotal;
fprintf(stderr, "xferinfo fail!\n");
return 1; /* fail as fast as we can */
}
int test(char *URL)
{
CURL *curls = NULL;
CURLM *multi = NULL;
int still_running;
int i = 0;
int res = 0;
curl_mimepart *field = NULL;
curl_mime *mime = NULL;
int counter = 1;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(curls);
mime = curl_mime_init(curls);
field = curl_mime_addpart(mime);
curl_mime_name(field, "name");
curl_mime_data(field, "value", CURL_ZERO_TERMINATED);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
easy_setopt(curls, CURLOPT_VERBOSE, 1L);
easy_setopt(curls, CURLOPT_MIMEPOST, mime);
easy_setopt(curls, CURLOPT_USERPWD, "u:s");
easy_setopt(curls, CURLOPT_XFERINFOFUNCTION, xferinfo);
easy_setopt(curls, CURLOPT_NOPROGRESS, 1L);
multi_add_handle(multi, curls);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running && counter--) {
int num;
res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
if(res != CURLM_OK) {
printf("curl_multi_wait() returned %d\n", res);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
test_cleanup:
curl_mime_free(mime);
curl_multi_remove_handle(multi, curls);
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1535.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* Test CURLINFO_PROTOCOL */
int test(char *URL)
{
CURL *curl, *dupe = NULL;
long protocol;
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
/* Test that protocol is properly initialized on curl_easy_init.
*/
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(protocol) {
fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
__FILE__, __LINE__, protocol);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
easy_setopt(curl, CURLOPT_URL, URL);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
/* Test that a protocol is properly set after receiving an HTTP resource.
*/
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(protocol != CURLPROTO_HTTP) {
fprintf(stderr, "%s:%d protocol of http resource is incorrect; "
"expected %d but is %ld\n",
__FILE__, __LINE__, CURLPROTO_HTTP, protocol);
res = CURLE_HTTP_RETURNED_ERROR;
goto test_cleanup;
}
/* Test that a protocol is properly initialized on curl_easy_duphandle.
*/
dupe = curl_easy_duphandle(curl);
if(!dupe) {
fprintf(stderr, "%s:%d curl_easy_duphandle() failed\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
res = curl_easy_getinfo(dupe, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(protocol) {
fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
__FILE__, __LINE__, protocol);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
/* Test that a protocol is properly initialized on curl_easy_reset.
*/
curl_easy_reset(curl);
res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(protocol) {
fprintf(stderr, "%s:%d protocol init failed; expected 0 but is %ld\n",
__FILE__, __LINE__, protocol);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_easy_cleanup(dupe);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1908.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2020, Linus Nielsen Feltzing, <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode ret = CURLE_OK;
CURL *hnd;
start_test_timing();
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
if(hnd) {
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_ALTSVC, "log/altsvc-1908");
ret = curl_easy_perform(hnd);
if(!ret) {
/* make a copy and check that this also has alt-svc activated */
CURL *also = curl_easy_duphandle(hnd);
if(also) {
ret = curl_easy_perform(also);
/* we close the second handle first, which makes it store the alt-svc
file only to get overwritten when the next handle is closed! */
curl_easy_cleanup(also);
}
}
curl_easy_reset(hnd);
/* using the same file name for the alt-svc cache, this clobbers the
content just written from the 'also' handle */
curl_easy_cleanup(hnd);
}
curl_global_cleanup();
return (int)ret;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1550.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
#include <curl/multi.h>
int test(char *URL)
{
CURLM *handle;
int res = CURLE_OK;
static const char * const bl_servers[] =
{"Microsoft-IIS/6.0", "nginx/0.8.54", NULL};
static const char * const bl_sites[] =
{"curl.se:443", "example.com:80", NULL};
global_init(CURL_GLOBAL_ALL);
handle = curl_multi_init();
(void)URL; /* unused */
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SERVER_BL, bl_servers);
curl_multi_setopt(handle, CURLMOPT_PIPELINING_SITE_BL, bl_sites);
curl_multi_cleanup(handle);
curl_global_cleanup();
return 0;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1515.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* Check for bugs #1303 and #1327: libcurl should never remove DNS entries
* created via CURLOPT_RESOLVE, neither after DNS_CACHE_TIMEOUT elapses
* (test1515) nor a dead connection is detected (test1616).
*/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define DNS_TIMEOUT 1
#if defined(WIN32) || defined(_WIN32)
#define sleep(sec) Sleep ((sec)*1000)
#endif
static int debug_callback(CURL *curl, curl_infotype info, char *msg,
size_t len, void *ptr)
{
(void)curl;
(void)ptr;
if(info == CURLINFO_TEXT)
fprintf(stderr, "debug: %.*s", (int) len, msg);
return 0;
}
static int do_one_request(CURLM *m, char *URL, char *resolve)
{
CURL *curls;
struct curl_slist *resolve_list = NULL;
int still_running;
int res = 0;
CURLMsg *msg;
int msgs_left;
resolve_list = curl_slist_append(resolve_list, resolve);
easy_init(curls);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_RESOLVE, resolve_list);
easy_setopt(curls, CURLOPT_DEBUGFUNCTION, debug_callback);
easy_setopt(curls, CURLOPT_VERBOSE, 1);
easy_setopt(curls, CURLOPT_DNS_CACHE_TIMEOUT, DNS_TIMEOUT);
multi_add_handle(m, curls);
multi_perform(m, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread, fdwrite, fdexcep;
int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
multi_fdset(m, &fdread, &fdwrite, &fdexcep, &maxfd);
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(m, &still_running);
abort_on_test_timeout();
}
do {
msg = curl_multi_info_read(m, &msgs_left);
if(msg && msg->msg == CURLMSG_DONE && msg->easy_handle == curls) {
res = msg->data.result;
break;
}
} while(msg);
test_cleanup:
curl_multi_remove_handle(m, curls);
curl_easy_cleanup(curls);
curl_slist_free_all(resolve_list);
return res;
}
int test(char *URL)
{
CURLM *multi = NULL;
int res = 0;
char *address = libtest_arg2;
char *port = libtest_arg3;
char *path = URL;
char dns_entry[256];
int i;
int count = 2;
msnprintf(dns_entry, sizeof(dns_entry), "testserver.example.com:%s:%s",
port, address);
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
for(i = 1; i <= count; i++) {
char target_url[256];
msnprintf(target_url, sizeof(target_url),
"http://testserver.example.com:%s/%s%04d", port, path, i);
/* second request must succeed like the first one */
res = do_one_request(multi, target_url, dns_entry);
if(res)
goto test_cleanup;
if(i < count)
sleep(DNS_TIMEOUT + 1);
}
test_cleanup:
curl_multi_cleanup(multi);
curl_global_cleanup();
return (int) res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1565.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#include <unistd.h>
#define TEST_HANG_TIMEOUT 60 * 1000
#define CONN_NUM 3
#define TIME_BETWEEN_START_SECS 2
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static CURL *pending_handles[CONN_NUM];
static int pending_num = 0;
static int test_failure = 0;
static CURLM *multi = NULL;
static const char *url;
static void *run_thread(void *ptr)
{
CURL *easy = NULL;
int res = 0;
int i;
(void)ptr;
for(i = 0; i < CONN_NUM; i++) {
wait_ms(TIME_BETWEEN_START_SECS * 1000);
easy_init(easy);
easy_setopt(easy, CURLOPT_URL, url);
easy_setopt(easy, CURLOPT_VERBOSE, 0L);
pthread_mutex_lock(&lock);
if(test_failure) {
pthread_mutex_unlock(&lock);
goto test_cleanup;
}
pending_handles[pending_num] = easy;
pending_num++;
easy = NULL;
pthread_mutex_unlock(&lock);
res_multi_wakeup(multi);
}
test_cleanup:
curl_easy_cleanup(easy);
pthread_mutex_lock(&lock);
if(!test_failure)
test_failure = res;
pthread_mutex_unlock(&lock);
return NULL;
}
int test(char *URL)
{
int still_running;
int num;
int i;
int res = 0;
CURL *started_handles[CONN_NUM];
int started_num = 0;
int finished_num = 0;
pthread_t tid;
bool tid_valid = false;
struct CURLMsg *message;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
url = URL;
res = pthread_create(&tid, NULL, run_thread, NULL);
if(!res)
tid_valid = true;
else {
fprintf(stderr, "%s:%d Couldn't create thread, errno %d\n",
__FILE__, __LINE__, res);
goto test_cleanup;
}
while(1) {
multi_perform(multi, &still_running);
abort_on_test_timeout();
while((message = curl_multi_info_read(multi, &num)) != NULL) {
if(message->msg == CURLMSG_DONE) {
res = message->data.result;
if(res)
goto test_cleanup;
multi_remove_handle(multi, message->easy_handle);
finished_num++;
}
else {
fprintf(stderr, "%s:%d Got an unexpected message from curl: %i\n",
__FILE__, __LINE__, (int)message->msg);
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
abort_on_test_timeout();
}
if(CONN_NUM == finished_num)
break;
multi_poll(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
abort_on_test_timeout();
pthread_mutex_lock(&lock);
while(pending_num > 0) {
res_multi_add_handle(multi, pending_handles[pending_num - 1]);
if(res) {
pthread_mutex_unlock(&lock);
goto test_cleanup;
}
started_handles[started_num] = pending_handles[pending_num - 1];
started_num++;
pending_num--;
}
pthread_mutex_unlock(&lock);
abort_on_test_timeout();
}
if(CONN_NUM != started_num) {
fprintf(stderr, "%s:%d Not all connections started: %d of %d\n",
__FILE__, __LINE__, started_num, CONN_NUM);
goto test_cleanup;
}
if(CONN_NUM != finished_num) {
fprintf(stderr, "%s:%d Not all connections finished: %d of %d\n",
__FILE__, __LINE__, started_num, CONN_NUM);
goto test_cleanup;
}
test_cleanup:
pthread_mutex_lock(&lock);
if(!test_failure)
test_failure = res;
pthread_mutex_unlock(&lock);
if(tid_valid)
pthread_join(tid, NULL);
curl_multi_cleanup(multi);
for(i = 0; i < pending_num; i++)
curl_easy_cleanup(pending_handles[i]);
for(i = 0; i < started_num; i++)
curl_easy_cleanup(started_handles[i]);
curl_global_cleanup();
return test_failure;
}
#else /* without pthread, this test doesn't work */
int test(char *URL)
{
(void)URL;
return 0;
}
#endif
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib515.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 0L);
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Now, we should be making a zero byte POST request */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1559.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define EXCESSIVE 10*1000*1000
int test(char *URL)
{
CURLcode res = 0;
CURL *curl = NULL;
char *longurl = malloc(EXCESSIVE);
CURLU *u;
(void)URL;
if(!longurl)
return 1;
memset(longurl, 'a', EXCESSIVE);
longurl[EXCESSIVE-1] = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
res = curl_easy_setopt(curl, CURLOPT_URL, longurl);
printf("CURLOPT_URL %d bytes URL == %d\n",
EXCESSIVE, (int)res);
res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, longurl);
printf("CURLOPT_POSTFIELDS %d bytes data == %d\n",
EXCESSIVE, (int)res);
u = curl_url();
if(u) {
CURLUcode uc = curl_url_set(u, CURLUPART_URL, longurl, 0);
printf("CURLUPART_URL %d bytes URL == %d (%s)\n",
EXCESSIVE, (int)uc, curl_url_strerror(uc));
uc = curl_url_set(u, CURLUPART_SCHEME, longurl, CURLU_NON_SUPPORT_SCHEME);
printf("CURLUPART_SCHEME %d bytes scheme == %d (%s)\n",
EXCESSIVE, (int)uc, curl_url_strerror(uc));
uc = curl_url_set(u, CURLUPART_USER, longurl, 0);
printf("CURLUPART_USER %d bytes user == %d (%s)\n",
EXCESSIVE, (int)uc, curl_url_strerror(uc));
curl_url_cleanup(u);
}
test_cleanup:
free(longurl);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res; /* return the final return code */
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1529.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
char bURL[512];
msnprintf(bURL, sizeof(bURL),
"%s HTTP/1.1\r\nGET http://1529.com/1529", URL);
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, bURL);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1510.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2020, Linus Nielsen Feltzing <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define NUM_URLS 4
int test(char *URL)
{
int res = 0;
CURL *curl = NULL;
int i;
char target_url[256];
char dnsentry[256];
struct curl_slist *slist = NULL, *slist2;
char *port = libtest_arg3;
char *address = libtest_arg2;
(void)URL;
/* Create fake DNS entries for serverX.example.com for all handles */
for(i = 0; i < NUM_URLS; i++) {
msnprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1,
port, address);
printf("%s\n", dnsentry);
slist2 = curl_slist_append(slist, dnsentry);
if(!slist2) {
fprintf(stderr, "curl_slist_append() failed\n");
goto test_cleanup;
}
slist = slist2;
}
start_test_timing();
global_init(CURL_GLOBAL_ALL);
/* get an easy handle */
easy_init(curl);
/* go verbose */
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers */
easy_setopt(curl, CURLOPT_HEADER, 1L);
easy_setopt(curl, CURLOPT_RESOLVE, slist);
easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
/* get NUM_HANDLES easy handles */
for(i = 0; i < NUM_URLS; i++) {
/* specify target */
msnprintf(target_url, sizeof(target_url),
"http://server%d.example.com:%s/path/1510%04i",
i + 1, port, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
easy_setopt(curl, CURLOPT_URL, target_url);
res = curl_easy_perform(curl);
abort_on_test_timeout();
}
test_cleanup:
/* proper cleanup sequence - type PB */
curl_easy_cleanup(curl);
curl_slist_free_all(slist);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/chkdecimalpoint.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curl_printf.h"
#include <string.h>
#include <locale.h>
#define TOTAL_STR_LEN 4
int main(void)
{
char zero[TOTAL_STR_LEN] = {'\0'};
int chars;
setlocale(LC_NUMERIC, "");
chars = msnprintf(zero, TOTAL_STR_LEN, "%.1f", 0.0);
if((chars == (TOTAL_STR_LEN - 1)) && (strcmp(zero, "0.0") == 0))
return 0;
else
return 1;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib572.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include "memdebug.h"
/* build request url */
static char *suburl(const char *base, int i)
{
return curl_maprintf("%s%.4d", base, i);
}
/*
* Test GET_PARAMETER: PUT, HEARTBEAT, and POST
*/
int test(char *URL)
{
int res;
CURL *curl;
int params;
FILE *paramsf = NULL;
struct_stat file_info;
char *stream_uri = NULL;
int request = 1;
struct curl_slist *custom_headers = NULL;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_HEADERDATA, stdout);
test_setopt(curl, CURLOPT_WRITEDATA, stdout);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_URL, URL);
/* SETUP */
stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles");
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
/* PUT style GET_PARAMETERS */
params = open("log/file572.txt", O_RDONLY);
fstat(params, &file_info);
close(params);
paramsf = fopen("log/file572.txt", "rb");
if(!paramsf) {
fprintf(stderr, "can't open log/file572.txt\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
test_setopt(curl, CURLOPT_READDATA, paramsf);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size);
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_UPLOAD, 0L);
fclose(paramsf);
paramsf = NULL;
/* Heartbeat GET_PARAMETERS */
stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
/* POST GET_PARAMETERS */
stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER);
test_setopt(curl, CURLOPT_POSTFIELDS, "packets_received\njitter\n");
res = curl_easy_perform(curl);
if(res)
goto test_cleanup;
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
/* Make sure we can do a normal request now */
stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
free(stream_uri);
stream_uri = NULL;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
res = curl_easy_perform(curl);
test_cleanup:
if(paramsf)
fclose(paramsf);
free(stream_uri);
if(custom_headers)
curl_slist_free_all(custom_headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib558.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7};
CURLcode res = CURLE_OK;
char *ptr = NULL;
int asize;
(void)URL; /* we don't use this */
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
ptr = malloc(558);
Curl_safefree(ptr);
asize = (int)sizeof(a);
ptr = curl_easy_escape(NULL, (char *)a, asize);
if(ptr)
curl_free(ptr);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/stub_gssapi.h | #ifndef HEADER_CURL_GSSAPI_STUBS_H
#define HEADER_CURL_GSSAPI_STUBS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2017 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* Roughly based on Heimdal's gssapi.h */
#include <stdint.h>
#include <stddef.h>
#define GSS_ERROR(status) (status & 0x80000000)
#define GSS_S_COMPLETE 0
#define GSS_S_FAILURE (0x80000000)
#define GSS_S_CONTINUE_NEEDED (1ul)
#define GSS_C_QOP_DEFAULT 0
#define GSS_C_NO_OID ((gss_OID) 0)
#define GSS_C_NO_NAME ((gss_name_t) 0)
#define GSS_C_NO_BUFFER ((gss_buffer_t) 0)
#define GSS_C_NO_CONTEXT ((gss_ctx_id_t) 0)
#define GSS_C_NO_CREDENTIAL ((gss_cred_id_t) 0)
#define GSS_C_NO_CHANNEL_BINDINGS ((gss_channel_bindings_t) 0)
#define GSS_C_NULL_OID GSS_C_NO_OID
#define GSS_C_EMPTY_BUFFER {0, NULL}
#define GSS_C_AF_INET 2
#define GSS_C_GSS_CODE 1
#define GSS_C_MECH_CODE 2
#define GSS_C_DELEG_FLAG 1
#define GSS_C_MUTUAL_FLAG 2
#define GSS_C_REPLAY_FLAG 4
#define GSS_C_CONF_FLAG 16
#define GSS_C_INTEG_FLAG 32
/*
* Expiration time of 2^32-1 seconds means infinite lifetime for a
* credential or security context
*/
#define GSS_C_INDEFINITE 0xfffffffful
#define GSS_C_NT_HOSTBASED_SERVICE NULL
typedef uint32_t OM_uint32;
typedef OM_uint32 gss_qop_t;
typedef struct gss_buffer_desc_struct {
size_t length;
void *value;
} gss_buffer_desc, *gss_buffer_t;
struct gss_cred_id_t_desc_struct;
typedef struct gss_cred_id_t_desc_struct *gss_cred_id_t;
typedef const struct gss_cred_id_t_desc_struct *gss_const_cred_id_t;
struct gss_ctx_id_t_desc_struct;
typedef struct gss_ctx_id_t_desc_struct *gss_ctx_id_t;
typedef const struct gss_ctx_id_t_desc_struct *gss_const_ctx_id_t;
struct gss_name_t_desc_struct;
typedef struct gss_name_t_desc_struct *gss_name_t;
typedef const struct gss_name_t_desc_struct *gss_const_name_t;
typedef struct gss_OID_desc_struct {
OM_uint32 length;
void *elements;
} gss_OID_desc, *gss_OID;
typedef struct gss_channel_bindings_struct {
OM_uint32 initiator_addrtype;
gss_buffer_desc initiator_address;
OM_uint32 acceptor_addrtype;
gss_buffer_desc acceptor_address;
gss_buffer_desc application_data;
} *gss_channel_bindings_t;
OM_uint32 gss_release_buffer(OM_uint32 * /*minor_status*/,
gss_buffer_t /*buffer*/);
OM_uint32 gss_init_sec_context(OM_uint32 * /*minor_status*/,
gss_const_cred_id_t /*initiator_cred_handle*/,
gss_ctx_id_t * /*context_handle*/,
gss_const_name_t /*target_name*/,
const gss_OID /*mech_type*/,
OM_uint32 /*req_flags*/,
OM_uint32 /*time_req*/,
const gss_channel_bindings_t /*input_chan_bindings*/,
const gss_buffer_t /*input_token*/,
gss_OID * /*actual_mech_type*/,
gss_buffer_t /*output_token*/,
OM_uint32 * /*ret_flags*/,
OM_uint32 * /*time_rec*/);
OM_uint32 gss_delete_sec_context(OM_uint32 * /*minor_status*/,
gss_ctx_id_t * /*context_handle*/,
gss_buffer_t /*output_token*/);
OM_uint32 gss_inquire_context(OM_uint32 * /*minor_status*/,
gss_const_ctx_id_t /*context_handle*/,
gss_name_t * /*src_name*/,
gss_name_t * /*targ_name*/,
OM_uint32 * /*lifetime_rec*/,
gss_OID * /*mech_type*/,
OM_uint32 * /*ctx_flags*/,
int * /*locally_initiated*/,
int * /*open_context*/);
OM_uint32 gss_wrap(OM_uint32 * /*minor_status*/,
gss_const_ctx_id_t /*context_handle*/,
int /*conf_req_flag*/,
gss_qop_t /*qop_req*/,
const gss_buffer_t /*input_message_buffer*/,
int * /*conf_state*/,
gss_buffer_t /*output_message_buffer*/);
OM_uint32 gss_unwrap(OM_uint32 * /*minor_status*/,
gss_const_ctx_id_t /*context_handle*/,
const gss_buffer_t /*input_message_buffer*/,
gss_buffer_t /*output_message_buffer*/,
int * /*conf_state*/,
gss_qop_t * /*qop_state*/);
OM_uint32 gss_seal(OM_uint32 * /*minor_status*/,
gss_ctx_id_t /*context_handle*/,
int /*conf_req_flag*/,
int /*qop_req*/,
gss_buffer_t /*input_message_buffer*/,
int * /*conf_state*/,
gss_buffer_t /*output_message_buffer*/);
OM_uint32 gss_unseal(OM_uint32 * /*minor_status*/,
gss_ctx_id_t /*context_handle*/,
gss_buffer_t /*input_message_buffer*/,
gss_buffer_t /*output_message_buffer*/,
int * /*conf_state*/,
int * /*qop_state*/);
OM_uint32 gss_import_name(OM_uint32 * /*minor_status*/,
const gss_buffer_t /*input_name_buffer*/,
const gss_OID /*input_name_type*/,
gss_name_t * /*output_name*/);
OM_uint32 gss_release_name(OM_uint32 * /*minor_status*/,
gss_name_t * /*input_name*/);
OM_uint32 gss_display_name(OM_uint32 * /*minor_status*/,
gss_const_name_t /*input_name*/,
gss_buffer_t /*output_name_buffer*/,
gss_OID * /*output_name_type*/);
OM_uint32 gss_display_status(OM_uint32 * /*minor_status*/,
OM_uint32 /*status_value*/,
int /*status_type*/,
const gss_OID /*mech_type*/,
OM_uint32 * /*message_context*/,
gss_buffer_t /*status_string*/);
#endif /* HEADER_CURL_GSSAPI_STUBS_H */
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib521.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib574.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static int new_fnmatch(void *ptr,
const char *pattern, const char *string)
{
(void)ptr;
(void)pattern;
(void)string;
return CURL_FNMATCHFUNC_MATCH;
}
int test(char *URL)
{
int res;
CURL *curl;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_WILDCARDMATCH, 1L);
test_setopt(curl, CURLOPT_FNMATCH_FUNCTION, new_fnmatch);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "curl_easy_perform() failed %d\n", res);
goto test_cleanup;
}
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "curl_easy_perform() failed %d\n", res);
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1591.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* This unit test PUT http data over proxy. Proxy header will be different
* from server http header
*/
#include "test.h"
#include <stdio.h>
#include "memdebug.h"
static char data [] = "Hello Cloud!\r\n";
static size_t consumed = 0;
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
if(consumed == strlen(data)) {
return 0;
}
if(amount > strlen(data)-consumed) {
amount = strlen(data);
}
consumed += amount;
(void)stream;
memcpy(ptr, data, amount);
return amount;
}
/*
* carefully not leak memory on OOM
*/
static int trailers_callback(struct curl_slist **list, void *userdata)
{
struct curl_slist *nlist = NULL;
struct curl_slist *nlist2 = NULL;
(void)userdata;
nlist = curl_slist_append(*list, "my-super-awesome-trailer: trail1");
if(nlist)
nlist2 = curl_slist_append(nlist, "my-other-awesome-trailer: trail2");
if(nlist2) {
*list = nlist2;
return CURL_TRAILERFUNC_OK;
}
else {
curl_slist_free_all(nlist);
return CURL_TRAILERFUNC_ABORT;
}
}
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
/* http and proxy header list*/
struct curl_slist *hhl = NULL;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
hhl = curl_slist_append(hhl, "Trailer: my-super-awesome-trailer,"
" my-other-awesome-trailer");
if(!hhl) {
goto test_cleanup;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_PUT, 1L);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_TRAILERFUNCTION, trailers_callback);
test_setopt(curl, CURLOPT_TRAILERDATA, NULL);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_slist_free_all(hhl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1935.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = TEST_ERR_MAJOR_BAD;
struct curl_slist *list = NULL;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "xxx:yyy:rrr");
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_HEADER, 0L);
test_setopt(curl, CURLOPT_URL, URL);
list = curl_slist_append(list, "Content-Type: application/json");
test_setopt(curl, CURLOPT_HTTPHEADER, list);
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1533.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* This test sends data with CURLOPT_KEEP_SENDING_ON_ERROR.
* The server responds with an early error response.
* The test is successful if the connection can be reused for the next request,
* because this implies that the data has been sent completely to the server.
*/
#include "test.h"
#include "memdebug.h"
struct cb_data {
CURL *easy_handle;
int response_received;
int paused;
size_t remaining_bytes;
};
static void reset_data(struct cb_data *data, CURL *curl)
{
data->easy_handle = curl;
data->response_received = 0;
data->paused = 0;
data->remaining_bytes = 3;
}
static size_t read_callback(char *ptr, size_t size, size_t nitems,
void *userdata)
{
struct cb_data *data = (struct cb_data *)userdata;
/* wait until the server has sent all response headers */
if(data->response_received) {
size_t totalsize = nitems * size;
size_t bytes_to_send = data->remaining_bytes;
if(bytes_to_send > totalsize) {
bytes_to_send = totalsize;
}
memset(ptr, 'a', bytes_to_send);
data->remaining_bytes -= bytes_to_send;
return bytes_to_send;
}
else {
data->paused = 1;
return CURL_READFUNC_PAUSE;
}
}
static size_t write_callback(char *ptr, size_t size, size_t nmemb,
void *userdata)
{
struct cb_data *data = (struct cb_data *)userdata;
size_t totalsize = nmemb * size;
/* unused parameter */
(void)ptr;
/* all response headers have been received */
data->response_received = 1;
if(data->paused) {
/* continue to send request body data */
data->paused = 0;
curl_easy_pause(data->easy_handle, CURLPAUSE_CONT);
}
return totalsize;
}
static int perform_and_check_connections(CURL *curl, const char *description,
long expected_connections)
{
CURLcode res;
long connections = 0;
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed\n");
return TEST_ERR_MAJOR_BAD;
}
res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connections);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_getinfo() failed\n");
return TEST_ERR_MAJOR_BAD;
}
fprintf(stderr, "%s: expected: %ld connections; actual: %ld connections\n",
description, expected_connections, connections);
if(connections != expected_connections) {
return TEST_ERR_FAILURE;
}
return TEST_ERR_SUCCESS;
}
int test(char *URL)
{
struct cb_data data;
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
reset_data(&data, curl);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_POST, 1L);
test_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
(curl_off_t)data.remaining_bytes);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_READDATA, &data);
test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
test_setopt(curl, CURLOPT_WRITEDATA, &data);
res = perform_and_check_connections(curl,
"First request without CURLOPT_KEEP_SENDING_ON_ERROR", 1);
if(res != TEST_ERR_SUCCESS) {
goto test_cleanup;
}
reset_data(&data, curl);
res = perform_and_check_connections(curl,
"Second request without CURLOPT_KEEP_SENDING_ON_ERROR", 1);
if(res != TEST_ERR_SUCCESS) {
goto test_cleanup;
}
test_setopt(curl, CURLOPT_KEEP_SENDING_ON_ERROR, 1L);
reset_data(&data, curl);
res = perform_and_check_connections(curl,
"First request with CURLOPT_KEEP_SENDING_ON_ERROR", 1);
if(res != TEST_ERR_SUCCESS) {
goto test_cleanup;
}
reset_data(&data, curl);
res = perform_and_check_connections(curl,
"Second request with CURLOPT_KEEP_SENDING_ON_ERROR", 0);
if(res != TEST_ERR_SUCCESS) {
goto test_cleanup;
}
res = TEST_ERR_SUCCESS;
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib511.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_FILETIME, 1L);
test_setopt(curl, CURLOPT_NOBODY, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1900.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2020, Linus Nielsen Feltzing, <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define MAX_URLS 200
#define MAX_BLOCKLIST 20
static int urltime[MAX_URLS];
static char *urlstring[MAX_URLS];
static CURL *handles[MAX_URLS];
static char *site_blocklist[MAX_BLOCKLIST];
static char *server_blocklist[MAX_BLOCKLIST];
static int num_handles;
static int blocklist_num_servers;
static int blocklist_num_sites;
static size_t
write_callback(void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
(void)contents;
(void)userp;
return realsize;
}
static int parse_url_file(const char *filename)
{
FILE *f;
int filetime;
char buf[200];
num_handles = 0;
blocklist_num_sites = 0;
blocklist_num_servers = 0;
f = fopen(filename, "rb");
if(!f)
return 0;
while(!feof(f)) {
if(fscanf(f, "%d %199s\n", &filetime, buf)) {
urltime[num_handles] = filetime;
urlstring[num_handles] = strdup(buf);
num_handles++;
continue;
}
if(fscanf(f, "blocklist_site %199s\n", buf)) {
site_blocklist[blocklist_num_sites] = strdup(buf);
blocklist_num_sites++;
continue;
}
break;
}
fclose(f);
site_blocklist[blocklist_num_sites] = NULL;
server_blocklist[blocklist_num_servers] = NULL;
return num_handles;
}
static void free_urls(void)
{
int i;
for(i = 0; i < num_handles; i++) {
Curl_safefree(urlstring[i]);
}
for(i = 0; i < blocklist_num_servers; i++) {
Curl_safefree(server_blocklist[i]);
}
for(i = 0; i < blocklist_num_sites; i++) {
Curl_safefree(site_blocklist[i]);
}
}
static int create_handles(void)
{
int i;
for(i = 0; i < num_handles; i++) {
handles[i] = curl_easy_init();
}
return 0;
}
static void setup_handle(char *base_url, CURLM *m, int handlenum)
{
char urlbuf[256];
msnprintf(urlbuf, sizeof(urlbuf), "%s%s", base_url, urlstring[handlenum]);
curl_easy_setopt(handles[handlenum], CURLOPT_URL, urlbuf);
curl_easy_setopt(handles[handlenum], CURLOPT_VERBOSE, 1L);
curl_easy_setopt(handles[handlenum], CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(handles[handlenum], CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(handles[handlenum], CURLOPT_WRITEDATA, NULL);
curl_multi_add_handle(m, handles[handlenum]);
}
static void remove_handles(void)
{
int i;
for(i = 0; i < num_handles; i++) {
if(handles[i])
curl_easy_cleanup(handles[i]);
}
}
int test(char *URL)
{
int res = 0;
CURLM *m = NULL;
CURLMsg *msg; /* for picking up messages with the transfer status */
int msgs_left; /* how many messages are left */
int running = 0;
int handlenum = 0;
struct timeval last_handle_add;
if(parse_url_file(libtest_arg2) <= 0)
goto test_cleanup;
start_test_timing();
curl_global_init(CURL_GLOBAL_ALL);
multi_init(m);
create_handles();
multi_setopt(m, CURLMOPT_PIPELINING, 1L);
multi_setopt(m, CURLMOPT_MAX_HOST_CONNECTIONS, 2L);
multi_setopt(m, CURLMOPT_MAX_PIPELINE_LENGTH, 3L);
multi_setopt(m, CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, 15000L);
multi_setopt(m, CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, 10000L);
multi_setopt(m, CURLMOPT_PIPELINING_SITE_BL, site_blocklist);
multi_setopt(m, CURLMOPT_PIPELINING_SERVER_BL, server_blocklist);
last_handle_add = tutil_tvnow();
for(;;) {
struct timeval interval;
struct timeval now;
fd_set rd, wr, exc;
int maxfd = -99;
long timeout;
interval.tv_sec = 1;
interval.tv_usec = 0;
if(handlenum < num_handles) {
now = tutil_tvnow();
if(tutil_tvdiff(now, last_handle_add) >= urltime[handlenum]) {
fprintf(stdout, "Adding handle %d\n", handlenum);
setup_handle(URL, m, handlenum);
last_handle_add = now;
handlenum++;
}
}
curl_multi_perform(m, &running);
abort_on_test_timeout();
/* See how the transfers went */
do {
msg = curl_multi_info_read(m, &msgs_left);
if(msg && msg->msg == CURLMSG_DONE) {
int i;
/* Find out which handle this message is about */
for(i = 0; i < num_handles; i++) {
int found = (msg->easy_handle == handles[i]);
if(found)
break;
}
printf("Handle %d Completed with status %d\n", i, msg->data.result);
curl_multi_remove_handle(m, handles[i]);
}
} while(msg);
if(handlenum == num_handles && !running) {
break; /* done */
}
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
curl_multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
curl_multi_timeout(m, &timeout);
if(timeout < 0)
timeout = 1;
interval.tv_sec = timeout / 1000;
interval.tv_usec = (timeout % 1000) * 1000;
interval.tv_sec = 0;
interval.tv_usec = 1000;
select_test(maxfd + 1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
test_cleanup:
remove_handles();
/* undocumented cleanup sequence - type UB */
curl_multi_cleanup(m);
curl_global_cleanup();
free_urls();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1910.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2020, Linus Nielsen Feltzing, <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode ret = CURLE_OK;
CURL *hnd;
start_test_timing();
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
if(hnd) {
curl_easy_setopt(hnd, CURLOPT_URL, URL);
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(hnd, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(hnd, CURLOPT_USERPWD, "user\nname:pass\nword");
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
}
curl_global_cleanup();
return (int)ret;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib556.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "warnless.h"
#include "memdebug.h"
/* For Windows, mainly (may be moved in a config file?) */
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
int test(char *URL)
{
CURLcode res;
CURL *curl;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if(!res) {
/* we are connected, now get a HTTP document the raw way */
const char *request =
#ifdef CURL_DOES_CONVERSIONS
/* ASCII representation with escape sequences for non-ASCII platforms */
"\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e"
"\x31\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x6e\x69\x6e\x6a\x61\x0d\x0a"
"\x0d\x0a";
#else
"GET /556 HTTP/1.1\r\n"
"Host: ninja\r\n\r\n";
#endif
size_t iolen = 0;
res = curl_easy_send(curl, request, strlen(request), &iolen);
if(!res) {
/* we assume that sending always work */
do {
char buf[1024];
/* busy-read like crazy */
res = curl_easy_recv(curl, buf, sizeof(buf), &iolen);
#ifdef TPF
sleep(1); /* avoid ctl-10 dump */
#endif
if(iolen) {
/* send received stuff to stdout */
if(!write(STDOUT_FILENO, buf, iolen))
break;
}
} while((res == CURLE_OK && iolen) || (res == CURLE_AGAIN));
}
if(iolen)
res = (CURLcode)TEST_ERR_FAILURE;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib543.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* Based on Alex Fishman's bug report on September 30, 2007 */
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
static const unsigned char a[] = {
0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1,
0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa,
0x1d, 0x57, 0xe1};
CURL *easy;
CURLcode res = CURLE_OK;
(void)URL;
global_init(CURL_GLOBAL_ALL);
easy = curl_easy_init();
if(!easy) {
fprintf(stderr, "curl_easy_init() failed\n");
res = TEST_ERR_MAJOR_BAD;
}
else {
int asize = (int)sizeof(a);
char *s = curl_easy_escape(easy, (const char *)a, asize);
if(s) {
printf("%s\n", s);
curl_free(s);
}
s = curl_easy_escape(easy, "", 0);
if(s) {
printf("IN: '' OUT: '%s'\n", s);
curl_free(s);
}
s = curl_easy_escape(easy, " 123", 3);
if(s) {
printf("IN: ' 12' OUT: '%s'\n", s);
curl_free(s);
}
curl_easy_cleanup(easy);
}
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1536.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* Test CURLINFO_SCHEME */
int test(char *URL)
{
CURL *curl, *dupe = NULL;
char *scheme;
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
/* Test that scheme is properly initialized on curl_easy_init.
*/
res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(scheme != NULL) {
fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
easy_setopt(curl, CURLOPT_URL, URL);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
/* Test that a scheme is properly set after receiving an HTTP resource.
*/
res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(!scheme || memcmp(scheme, "HTTP", 5) != 0) {
fprintf(stderr, "%s:%d scheme of http resource is incorrect; "
"expected 'HTTP' but is %s\n",
__FILE__, __LINE__,
(scheme == NULL ? "NULL" : "invalid"));
res = CURLE_HTTP_RETURNED_ERROR;
goto test_cleanup;
}
/* Test that a scheme is properly initialized on curl_easy_duphandle.
*/
dupe = curl_easy_duphandle(curl);
if(!dupe) {
fprintf(stderr, "%s:%d curl_easy_duphandle() failed\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
res = curl_easy_getinfo(dupe, CURLINFO_SCHEME, &scheme);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(scheme) {
fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
/* Test that a scheme is properly initialized on curl_easy_reset.
*/
curl_easy_reset(curl);
res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
if(res) {
fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
if(scheme) {
fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
__FILE__, __LINE__);
res = CURLE_FAILED_INIT;
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(curl);
curl_easy_cleanup(dupe);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/libauthretry.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* argv1 = URL
* argv2 = main auth type
* argv3 = second auth type
*/
#include "test.h"
#include "memdebug.h"
static CURLcode send_request(CURL *curl, const char *url, int seq,
long auth_scheme, const char *userpwd)
{
CURLcode res;
size_t len = strlen(url) + 4 + 1;
char *full_url = malloc(len);
if(!full_url) {
fprintf(stderr, "Not enough memory for full url\n");
return CURLE_OUT_OF_MEMORY;
}
msnprintf(full_url, len, "%s%04d", url, seq);
fprintf(stderr, "Sending new request %d to %s with credential %s "
"(auth %ld)\n", seq, full_url, userpwd, auth_scheme);
test_setopt(curl, CURLOPT_URL, full_url);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_HTTPGET, 1L);
test_setopt(curl, CURLOPT_USERPWD, userpwd);
test_setopt(curl, CURLOPT_HTTPAUTH, auth_scheme);
res = curl_easy_perform(curl);
test_cleanup:
free(full_url);
return res;
}
static CURLcode send_wrong_password(CURL *curl, const char *url, int seq,
long auth_scheme)
{
return send_request(curl, url, seq, auth_scheme, "testuser:wrongpass");
}
static CURLcode send_right_password(CURL *curl, const char *url, int seq,
long auth_scheme)
{
return send_request(curl, url, seq, auth_scheme, "testuser:testpass");
}
static long parse_auth_name(const char *arg)
{
if(!arg)
return CURLAUTH_NONE;
if(curl_strequal(arg, "basic"))
return CURLAUTH_BASIC;
if(curl_strequal(arg, "digest"))
return CURLAUTH_DIGEST;
if(curl_strequal(arg, "ntlm"))
return CURLAUTH_NTLM;
return CURLAUTH_NONE;
}
int test(char *url)
{
CURLcode res;
CURL *curl = NULL;
long main_auth_scheme = parse_auth_name(libtest_arg2);
long fallback_auth_scheme = parse_auth_name(libtest_arg3);
if(main_auth_scheme == CURLAUTH_NONE ||
fallback_auth_scheme == CURLAUTH_NONE) {
fprintf(stderr, "auth schemes not found on commandline\n");
return TEST_ERR_MAJOR_BAD;
}
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
/* Send wrong password, then right password */
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
res = send_wrong_password(curl, url, 100, main_auth_scheme);
if(res != CURLE_OK)
goto test_cleanup;
res = send_right_password(curl, url, 200, fallback_auth_scheme);
if(res != CURLE_OK)
goto test_cleanup;
curl_easy_cleanup(curl);
/* Send wrong password twice, then right password */
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
res = send_wrong_password(curl, url, 300, main_auth_scheme);
if(res != CURLE_OK)
goto test_cleanup;
res = send_wrong_password(curl, url, 400, fallback_auth_scheme);
if(res != CURLE_OK)
goto test_cleanup;
res = send_right_password(curl, url, 500, fallback_auth_scheme);
if(res != CURLE_OK)
goto test_cleanup;
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1542.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* Test CURLOPT_MAXLIFETIME_CONN:
* Send four requests, sleeping between the second and third and setting
* MAXLIFETIME_CONN between the third and fourth. The first three requests
* should use the same connection, and the fourth request should close the
* first connection and open a second.
*/
#include "test.h"
#include "testutil.h"
#include "testtrace.h"
#include "warnless.h"
#include "memdebug.h"
#if defined(WIN32) || defined(_WIN32)
#define sleep(sec) Sleep ((sec)*1000)
#endif
int test(char *URL)
{
CURL *easy = NULL;
int res = 0;
global_init(CURL_GLOBAL_ALL);
res_easy_init(easy);
easy_setopt(easy, CURLOPT_URL, URL);
libtest_debug_config.nohex = 1;
libtest_debug_config.tracetime = 0;
easy_setopt(easy, CURLOPT_DEBUGDATA, &libtest_debug_config);
easy_setopt(easy, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
easy_setopt(easy, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(easy);
if(res)
goto test_cleanup;
res = curl_easy_perform(easy);
if(res)
goto test_cleanup;
/* CURLOPT_MAXLIFETIME_CONN is inclusive - the connection needs to be 2
* seconds old */
sleep(2);
res = curl_easy_perform(easy);
if(res)
goto test_cleanup;
easy_setopt(easy, CURLOPT_MAXLIFETIME_CONN, 1L);
res = curl_easy_perform(easy);
if(res)
goto test_cleanup;
test_cleanup:
curl_easy_cleanup(easy);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib520.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_FILETIME, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib670.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include <time.h>
#include "test.h"
#include "memdebug.h"
#define PAUSE_TIME 2
static const char name[] = "field";
struct ReadThis {
CURL *easy;
time_t origin;
int count;
};
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct ReadThis *pooh = (struct ReadThis *) userp;
time_t delta;
if(size * nmemb < 1)
return 0;
switch(pooh->count++) {
case 0:
*ptr = '\x41'; /* ASCII A. */
return 1;
case 1:
pooh->origin = time(NULL);
return CURL_READFUNC_PAUSE;
case 2:
delta = time(NULL) - pooh->origin;
*ptr = delta >= PAUSE_TIME? '\x42': '\x41'; /* ASCII A or B. */
return 1;
case 3:
return 0;
}
fprintf(stderr, "Read callback called after EOF\n");
exit(1);
}
#if !defined(LIB670) && !defined(LIB672)
static int xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow)
{
struct ReadThis *pooh = (struct ReadThis *) clientp;
(void) dltotal;
(void) dlnow;
(void) ultotal;
(void) ulnow;
if(pooh->origin) {
time_t delta = time(NULL) - pooh->origin;
if(delta >= 4 * PAUSE_TIME) {
fprintf(stderr, "unpausing failed: drain problem?\n");
return CURLE_ABORTED_BY_CALLBACK;
}
if(delta >= PAUSE_TIME)
curl_easy_pause(pooh->easy, CURLPAUSE_CONT);
}
return 0;
}
#endif
int test(char *URL)
{
#if defined(LIB670) || defined(LIB671)
curl_mime *mime = NULL;
curl_mimepart *part;
#else
CURLFORMcode formrc;
struct curl_httppost *formpost = NULL;
struct curl_httppost *lastptr = NULL;
#endif
#if defined(LIB670) || defined(LIB672)
CURLM *multi = NULL;
CURLMcode mres;
CURLMsg *msg;
int msgs_left;
int still_running = 0;
#endif
struct ReadThis pooh;
CURLcode result;
int res = TEST_ERR_FAILURE;
/*
* Check proper pausing/unpausing from a mime or form read callback.
*/
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
pooh.origin = (time_t) 0;
pooh.count = 0;
pooh.easy = curl_easy_init();
/* First set the URL that is about to receive our POST. */
test_setopt(pooh.easy, CURLOPT_URL, URL);
/* get verbose debug output please */
test_setopt(pooh.easy, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(pooh.easy, CURLOPT_HEADER, 1L);
#if defined(LIB670) || defined(LIB671)
/* Build the mime tree. */
mime = curl_mime_init(pooh.easy);
part = curl_mime_addpart(mime);
result = curl_mime_name(part, name);
if(!result)
res = curl_mime_data_cb(part, (curl_off_t) 2, read_callback,
NULL, NULL, &pooh);
if(result) {
fprintf(stderr,
"Something went wrong when building the mime structure: %d\n",
(int) result);
goto test_cleanup;
}
/* Bind mime data to its easy handle. */
if(!res)
test_setopt(pooh.easy, CURLOPT_MIMEPOST, mime);
#else
/* Build the form. */
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, name,
CURLFORM_STREAM, &pooh,
CURLFORM_CONTENTLEN, (curl_off_t) 2,
CURLFORM_END);
if(formrc) {
fprintf(stderr, "curl_formadd() = %d\n", (int) formrc);
goto test_cleanup;
}
/* We want to use our own read function. */
test_setopt(pooh.easy, CURLOPT_READFUNCTION, read_callback);
/* Send a multi-part formpost. */
test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost);
#endif
#if defined(LIB670) || defined(LIB672)
/* Use the multi interface. */
multi = curl_multi_init();
mres = curl_multi_add_handle(multi, pooh.easy);
while(!mres) {
struct timeval timeout;
int rc = 0;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcept;
int maxfd = -1;
mres = curl_multi_perform(multi, &still_running);
if(!still_running || mres != CURLM_OK)
break;
if(pooh.origin) {
time_t delta = time(NULL) - pooh.origin;
if(delta >= 4 * PAUSE_TIME) {
fprintf(stderr, "unpausing failed: drain problem?\n");
res = CURLE_OPERATION_TIMEDOUT;
break;
}
if(delta >= PAUSE_TIME)
curl_easy_pause(pooh.easy, CURLPAUSE_CONT);
}
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcept);
timeout.tv_sec = 0;
timeout.tv_usec = 1000000 * PAUSE_TIME / 10;
mres = curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcept, &maxfd);
if(mres)
break;
#if defined(WIN32) || defined(_WIN32)
if(maxfd == -1)
Sleep(100);
else
#endif
rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcept, &timeout);
if(rc == -1) {
fprintf(stderr, "Select error\n");
break;
}
}
if(mres != CURLM_OK)
for(;;) {
msg = curl_multi_info_read(multi, &msgs_left);
if(!msg)
break;
if(msg->msg == CURLMSG_DONE) {
result = msg->data.result;
res = (int) result;
}
}
curl_multi_remove_handle(multi, pooh.easy);
curl_multi_cleanup(multi);
#else
/* Use the easy interface. */
test_setopt(pooh.easy, CURLOPT_XFERINFODATA, &pooh);
test_setopt(pooh.easy, CURLOPT_XFERINFOFUNCTION, xferinfo);
test_setopt(pooh.easy, CURLOPT_NOPROGRESS, 0L);
result = curl_easy_perform(pooh.easy);
res = (int) result;
#endif
test_cleanup:
curl_easy_cleanup(pooh.easy);
#if defined(LIB670) || defined(LIB671)
curl_mime_free(mime);
#else
curl_formfree(formpost);
#endif
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1513.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* Test case converted from bug report #1318 by Petr Novak.
*
* Before the fix, this test program returned 52 (CURLE_GOT_NOTHING) instead
* of 42 (CURLE_ABORTED_BY_CALLBACK).
*/
#include "test.h"
#include "memdebug.h"
static int progressKiller(void *arg,
double dltotal,
double dlnow,
double ultotal,
double ulnow)
{
(void)arg;
(void)dltotal;
(void)dlnow;
(void)ultotal;
(void)ulnow;
printf("PROGRESSFUNCTION called\n");
return 1;
}
int test(char *URL)
{
CURL *curl;
int res = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_TIMEOUT, (long)7);
easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1);
easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressKiller);
easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0);
res = curl_easy_perform(curl);
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib514.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Based on a bug report by Niels van Tongeren on June 29, 2004:
A weird situation occurs when request 1 is a POST request and the request
2 is a HEAD request. For the POST request we set the CURLOPT_POSTFIELDS,
CURLOPT_POSTFIELDSIZE and CURLOPT_POST options. For the HEAD request we
set the CURLOPT_NOBODY option to '1'.
*/
test_setopt(curl, CURLOPT_POSTFIELDS, "moo");
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 3L);
test_setopt(curl, CURLOPT_POST, 1L);
/* this is where transfer 1 would take place, but skip that and change
options right away instead */
test_setopt(curl, CURLOPT_NOBODY, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
/* Now, we should be making a fine HEAD request */
/* Perform the request 2, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib578.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
static char data[]="this is a short string.\n";
static size_t data_size = sizeof(data) / sizeof(char);
static int progress_callback(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow)
{
FILE *moo = fopen(libtest_arg2, "wb");
(void)clientp; /* UNUSED */
(void)dltotal; /* UNUSED */
(void)dlnow; /* UNUSED */
if(moo) {
if((size_t)ultotal == data_size && (size_t)ulnow == data_size)
fprintf(moo, "PASSED, UL data matched data size\n");
else
fprintf(moo, "Progress callback called with UL %f out of %f\n",
ulnow, ultotal);
fclose(moo);
}
return 0;
}
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)data_size);
test_setopt(curl, CURLOPT_POSTFIELDS, data);
/* we want to use our own progress function */
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
/* pointer to pass to our read function */
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1937.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curl;
CURLcode res = TEST_ERR_MAJOR_BAD;
struct curl_slist *list = NULL;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_POST, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "provider1:provider2:region:service");
test_setopt(curl, CURLOPT_USERPWD, "keyId:SecretKey");
test_setopt(curl, CURLOPT_HEADER, 0L);
test_setopt(curl, CURLOPT_URL, URL);
list = curl_slist_append(list, "Content-Type: application/json");
test_setopt(curl, CURLOPT_HTTPHEADER, list);
test_setopt(curl, CURLOPT_POSTFIELDS, "postData");
res = curl_easy_perform(curl);
test_cleanup:
curl_slist_free_all(list);
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib591.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
/* lib591 is used for test cases 591, 592, 593 and 594 */
#include <limits.h>
#include <fcntl.h>
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL *easy = NULL;
CURLM *multi = NULL;
int res = 0;
int running;
int msgs_left;
CURLMsg *msg;
FILE *upload = NULL;
start_test_timing();
upload = fopen(libtest_arg3, "rb");
if(!upload) {
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
errno, strerror(errno));
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg3);
return TEST_ERR_FOPEN;
}
res_global_init(CURL_GLOBAL_ALL);
if(res) {
fclose(upload);
return res;
}
easy_init(easy);
/* go verbose */
easy_setopt(easy, CURLOPT_VERBOSE, 1L);
/* specify target */
easy_setopt(easy, CURLOPT_URL, URL);
/* enable uploading */
easy_setopt(easy, CURLOPT_UPLOAD, 1L);
/* data pointer for the file read function */
easy_setopt(easy, CURLOPT_READDATA, upload);
/* use active mode FTP */
easy_setopt(easy, CURLOPT_FTPPORT, "-");
/* server connection timeout */
easy_setopt(easy, CURLOPT_ACCEPTTIMEOUT_MS,
strtol(libtest_arg2, NULL, 10)*1000);
multi_init(multi);
multi_add_handle(multi, easy);
for(;;) {
struct timeval interval;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
long timeout = -99;
int maxfd = -99;
multi_perform(multi, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
multi_timeout(multi, &timeout);
/* At this point, timeout is guaranteed to be greater or equal than -1. */
if(timeout != -1L) {
int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
interval.tv_sec = itimeout/1000;
interval.tv_usec = (itimeout%1000)*1000;
}
else {
interval.tv_sec = 0;
interval.tv_usec = 100000L; /* 100 ms */
}
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &interval);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &msgs_left);
if(msg)
res = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(easy);
curl_global_cleanup();
/* close the local file */
fclose(upload);
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1525.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
* Copyright (C) 2014, Vijay Panghal, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* This unit test PUT http data over proxy. Proxy header will be different
* from server http header
*/
#include "test.h"
#include "memdebug.h"
static char data [] = "Hello Cloud!\n";
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
if(amount < strlen(data)) {
return strlen(data);
}
(void)stream;
memcpy(ptr, data, strlen(data));
return strlen(data);
}
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
/* http and proxy header list*/
struct curl_slist *hhl = NULL;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
if(!hhl) {
goto test_cleanup;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_PROXYHEADER, hhl);
test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED);
test_setopt(curl, CURLOPT_POST, 0L);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(data));
res = curl_easy_perform(curl);
test_cleanup:
curl_easy_cleanup(curl);
curl_slist_free_all(hhl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/sethostname.h | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#ifdef CURL_STATICLIB
# define LIBHOSTNAME_EXTERN
#elif defined(WIN32)
# define LIBHOSTNAME_EXTERN __declspec(dllexport)
#elif defined(CURL_HIDDEN_SYMBOLS)
# define LIBHOSTNAME_EXTERN CURL_EXTERN_SYMBOL
#else
# define LIBHOSTNAME_EXTERN
#endif
#ifdef USE_WINSOCK
# define FUNCALLCONV __stdcall
#else
# define FUNCALLCONV
#endif
LIBHOSTNAME_EXTERN int FUNCALLCONV
gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen);
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1506.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2020, Linus Nielsen Feltzing <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
#define NUM_HANDLES 4
int test(char *URL)
{
int res = 0;
CURL *curl[NUM_HANDLES] = {0};
int running;
CURLM *m = NULL;
int i;
char target_url[256];
char dnsentry[256];
struct curl_slist *slist = NULL, *slist2;
char *port = libtest_arg3;
char *address = libtest_arg2;
(void)URL;
/* Create fake DNS entries for serverX.example.com for all handles */
for(i = 0; i < NUM_HANDLES; i++) {
msnprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s",
i + 1, port, address);
printf("%s\n", dnsentry);
slist2 = curl_slist_append(slist, dnsentry);
if(!slist2) {
fprintf(stderr, "curl_slist_append() failed\n");
goto test_cleanup;
}
slist = slist2;
}
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(m);
multi_setopt(m, CURLMOPT_MAXCONNECTS, 3L);
/* get NUM_HANDLES easy handles */
for(i = 0; i < NUM_HANDLES; i++) {
/* get an easy handle */
easy_init(curl[i]);
/* specify target */
msnprintf(target_url, sizeof(target_url),
"http://server%d.example.com:%s/path/1506%04i",
i + 1, port, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
easy_setopt(curl[i], CURLOPT_URL, target_url);
/* go verbose */
easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
/* include headers */
easy_setopt(curl[i], CURLOPT_HEADER, 1L);
easy_setopt(curl[i], CURLOPT_RESOLVE, slist);
}
fprintf(stderr, "Start at URL 0\n");
for(i = 0; i < NUM_HANDLES; i++) {
/* add handle to multi */
multi_add_handle(m, curl[i]);
for(;;) {
struct timeval interval;
fd_set rd, wr, exc;
int maxfd = -99;
interval.tv_sec = 1;
interval.tv_usec = 0;
multi_perform(m, &running);
abort_on_test_timeout();
if(!running)
break; /* done */
FD_ZERO(&rd);
FD_ZERO(&wr);
FD_ZERO(&exc);
multi_fdset(m, &rd, &wr, &exc, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &rd, &wr, &exc, &interval);
abort_on_test_timeout();
}
wait_ms(1); /* to ensure different end times */
}
test_cleanup:
/* proper cleanup sequence - type PB */
for(i = 0; i < NUM_HANDLES; i++) {
curl_multi_remove_handle(m, curl[i]);
curl_easy_cleanup(curl[i]);
}
curl_slist_free_all(slist);
curl_multi_cleanup(m);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib508.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static char data[]="this is what we post to the silly web server\n";
struct WriteThis {
char *readptr;
size_t sizeleft;
};
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct WriteThis *pooh = (struct WriteThis *)userp;
if(size*nmemb < 1)
return 0;
if(pooh->sizeleft) {
*ptr = pooh->readptr[0]; /* copy one single byte */
pooh->readptr++; /* advance pointer */
pooh->sizeleft--; /* less data left */
return 1; /* we return 1 byte at a time! */
}
return 0; /* no more data left to deliver */
}
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
struct WriteThis pooh;
pooh.readptr = data;
pooh.sizeleft = strlen(data);
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib676.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
test_setopt(curl, CURLOPT_USERAGENT, "the-moo agent next generation");
test_setopt(curl, CURLOPT_COOKIEFILE, "log/cookies676");
test_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if(res) {
fprintf(stderr, "retrieve 1 failed\n");
goto test_cleanup;
}
/* now clear the cookies */
test_setopt(curl, CURLOPT_COOKIEFILE, NULL);
res = curl_easy_perform(curl);
if(res)
fprintf(stderr, "retrieve 2 failed\n");
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/stub_gssapi.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2017 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/* Only provides the bare minimum to link with libcurl */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stub_gssapi.h"
/* !checksrc! disable SNPRINTF all */
#define MAX_CREDS_LENGTH 250
#define APPROX_TOKEN_LEN 250
enum min_err_code {
GSS_OK = 0,
GSS_NO_MEMORY,
GSS_INVALID_ARGS,
GSS_INVALID_CREDS,
GSS_INVALID_CTX,
GSS_SERVER_ERR,
GSS_NO_MECH,
GSS_LAST
};
static const char *min_err_table[] = {
"stub-gss: no error",
"stub-gss: no memory",
"stub-gss: invalid arguments",
"stub-gss: invalid credentials",
"stub-gss: invalid context",
"stub-gss: server returned error",
"stub-gss: cannot find a mechanism",
NULL
};
struct gss_ctx_id_t_desc_struct {
enum { NONE, KRB5, NTLM1, NTLM3 } sent;
int have_krb5;
int have_ntlm;
OM_uint32 flags;
char creds[MAX_CREDS_LENGTH];
};
OM_uint32 gss_init_sec_context(OM_uint32 *min,
gss_const_cred_id_t initiator_cred_handle,
gss_ctx_id_t *context_handle,
gss_const_name_t target_name,
const gss_OID mech_type,
OM_uint32 req_flags,
OM_uint32 time_req,
const gss_channel_bindings_t input_chan_bindings,
const gss_buffer_t input_token,
gss_OID *actual_mech_type,
gss_buffer_t output_token,
OM_uint32 *ret_flags,
OM_uint32 *time_rec)
{
/* The token will be encoded in base64 */
int length = APPROX_TOKEN_LEN * 3 / 4;
int used = 0;
char *token = NULL;
const char *creds = NULL;
gss_ctx_id_t ctx = NULL;
(void)initiator_cred_handle;
(void)mech_type;
(void)time_req;
(void)input_chan_bindings;
(void)actual_mech_type;
if(!min)
return GSS_S_FAILURE;
*min = 0;
if(!context_handle || !target_name || !output_token) {
*min = GSS_INVALID_ARGS;
return GSS_S_FAILURE;
}
creds = getenv("CURL_STUB_GSS_CREDS");
if(!creds || strlen(creds) >= MAX_CREDS_LENGTH) {
*min = GSS_INVALID_CREDS;
return GSS_S_FAILURE;
}
ctx = *context_handle;
if(ctx && strcmp(ctx->creds, creds)) {
*min = GSS_INVALID_CREDS;
return GSS_S_FAILURE;
}
output_token->length = 0;
output_token->value = NULL;
if(input_token && input_token->length) {
if(!ctx) {
*min = GSS_INVALID_CTX;
return GSS_S_FAILURE;
}
/* Server response, either D (RA==) or C (Qw==) */
if(((char *) input_token->value)[0] == 'D') {
/* Done */
switch(ctx->sent) {
case KRB5:
case NTLM3:
if(ret_flags)
*ret_flags = ctx->flags;
if(time_rec)
*time_rec = GSS_C_INDEFINITE;
return GSS_S_COMPLETE;
default:
*min = GSS_SERVER_ERR;
return GSS_S_FAILURE;
}
}
if(((char *) input_token->value)[0] != 'C') {
/* We only support Done or Continue */
*min = GSS_SERVER_ERR;
return GSS_S_FAILURE;
}
/* Continue */
switch(ctx->sent) {
case KRB5:
/* We sent KRB5 and it failed, let's try NTLM */
if(ctx->have_ntlm) {
ctx->sent = NTLM1;
break;
}
else {
*min = GSS_SERVER_ERR;
return GSS_S_FAILURE;
}
case NTLM1:
ctx->sent = NTLM3;
break;
default:
*min = GSS_SERVER_ERR;
return GSS_S_FAILURE;
}
}
else {
if(ctx) {
*min = GSS_INVALID_CTX;
return GSS_S_FAILURE;
}
ctx = (gss_ctx_id_t) calloc(sizeof(*ctx), 1);
if(!ctx) {
*min = GSS_NO_MEMORY;
return GSS_S_FAILURE;
}
if(strstr(creds, "KRB5"))
ctx->have_krb5 = 1;
if(strstr(creds, "NTLM"))
ctx->have_ntlm = 1;
if(ctx->have_krb5)
ctx->sent = KRB5;
else if(ctx->have_ntlm)
ctx->sent = NTLM1;
else {
free(ctx);
*min = GSS_NO_MECH;
return GSS_S_FAILURE;
}
strcpy(ctx->creds, creds);
ctx->flags = req_flags;
}
token = malloc(length);
if(!token) {
free(ctx);
*min = GSS_NO_MEMORY;
return GSS_S_FAILURE;
}
/* Token format: creds:target:type:padding */
/* Note: this is using the *real* snprintf() and not the curl provided
one */
used = snprintf(token, length, "%s:%s:%d:", creds,
(char *) target_name, ctx->sent);
if(used >= length) {
free(token);
free(ctx);
*min = GSS_NO_MEMORY;
return GSS_S_FAILURE;
}
/* Overwrite null terminator */
memset(token + used, 'A', length - used);
*context_handle = ctx;
output_token->value = token;
output_token->length = length;
return GSS_S_CONTINUE_NEEDED;
}
OM_uint32 gss_delete_sec_context(OM_uint32 *min,
gss_ctx_id_t *context_handle,
gss_buffer_t output_token)
{
(void)output_token;
if(!min)
return GSS_S_FAILURE;
if(!context_handle) {
*min = GSS_INVALID_CTX;
return GSS_S_FAILURE;
}
free(*context_handle);
*context_handle = NULL;
*min = 0;
return GSS_S_COMPLETE;
}
OM_uint32 gss_release_buffer(OM_uint32 *min,
gss_buffer_t buffer)
{
if(min)
*min = 0;
if(buffer && buffer->length) {
free(buffer->value);
buffer->length = 0;
}
return GSS_S_COMPLETE;
}
OM_uint32 gss_import_name(OM_uint32 *min,
const gss_buffer_t input_name_buffer,
const gss_OID input_name_type,
gss_name_t *output_name)
{
char *name = NULL;
(void)input_name_type;
if(!min)
return GSS_S_FAILURE;
if(!input_name_buffer || !output_name) {
*min = GSS_INVALID_ARGS;
return GSS_S_FAILURE;
}
name = strndup(input_name_buffer->value, input_name_buffer->length);
if(!name) {
*min = GSS_NO_MEMORY;
return GSS_S_FAILURE;
}
*output_name = (gss_name_t) name;
*min = 0;
return GSS_S_COMPLETE;
}
OM_uint32 gss_release_name(OM_uint32 *min,
gss_name_t *input_name)
{
if(min)
*min = 0;
if(input_name)
free(*input_name);
return GSS_S_COMPLETE;
}
OM_uint32 gss_display_status(OM_uint32 *min,
OM_uint32 status_value,
int status_type,
const gss_OID mech_type,
OM_uint32 *message_context,
gss_buffer_t status_string)
{
const char maj_str[] = "Stub GSS error";
(void)mech_type;
if(min)
*min = 0;
if(message_context)
*message_context = 0;
if(status_string) {
status_string->value = NULL;
status_string->length = 0;
if(status_value >= GSS_LAST)
return GSS_S_FAILURE;
switch(status_type) {
case GSS_C_GSS_CODE:
status_string->value = strdup(maj_str);
break;
case GSS_C_MECH_CODE:
status_string->value = strdup(min_err_table[status_value]);
break;
default:
return GSS_S_FAILURE;
}
if(status_string->value)
status_string->length = strlen(status_string->value);
else
return GSS_S_FAILURE;
}
return GSS_S_COMPLETE;
}
/* Stubs returning error */
OM_uint32 gss_display_name(OM_uint32 *min,
gss_const_name_t input_name,
gss_buffer_t output_name_buffer,
gss_OID *output_name_type)
{
(void)min;
(void)input_name;
(void)output_name_buffer;
(void)output_name_type;
return GSS_S_FAILURE;
}
OM_uint32 gss_inquire_context(OM_uint32 *min,
gss_const_ctx_id_t context_handle,
gss_name_t *src_name,
gss_name_t *targ_name,
OM_uint32 *lifetime_rec,
gss_OID *mech_type,
OM_uint32 *ctx_flags,
int *locally_initiated,
int *open_context)
{
(void)min;
(void)context_handle;
(void)src_name;
(void)targ_name;
(void)lifetime_rec;
(void)mech_type;
(void)ctx_flags;
(void)locally_initiated;
(void)open_context;
return GSS_S_FAILURE;
}
OM_uint32 gss_wrap(OM_uint32 *min,
gss_const_ctx_id_t context_handle,
int conf_req_flag,
gss_qop_t qop_req,
const gss_buffer_t input_message_buffer,
int *conf_state,
gss_buffer_t output_message_buffer)
{
(void)min;
(void)context_handle;
(void)conf_req_flag;
(void)qop_req;
(void)input_message_buffer;
(void)conf_state;
(void)output_message_buffer;
return GSS_S_FAILURE;
}
OM_uint32 gss_unwrap(OM_uint32 *min,
gss_const_ctx_id_t context_handle,
const gss_buffer_t input_message_buffer,
gss_buffer_t output_message_buffer,
int *conf_state,
gss_qop_t *qop_state)
{
(void)min;
(void)context_handle;
(void)input_message_buffer;
(void)output_message_buffer;
(void)conf_state;
(void)qop_state;
return GSS_S_FAILURE;
}
OM_uint32 gss_seal(OM_uint32 *min,
gss_ctx_id_t context_handle,
int conf_req_flag,
int qop_req,
gss_buffer_t input_message_buffer,
int *conf_state,
gss_buffer_t output_message_buffer)
{
(void)min;
(void)context_handle;
(void)conf_req_flag;
(void)qop_req;
(void)input_message_buffer;
(void)conf_state;
(void)output_message_buffer;
return GSS_S_FAILURE;
}
OM_uint32 gss_unseal(OM_uint32 *min,
gss_ctx_id_t context_handle,
gss_buffer_t input_message_buffer,
gss_buffer_t output_message_buffer,
int *conf_state,
int *qop_state)
{
(void)min;
(void)context_handle;
(void)input_message_buffer;
(void)output_message_buffer;
(void)conf_state;
(void)qop_state;
return GSS_S_FAILURE;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib674.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
/*
* Get a single URL without select().
*/
int test(char *URL)
{
CURL *handle = NULL;
CURL *handle2;
CURLcode res = 0;
CURLU *urlp = NULL;
CURLUcode uc = 0;
global_init(CURL_GLOBAL_ALL);
easy_init(handle);
urlp = curl_url();
if(!urlp) {
fprintf(stderr, "problem init URL api.");
goto test_cleanup;
}
uc = curl_url_set(urlp, CURLUPART_URL, URL, 0);
if(uc) {
fprintf(stderr, "problem setting CURLUPART_URL: %s.",
curl_url_strerror(uc));
goto test_cleanup;
}
/* demonstrate override behavior */
easy_setopt(handle, CURLOPT_CURLU, urlp);
easy_setopt(handle, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(handle);
if(res) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, res, curl_easy_strerror(res));
goto test_cleanup;
}
handle2 = curl_easy_duphandle(handle);
res = curl_easy_perform(handle2);
curl_easy_cleanup(handle2);
test_cleanup:
curl_url_cleanup(urlp);
curl_easy_cleanup(handle);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib507.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define TEST_HANG_TIMEOUT 60 * 1000
int test(char *URL)
{
CURL *curls = NULL;
CURLM *multi = NULL;
int still_running;
int i = -1;
int res = 0;
CURLMsg *msg;
start_test_timing();
global_init(CURL_GLOBAL_ALL);
multi_init(multi);
easy_init(curls);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
multi_add_handle(multi, curls);
multi_perform(multi, &still_running);
abort_on_test_timeout();
while(still_running) {
struct timeval timeout;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -99;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
/* At this point, maxfd is guaranteed to be greater or equal than -1. */
select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
abort_on_test_timeout();
multi_perform(multi, &still_running);
abort_on_test_timeout();
}
msg = curl_multi_info_read(multi, &still_running);
if(msg)
/* this should now contain a result code from the easy handle,
get it */
i = msg->data.result;
test_cleanup:
/* undocumented cleanup sequence - type UA */
curl_multi_cleanup(multi);
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1518.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
/* Test inspired by github issue 3340 */
int test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
long curlResponseCode;
long curlRedirectCount;
char *effectiveUrl = NULL;
char *redirectUrl = NULL;
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
/* just to make it explicit and visible in this test: */
test_setopt(curl, CURLOPT_FOLLOWLOCATION, 0L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &curlResponseCode);
curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &curlRedirectCount);
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effectiveUrl);
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirectUrl);
printf("res %d\n"
"status %d\n"
"redirects %d\n"
"effectiveurl %s\n"
"redirecturl %s\n",
(int)res,
(int)curlResponseCode,
(int)curlRedirectCount,
effectiveUrl,
redirectUrl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1912.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#define print_err(name, exp) \
fprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", name, exp);
int test(char *URL)
{
/* Only test if GCC typechecking is available */
int error = 0;
#ifdef CURLINC_TYPECHECK_GCC_H
const struct curl_easyoption *o;
for(o = curl_easy_option_next(NULL);
o;
o = curl_easy_option_next(o)) {
/* Test for mismatch OR missing typecheck macros */
if(curlcheck_long_option(o->id) !=
(o->type == CURLOT_LONG || o->type == CURLOT_VALUES)) {
print_err(o->name, "CURLOT_LONG or CURLOT_VALUES");
error++;
}
if(curlcheck_off_t_option(o->id) != (o->type == CURLOT_OFF_T)) {
print_err(o->name, "CURLOT_OFF_T");
error++;
}
if(curlcheck_string_option(o->id) != (o->type == CURLOT_STRING)) {
print_err(o->name, "CURLOT_STRING");
error++;
}
if(curlcheck_slist_option(o->id) != (o->type == CURLOT_SLIST)) {
print_err(o->name, "CURLOT_SLIST");
error++;
}
if(curlcheck_cb_data_option(o->id) != (o->type == CURLOT_CBPTR)) {
print_err(o->name, "CURLOT_CBPTR");
error++;
}
/* From here: only test that the type matches if macro is known */
if(curlcheck_write_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
print_err(o->name, "CURLOT_FUNCTION");
error++;
}
if(curlcheck_conv_cb_option(o->id) && (o->type != CURLOT_FUNCTION)) {
print_err(o->name, "CURLOT_FUNCTION");
error++;
}
if(curlcheck_postfields_option(o->id) && (o->type != CURLOT_OBJECT)) {
print_err(o->name, "CURLOT_OBJECT");
error++;
}
/* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */
}
#endif
(void)URL;
return error;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib566.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
int test(char *URL)
{
CURLcode res;
CURL *curl;
double content_length = 3;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HEADER, 1L);
res = curl_easy_perform(curl);
if(!res) {
FILE *moo;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
&content_length);
moo = fopen(libtest_arg2, "wb");
if(moo) {
fprintf(moo, "CL %.0f\n", content_length);
fclose(moo);
}
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib678.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
static int loadfile(const char *filename, void **filedata, size_t *filesize)
{
size_t datasize = 0;
void *data = NULL;
if(filename) {
FILE *fInCert = fopen(filename, "rb");
if(fInCert) {
long cert_tell = 0;
bool continue_reading = fseek(fInCert, 0, SEEK_END) == 0;
if(continue_reading)
cert_tell = ftell(fInCert);
if(cert_tell < 0)
continue_reading = FALSE;
else
datasize = (size_t)cert_tell;
if(continue_reading)
continue_reading = fseek(fInCert, 0, SEEK_SET) == 0;
if(continue_reading)
data = malloc(datasize + 1);
if((!data) ||
((int)fread(data, datasize, 1, fInCert) != 1))
continue_reading = FALSE;
fclose(fInCert);
if(!continue_reading) {
free(data);
datasize = 0;
data = NULL;
}
}
}
*filesize = datasize;
*filedata = data;
return data ? 1 : 0;
}
static int test_cert_blob(const char *url, const char *cafile)
{
CURLcode code = CURLE_OUT_OF_MEMORY;
CURL *curl;
struct curl_blob blob;
size_t certsize;
void *certdata;
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
return CURLE_FAILED_INIT;
}
if(loadfile(cafile, &certdata, &certsize)) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "CURLOPT_CAINFO_BLOB");
curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS,
CURLSSLOPT_REVOKE_BEST_EFFORT);
blob.data = certdata;
blob.len = certsize;
blob.flags = CURL_BLOB_COPY;
curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob);
free(certdata);
code = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
return (int)code;
}
int test(char *URL)
{
int res = 0;
curl_global_init(CURL_GLOBAL_DEFAULT);
if(!strcmp("check", URL)) {
CURL *e;
CURLcode w = CURLE_OK;
struct curl_blob blob = {0};
e = curl_easy_init();
if(e) {
w = curl_easy_setopt(e, CURLOPT_CAINFO_BLOB, &blob);
if(w)
printf("CURLOPT_CAINFO_BLOB is not supported\n");
curl_easy_cleanup(e);
}
res = (int)w;
}
else
res = test_cert_blob(URL, libtest_arg2);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/libprereq.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2021, Max Dymond, <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
typedef struct prcs {
int prereq_retcode;
int ipv6;
} PRCS;
static int prereq_callback(void *clientp,
char *conn_primary_ip,
char *conn_local_ip,
int conn_primary_port,
int conn_local_port)
{
PRCS *prereq_cb = (PRCS *)clientp;
if(prereq_cb->ipv6) {
printf("Connected to [%s]\n", conn_primary_ip);
printf("Connected from [%s]\n", conn_local_ip);
}
else {
printf("Connected to %s\n", conn_primary_ip);
printf("Connected from %s\n", conn_local_ip);
}
printf("Remote port = %d\n", conn_primary_port);
printf("Local port = %d\n", conn_local_port);
printf("Returning = %d\n", prereq_cb->prereq_retcode);
return prereq_cb->prereq_retcode;
}
int test(char *URL)
{
PRCS prereq_cb;
CURLcode ret = CURLE_OK;
CURL *curl = NULL;
prereq_cb.prereq_retcode = CURL_PREREQFUNC_OK;
prereq_cb.ipv6 = 0;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
if(strstr(URL, "#ipv6")) {
/* The IP addresses should be surrounded by brackets! */
prereq_cb.ipv6 = 1;
}
if(strstr(URL, "#err")) {
/* Set the callback to exit with failure */
prereq_cb.prereq_retcode = CURL_PREREQFUNC_ABORT;
}
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_PREREQFUNCTION, prereq_callback);
curl_easy_setopt(curl, CURLOPT_PREREQDATA, &prereq_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stderr);
if(strstr(URL, "#redir")) {
/* Enable follow-location */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
}
ret = curl_easy_perform(curl);
if(ret) {
fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
__FILE__, __LINE__, ret, curl_easy_strerror(ret));
goto test_cleanup;
}
}
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return ret;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib653.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
int test(char *URL)
{
CURL *curls = NULL;
int res = 0;
curl_mimepart *field = NULL;
curl_mime *mime = NULL;
global_init(CURL_GLOBAL_ALL);
easy_init(curls);
mime = curl_mime_init(curls);
field = curl_mime_addpart(mime);
curl_mime_name(field, "name");
curl_mime_data(field, "short value", CURL_ZERO_TERMINATED);
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_HEADER, 1L);
easy_setopt(curls, CURLOPT_VERBOSE, 1L);
easy_setopt(curls, CURLOPT_MIMEPOST, mime);
easy_setopt(curls, CURLOPT_NOPROGRESS, 1L);
res = curl_easy_perform(curls);
if(res)
goto test_cleanup;
/* Alter form and resubmit. */
curl_mime_data(field, "long value for length change", CURL_ZERO_TERMINATED);
res = curl_easy_perform(curls);
test_cleanup:
curl_mime_free(mime);
curl_easy_cleanup(curls);
curl_global_cleanup();
return (int) res; /* return the final return code */
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib654.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static char data[]=
#ifdef CURL_DOES_CONVERSIONS
/* ASCII representation with escape sequences for non-ASCII platforms */
"\x64\x75\x6d\x6d\x79\x0a";
#else
"dummy\n";
#endif
struct WriteThis {
char *readptr;
curl_off_t sizeleft;
int freecount;
};
static void free_callback(void *userp)
{
struct WriteThis *pooh = (struct WriteThis *) userp;
pooh->freecount++;
}
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
struct WriteThis *pooh = (struct WriteThis *)userp;
int eof = !*pooh->readptr;
if(size*nmemb < 1)
return 0;
eof = pooh->sizeleft <= 0;
if(!eof)
pooh->sizeleft--;
if(!eof) {
*ptr = *pooh->readptr; /* copy one single byte */
pooh->readptr++; /* advance pointer */
return 1; /* we return 1 byte at a time! */
}
return 0; /* no more data left to deliver */
}
int test(char *URL)
{
CURL *easy = NULL;
CURL *easy2 = NULL;
curl_mime *mime = NULL;
curl_mimepart *part;
struct curl_slist *hdrs = NULL;
CURLcode result;
int res = TEST_ERR_FAILURE;
struct WriteThis pooh;
/*
* Check proper copy/release of mime post data bound to a duplicated
* easy handle.
*/
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
easy = curl_easy_init();
/* First set the URL that is about to receive our POST. */
test_setopt(easy, CURLOPT_URL, URL);
/* get verbose debug output please */
test_setopt(easy, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(easy, CURLOPT_HEADER, 1L);
/* Prepare the callback structure. */
pooh.readptr = data;
pooh.sizeleft = (curl_off_t) strlen(data);
pooh.freecount = 0;
/* Build the mime tree. */
mime = curl_mime_init(easy);
part = curl_mime_addpart(mime);
curl_mime_data(part, "hello", CURL_ZERO_TERMINATED);
curl_mime_name(part, "greeting");
curl_mime_type(part, "application/X-Greeting");
curl_mime_encoder(part, "base64");
hdrs = curl_slist_append(hdrs, "X-Test-Number: 654");
curl_mime_headers(part, hdrs, TRUE);
part = curl_mime_addpart(mime);
curl_mime_filedata(part, "log/file654.txt");
part = curl_mime_addpart(mime);
curl_mime_data_cb(part, (curl_off_t) -1, read_callback, NULL, free_callback,
&pooh);
/* Bind mime data to its easy handle. */
test_setopt(easy, CURLOPT_MIMEPOST, mime);
/* Duplicate the handle. */
easy2 = curl_easy_duphandle(easy);
if(!easy2) {
fprintf(stderr, "curl_easy_duphandle() failed\n");
res = TEST_ERR_FAILURE;
goto test_cleanup;
}
/* Now free the mime structure: it should unbind it from the first
easy handle. */
curl_mime_free(mime);
mime = NULL; /* Already cleaned up. */
/* Perform on the first handle: should not send any data. */
result = curl_easy_perform(easy);
if(result) {
fprintf(stderr, "curl_easy_perform(original) failed\n");
res = (int) result;
goto test_cleanup;
}
/* Perform on the second handle: if the bound mime structure has not been
duplicated properly, it should cause a valgrind error. */
result = curl_easy_perform(easy2);
if(result) {
fprintf(stderr, "curl_easy_perform(duplicated) failed\n");
res = (int) result;
goto test_cleanup;
}
/* Free the duplicated handle: it should call free_callback again.
If the mime copy was bad or not automatically released, valgrind
will signal it. */
curl_easy_cleanup(easy2);
easy2 = NULL; /* Already cleaned up. */
if(pooh.freecount != 2) {
fprintf(stderr, "free_callback() called %d times instead of 2\n",
pooh.freecount);
res = TEST_ERR_FAILURE;
goto test_cleanup;
}
test_cleanup:
curl_easy_cleanup(easy);
curl_easy_cleanup(easy2);
curl_mime_free(mime);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1156.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
/*
Check range/resume returned error codes and data presence.
The input parameters are:
- CURLOPT_RANGE/CURLOPT_RESUME_FROM
- CURLOPT_FAILONERROR
- Returned http code (2xx/416)
- Content-Range header present in reply.
*/
#include "memdebug.h"
#define F_RESUME (1 << 0) /* resume/range. */
#define F_HTTP416 (1 << 1) /* Server returns http code 416. */
#define F_FAIL (1 << 2) /* Fail on error. */
#define F_CONTENTRANGE (1 << 3) /* Server sends content-range hdr. */
#define F_IGNOREBODY (1 << 4) /* Body should be ignored. */
struct testparams {
unsigned int flags; /* ORed flags as above. */
CURLcode result; /* Code that should be returned by curl_easy_perform(). */
};
static const struct testparams params[] = {
{ 0, CURLE_OK },
{ F_CONTENTRANGE, CURLE_OK },
{ F_FAIL, CURLE_OK },
{ F_FAIL | F_CONTENTRANGE, CURLE_OK },
{ F_HTTP416, CURLE_OK },
{ F_HTTP416 | F_CONTENTRANGE, CURLE_OK },
{ F_HTTP416 | F_FAIL | F_IGNOREBODY,
CURLE_HTTP_RETURNED_ERROR },
{ F_HTTP416 | F_FAIL | F_CONTENTRANGE | F_IGNOREBODY,
CURLE_HTTP_RETURNED_ERROR },
{ F_RESUME | F_IGNOREBODY,
CURLE_RANGE_ERROR },
{ F_RESUME | F_CONTENTRANGE, CURLE_OK },
{ F_RESUME | F_FAIL | F_IGNOREBODY,
CURLE_RANGE_ERROR },
{ F_RESUME | F_FAIL | F_CONTENTRANGE, CURLE_OK },
{ F_RESUME | F_HTTP416 | F_IGNOREBODY, CURLE_OK },
{ F_RESUME | F_HTTP416 | F_CONTENTRANGE | F_IGNOREBODY, CURLE_OK },
{ F_RESUME | F_HTTP416 | F_FAIL | F_IGNOREBODY, CURLE_OK },
{ F_RESUME | F_HTTP416 | F_FAIL | F_CONTENTRANGE | F_IGNOREBODY,
CURLE_HTTP_RETURNED_ERROR }
};
static int hasbody;
static size_t writedata(char *data, size_t size, size_t nmemb, void *userdata)
{
(void) data;
(void) userdata;
if(size && nmemb)
hasbody = 1;
return size * nmemb;
}
static int onetest(CURL *curl, const char *url, const struct testparams *p,
size_t num)
{
CURLcode res;
unsigned int replyselector;
char urlbuf[256];
replyselector = (p->flags & F_CONTENTRANGE)? 1: 0;
if(p->flags & F_HTTP416)
replyselector += 2;
msnprintf(urlbuf, sizeof(urlbuf), "%s%04u", url, replyselector);
test_setopt(curl, CURLOPT_URL, urlbuf);
test_setopt(curl, CURLOPT_RESUME_FROM, (p->flags & F_RESUME)? 3: 0);
test_setopt(curl, CURLOPT_RANGE, !(p->flags & F_RESUME)?
"3-1000000": (char *) NULL);
test_setopt(curl, CURLOPT_FAILONERROR, (p->flags & F_FAIL)? 1: 0);
hasbody = 0;
res = curl_easy_perform(curl);
if(res != p->result) {
fprintf(stderr, "%d: bad error code (%d): resume=%s, fail=%s, http416=%s, "
"content-range=%s, expected=%d\n", num, res,
(p->flags & F_RESUME)? "yes": "no",
(p->flags & F_FAIL)? "yes": "no",
(p->flags & F_HTTP416)? "yes": "no",
(p->flags & F_CONTENTRANGE)? "yes": "no",
p->result);
return 1;
}
if(hasbody && (p->flags & F_IGNOREBODY)) {
fprintf(stderr, "body should be ignored and is not: resume=%s, fail=%s, "
"http416=%s, content-range=%s\n",
(p->flags & F_RESUME)? "yes": "no",
(p->flags & F_FAIL)? "yes": "no",
(p->flags & F_HTTP416)? "yes": "no",
(p->flags & F_CONTENTRANGE)? "yes": "no");
return 1;
}
return 0;
test_cleanup:
return 1;
}
int test(char *URL)
{
CURLcode res;
CURL *curl;
size_t i;
int status = 0;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_setopt(curl, CURLOPT_WRITEFUNCTION, writedata);
for(i = 0; i < sizeof(params) / sizeof(params[0]); i++)
status |= onetest(curl, URL, params + i, i);
curl_easy_cleanup(curl);
curl_global_cleanup();
fprintf(stderr, "%d\n", status);
return status;
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();
return (int)res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1540.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
struct transfer_status {
CURL *easy;
int halted;
int counter; /* count write callback invokes */
int please; /* number of times xferinfo is called while halted */
};
static int please_continue(void *userp,
curl_off_t dltotal,
curl_off_t dlnow,
curl_off_t ultotal,
curl_off_t ulnow)
{
struct transfer_status *st = (struct transfer_status *)userp;
(void)dltotal;
(void)dlnow;
(void)ultotal;
(void)ulnow;
if(st->halted) {
st->please++;
if(st->please == 2) {
/* waited enough, unpause! */
curl_easy_pause(st->easy, CURLPAUSE_CONT);
}
}
fprintf(stderr, "xferinfo: paused %d\n", st->halted);
return 0; /* go on */
}
static size_t header_callback(void *ptr, size_t size, size_t nmemb,
void *userp)
{
size_t len = size * nmemb;
(void)userp;
(void)fwrite(ptr, size, nmemb, stdout);
return len;
}
static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *userp)
{
struct transfer_status *st = (struct transfer_status *)userp;
size_t len = size * nmemb;
st->counter++;
if(st->counter > 1) {
/* the first call puts us on pause, so subsequent calls are after
unpause */
fwrite(ptr, size, nmemb, stdout);
return len;
}
printf("Got %d bytes but pausing!\n", (int)len);
st->halted = 1;
return CURL_WRITEFUNC_PAUSE;
}
int test(char *URL)
{
CURL *curls = NULL;
int i = 0;
int res = 0;
struct transfer_status st;
start_test_timing();
memset(&st, 0, sizeof(st));
global_init(CURL_GLOBAL_ALL);
easy_init(curls);
st.easy = curls; /* to allow callbacks access */
easy_setopt(curls, CURLOPT_URL, URL);
easy_setopt(curls, CURLOPT_WRITEFUNCTION, write_callback);
easy_setopt(curls, CURLOPT_WRITEDATA, &st);
easy_setopt(curls, CURLOPT_HEADERFUNCTION, header_callback);
easy_setopt(curls, CURLOPT_HEADERDATA, &st);
easy_setopt(curls, CURLOPT_XFERINFOFUNCTION, please_continue);
easy_setopt(curls, CURLOPT_XFERINFODATA, &st);
easy_setopt(curls, CURLOPT_NOPROGRESS, 0L);
res = curl_easy_perform(curls);
test_cleanup:
curl_easy_cleanup(curls);
curl_global_cleanup();
if(res)
i = res;
return i; /* return the final return code */
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib576.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "testutil.h"
#include "memdebug.h"
struct chunk_data {
int remains;
int print_content;
};
static
long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains);
static
long chunk_end(void *ptr);
static
long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains)
{
struct chunk_data *ch_d = ptr;
ch_d->remains = remains;
printf("=============================================================\n");
printf("Remains: %d\n", remains);
printf("Filename: %s\n", finfo->filename);
if(finfo->strings.perm) {
printf("Permissions: %s", finfo->strings.perm);
if(finfo->flags & CURLFINFOFLAG_KNOWN_PERM)
printf(" (parsed => %o)", finfo->perm);
printf("\n");
}
printf("Size: %ldB\n", (long)finfo->size);
if(finfo->strings.user)
printf("User: %s\n", finfo->strings.user);
if(finfo->strings.group)
printf("Group: %s\n", finfo->strings.group);
if(finfo->strings.time)
printf("Time: %s\n", finfo->strings.time);
printf("Filetype: ");
switch(finfo->filetype) {
case CURLFILETYPE_FILE:
printf("regular file\n");
break;
case CURLFILETYPE_DIRECTORY:
printf("directory\n");
break;
case CURLFILETYPE_SYMLINK:
printf("symlink\n");
printf("Target: %s\n", finfo->strings.target);
break;
default:
printf("other type\n");
break;
}
if(finfo->filetype == CURLFILETYPE_FILE) {
ch_d->print_content = 1;
printf("Content:\n-----------------------"
"--------------------------------------\n");
}
if(strcmp(finfo->filename, "someothertext.txt") == 0) {
printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n");
return CURL_CHUNK_BGN_FUNC_SKIP;
}
return CURL_CHUNK_BGN_FUNC_OK;
}
static
long chunk_end(void *ptr)
{
struct chunk_data *ch_d = ptr;
if(ch_d->print_content) {
ch_d->print_content = 0;
printf("-------------------------------------------------------------\n");
}
if(ch_d->remains == 1)
printf("=============================================================\n");
return CURL_CHUNK_END_FUNC_OK;
}
int test(char *URL)
{
CURL *handle = NULL;
CURLcode res = CURLE_OK;
struct chunk_data chunk_data = {0, 0};
curl_global_init(CURL_GLOBAL_ALL);
handle = curl_easy_init();
if(!handle) {
res = CURLE_OUT_OF_MEMORY;
goto test_cleanup;
}
test_setopt(handle, CURLOPT_URL, URL);
test_setopt(handle, CURLOPT_WILDCARDMATCH, 1L);
test_setopt(handle, CURLOPT_CHUNK_BGN_FUNCTION, chunk_bgn);
test_setopt(handle, CURLOPT_CHUNK_END_FUNCTION, chunk_end);
test_setopt(handle, CURLOPT_CHUNK_DATA, &chunk_data);
res = curl_easy_perform(handle);
test_cleanup:
if(handle)
curl_easy_cleanup(handle);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib1512.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2013 - 2020, Linus Nielsen Feltzing <[email protected]>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
/*
* Use global DNS cache (while deprecated it should still work), populate it
* with CURLOPT_RESOLVE in the first request and then make sure a subsequent
* easy transfer finds and uses the populated stuff.
*/
#include "test.h"
#include "memdebug.h"
#define NUM_HANDLES 2
int test(char *URL)
{
int res = 0;
CURL *curl[NUM_HANDLES] = {NULL, NULL};
char *port = libtest_arg3;
char *address = libtest_arg2;
char dnsentry[256];
struct curl_slist *slist = NULL;
int i;
char target_url[256];
(void)URL; /* URL is setup in the code */
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
msnprintf(dnsentry, sizeof(dnsentry), "server.example.curl:%s:%s",
port, address);
printf("%s\n", dnsentry);
slist = curl_slist_append(slist, dnsentry);
/* get NUM_HANDLES easy handles */
for(i = 0; i < NUM_HANDLES; i++) {
/* get an easy handle */
easy_init(curl[i]);
/* specify target */
msnprintf(target_url, sizeof(target_url),
"http://server.example.curl:%s/path/1512%04i",
port, i + 1);
target_url[sizeof(target_url) - 1] = '\0';
easy_setopt(curl[i], CURLOPT_URL, target_url);
/* go verbose */
easy_setopt(curl[i], CURLOPT_VERBOSE, 1L);
/* include headers */
easy_setopt(curl[i], CURLOPT_HEADER, 1L);
easy_setopt(curl[i], CURLOPT_DNS_USE_GLOBAL_CACHE, 1L);
}
/* make the first one populate the GLOBAL cache */
easy_setopt(curl[0], CURLOPT_RESOLVE, slist);
/* run NUM_HANDLES transfers */
for(i = 0; (i < NUM_HANDLES) && !res; i++)
res = curl_easy_perform(curl[i]);
test_cleanup:
curl_easy_cleanup(curl[0]);
curl_easy_cleanup(curl[1]);
curl_slist_free_all(slist);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/libtest/lib666.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
#include "memdebug.h"
static char buffer[17000]; /* more than 16K */
int test(char *URL)
{
CURL *curl = NULL;
CURLcode res = CURLE_OK;
curl_mime *mime = NULL;
curl_mimepart *part;
size_t i;
/* Checks huge binary-encoded mime post. */
/* Create a buffer with pseudo-binary data. */
for(i = 0; i < sizeof(buffer); i++)
if(i % 77 == 76)
buffer[i] = '\n';
else
buffer[i] = (char) (0x41 + i % 26); /* A...Z */
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
res = (CURLcode) TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
/* Build mime structure. */
mime = curl_mime_init(curl);
if(!mime) {
fprintf(stderr, "curl_mime_init() failed\n");
res = (CURLcode) TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
part = curl_mime_addpart(mime);
if(!part) {
fprintf(stderr, "curl_mime_addpart() failed\n");
res = (CURLcode) TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
res = curl_mime_name(part, "upfile");
if(res) {
fprintf(stderr, "curl_mime_name() failed\n");
goto test_cleanup;
}
res = curl_mime_filename(part, "myfile.txt");
if(res) {
fprintf(stderr, "curl_mime_filename() failed\n");
goto test_cleanup;
}
res = curl_mime_data(part, buffer, sizeof(buffer));
if(res) {
fprintf(stderr, "curl_mime_data() failed\n");
goto test_cleanup;
}
res = curl_mime_encoder(part, "binary");
if(res) {
fprintf(stderr, "curl_mime_encoder() failed\n");
goto test_cleanup;
}
/* First set the URL that is about to receive our mime mail. */
test_setopt(curl, CURLOPT_URL, URL);
/* Post form */
test_setopt(curl, CURLOPT_MIMEPOST, mime);
/* Shorten upload buffer. */
test_setopt(curl, CURLOPT_UPLOAD_BUFFERSIZE, 16411L);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* always cleanup */
curl_easy_cleanup(curl);
/* now cleanup the mime structure */
curl_mime_free(mime);
curl_global_cleanup();
return res;
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests/certs | repos/gpt4all.zig/src/zig-libcurl/curl/tests/certs/scripts/genserv.sh | #!/bin/bash
# (c) CopyRight 2000 - 2020, EdelWeb for EdelKey and OpenEvidence
# Author: Peter Sylvester
# "libre" for integration with curl
OPENSSL=openssl
if [ -f /usr/local/ssl/bin/openssl ] ; then
OPENSSL=/usr/local/ssl/bin/openssl
fi
USAGE="echo Usage is genserv.sh <prefix> <caprefix>"
HOME=`pwd`
cd $HOME
KEYSIZE=2048
DURATION=3000
# The -sha256 option was introduced in OpenSSL 1.0.1
DIGESTALGO=-sha256
REQ=YES
P12=NO
DHP=NO
PREFIX=$1
if [ ".$PREFIX" = . ] ; then
echo No configuration prefix
NOTOK=1
else
if [ ! -f $PREFIX-sv.prm ] ; then
echo No configuration file $PREFIX-sv.prm
NOTOK=1
fi
fi
CAPREFIX=$2
if [ ".$CAPREFIX" = . ] ; then
echo No CA prefix
NOTOK=1
else
if [ ! -f $CAPREFIX-ca.cacert ] ; then
echo No CA certificate file $CAPREFIX-ca.caert
NOTOK=1
fi
if [ ! -f $CAPREFIX-ca.key ] ; then
echo No $CAPREFIX key
NOTOK=1
fi
fi
if [ ".$NOTOK" != . ] ; then
echo "Sorry, I can't do that for you."
$USAGE
exit
fi
if [ ".$SERIAL" = . ] ; then
GETSERIAL="\$t = time ;\$d = \$t . substr(\$t+$$ ,-4,4)-1;print \$d"
SERIAL=`/usr/bin/env perl -e "$GETSERIAL"`
fi
echo SERIAL=$SERIAL PREFIX=$PREFIX CAPREFIX=$CAPREFIX DURATION=$DURATION KEYSIZE=$KEYSIZE
if [ "$DHP." = YES. ] ; then
echo "openssl dhparam -2 -out $PREFIX-sv.dhp $KEYSIZE"
$OPENSSL dhparam -2 -out $PREFIX-sv.dhp $KEYSIZE
fi
if [ "$REQ." = YES. ] ; then
echo "openssl req -config $PREFIX-sv.prm -newkey rsa:$KEYSIZE -keyout $PREFIX-sv.key -out $PREFIX-sv.csr -passout XXX"
$OPENSSL req -config $PREFIX-sv.prm -newkey rsa:$KEYSIZE -keyout $PREFIX-sv.key -out $PREFIX-sv.csr -passout pass:secret
fi
echo "openssl rsa -in $PREFIX-sv.key -out $PREFIX-sv.key"
$OPENSSL rsa -in $PREFIX-sv.key -out $PREFIX-sv.key -passin pass:secret
echo pseudo secrets generated
echo "openssl rsa -in $PREFIX-sv.key -pubout -outform DER -out $PREFIX-sv.pub.der"
$OPENSSL rsa -in $PREFIX-sv.key -pubout -outform DER -out $PREFIX-sv.pub.der
echo "openssl rsa -in $PREFIX-sv.key -pubout -outform PEM -out $PREFIX-sv.pub.pem"
$OPENSSL rsa -in $PREFIX-sv.key -pubout -outform PEM -out $PREFIX-sv.pub.pem
echo "openssl x509 -set_serial $SERIAL -extfile $PREFIX-sv.prm -days $DURATION -CA $CAPREFIX-ca.cacert -CAkey $CAPREFIX-ca.key -in $PREFIX-sv.csr -req -text -nameopt multiline $DIGESTALGO > $PREFIX-sv.crt "
$OPENSSL x509 -set_serial $SERIAL -extfile $PREFIX-sv.prm -days $DURATION -CA $CAPREFIX-ca.cacert -CAkey $CAPREFIX-ca.key -in $PREFIX-sv.csr -req -text -nameopt multiline $DIGESTALGO > $PREFIX-sv.crt
if [ "$P12." = YES. ] ; then
echo "$OPENSSL pkcs12 -export -des3 -out $PREFIX-sv.p12 -caname $CAPREFIX -name $PREFIX -inkey $PREFIX-sv.key -in $PREFIX-sv.crt -certfile $CAPREFIX-ca.crt "
$OPENSSL pkcs12 -export -des3 -out $PREFIX-sv.p12 -caname $CAPREFIX -name $PREFIX -inkey $PREFIX-sv.key -in $PREFIX-sv.crt -certfile $CAPREFIX-ca.crt
fi
echo "openssl x509 -noout -text -hash -in $PREFIX-sv.selfcert -nameopt multiline"
$OPENSSL x509 -noout -text -hash -in $PREFIX-sv.crt -nameopt multiline
# revoke server cert
touch $CAPREFIX-ca.db
echo 01 > $CAPREFIX-ca.cnt
echo "openssl ca -config $CAPREFIX-ca.cnf -revoke $PREFIX-sv.crt"
$OPENSSL ca -config $CAPREFIX-ca.cnf -revoke $PREFIX-sv.crt
# issue CRL
echo "openssl ca -config $CAPREFIX-ca.cnf -gencrl -out $PREFIX-sv.crl"
$OPENSSL ca -config $CAPREFIX-ca.cnf -gencrl -out $PREFIX-sv.crl
echo "openssl x509 -in $PREFIX-sv.crt -outform der -out $PREFIX-sv.der "
$OPENSSL x509 -in $PREFIX-sv.crt -outform der -out $PREFIX-sv.der
# all together now
touch $PREFIX-sv.dhp
cat $PREFIX-sv.prm $PREFIX-sv.key $PREFIX-sv.crt $PREFIX-sv.dhp >$PREFIX-sv.pem
chmod o-r $PREFIX-sv.prm
echo "$PREFIX-sv.pem done"
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests/certs | repos/gpt4all.zig/src/zig-libcurl/curl/tests/certs/scripts/genroot.sh | #!/bin/bash
# (c) CopyRight 2000 - 2020, EdelWeb for EdelKey and OpenEvidence
# Author: Peter Sylvester
# "libre" for integration with curl
OPENSSL=openssl
if [ -f /usr/local/ssl/bin/openssl ] ; then
OPENSSL=/usr/local/ssl/bin/openssl
fi
USAGE="echo Usage is genroot.sh \<name\>"
HOME=`pwd`
cd $HOME
KEYSIZE=2048
DURATION=6000
# The -sha256 option was introduced in OpenSSL 1.0.1
DIGESTALGO=-sha256
PREFIX=$1
if [ ".$PREFIX" = . ] ; then
echo No configuration prefix
NOTOK=1
else
if [ ! -f $PREFIX-ca.prm ] ; then
echo No configuration file $PREFIX-ca.prm
NOTOK=1
fi
fi
if [ ".$NOTOK" != . ] ; then
echo "Sorry, I can't do that for you."
$USAGE
exit
fi
GETSERIAL="\$t = time ;\$d = \$t . substr(\$t+$$ ,-4,4)-1;print \$d"
SERIAL=`/usr/bin/env perl -e "$GETSERIAL"`
echo SERIAL=$SERIAL PREFIX=$PREFIX DURATION=$DURATION KEYSIZE=$KEYSIZE
echo "openssl genrsa -out $PREFIX-ca.key $KEYSIZE -passout XXX"
openssl genrsa -out $PREFIX-ca.key $KEYSIZE -passout pass:secret
echo "openssl req -config $PREFIX-ca.prm -new -key $PREFIX-ca.key -out $PREFIX-ca.csr"
$OPENSSL req -config $PREFIX-ca.prm -new -key $PREFIX-ca.key -out $PREFIX-ca.csr -passin pass:secret
echo "openssl x509 -set_serial $SERIAL -extfile $PREFIX-ca.prm -days $DURATION -req -signkey $PREFIX-ca.key -in $PREFIX-ca.csr -out $PREFIX-$SERIAL.ca-cacert $DIGESTALGO "
$OPENSSL x509 -set_serial $SERIAL -extfile $PREFIX-ca.prm -days $DURATION -req -signkey $PREFIX-ca.key -in $PREFIX-ca.csr -out $PREFIX-$SERIAL-ca.cacert $DIGESTALGO
echo "openssl x509 -text -in $PREFIX-$SERIAL-ca.cacert -nameopt multiline > $PREFIX-ca.cacert "
$OPENSSL x509 -text -in $PREFIX-$SERIAL-ca.cacert -nameopt multiline > $PREFIX-ca.cacert
echo "openssl x509 -in $PREFIX-ca.cacert -outform der -out $PREFIX-ca.der "
$OPENSSL x509 -in $PREFIX-ca.cacert -outform der -out $PREFIX-ca.der
echo "openssl x509 -in $PREFIX-ca.cacert -text -nameopt multiline > $PREFIX-ca.crt "
$OPENSSL x509 -in $PREFIX-ca.cacert -text -nameopt multiline > $PREFIX-ca.crt
echo "openssl x509 -noout -text -in $PREFIX-ca.cacert -nameopt multiline"
$OPENSSL x509 -noout -text -in $PREFIX-ca.cacert -nameopt multiline
#$OPENSSL rsa -in ../keys/$PREFIX-ca.key -text -noout -pubout
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1397.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "hostcheck.h" /* from the lib dir */
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
/* done before shutting down and exiting */
}
UNITTEST_START
/* only these backends define the tested functions */
#if defined(USE_OPENSSL) || defined(USE_GSKIT)
/* here you start doing things and checking that the results are good */
fail_unless(Curl_cert_hostcheck("www.example.com", "www.example.com"),
"good 1");
fail_unless(Curl_cert_hostcheck("*.example.com", "www.example.com"),
"good 2");
fail_unless(Curl_cert_hostcheck("xxx*.example.com", "xxxwww.example.com"),
"good 3");
fail_unless(Curl_cert_hostcheck("f*.example.com", "foo.example.com"),
"good 4");
fail_unless(Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"),
"good 5");
fail_if(Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1");
fail_if(Curl_cert_hostcheck("*", "www.example.com"), "bad 2");
fail_if(Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3");
fail_if(Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4");
fail_if(Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5");
fail_if(Curl_cert_hostcheck("*.com", "example.com"), "bad 6");
fail_if(Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7");
fail_if(Curl_cert_hostcheck("*.example.", "www.example."), "bad 8");
fail_if(Curl_cert_hostcheck("*.example.", "www.example"), "bad 9");
fail_if(Curl_cert_hostcheck("", "www"), "bad 10");
fail_if(Curl_cert_hostcheck("*", "www"), "bad 11");
fail_if(Curl_cert_hostcheck("*.168.0.0", "192.168.0.0"), "bad 12");
fail_if(Curl_cert_hostcheck("www.example.com", "192.168.0.0"), "bad 13");
#ifdef ENABLE_IPV6
fail_if(Curl_cert_hostcheck("*::3285:a9ff:fe46:b619",
"fe80::3285:a9ff:fe46:b619"), "bad 14");
fail_unless(Curl_cert_hostcheck("fe80::3285:a9ff:fe46:b619",
"fe80::3285:a9ff:fe46:b619"), "good 6");
#endif
#endif
/* you end the test code like this: */
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1603.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2015 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#define ENABLE_CURLX_PRINTF
#include "curlx.h"
#include "hash.h"
#include "memdebug.h" /* LAST include file */
static struct Curl_hash hash_static;
static const int slots = 3;
static void mydtor(void *p)
{
/* Data are statically allocated */
(void)p; /* unused */
}
static CURLcode unit_setup(void)
{
return Curl_hash_init(&hash_static, slots, Curl_hash_str,
Curl_str_key_compare, mydtor);
}
static void unit_stop(void)
{
Curl_hash_destroy(&hash_static);
}
UNITTEST_START
char key1[] = "key1";
char key2[] = "key2b";
char key3[] = "key3";
char key4[] = "key4";
char notakey[] = "notakey";
char *nodep;
int rc;
/* Ensure the key hashes are as expected in order to test both hash
collisions and a full table. Unfortunately, the hashes can vary
between architectures. */
if(Curl_hash_str(key1, strlen(key1), slots) != 1 ||
Curl_hash_str(key2, strlen(key2), slots) != 0 ||
Curl_hash_str(key3, strlen(key3), slots) != 2 ||
Curl_hash_str(key4, strlen(key4), slots) != 1)
fprintf(stderr, "Warning: hashes are not computed as expected on this "
"architecture; test coverage will be less comprehensive\n");
nodep = Curl_hash_add(&hash_static, &key1, strlen(key1), &key1);
fail_unless(nodep, "insertion into hash failed");
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
fail_unless(nodep == key1, "hash retrieval failed");
nodep = Curl_hash_add(&hash_static, &key2, strlen(key2), &key2);
fail_unless(nodep, "insertion into hash failed");
nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
fail_unless(nodep == key2, "hash retrieval failed");
nodep = Curl_hash_add(&hash_static, &key3, strlen(key3), &key3);
fail_unless(nodep, "insertion into hash failed");
nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
fail_unless(nodep == key3, "hash retrieval failed");
/* The fourth element exceeds the number of slots & collides */
nodep = Curl_hash_add(&hash_static, &key4, strlen(key4), &key4);
fail_unless(nodep, "insertion into hash failed");
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
fail_unless(nodep == key4, "hash retrieval failed");
/* Make sure all elements are still accessible */
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
fail_unless(nodep == key1, "hash retrieval failed");
nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
fail_unless(nodep == key2, "hash retrieval failed");
nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
fail_unless(nodep == key3, "hash retrieval failed");
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
fail_unless(nodep == key4, "hash retrieval failed");
/* Delete the second of two entries in a bucket */
rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
fail_unless(rc == 0, "hash delete failed");
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
fail_unless(nodep == key1, "hash retrieval failed");
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
fail_unless(!nodep, "hash retrieval should have failed");
/* Insert that deleted node again */
nodep = Curl_hash_add(&hash_static, &key4, strlen(key4), &key4);
fail_unless(nodep, "insertion into hash failed");
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
fail_unless(nodep == key4, "hash retrieval failed");
/* Delete the first of two entries in a bucket */
rc = Curl_hash_delete(&hash_static, &key1, strlen(key1));
fail_unless(rc == 0, "hash delete failed");
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
fail_unless(!nodep, "hash retrieval should have failed");
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
fail_unless(nodep == key4, "hash retrieval failed");
/* Delete the remaining one of two entries in a bucket */
rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
fail_unless(rc == 0, "hash delete failed");
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
fail_unless(!nodep, "hash retrieval should have failed");
nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
fail_unless(!nodep, "hash retrieval should have failed");
/* Delete an already deleted node */
rc = Curl_hash_delete(&hash_static, &key4, strlen(key4));
fail_unless(rc, "hash delete should have failed");
/* Replace an existing node */
nodep = Curl_hash_add(&hash_static, &key1, strlen(key1), ¬akey);
fail_unless(nodep, "insertion into hash failed");
nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
fail_unless(nodep == notakey, "hash retrieval failed");
/* Make sure all remaining elements are still accessible */
nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
fail_unless(nodep == key2, "hash retrieval failed");
nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
fail_unless(nodep == key3, "hash retrieval failed");
/* Clean up */
Curl_hash_clean(&hash_static);
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/curlcheck.h | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "test.h"
/* The fail macros mark the current test step as failed, and continue */
#define fail_if(expr, msg) \
do { \
if(expr) { \
fprintf(stderr, "%s:%d Assertion '%s' met: %s\n", \
__FILE__, __LINE__, #expr, msg); \
unitfail++; \
} \
} while(0)
#define fail_unless(expr, msg) \
do { \
if(!(expr)) { \
fprintf(stderr, "%s:%d Assertion '%s' failed: %s\n", \
__FILE__, __LINE__, #expr, msg); \
unitfail++; \
} \
} while(0)
#define verify_memory(dynamic, check, len) \
do { \
if(dynamic && memcmp(dynamic, check, len)) { \
fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n", \
__FILE__, __LINE__, len, \
hexdump((const unsigned char *)check, len)); \
fprintf(stderr, "%s:%d the same as '%s'\n", __FILE__, __LINE__, \
hexdump((const unsigned char *)dynamic, len)); \
unitfail++; \
} \
} while(0)
/* fail() is for when the test case figured out by itself that a check
proved a failure */
#define fail(msg) do { \
fprintf(stderr, "%s:%d test failed: '%s'\n", \
__FILE__, __LINE__, msg); \
unitfail++; \
} while(0)
/* The abort macros mark the current test step as failed, and exit the test */
#define abort_if(expr, msg) \
do { \
if(expr) { \
fprintf(stderr, "%s:%d Abort assertion '%s' met: %s\n", \
__FILE__, __LINE__, #expr, msg); \
unitfail++; \
goto unit_test_abort; \
} \
} while(0)
#define abort_unless(expr, msg) \
do { \
if(!(expr)) { \
fprintf(stderr, "%s:%d Abort assertion '%s' failed: %s\n", \
__FILE__, __LINE__, #expr, msg); \
unitfail++; \
goto unit_test_abort; \
} \
} while(0)
#define abort_test(msg) \
do { \
fprintf(stderr, "%s:%d test aborted: '%s'\n", \
__FILE__, __LINE__, msg); \
unitfail++; \
goto unit_test_abort; \
} while(0)
extern int unitfail;
#define UNITTEST_START \
int test(char *arg) \
{ \
(void)arg; \
if(unit_setup()) { \
fail("unit_setup() failure"); \
} \
else {
#define UNITTEST_STOP \
goto unit_test_abort; /* avoid warning */ \
unit_test_abort: \
unit_stop(); \
} \
return unitfail; \
}
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1399.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "progress.h"
static int usec_magnitude = 1000000;
static bool unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
/*
* Invoke Curl_pgrsTime for TIMER_STARTSINGLE to trigger the behavior that
* manages is_t_startransfer_set, but fake the t_startsingle time for purposes
* of the test.
*/
static void fake_t_startsingle_time(struct Curl_easy *data,
struct curltime fake_now,
int seconds_offset)
{
Curl_pgrsTime(data, TIMER_STARTSINGLE);
data->progress.t_startsingle.tv_sec = fake_now.tv_sec + seconds_offset;
data->progress.t_startsingle.tv_usec = fake_now.tv_usec;
}
static bool usec_matches_seconds(timediff_t time_usec, int expected_seconds)
{
int time_sec = (int)(time_usec / usec_magnitude);
bool same = (time_sec == expected_seconds);
fprintf(stderr, "is %d us same as %d seconds? %s\n",
(int)time_usec, expected_seconds,
same?"Yes":"No");
return same;
}
static void expect_timer_seconds(struct Curl_easy *data, int seconds)
{
char msg[64];
msnprintf(msg, sizeof(msg), "about %d seconds should have passed", seconds);
fail_unless(usec_matches_seconds(data->progress.t_nslookup, seconds), msg);
fail_unless(usec_matches_seconds(data->progress.t_connect, seconds), msg);
fail_unless(usec_matches_seconds(data->progress.t_appconnect, seconds), msg);
fail_unless(usec_matches_seconds(data->progress.t_pretransfer, seconds),
msg);
fail_unless(usec_matches_seconds(data->progress.t_starttransfer, seconds),
msg);
}
/* Scenario: simulate a redirect. When a redirect occurs, t_nslookup,
* t_connect, t_appconnect, t_pretransfer, and t_starttransfer are addative.
* E.g., if t_starttransfer took 2 seconds initially and took another 1
* second for the redirect request, then the resulting t_starttransfer should
* be 3 seconds. */
UNITTEST_START
struct Curl_easy data;
struct curltime now = Curl_now();
data.progress.t_nslookup = 0;
data.progress.t_connect = 0;
data.progress.t_appconnect = 0;
data.progress.t_pretransfer = 0;
data.progress.t_starttransfer = 0;
data.progress.t_redirect = 0;
data.progress.start.tv_sec = now.tv_sec - 2;
data.progress.start.tv_usec = now.tv_usec;
fake_t_startsingle_time(&data, now, -2);
Curl_pgrsTime(&data, TIMER_NAMELOOKUP);
Curl_pgrsTime(&data, TIMER_CONNECT);
Curl_pgrsTime(&data, TIMER_APPCONNECT);
Curl_pgrsTime(&data, TIMER_PRETRANSFER);
Curl_pgrsTime(&data, TIMER_STARTTRANSFER);
expect_timer_seconds(&data, 2);
/* now simulate the redirect */
data.progress.t_redirect = data.progress.t_starttransfer + 1;
fake_t_startsingle_time(&data, now, -1);
Curl_pgrsTime(&data, TIMER_NAMELOOKUP);
Curl_pgrsTime(&data, TIMER_CONNECT);
Curl_pgrsTime(&data, TIMER_APPCONNECT);
Curl_pgrsTime(&data, TIMER_PRETRANSFER);
/* ensure t_starttransfer is only set on the first invocation by attempting
* to set it twice */
Curl_pgrsTime(&data, TIMER_STARTTRANSFER);
Curl_pgrsTime(&data, TIMER_STARTTRANSFER);
expect_timer_seconds(&data, 3);
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1323.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "timeval.h"
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
struct a {
struct curltime first;
struct curltime second;
time_t result;
};
UNITTEST_START
{
struct a tests[] = {
{ {36762, 8345 }, {36761, 995926 }, 13 },
{ {36761, 995926 }, {36762, 8345 }, -13 },
{ {36761, 995926 }, {0, 0}, 36761995 },
{ {0, 0}, {36761, 995926 }, -36761995 },
};
size_t i;
for(i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
timediff_t result = Curl_timediff(tests[i].first, tests[i].second);
if(result != tests[i].result) {
printf("%d.%06u to %d.%06u got %d, but expected %d\n",
tests[i].first.tv_sec,
tests[i].first.tv_usec,
tests[i].second.tv_sec,
tests[i].second.tv_usec,
result,
tests[i].result);
fail("unexpected result!");
}
}
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1610.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "curl_sha256.h"
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
UNITTEST_START
#ifndef CURL_DISABLE_CRYPTO_AUTH
const char string1[] = "1";
const char string2[] = "hello-you-fool";
unsigned char output[SHA256_DIGEST_LENGTH];
unsigned char *testp = output;
Curl_sha256it(output, (const unsigned char *) string1, strlen(string1));
verify_memory(testp,
"\x6b\x86\xb2\x73\xff\x34\xfc\xe1\x9d\x6b\x80\x4e\xff\x5a\x3f"
"\x57\x47\xad\xa4\xea\xa2\x2f\x1d\x49\xc0\x1e\x52\xdd\xb7\x87"
"\x5b\x4b", SHA256_DIGEST_LENGTH);
Curl_sha256it(output, (const unsigned char *) string2, strlen(string2));
verify_memory(testp,
"\xcb\xb1\x6a\x8a\xb9\xcb\xb9\x35\xa8\xcb\xa0\x2e\x28\xc0\x26"
"\x30\xd1\x19\x9c\x1f\x02\x17\xf4\x7c\x96\x20\xf3\xef\xe8\x27"
"\x15\xae", SHA256_DIGEST_LENGTH);
#endif
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1620.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "url.h"
#include "memdebug.h" /* LAST include file */
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
UNITTEST_START
{
int rc;
struct Curl_easy *empty;
const char *hostname = "hostname";
enum dupstring i;
bool async = FALSE;
bool protocol_connect = FALSE;
rc = Curl_open(&empty);
if(rc)
goto unit_test_abort;
fail_unless(rc == CURLE_OK, "Curl_open() failed");
rc = Curl_connect(empty, &async, &protocol_connect);
fail_unless(rc == CURLE_URL_MALFORMAT,
"Curl_connect() failed to return CURLE_URL_MALFORMAT");
fail_unless(empty->magic == CURLEASY_MAGIC_NUMBER,
"empty->magic should be equal to CURLEASY_MAGIC_NUMBER");
/* double invoke to ensure no dependency on internal state */
rc = Curl_connect(empty, &async, &protocol_connect);
fail_unless(rc == CURLE_URL_MALFORMAT,
"Curl_connect() failed to return CURLE_URL_MALFORMAT");
rc = Curl_init_userdefined(empty);
fail_unless(rc == CURLE_OK, "Curl_userdefined() failed");
rc = Curl_init_do(empty, empty->conn);
fail_unless(rc == CURLE_OK, "Curl_init_do() failed");
rc = Curl_parse_login_details(
hostname, strlen(hostname), NULL, NULL, NULL);
fail_unless(rc == CURLE_OK,
"Curl_parse_login_details() failed");
Curl_freeset(empty);
for(i = (enum dupstring)0; i < STRING_LAST; i++) {
fail_unless(empty->set.str[i] == NULL,
"Curl_free() did not set to NULL");
}
Curl_free_request_state(empty);
rc = Curl_close(&empty);
fail_unless(rc == CURLE_OK, "Curl_close() failed");
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1621.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "url.h"
#include "memdebug.h" /* LAST include file */
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
#if defined(__MINGW32__) || \
(!defined(HAVE_FSETXATTR) && \
(!defined(__FreeBSD_version) || (__FreeBSD_version < 500000)))
UNITTEST_START
{
return 0;
}
UNITTEST_STOP
#else
bool stripcredentials(char **url);
struct checkthis {
const char *input;
const char *output;
};
static const struct checkthis tests[] = {
{ "ninja://[email protected]", "ninja://[email protected]" },
{ "https://[email protected]", "https://example.com/" },
{ "https://localhost:45", "https://localhost:45/" },
{ "https://foo@localhost:45", "https://localhost:45/" },
{ "http://daniel:password@localhost", "http://localhost/" },
{ "http://daniel@localhost", "http://localhost/" },
{ "http://localhost/", "http://localhost/" },
{ NULL, NULL } /* end marker */
};
UNITTEST_START
{
bool cleanup;
char *url;
int i;
int rc = 0;
for(i = 0; tests[i].input; i++) {
url = (char *)tests[i].input;
cleanup = stripcredentials(&url);
printf("Test %u got input \"%s\", output: \"%s\"\n",
i, tests[i].input, url);
if(strcmp(tests[i].output, url)) {
fprintf(stderr, "Test %u got input \"%s\", expected output \"%s\"\n"
" Actual output: \"%s\"\n", i, tests[i].input, tests[i].output,
url);
rc++;
}
if(cleanup)
curl_free(url);
}
return rc;
}
UNITTEST_STOP
#endif
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1301.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "strcase.h"
static CURLcode unit_setup(void) {return CURLE_OK;}
static void unit_stop(void) {}
UNITTEST_START
int rc;
rc = curl_strequal("iii", "III");
fail_unless(rc != 0, "return code should be non-zero");
rc = curl_strequal("iiia", "III");
fail_unless(rc == 0, "return code should be zero");
rc = curl_strequal("iii", "IIIa");
fail_unless(rc == 0, "return code should be zero");
rc = curl_strequal("iiiA", "IIIa");
fail_unless(rc != 0, "return code should be non-zero");
rc = curl_strnequal("iii", "III", 3);
fail_unless(rc != 0, "return code should be non-zero");
rc = curl_strnequal("iiiABC", "IIIcba", 3);
fail_unless(rc != 0, "return code should be non-zero");
rc = curl_strnequal("ii", "II", 3);
fail_unless(rc != 0, "return code should be non-zero");
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1655.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2019 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "doh.h" /* from the lib dir */
static CURLcode unit_setup(void)
{
/* whatever you want done first */
return CURLE_OK;
}
static void unit_stop(void)
{
/* done before shutting down and exiting */
}
#ifndef CURL_DISABLE_DOH
UNITTEST_START
/*
* Prove detection of write overflow using a short buffer and a name
* of maximal valid length.
*
* Prove detection of other invalid input.
*/
do {
const char *max =
/* ..|....1.........2.........3.........4.........5.........6... */
/* 3456789012345678901234567890123456789012345678901234567890123 */
"this.is.a.maximum-length.hostname." /* 34: 34 */
"with-no-label-of-greater-length-than-the-sixty-three-characters."
/* 64: 98 */
"specified.in.the.RFCs." /* 22: 120 */
"and.with.a.QNAME.encoding.whose.length.is.exactly." /* 50: 170 */
"the.maximum.length.allowed." /* 27: 197 */
"that.is.two-hundred.and.fifty-six." /* 34: 231 */
"including.the.last.null." /* 24: 255 */
"";
const char *toolong =
/* ..|....1.........2.........3.........4.........5.........6... */
/* 3456789012345678901234567890123456789012345678901234567890123 */
"here.is.a.hostname.which.is.just.barely.too.long." /* 49: 49 */
"to.be.encoded.as.a.QNAME.of.the.maximum.allowed.length."
/* 55: 104 */
"which.is.256.including.a.final.zero-length.label." /* 49: 153 */
"representing.the.root.node.so.that.a.name.with." /* 47: 200 */
"a.trailing.dot.may.have.up.to." /* 30: 230 */
"255.characters.never.more." /* 26: 256 */
"";
const char *emptylabel =
"this.is.an.otherwise-valid.hostname."
".with.an.empty.label.";
const char *outsizelabel =
"this.is.an.otherwise-valid.hostname."
"with-a-label-of-greater-length-than-the-sixty-three-characters-"
"specified.in.the.RFCs.";
int i;
struct test {
const char *name;
const DOHcode expected_result;
};
/* plays the role of struct dnsprobe in urldata.h */
struct demo {
unsigned char dohbuffer[255 + 16]; /* deliberately short buffer */
unsigned char canary1;
unsigned char canary2;
unsigned char canary3;
};
const struct test playlist[4] = {
{ toolong, DOH_DNS_NAME_TOO_LONG }, /* expect early failure */
{ emptylabel, DOH_DNS_BAD_LABEL }, /* also */
{ outsizelabel, DOH_DNS_BAD_LABEL }, /* also */
{ max, DOH_OK } /* expect buffer overwrite */
};
for(i = 0; i < (int)(sizeof(playlist)/sizeof(*playlist)); i++) {
const char *name = playlist[i].name;
size_t olen = 100000;
struct demo victim;
DOHcode d;
victim.canary1 = 87; /* magic numbers, arbritrarily picked */
victim.canary2 = 35;
victim.canary3 = 41;
d = doh_encode(name, DNS_TYPE_A, victim.dohbuffer,
sizeof(struct demo), /* allow room for overflow */
&olen);
fail_unless(d == playlist[i].expected_result,
"result returned was not as expected");
if(d == playlist[i].expected_result) {
if(name == max) {
fail_if(victim.canary1 == 87,
"demo one-byte buffer overwrite did not happen");
}
else {
fail_unless(victim.canary1 == 87,
"one-byte buffer overwrite has happened");
}
fail_unless(victim.canary2 == 35,
"two-byte buffer overwrite has happened");
fail_unless(victim.canary3 == 41,
"three-byte buffer overwrite has happened");
}
else {
if(d == DOH_OK) {
fail_unless(olen <= sizeof(victim.dohbuffer), "wrote outside bounds");
fail_unless(olen > strlen(name), "unrealistic low size");
}
}
}
} while(0);
/* run normal cases and try to trigger buffer length related errors */
do {
DNStype dnstype = DNS_TYPE_A;
unsigned char buffer[128];
const size_t buflen = sizeof(buffer);
const size_t magic1 = 9765;
size_t olen1 = magic1;
const char *sunshine1 = "a.com";
const char *dotshine1 = "a.com.";
const char *sunshine2 = "aa.com";
size_t olen2;
DOHcode ret2;
size_t olen;
DOHcode ret = doh_encode(sunshine1, dnstype, buffer, buflen, &olen1);
fail_unless(ret == DOH_OK, "sunshine case 1 should pass fine");
fail_if(olen1 == magic1, "olen has not been assigned properly");
fail_unless(olen1 > strlen(sunshine1), "bad out length");
/* with a trailing dot, the response should have the same length */
olen2 = magic1;
ret2 = doh_encode(dotshine1, dnstype, buffer, buflen, &olen2);
fail_unless(ret2 == DOH_OK, "dotshine case should pass fine");
fail_if(olen2 == magic1, "olen has not been assigned properly");
fail_unless(olen1 == olen2, "olen should not grow for a trailing dot");
/* add one letter, the response should be one longer */
olen2 = magic1;
ret2 = doh_encode(sunshine2, dnstype, buffer, buflen, &olen2);
fail_unless(ret2 == DOH_OK, "sunshine case 2 should pass fine");
fail_if(olen2 == magic1, "olen has not been assigned properly");
fail_unless(olen1 + 1 == olen2, "olen should grow with the hostname");
/* pass a short buffer, should fail */
ret = doh_encode(sunshine1, dnstype, buffer, olen1 - 1, &olen);
fail_if(ret == DOH_OK, "short buffer should have been noticed");
/* pass a minimum buffer, should succeed */
ret = doh_encode(sunshine1, dnstype, buffer, olen1, &olen);
fail_unless(ret == DOH_OK, "minimal length buffer should be long enough");
fail_unless(olen == olen1, "bad buffer length");
} while(0);
UNITTEST_STOP
#else /* CURL_DISABLE_DOH */
UNITTEST_START
{
return 1; /* nothing to do, just fail */
}
UNITTEST_STOP
#endif
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1606.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "speedcheck.h"
#include "urldata.h"
static CURL *easy;
static CURLcode unit_setup(void)
{
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy = curl_easy_init();
if(!easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
return res;
}
static void unit_stop(void)
{
curl_easy_cleanup(easy);
curl_global_cleanup();
}
static int runawhile(long time_limit,
long speed_limit,
curl_off_t speed,
int dec)
{
int counter = 1;
struct curltime now = {1, 0};
CURLcode result;
int finaltime;
curl_easy_setopt(easy, CURLOPT_LOW_SPEED_LIMIT, speed_limit);
curl_easy_setopt(easy, CURLOPT_LOW_SPEED_TIME, time_limit);
Curl_speedinit(easy);
do {
/* fake the current transfer speed */
easy->progress.current_speed = speed;
result = Curl_speedcheck(easy, now);
if(result)
break;
/* step the time */
now.tv_sec = ++counter;
speed -= dec;
} while(counter < 100);
finaltime = (int)(now.tv_sec - 1);
return finaltime;
}
UNITTEST_START
fail_unless(runawhile(41, 41, 40, 0) == 41,
"wrong low speed timeout");
fail_unless(runawhile(21, 21, 20, 0) == 21,
"wrong low speed timeout");
fail_unless(runawhile(60, 60, 40, 0) == 60,
"wrong log speed timeout");
fail_unless(runawhile(50, 50, 40, 0) == 50,
"wrong log speed timeout");
fail_unless(runawhile(40, 40, 40, 0) == 99,
"should not time out");
fail_unless(runawhile(10, 50, 100, 2) == 36,
"bad timeout");
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1304.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "netrc.h"
#include "memdebug.h" /* LAST include file */
static char *login;
static char *password;
static char filename[64];
static CURLcode unit_setup(void)
{
password = strdup("");
login = strdup("");
if(!password || !login) {
Curl_safefree(password);
Curl_safefree(login);
return CURLE_OUT_OF_MEMORY;
}
return CURLE_OK;
}
static void unit_stop(void)
{
Curl_safefree(password);
Curl_safefree(login);
}
UNITTEST_START
int result;
bool login_changed;
bool password_changed;
static const char * const filename1 = "log/netrc1304";
memcpy(filename, filename1, strlen(filename1));
/*
* Test a non existent host in our netrc file.
*/
result = Curl_parsenetrc("test.example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 1, "Host not found should return 1");
abort_unless(password != NULL, "returned NULL!");
fail_unless(password[0] == 0, "password should not have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(login[0] == 0, "login should not have been changed");
/*
* Test a non existent login in our netrc file.
*/
free(login);
login = strdup("me");
abort_unless(login != NULL, "returned NULL!");
result = Curl_parsenetrc("example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 0, "Host should have been found");
abort_unless(password != NULL, "returned NULL!");
fail_unless(password[0] == 0, "password should not have been changed");
fail_unless(!password_changed, "password should not have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(strncmp(login, "me", 2) == 0,
"login should not have been changed");
fail_unless(!login_changed, "login should not have been changed");
/*
* Test a non existent login and host in our netrc file.
*/
free(login);
login = strdup("me");
abort_unless(login != NULL, "returned NULL!");
result = Curl_parsenetrc("test.example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 1, "Host not found should return 1");
abort_unless(password != NULL, "returned NULL!");
fail_unless(password[0] == 0, "password should not have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(strncmp(login, "me", 2) == 0,
"login should not have been changed");
/*
* Test a non existent login (substring of an existing one) in our
* netrc file.
*/
free(login);
login = strdup("admi");
abort_unless(login != NULL, "returned NULL!");
result = Curl_parsenetrc("example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 0, "Host should have been found");
abort_unless(password != NULL, "returned NULL!");
fail_unless(password[0] == 0, "password should not have been changed");
fail_unless(!password_changed, "password should not have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(strncmp(login, "admi", 4) == 0,
"login should not have been changed");
fail_unless(!login_changed, "login should not have been changed");
/*
* Test a non existent login (superstring of an existing one)
* in our netrc file.
*/
free(login);
login = strdup("adminn");
abort_unless(login != NULL, "returned NULL!");
result = Curl_parsenetrc("example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 0, "Host should have been found");
abort_unless(password != NULL, "returned NULL!");
fail_unless(password[0] == 0, "password should not have been changed");
fail_unless(!password_changed, "password should not have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(strncmp(login, "adminn", 6) == 0,
"login should not have been changed");
fail_unless(!login_changed, "login should not have been changed");
/*
* Test for the first existing host in our netrc file
* with login[0] = 0.
*/
free(login);
login = strdup("");
abort_unless(login != NULL, "returned NULL!");
result = Curl_parsenetrc("example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 0, "Host should have been found");
abort_unless(password != NULL, "returned NULL!");
fail_unless(strncmp(password, "passwd", 6) == 0,
"password should be 'passwd'");
fail_unless(password_changed, "password should have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(strncmp(login, "admin", 5) == 0, "login should be 'admin'");
fail_unless(login_changed, "login should have been changed");
/*
* Test for the first existing host in our netrc file
* with login[0] != 0.
*/
free(password);
password = strdup("");
abort_unless(password != NULL, "returned NULL!");
result = Curl_parsenetrc("example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 0, "Host should have been found");
abort_unless(password != NULL, "returned NULL!");
fail_unless(strncmp(password, "passwd", 6) == 0,
"password should be 'passwd'");
fail_unless(password_changed, "password should have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(strncmp(login, "admin", 5) == 0, "login should be 'admin'");
fail_unless(!login_changed, "login should not have been changed");
/*
* Test for the second existing host in our netrc file
* with login[0] = 0.
*/
free(password);
password = strdup("");
abort_unless(password != NULL, "returned NULL!");
free(login);
login = strdup("");
abort_unless(login != NULL, "returned NULL!");
result = Curl_parsenetrc("curl.example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 0, "Host should have been found");
abort_unless(password != NULL, "returned NULL!");
fail_unless(strncmp(password, "none", 4) == 0,
"password should be 'none'");
fail_unless(password_changed, "password should have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
fail_unless(login_changed, "login should have been changed");
/*
* Test for the second existing host in our netrc file
* with login[0] != 0.
*/
free(password);
password = strdup("");
abort_unless(password != NULL, "returned NULL!");
result = Curl_parsenetrc("curl.example.com", &login, &password,
&login_changed, &password_changed, filename);
fail_unless(result == 0, "Host should have been found");
abort_unless(password != NULL, "returned NULL!");
fail_unless(strncmp(password, "none", 4) == 0,
"password should be 'none'");
fail_unless(password_changed, "password should have been changed");
abort_unless(login != NULL, "returned NULL!");
fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
fail_unless(!login_changed, "login should not have been changed");
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1660.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2020 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "hsts.h"
static CURLcode
unit_setup(void)
{
return CURLE_OK;
}
static void
unit_stop(void)
{
curl_global_cleanup();
}
#if defined(CURL_DISABLE_HTTP) || defined(CURL_DISABLE_HSTS)
UNITTEST_START
{
return 0; /* nothing to do when HTTP or HSTS are disabled */
}
UNITTEST_STOP
#else
struct testit {
const char *host;
const char *chost; /* if non-NULL, use to lookup with */
const char *hdr; /* if NULL, just do the lookup */
const CURLcode result; /* parse result */
};
static const struct testit headers[] = {
/* two entries read from disk cache, verify first */
{ "-", "readfrom.example", NULL, CURLE_OK},
{ "-", "old.example", NULL, CURLE_OK},
/* delete the remaining one read from disk */
{ "readfrom.example", NULL, "max-age=\"0\"", CURLE_OK},
{ "example.com", NULL, "max-age=\"31536000\"\r\n", CURLE_OK },
{ "example.com", NULL, "max-age=\"21536000\"\r\n", CURLE_OK },
{ "example.com", NULL, "max-age=\"21536000\"; \r\n", CURLE_OK },
{ "example.com", NULL, "max-age=\"21536000\"; includeSubDomains\r\n",
CURLE_OK },
{ "example.org", NULL, "max-age=\"31536000\"\r\n", CURLE_OK },
{ "this.example", NULL, "max=\"31536\";", CURLE_BAD_FUNCTION_ARGUMENT },
{ "this.example", NULL, "max-age=\"31536", CURLE_BAD_FUNCTION_ARGUMENT },
{ "this.example", NULL, "max-age=31536\"", CURLE_OK },
/* max-age=0 removes the entry */
{ "this.example", NULL, "max-age=0", CURLE_OK },
{ "another.example", NULL, "includeSubDomains; ",
CURLE_BAD_FUNCTION_ARGUMENT },
/* Two max-age is illegal */
{ "example.com", NULL,
"max-age=\"21536000\"; includeSubDomains; max-age=\"3\";",
CURLE_BAD_FUNCTION_ARGUMENT },
/* Two includeSubDomains is illegal */
{ "2.example.com", NULL,
"max-age=\"21536000\"; includeSubDomains; includeSubDomains;",
CURLE_BAD_FUNCTION_ARGUMENT },
/* use a unknown directive "include" that should be ignored */
{ "3.example.com", NULL, "max-age=\"21536000\"; include; includeSubDomains;",
CURLE_OK },
/* remove the "3.example.com" one, should still match the example.com */
{ "3.example.com", NULL, "max-age=\"0\"; includeSubDomains;",
CURLE_OK },
{ "-", "foo.example.com", NULL, CURLE_OK},
{ "-", "foo.xample.com", NULL, CURLE_OK},
/* should not match */
{ "example.net", "forexample.net", "max-age=\"31536000\"\r\n", CURLE_OK },
/* should not match either, since forexample.net is not in the example.net
domain */
{ "example.net", "forexample.net",
"max-age=\"31536000\"; includeSubDomains\r\n", CURLE_OK },
/* remove example.net again */
{ "example.net", NULL, "max-age=\"0\"; includeSubDomains\r\n", CURLE_OK },
/* make this live for 7 seconds */
{ "expire.example", NULL, "max-age=\"7\"\r\n", CURLE_OK },
{ NULL, NULL, NULL, 0 }
};
static void showsts(struct stsentry *e, const char *chost)
{
if(!e)
printf("'%s' is not HSTS\n", chost);
else {
printf("%s [%s]: %" CURL_FORMAT_CURL_OFF_T "%s\n",
chost, e->host, e->expires,
e->includeSubDomains ? " includeSubDomains" : "");
}
}
UNITTEST_START
{
CURLcode result;
struct stsentry *e;
struct hsts *h = Curl_hsts_init();
int i;
const char *chost;
CURL *easy;
if(!h)
return 1;
curl_global_init(CURL_GLOBAL_ALL);
easy = curl_easy_init();
if(!easy) {
Curl_hsts_cleanup(&h);
curl_global_cleanup();
return 1;
}
Curl_hsts_loadfile(easy, h, "log/input1660");
for(i = 0; headers[i].host ; i++) {
if(headers[i].hdr) {
result = Curl_hsts_parse(h, headers[i].host, headers[i].hdr);
if(result != headers[i].result) {
fprintf(stderr, "Curl_hsts_parse(%s) failed: %d\n",
headers[i].hdr, result);
unitfail++;
continue;
}
else if(result) {
printf("Input %u: error %d\n", i, (int) result);
continue;
}
}
chost = headers[i].chost ? headers[i].chost : headers[i].host;
e = Curl_hsts(h, chost, TRUE);
showsts(e, chost);
}
printf("Number of entries: %zu\n", h->list.size);
/* verify that it is exists for 7 seconds */
chost = "expire.example";
for(i = 100; i < 110; i++) {
e = Curl_hsts(h, chost, TRUE);
showsts(e, chost);
deltatime++; /* another second passed */
}
(void)Curl_hsts_save(easy, h, "log/hsts1660");
Curl_hsts_cleanup(&h);
curl_easy_cleanup(easy);
curl_global_cleanup();
return unitfail;
}
UNITTEST_STOP
#endif
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1608.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "hostip.h"
CURLcode Curl_shuffle_addr(struct Curl_easy *data,
struct Curl_addrinfo **addr);
#define NUM_ADDRS 8
static struct Curl_addrinfo addrs[NUM_ADDRS];
static CURLcode unit_setup(void)
{
int i;
for(i = 0; i < NUM_ADDRS - 1; i++) {
addrs[i].ai_next = &addrs[i + 1];
}
return CURLE_OK;
}
static void unit_stop(void)
{
curl_global_cleanup();
}
UNITTEST_START
{
int i;
CURLcode code;
struct Curl_addrinfo *addrhead = addrs;
struct Curl_easy *easy = curl_easy_init();
abort_unless(easy, "out of memory");
code = curl_easy_setopt(easy, CURLOPT_DNS_SHUFFLE_ADDRESSES, 1L);
abort_unless(code == CURLE_OK, "curl_easy_setopt failed");
/* Shuffle repeatedly and make sure that the list changes */
for(i = 0; i < 10; i++) {
if(CURLE_OK != Curl_shuffle_addr(easy, &addrhead))
break;
if(addrhead != addrs)
break;
}
curl_easy_cleanup(easy);
curl_global_cleanup();
abort_unless(addrhead != addrs, "addresses are not being reordered");
return 0;
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1652.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "sendf.h"
/*
* This test hardcodes the knowledge of the buffer size which is internal to
* Curl_infof(). If that buffer is changed in size, this tests needs to be
* updated to still be valid.
*/
static struct Curl_easy *data;
static char input[4096];
static char result[4096];
int debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
void *userptr);
/*
* This debugf callback is simply dumping the string into the static buffer
* for the unit test to inspect. Since we know that we're only dealing with
* text we can afford the luxury of skipping the type check here.
*/
int
debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
void *userptr)
{
(void)handle;
(void)type;
(void)userptr;
memset(result, '\0', sizeof(result));
memcpy(result, buf, size);
return 0;
}
static CURLcode
unit_setup(void)
{
int res = 0;
global_init(CURL_GLOBAL_ALL);
data = curl_easy_init();
if(!data) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
curl_easy_setopt(data, CURLOPT_DEBUGFUNCTION, debugf_cb);
curl_easy_setopt(data, CURLOPT_VERBOSE, 1L);
return CURLE_OK;
}
static void
unit_stop(void)
{
curl_easy_cleanup(data);
curl_global_cleanup();
}
static int verify(const char *info, const char *two)
{
/* the 'info' one has a newline appended */
char *nl = strchr(info, '\n');
if(!nl)
return 1; /* nope */
return strncmp(info, two, nl - info);
}
UNITTEST_START
/* Injecting a simple short string via a format */
msnprintf(input, sizeof(input), "Simple Test");
Curl_infof(data, "%s", input);
fail_unless(verify(result, input) == 0, "Simple string test");
/* Injecting a few different variables with a format */
Curl_infof(data, "%s %u testing %lu", input, 42, 43L);
fail_unless(verify(result, "Simple Test 42 testing 43\n") == 0,
"Format string");
/* Variations of empty strings */
Curl_infof(data, "");
fail_unless(strlen(result) == 1, "Empty string");
Curl_infof(data, "%s", NULL);
fail_unless(verify(result, "(nil)") == 0, "Passing NULL as string");
/* A string just long enough to not be truncated */
memset(input, '\0', sizeof(input));
memset(input, 'A', 2047);
Curl_infof(data, "%s", input);
fail_unless(strlen(result) == 2048, "No truncation of infof input");
fail_unless(verify(result, input) == 0, "No truncation of infof input");
fail_unless(result[sizeof(result) - 1] == '\0',
"No truncation of infof input");
/* Just over the limit for truncation without newline */
memset(input + 2047, 'A', 4);
Curl_infof(data, "%s", input);
fail_unless(strlen(result) == 2048, "Truncation of infof input 1");
fail_unless(result[sizeof(result) - 1] == '\0', "Truncation of infof input 1");
/* Just over the limit for truncation with newline */
memset(input + 2047, 'A', 4);
memset(input + 2047 + 4, '\n', 1);
Curl_infof(data, "%s", input);
fail_unless(strlen(result) == 2048, "Truncation of infof input 2");
fail_unless(result[sizeof(result) - 1] == '\0', "Truncation of infof input 2");
/* Way over the limit for truncation with newline */
memset(input, '\0', sizeof(input));
memset(input, 'A', sizeof(input) - 1);
Curl_infof(data, "%s", input);
fail_unless(strlen(result) == 2048, "Truncation of infof input 3");
fail_unless(result[sizeof(result) - 1] == '\0', "Truncation of infof input 3");
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1308.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include <curl/curl.h>
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
static size_t print_httppost_callback(void *arg, const char *buf, size_t len)
{
fwrite(buf, len, 1, stdout);
(*(size_t *) arg) += len;
return len;
}
UNITTEST_START
int rc;
struct curl_httppost *post = NULL;
struct curl_httppost *last = NULL;
size_t total_size = 0;
char buffer[] = "test buffer";
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name",
CURLFORM_COPYCONTENTS, "content", CURLFORM_END);
fail_unless(rc == 0, "curl_formadd returned error");
/* after the first curl_formadd when there's a single entry, both pointers
should point to the same struct */
fail_unless(post == last, "post and last weren't the same");
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "htmlcode",
CURLFORM_COPYCONTENTS, "<HTML></HTML>",
CURLFORM_CONTENTTYPE, "text/html", CURLFORM_END);
fail_unless(rc == 0, "curl_formadd returned error");
rc = curl_formadd(&post, &last, CURLFORM_COPYNAME, "name_for_ptrcontent",
CURLFORM_PTRCONTENTS, buffer, CURLFORM_END);
fail_unless(rc == 0, "curl_formadd returned error");
rc = curl_formget(post, &total_size, print_httppost_callback);
fail_unless(rc == 0, "curl_formget returned error");
fail_unless(total_size == 488, "curl_formget got wrong size back");
curl_formfree(post);
/* start a new formpost with a file upload and formget */
post = last = NULL;
rc = curl_formadd(&post, &last,
CURLFORM_PTRNAME, "name of file field",
CURLFORM_FILE, "log/test-1308",
CURLFORM_FILENAME, "custom named file",
CURLFORM_END);
fail_unless(rc == 0, "curl_formadd returned error");
rc = curl_formget(post, &total_size, print_httppost_callback);
fail_unless(rc == 0, "curl_formget returned error");
fail_unless(total_size == 851, "curl_formget got wrong size back");
curl_formfree(post);
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1302.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "url.h" /* for Curl_safefree */
#include "curl_base64.h"
#include "memdebug.h" /* LAST include file */
static struct Curl_easy *data;
static CURLcode unit_setup(void)
{
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
data = curl_easy_init();
if(!data) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
return res;
}
static void unit_stop(void)
{
curl_easy_cleanup(data);
curl_global_cleanup();
}
UNITTEST_START
char *output;
unsigned char *decoded;
size_t size = 0;
unsigned char anychar = 'x';
CURLcode rc;
rc = Curl_base64_encode(data, "i", 1, &output, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 4, "size should be 4");
verify_memory(output, "aQ==", 4);
Curl_safefree(output);
rc = Curl_base64_encode(data, "ii", 2, &output, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 4, "size should be 4");
verify_memory(output, "aWk=", 4);
Curl_safefree(output);
rc = Curl_base64_encode(data, "iii", 3, &output, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 4, "size should be 4");
verify_memory(output, "aWlp", 4);
Curl_safefree(output);
rc = Curl_base64_encode(data, "iiii", 4, &output, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 8, "size should be 8");
verify_memory(output, "aWlpaQ==", 8);
Curl_safefree(output);
rc = Curl_base64_encode(data, "\xff\x01\xfe\x02", 4, &output, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 8, "size should be 8");
verify_memory(output, "/wH+Ag==", 8);
Curl_safefree(output);
rc = Curl_base64url_encode(data, "\xff\x01\xfe\x02", 4, &output, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 8, "size should be 8");
verify_memory(output, "_wH-Ag==", 8);
Curl_safefree(output);
rc = Curl_base64url_encode(data, "iiii", 4, &output, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 8, "size should be 8");
verify_memory(output, "aWlpaQ==", 8);
Curl_safefree(output);
/* 0 length makes it do strlen() */
rc = Curl_base64_encode(data, "iiii", 0, &output, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 8, "size should be 8");
verify_memory(output, "aWlpaQ==", 8);
Curl_safefree(output);
rc = Curl_base64_decode("aWlpaQ==", &decoded, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 4, "size should be 4");
verify_memory(decoded, "iiii", 4);
Curl_safefree(decoded);
rc = Curl_base64_decode("aWlp", &decoded, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 3, "size should be 3");
verify_memory(decoded, "iii", 3);
Curl_safefree(decoded);
rc = Curl_base64_decode("aWk=", &decoded, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 2, "size should be 2");
verify_memory(decoded, "ii", 2);
Curl_safefree(decoded);
rc = Curl_base64_decode("aQ==", &decoded, &size);
fail_unless(rc == CURLE_OK, "return code should be CURLE_OK");
fail_unless(size == 1, "size should be 1");
verify_memory(decoded, "i", 2);
Curl_safefree(decoded);
/* This is illegal input as the data is too short */
size = 1; /* not zero */
decoded = &anychar; /* not NULL */
rc = Curl_base64_decode("aQ", &decoded, &size);
fail_unless(rc == CURLE_BAD_CONTENT_ENCODING,
"return code should be CURLE_BAD_CONTENT_ENCODING");
fail_unless(size == 0, "size should be 0");
fail_if(decoded, "returned pointer should be NULL");
/* This is illegal input as it contains three padding characters */
size = 1; /* not zero */
decoded = &anychar; /* not NULL */
rc = Curl_base64_decode("a===", &decoded, &size);
fail_unless(rc == CURLE_BAD_CONTENT_ENCODING,
"return code should be CURLE_BAD_CONTENT_ENCODING");
fail_unless(size == 0, "size should be 0");
fail_if(decoded, "returned pointer should be NULL");
/* This is illegal input as it contains a padding character mid input */
size = 1; /* not zero */
decoded = &anychar; /* not NULL */
rc = Curl_base64_decode("a=Q=", &decoded, &size);
fail_unless(rc == CURLE_BAD_CONTENT_ENCODING,
"return code should be CURLE_BAD_CONTENT_ENCODING");
fail_unless(size == 0, "size should be 0");
fail_if(decoded, "returned pointer should be NULL");
/* This is garbage input as it contains an illegal base64 character */
size = 1; /* not zero */
decoded = &anychar; /* not NULL */
rc = Curl_base64_decode("a\x1f==", &decoded, &size);
fail_unless(rc == CURLE_BAD_CONTENT_ENCODING,
"return code should be CURLE_BAD_CONTENT_ENCODING");
fail_unless(size == 0, "size should be 0");
fail_if(decoded, "returned pointer should be NULL");
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1398.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "curl/mprintf.h"
static CURLcode unit_setup(void) {return CURLE_OK;}
static void unit_stop(void) {}
UNITTEST_START
int rc;
char buf[3] = {'b', 'u', 'g'};
const char *str = "bug";
int width = 3;
char output[24];
/*#define curl_msnprintf snprintf */
/* without a trailing zero */
rc = curl_msnprintf(output, 4, "%.*s", width, buf);
fail_unless(rc == 3, "return code should be 3");
fail_unless(!strcmp(output, "bug"), "wrong output");
/* with a trailing zero */
rc = curl_msnprintf(output, 4, "%.*s", width, str);
fail_unless(rc == 3, "return code should be 3");
fail_unless(!strcmp(output, "bug"), "wrong output");
width = 2;
/* one byte less */
rc = curl_msnprintf(output, 4, "%.*s", width, buf);
fail_unless(rc == 2, "return code should be 2");
fail_unless(!strcmp(output, "bu"), "wrong output");
/* string with larger precision */
rc = curl_msnprintf(output, 8, "%.8s", str);
fail_unless(rc == 3, "return code should be 3");
fail_unless(!strcmp(output, "bug"), "wrong output");
/* longer string with precision */
rc = curl_msnprintf(output, 8, "%.3s", "0123456789");
fail_unless(rc == 3, "return code should be 3");
fail_unless(!strcmp(output, "012"), "wrong output");
/* negative width */
rc = curl_msnprintf(output, 8, "%-8s", str);
fail_unless(rc == 7, "return code should be 7");
fail_unless(!strcmp(output, "bug "), "wrong output");
/* larger width that string length */
rc = curl_msnprintf(output, 8, "%8s", str);
fail_unless(rc == 7, "return code should be 7");
fail_unless(!strcmp(output, " bu"), "wrong output");
/* output a number in a limited output */
rc = curl_msnprintf(output, 4, "%d", 10240);
fail_unless(rc == 3, "return code should be 3");
fail_unless(!strcmp(output, "102"), "wrong output");
/* padded strings */
rc = curl_msnprintf(output, 16, "%8s%8s", str, str);
fail_unless(rc == 15, "return code should be 15");
fail_unless(!strcmp(output, " bug bu"), "wrong output");
/* padded numbers */
rc = curl_msnprintf(output, 16, "%8d%8d", 1234, 5678);
fail_unless(rc == 15, "return code should be 15");
fail_unless(!strcmp(output, " 1234 567"), "wrong output");
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1307.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "curl_fnmatch.h"
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
#ifndef CURL_DISABLE_FTP
/*
CURL_FNMATCH_MATCH 0
CURL_FNMATCH_NOMATCH 1
CURL_FNMATCH_FAIL 2
*/
#define MATCH CURL_FNMATCH_MATCH
#define NOMATCH CURL_FNMATCH_NOMATCH
#define LINUX_DIFFER 0x80
#define LINUX_SHIFT 8
#define LINUX_MATCH ((CURL_FNMATCH_MATCH << LINUX_SHIFT) | LINUX_DIFFER)
#define LINUX_NOMATCH ((CURL_FNMATCH_NOMATCH << LINUX_SHIFT) | LINUX_DIFFER)
#define LINUX_FAIL ((CURL_FNMATCH_FAIL << LINUX_SHIFT) | LINUX_DIFFER)
#define MAC_DIFFER 0x40
#define MAC_SHIFT 16
#define MAC_MATCH ((CURL_FNMATCH_MATCH << MAC_SHIFT) | MAC_DIFFER)
#define MAC_NOMATCH ((CURL_FNMATCH_NOMATCH << MAC_SHIFT) | MAC_DIFFER)
#define MAC_FAIL ((CURL_FNMATCH_FAIL << MAC_SHIFT) | MAC_DIFFER)
struct testcase {
const char *pattern;
const char *string;
int result;
};
static const struct testcase tests[] = {
/* brackets syntax */
{"*[*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\001\177[[[[[[[[[[[[[[[[[[[[[",
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[",
NOMATCH|MAC_FAIL},
{ "\\[", "[", MATCH },
{ "[", "[", NOMATCH|LINUX_MATCH|MAC_FAIL},
{ "[]", "[]", NOMATCH|LINUX_MATCH|MAC_FAIL},
{ "[][]", "[", MATCH },
{ "[][]", "]", MATCH },
{ "[[]", "[", MATCH },
{ "[[[]", "[", MATCH },
{ "[[[[]", "[", MATCH },
{ "[[[[]", "[", MATCH },
{ "[][[]", "]", MATCH },
{ "[][[[]", "[", MATCH },
{ "[[]", "]", NOMATCH },
{ "[a@]", "a", MATCH },
{ "[a-z]", "a", MATCH },
{ "[a-z]", "A", NOMATCH },
{ "?[a-z]", "?Z", NOMATCH },
{ "[A-Z]", "C", MATCH },
{ "[A-Z]", "c", NOMATCH },
{ "[0-9]", "7", MATCH },
{ "[7-8]", "7", MATCH },
{ "[7-]", "7", MATCH },
{ "[7-]", "-", MATCH },
{ "[7-]", "[", NOMATCH },
{ "[a-bA-F]", "F", MATCH },
{ "[a-bA-B9]", "9", MATCH },
{ "[a-bA-B98]", "8", MATCH },
{ "[a-bA-B98]", "C", NOMATCH },
{ "[a-bA-Z9]", "F", MATCH },
{ "[a-bA-Z9]ero*", "Zero chance.", MATCH },
{ "S[a-][x]opho*", "Saxophone", MATCH },
{ "S[a-][x]opho*", "SaXophone", NOMATCH },
{ "S[a-][x]*.txt", "S-x.txt", MATCH },
{ "[\\a-\\b]", "a", MATCH },
{ "[\\a-\\b]", "b", MATCH },
{ "[?*[][?*[][?*[]", "?*[", MATCH },
{ "[][?*-]", "]", MATCH },
{ "[][?*-]", "[", MATCH },
{ "[][?*-]", "?", MATCH },
{ "[][?*-]", "*", MATCH },
{ "[][?*-]", "-", MATCH },
{ "[]?*-]", "-", MATCH },
{ "[\xFF]", "\xFF", MATCH|LINUX_FAIL|MAC_FAIL},
{ "?/b/c", "a/b/c", MATCH },
{ "^_{}~", "^_{}~", MATCH },
{ "!#%+,-./01234567889", "!#%+,-./01234567889", MATCH },
{ "PQRSTUVWXYZ]abcdefg", "PQRSTUVWXYZ]abcdefg", MATCH },
{ ":;=@ABCDEFGHIJKLMNO", ":;=@ABCDEFGHIJKLMNO", MATCH },
/* negate */
{ "[!a]", "b", MATCH },
{ "[!a]", "a", NOMATCH },
{ "[^a]", "b", MATCH },
{ "[^a]", "a", NOMATCH },
{ "[^a-z0-9A-Z]", "a", NOMATCH },
{ "[^a-z0-9A-Z]", "-", MATCH },
{ "curl[!a-z]lib", "curl lib", MATCH },
{ "curl[! ]lib", "curl lib", NOMATCH },
{ "[! ][ ]", " ", NOMATCH },
{ "[! ][ ]", "a ", MATCH },
{ "*[^a].t?t", "a.txt", NOMATCH },
{ "*[^a].t?t", "ba.txt", NOMATCH },
{ "*[^a].t?t", "ab.txt", MATCH },
{ "*[^a]", "", NOMATCH },
{ "[!\xFF]", "", NOMATCH|LINUX_FAIL},
{ "[!\xFF]", "\xFF", NOMATCH|LINUX_FAIL|MAC_FAIL},
{ "[!\xFF]", "a", MATCH|LINUX_FAIL|MAC_FAIL},
{ "[!?*[]", "?", NOMATCH },
{ "[!!]", "!", NOMATCH },
{ "[!!]", "x", MATCH },
{ "[[:alpha:]]", "a", MATCH },
{ "[[:alpha:]]", "9", NOMATCH },
{ "[[:alnum:]]", "a", MATCH },
{ "[[:alnum:]]", "[", NOMATCH },
{ "[[:alnum:]]", "]", NOMATCH },
{ "[[:alnum:]]", "9", MATCH },
{ "[[:digit:]]", "9", MATCH },
{ "[[:xdigit:]]", "9", MATCH },
{ "[[:xdigit:]]", "F", MATCH },
{ "[[:xdigit:]]", "G", NOMATCH },
{ "[[:upper:]]", "U", MATCH },
{ "[[:upper:]]", "u", NOMATCH },
{ "[[:lower:]]", "l", MATCH },
{ "[[:lower:]]", "L", NOMATCH },
{ "[[:print:]]", "L", MATCH },
{ "[[:print:]]", "\10", NOMATCH },
{ "[[:print:]]", "\10", NOMATCH },
{ "[[:space:]]", " ", MATCH },
{ "[[:space:]]", "x", NOMATCH },
{ "[[:graph:]]", " ", NOMATCH },
{ "[[:graph:]]", "x", MATCH },
{ "[[:blank:]]", "\t", MATCH },
{ "[[:blank:]]", " ", MATCH },
{ "[[:blank:]]", "\r", NOMATCH },
{ "[^[:blank:]]", "\t", NOMATCH },
{ "[^[:print:]]", "\10", MATCH },
{ "[[:lower:]][[:lower:]]", "ll", MATCH },
{ "[[:foo:]]", "bar", NOMATCH|MAC_FAIL},
{ "[[:foo:]]", "f]", MATCH|LINUX_NOMATCH|MAC_FAIL},
{ "Curl[[:blank:]];-)", "Curl ;-)", MATCH },
{ "*[[:blank:]]*", " ", MATCH },
{ "*[[:blank:]]*", "", NOMATCH },
{ "*[[:blank:]]*", "hi, im_Pavel", MATCH },
/* common using */
{ "filename.dat", "filename.dat", MATCH },
{ "*curl*", "lets use curl!!", MATCH },
{ "filename.txt", "filename.dat", NOMATCH },
{ "*.txt", "text.txt", MATCH },
{ "*.txt", "a.txt", MATCH },
{ "*.txt", ".txt", MATCH },
{ "*.txt", "txt", NOMATCH },
{ "??.txt", "99.txt", MATCH },
{ "??.txt", "a99.txt", NOMATCH },
{ "?.???", "a.txt", MATCH },
{ "*.???", "somefile.dat", MATCH },
{ "*.???", "photo.jpeg", NOMATCH },
{ ".*", ".htaccess", MATCH },
{ ".*", ".", MATCH },
{ ".*", "..", MATCH },
/* many stars => one star */
{ "**.txt", "text.txt", MATCH },
{ "***.txt", "t.txt", MATCH },
{ "****.txt", ".txt", MATCH },
/* empty string or pattern */
{ "", "", MATCH },
{ "", "hello", NOMATCH },
{ "file", "", NOMATCH },
{ "?", "", NOMATCH },
{ "*", "", MATCH },
{ "x", "", NOMATCH },
/* backslash */
{ "\\", "\\", MATCH|LINUX_NOMATCH},
{ "\\\\", "\\", MATCH },
{ "\\\\", "\\\\", NOMATCH },
{ "\\?", "?", MATCH },
{ "\\*", "*", MATCH },
{ "?.txt", "?.txt", MATCH },
{ "*.txt", "*.txt", MATCH },
{ "\\?.txt", "?.txt", MATCH },
{ "\\*.txt", "*.txt", MATCH },
{ "\\?.txt", "x.txt", NOMATCH },
{ "\\*.txt", "x.txt", NOMATCH },
{ "\\*\\\\.txt", "*\\.txt", MATCH },
{ "*\\**\\?*\\\\*", "cc*cc?cccc", NOMATCH },
{ "*\\?*\\**", "cc?cc", NOMATCH },
{ "\\\"\\$\\&\\'\\(\\)", "\"$&'()", MATCH },
{ "\\*\\?\\[\\\\\\`\\|", "*?[\\`|", MATCH },
{ "[\\a\\b]c", "ac", MATCH },
{ "[\\a\\b]c", "bc", MATCH },
{ "[\\a\\b]d", "bc", NOMATCH },
{ "[a-bA-B\\?]", "?", MATCH },
{ "cu[a-ab-b\\r]l", "curl", MATCH },
{ "[\\a-z]", "c", MATCH },
{ "?*?*?.*?*", "abc.c", MATCH },
{ "?*?*?.*?*", "abcc", NOMATCH },
{ "?*?*?.*?*", "abc.", NOMATCH },
{ "?*?*?.*?*", "abc.c++", MATCH },
{ "?*?*?.*?*", "abcdef.c++", MATCH },
{ "?*?*?.?", "abcdef.c", MATCH },
{ "?*?*?.?", "abcdef.cd", NOMATCH },
{ "Lindmätarv", "Lindmätarv", MATCH },
{ "", "", MATCH},
{"**]*[*[\x13]**[*\x13)]*]*[**[*\x13~r-]*]**[.*]*[\xe3\xe3\xe3\xe3\xe3\xe3"
"\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3\xe3"
"\xe3\xe3\xe3\xe3\xe3*[\x13]**[*\x13)]*]*[*[\x13]*[~r]*]*\xba\x13\xa6~b-]*",
"a", NOMATCH|LINUX_FAIL}
};
static const char *ret2name(int i)
{
switch(i) {
case 0:
return "MATCH";
case 1:
return "NOMATCH";
case 2:
return "FAIL";
default:
return "unknown";
}
/* not reached */
}
enum system {
SYSTEM_CUSTOM,
SYSTEM_LINUX,
SYSTEM_MACOS
};
UNITTEST_START
{
int testnum = sizeof(tests) / sizeof(struct testcase);
int i;
enum system machine;
#ifdef HAVE_FNMATCH
if(strstr(OS, "apple") || strstr(OS, "darwin")) {
machine = SYSTEM_MACOS;
}
else
machine = SYSTEM_LINUX;
printf("Tested with system fnmatch(), %s-style\n",
machine == SYSTEM_LINUX ? "linux" : "mac");
#else
printf("Tested with custom fnmatch()\n");
machine = SYSTEM_CUSTOM;
#endif
for(i = 0; i < testnum; i++) {
int result = tests[i].result;
int rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string);
if(result & (LINUX_DIFFER|MAC_DIFFER)) {
if((result & LINUX_DIFFER) && (machine == SYSTEM_LINUX))
result >>= LINUX_SHIFT;
else if((result & MAC_DIFFER) && (machine == SYSTEM_MACOS))
result >>= MAC_SHIFT;
result &= 0x03; /* filter off all high bits */
}
if(rc != result) {
printf("Curl_fnmatch(\"%s\", \"%s\") should return %s (returns %s)"
" [%d]\n",
tests[i].pattern, tests[i].string, ret2name(result),
ret2name(rc), i);
fail("pattern mismatch");
}
}
}
UNITTEST_STOP
#else
UNITTEST_START
{
/* nothing to do, just fail */
return 1;
}
UNITTEST_STOP
#endif
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1650.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2018 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "doh.h"
#include "dynbuf.h"
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
#ifndef CURL_DISABLE_DOH
#define DNS_PREAMBLE "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00"
#define LABEL_TEST "\x04\x74\x65\x73\x74"
#define LABEL_HOST "\x04\x68\x6f\x73\x74"
#define LABEL_NAME "\x04\x6e\x61\x6d\x65"
#define DNSA_TYPE "\x01"
#define DNSAAAA_TYPE "\x1c"
#define DNSA_EPILOGUE "\x00\x00" DNSA_TYPE "\x00\x01"
#define DNSAAAA_EPILOGUE "\x00\x00" DNSAAAA_TYPE "\x00\x01"
#define DNS_Q1 DNS_PREAMBLE LABEL_TEST LABEL_HOST LABEL_NAME DNSA_EPILOGUE
#define DNS_Q2 DNS_PREAMBLE LABEL_TEST LABEL_HOST LABEL_NAME DNSAAAA_EPILOGUE
struct dohrequest {
/* input */
const char *name;
DNStype type;
/* output */
const char *packet;
size_t size;
int rc;
};
static const struct dohrequest req[] = {
{"test.host.name", DNS_TYPE_A, DNS_Q1, sizeof(DNS_Q1)-1, 0 },
{"test.host.name", DNS_TYPE_AAAA, DNS_Q2, sizeof(DNS_Q2)-1, 0 },
{"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
".host.name",
DNS_TYPE_AAAA, NULL, 0, DOH_DNS_BAD_LABEL }
};
struct dohresp {
/* input */
const char *packet;
size_t size;
DNStype type;
/* output */
int rc;
const char *out;
};
#define DNS_FOO_EXAMPLE_COM \
"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f" \
"\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\x00\x01\x00" \
"\x01\xc0\x0c\x00\x01\x00\x01\x00\x00\x00\x37\x00\x04\x7f\x00\x00" \
"\x01"
static const char full49[] = DNS_FOO_EXAMPLE_COM;
static const struct dohresp resp[] = {
{"\x00\x00", 2, DNS_TYPE_A, DOH_TOO_SMALL_BUFFER, NULL },
{"\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01", 12,
DNS_TYPE_A, DOH_DNS_BAD_ID, NULL },
{"\x00\x00\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01", 12,
DNS_TYPE_A, DOH_DNS_BAD_RCODE, NULL },
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f", 16,
DNS_TYPE_A, DOH_DNS_OUT_OF_RANGE, NULL },
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f\x00", 17,
DNS_TYPE_A, DOH_DNS_OUT_OF_RANGE, NULL },
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f\x00"
"\x00\x01\x00\x01", 21,
DNS_TYPE_A, DOH_DNS_OUT_OF_RANGE, NULL },
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x03\x66\x6f\x6f\x00"
"\x00\x01\x00\x01"
"\x04", 18,
DNS_TYPE_A, DOH_DNS_OUT_OF_RANGE, NULL },
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x04\x63\x75\x72"
"\x6c\x04\x63\x75\x72\x6c\x00\x00\x05\x00\x01\xc0\x0c\x00\x05\x00"
"\x01\x00\x00\x00\x37\x00\x11\x08\x61\x6e\x79\x77\x68\x65\x72\x65"
"\x06\x72\x65\x61\x6c\x6c\x79\x00", 56,
DNS_TYPE_A, DOH_OK, "anywhere.really "},
{DNS_FOO_EXAMPLE_COM, 49, DNS_TYPE_A, DOH_OK, "127.0.0.1 "},
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x04\x61\x61\x61"
"\x61\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\x00\x1c"
"\x00\x01\xc0\x0c\x00\x1c\x00\x01\x00\x00\x00\x37\x00\x10\x20\x20"
"\x20\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20", 62,
DNS_TYPE_AAAA, DOH_OK,
"2020:2020:0000:0000:0000:0000:0000:2020 " },
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x00\x04\x63\x75\x72"
"\x6c\x04\x63\x75\x72\x6c\x00\x00\x05\x00\x01\xc0\x0c\x00\x05\x00"
"\x01\x00\x00\x00\x37\x00"
"\x07\x03\x61\x6e\x79\xc0\x27\x00", 46,
DNS_TYPE_A, DOH_DNS_LABEL_LOOP, NULL},
/* packet with NSCOUNT == 1 */
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x01\x00\x00\x04\x61\x61\x61"
"\x61\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\x00\x1c"
"\x00\x01\xc0\x0c\x00\x1c\x00\x01\x00\x00\x00\x37\x00\x10\x20\x20"
"\x20\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20"
LABEL_TEST LABEL_HOST LABEL_NAME DNSAAAA_EPILOGUE "\x00\x00\x00\x01"
"\00\x04\x01\x01\x01\x01", /* RDDATA */
62 + 30,
DNS_TYPE_AAAA, DOH_OK,
"2020:2020:0000:0000:0000:0000:0000:2020 " },
/* packet with ARCOUNT == 1 */
{"\x00\x00\x01\x00\x00\x01\x00\x01\x00\x00\x00\x01\x04\x61\x61\x61"
"\x61\x07\x65\x78\x61\x6d\x70\x6c\x65\x03\x63\x6f\x6d\x00\x00\x1c"
"\x00\x01\xc0\x0c\x00\x1c\x00\x01\x00\x00\x00\x37\x00\x10\x20\x20"
"\x20\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20"
LABEL_TEST LABEL_HOST LABEL_NAME DNSAAAA_EPILOGUE "\x00\x00\x00\x01"
"\00\x04\x01\x01\x01\x01", /* RDDATA */
62 + 30,
DNS_TYPE_AAAA, DOH_OK,
"2020:2020:0000:0000:0000:0000:0000:2020 " },
};
UNITTEST_START
{
size_t size = 0;
unsigned char buffer[256];
size_t i;
unsigned char *p;
for(i = 0; i < sizeof(req) / sizeof(req[0]); i++) {
int rc = doh_encode(req[i].name, req[i].type,
buffer, sizeof(buffer), &size);
if(rc != req[i].rc) {
fprintf(stderr, "req %zu: Expected return code %d got %d\n", i,
req[i].rc, rc);
return 1;
}
else if(size != req[i].size) {
fprintf(stderr, "req %zu: Expected size %zu got %zu\n", i,
req[i].size, size);
fprintf(stderr, "DNS encode made: %s\n", hexdump(buffer, size));
return 2;
}
else if(req[i].packet && memcmp(req[i].packet, buffer, size)) {
fprintf(stderr, "DNS encode made: %s\n", hexdump(buffer, size));
fprintf(stderr, "... instead of: %s\n",
hexdump((unsigned char *)req[i].packet, size));
return 3;
}
}
for(i = 0; i < sizeof(resp) / sizeof(resp[0]); i++) {
struct dohentry d;
int rc;
char *ptr;
size_t len;
int u;
de_init(&d);
rc = doh_decode((const unsigned char *)resp[i].packet, resp[i].size,
resp[i].type, &d);
if(rc != resp[i].rc) {
fprintf(stderr, "resp %zu: Expected return code %d got %d\n", i,
resp[i].rc, rc);
return 4;
}
len = sizeof(buffer);
ptr = (char *)buffer;
for(u = 0; u < d.numaddr; u++) {
size_t o;
struct dohaddr *a;
a = &d.addr[u];
if(resp[i].type == DNS_TYPE_A) {
p = &a->ip.v4[0];
msnprintf(ptr, len, "%u.%u.%u.%u ", p[0], p[1], p[2], p[3]);
o = strlen(ptr);
len -= o;
ptr += o;
}
else {
int j;
for(j = 0; j < 16; j += 2) {
size_t l;
msnprintf(ptr, len, "%s%02x%02x", j?":":"", a->ip.v6[j],
a->ip.v6[j + 1]);
l = strlen(ptr);
len -= l;
ptr += l;
}
msnprintf(ptr, len, " ");
len--;
ptr++;
}
}
for(u = 0; u < d.numcname; u++) {
size_t o;
msnprintf(ptr, len, "%s ", Curl_dyn_ptr(&d.cname[u]));
o = strlen(ptr);
len -= o;
ptr += o;
}
de_cleanup(&d);
if(resp[i].out && strcmp((char *)buffer, resp[i].out)) {
fprintf(stderr, "resp %zu: Expected %s got %s\n", i,
resp[i].out, buffer);
return 1;
}
}
{
/* pass all sizes into the decoder until full */
for(i = 0; i < sizeof(full49)-1; i++) {
struct dohentry d;
int rc;
memset(&d, 0, sizeof(d));
rc = doh_decode((const unsigned char *)full49, i, DNS_TYPE_A, &d);
if(!rc) {
/* none of them should work */
fprintf(stderr, "%zu: %d\n", i, rc);
return 5;
}
}
/* and try all pieces from the other end of the packet */
for(i = 1; i < sizeof(full49); i++) {
struct dohentry d;
int rc;
memset(&d, 0, sizeof(d));
rc = doh_decode((const unsigned char *)&full49[i], sizeof(full49)-i-1,
DNS_TYPE_A, &d);
if(!rc) {
/* none of them should work */
fprintf(stderr, "2 %zu: %d\n", i, rc);
return 7;
}
}
{
int rc;
struct dohentry d;
struct dohaddr *a;
memset(&d, 0, sizeof(d));
rc = doh_decode((const unsigned char *)full49, sizeof(full49)-1,
DNS_TYPE_A, &d);
fail_if(d.numaddr != 1, "missing address");
a = &d.addr[0];
p = &a->ip.v4[0];
msnprintf((char *)buffer, sizeof(buffer),
"%u.%u.%u.%u", p[0], p[1], p[2], p[3]);
if(rc || strcmp((char *)buffer, "127.0.0.1")) {
fprintf(stderr, "bad address decoded: %s, rc == %d\n", buffer, rc);
return 7;
}
fail_if(d.numcname, "bad cname counter");
}
}
}
UNITTEST_STOP
#else /* CURL_DISABLE_DOH */
UNITTEST_START
{
return 1; /* nothing to do, just fail */
}
UNITTEST_STOP
#endif
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1609.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "connect.h"
#include "share.h"
#include "memdebug.h" /* LAST include file */
static void unit_stop(void)
{
curl_global_cleanup();
}
static CURLcode unit_setup(void)
{
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
return res;
}
struct testcase {
/* host:port:address[,address]... */
const char *optval;
/* lowercase host and port to retrieve the addresses from hostcache */
const char *host;
int port;
/* 0 to 9 addresses expected from hostcache */
const char *address[10];
};
/* CURLOPT_RESOLVE address parsing test - to test the following defect fix:
1) if there is already existing host:port pair in the DNS cache and
we call CURLOPT_RESOLVE, it should also replace addresses.
for example, if there is "test.com:80" with address "1.1.1.1"
and we called CURLOPT_RESOLVE with address "2.2.2.2", then DNS entry needs to
reflect that.
2) when cached address is already there and close to expire, then by the
time request is made, it can get expired. This happens because, when
we set address using CURLOPT_RESOLVE,
it usually marks as permanent (by setting timestamp to zero). However,
if address already exists
in the cache, then it does not mark it, but just leaves it as it is.
So we fixing this by timestamp to zero if address already exists too.
Test:
- insert new entry
- verify that timestamp is not zero
- call set options with CURLOPT_RESOLVE
- then, call Curl_loadhostpairs
expected result: cached address has zero timestamp.
- call set options with CURLOPT_RESOLVE with same host:port pair,
different address.
- then, call Curl_loadhostpairs
expected result: cached address has zero timestamp and new address
*/
static const struct testcase tests[] = {
/* spaces aren't allowed, for now */
{ "test.com:80:127.0.0.1",
"test.com", 80, { "127.0.0.1", }
},
{ "test.com:80:127.0.0.2",
"test.com", 80, { "127.0.0.2", }
},
};
UNITTEST_START
{
int i;
int testnum = sizeof(tests) / sizeof(struct testcase);
struct Curl_multi *multi = NULL;
struct Curl_easy *easy = NULL;
struct curl_slist *list = NULL;
/* important: we setup cache outside of the loop
and also clean cache after the loop. In contrast,for example,
test 1607 sets up and cleans cache on each iteration. */
for(i = 0; i < testnum; ++i) {
int j;
int addressnum = sizeof (tests[i].address) / sizeof (*tests[i].address);
struct Curl_addrinfo *addr;
struct Curl_dns_entry *dns;
void *entry_id;
bool problem = false;
easy = curl_easy_init();
if(!easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
/* create a multi handle and add the easy handle to it so that the
hostcache is setup */
multi = curl_multi_init();
if(!multi)
goto error;
curl_multi_add_handle(multi, easy);
list = curl_slist_append(NULL, tests[i].optval);
if(!list)
goto error;
curl_easy_setopt(easy, CURLOPT_RESOLVE, list);
if(Curl_loadhostpairs(easy))
goto error;
entry_id = (void *)aprintf("%s:%d", tests[i].host, tests[i].port);
if(!entry_id)
goto error;
dns = Curl_hash_pick(easy->dns.hostcache, entry_id, strlen(entry_id) + 1);
free(entry_id);
entry_id = NULL;
addr = dns ? dns->addr : NULL;
for(j = 0; j < addressnum; ++j) {
int port = 0;
char ipaddress[MAX_IPADR_LEN] = {0};
if(!addr && !tests[i].address[j])
break;
if(addr && !Curl_addr2string(addr->ai_addr, addr->ai_addrlen,
ipaddress, &port)) {
fprintf(stderr, "%s:%d tests[%d] failed. Curl_addr2string failed.\n",
__FILE__, __LINE__, i);
problem = true;
break;
}
if(addr && !tests[i].address[j]) {
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
"is %s but tests[%d].address[%d] is NULL.\n",
__FILE__, __LINE__, i, ipaddress, i, j);
problem = true;
break;
}
if(!addr && tests[i].address[j]) {
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
"is NULL but tests[%d].address[%d] is %s.\n",
__FILE__, __LINE__, i, i, j, tests[i].address[j]);
problem = true;
break;
}
if(!curl_strequal(ipaddress, tests[i].address[j])) {
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
"%s is not equal to tests[%d].address[%d] %s.\n",
__FILE__, __LINE__, i, ipaddress, i, j, tests[i].address[j]);
problem = true;
break;
}
if(port != tests[i].port) {
fprintf(stderr, "%s:%d tests[%d] failed. the retrieved port "
"for tests[%d].address[%d] is %ld but tests[%d].port is %d.\n",
__FILE__, __LINE__, i, i, j, port, i, tests[i].port);
problem = true;
break;
}
addr = addr->ai_next;
}
curl_easy_cleanup(easy);
easy = NULL;
Curl_hash_destroy(&multi->hostcache);
curl_multi_cleanup(multi);
multi = NULL;
curl_slist_free_all(list);
list = NULL;
if(problem) {
unitfail++;
continue;
}
}
goto unit_test_abort;
error:
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_slist_free_all(list);
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/CMakeLists.txt | #***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
###########################################################################
# TODO build a special libcurlu library for unittests.
return()
set(UT_SRC
unit1300.c
unit1301.c
unit1302.c
unit1303.c
unit1304.c
unit1305.c
unit1307.c
unit1308.c
unit1309.c
unit1330.c
# Broken link on Linux
# unit1394.c
unit1395.c
unit1396.c
unit1397.c
unit1398.c
unit1600.c
unit1601.c
unit1603.c
# Broken link on Linux
# unit1604.c
unit1620.c
unit1655.c
)
set(UT_COMMON_FILES ../libtest/first.c ../libtest/test.h curlcheck.h)
include_directories(
${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h"
${CURL_SOURCE_DIR}/tests/libtest
${CURL_SOURCE_DIR}/src
${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
${CURL_BINARY_DIR}/include # To be able to reach "curl/curl.h"
)
foreach(_testfile ${UT_SRC})
get_filename_component(_testname ${_testfile} NAME_WE)
add_executable(${_testname} EXCLUDE_FROM_ALL ${_testfile} ${UT_COMMON_FILES})
#add_dependencies(testdeps ${_testname})
target_link_libraries(${_testname} libcurl ${CURL_LIBS})
set_target_properties(${_testname}
PROPERTIES COMPILE_DEFINITIONS "UNITTESTS")
endforeach()
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1394.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "tool_getparam.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "memdebug.h" /* LAST include file */
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
UNITTEST_START
const char *values[] = {
/* -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",
"foo:bar\\\\:baz", "foo", "bar\\\\:baz",
"foo\\bar\\baz", "foo\\bar\\baz", NULL,
"foo\\\\bar\\\\baz", "foo\\bar\\baz", NULL,
"foo\\", "foo\\", NULL,
"foo\\\\", "foo\\", NULL,
"foo:bar\\", "foo", "bar\\",
"foo:bar\\\\", "foo", "bar\\\\",
"foo:bar:", "foo", "bar:",
"foo\\::bar\\:", "foo:", "bar\\:",
"pkcs11:foobar", "pkcs11:foobar", NULL,
"PKCS11:foobar", "PKCS11:foobar", NULL,
"PkCs11:foobar", "PkCs11:foobar", NULL,
#ifdef WIN32
"c:\\foo:bar:baz", "c:\\foo", "bar:baz",
"c:\\foo\\:bar:baz", "c:\\foo:bar", "baz",
"c:\\foo\\\\:bar:baz", "c:\\foo\\", "bar:baz",
"c:\\foo:bar\\:baz", "c:\\foo", "bar\\:baz",
"c:\\foo:bar\\\\:baz", "c:\\foo", "bar\\\\:baz",
"c:\\foo\\bar\\baz", "c:\\foo\\bar\\baz", NULL,
"c:\\foo\\\\bar\\\\baz", "c:\\foo\\bar\\baz", NULL,
"c:\\foo\\", "c:\\foo\\", NULL,
"c:\\foo\\\\", "c:\\foo\\", NULL,
"c:\\foo:bar\\", "c:\\foo", "bar\\",
"c:\\foo:bar\\\\", "c:\\foo", "bar\\\\",
"c:\\foo:bar:", "c:\\foo", "bar:",
"c:\\foo\\::bar\\:", "c:\\foo:", "bar\\:",
#endif
NULL, NULL, NULL,
};
const char **p;
char *certname, *passphrase;
for(p = values; *p; p += 3) {
parse_cert_parameter(p[0], &certname, &passphrase);
if(p[1]) {
if(certname) {
if(strcmp(p[1], certname)) {
printf("expected certname '%s' but got '%s' "
"for -E param '%s'\n", p[1], certname, p[0]);
fail("assertion failure");
}
}
else {
printf("expected certname '%s' but got NULL "
"for -E param '%s'\n", p[1], p[0]);
fail("assertion failure");
}
}
else {
if(certname) {
printf("expected certname NULL but got '%s' "
"for -E param '%s'\n", certname, p[0]);
fail("assertion failure");
}
}
if(p[2]) {
if(passphrase) {
if(strcmp(p[2], passphrase)) {
printf("expected passphrase '%s' but got '%s'"
"for -E param '%s'\n", p[2], passphrase, p[0]);
fail("assertion failure");
}
}
else {
printf("expected passphrase '%s' but got NULL "
"for -E param '%s'\n", p[2], p[0]);
fail("assertion failure");
}
}
else {
if(passphrase) {
printf("expected passphrase NULL but got '%s' "
"for -E param '%s'\n", passphrase, p[0]);
fail("assertion failure");
}
}
if(certname)
free(certname);
if(passphrase)
free(passphrase);
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1604.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "tool_cfgable.h"
#include "tool_doswin.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "memdebug.h" /* LAST include file */
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
#if defined(MSDOS) || defined(WIN32)
static char *getflagstr(int flags)
{
char *buf = malloc(256);
if(buf) {
msnprintf(buf, 256, "%s,%s,%s,%s",
((flags & SANITIZE_ALLOW_COLONS) ?
"SANITIZE_ALLOW_COLONS" : ""),
((flags & SANITIZE_ALLOW_PATH) ?
"SANITIZE_ALLOW_PATH" : ""),
((flags & SANITIZE_ALLOW_RESERVED) ?
"SANITIZE_ALLOW_RESERVED" : ""),
((flags & SANITIZE_ALLOW_TRUNCATE) ?
"SANITIZE_ALLOW_TRUNCATE" : ""));
}
return buf;
}
static char *getcurlcodestr(int cc)
{
char *buf = malloc(256);
if(buf) {
msnprintf(buf, 256, "%s (%d)",
(cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" :
cc == SANITIZE_ERR_OUT_OF_MEMORY ? "SANITIZE_ERR_OUT_OF_MEMORY":
"unexpected error code - add name"),
cc);
}
return buf;
}
struct data {
const char *input;
int flags;
const char *expected_output;
SANITIZEcode expected_result;
};
UNITTEST_START
{ /* START sanitize_file_name */
struct data data[] = {
{ "", 0,
"", SANITIZE_ERR_OK
},
{ "normal filename", 0,
"normal filename", SANITIZE_ERR_OK
},
{ "control\tchar", 0,
"control_char", SANITIZE_ERR_OK
},
{ "banned*char", 0,
"banned_char", SANITIZE_ERR_OK
},
{ "f:foo", 0,
"f_foo", SANITIZE_ERR_OK
},
{ "f:foo", SANITIZE_ALLOW_COLONS,
"f:foo", SANITIZE_ERR_OK
},
{ "f:foo", SANITIZE_ALLOW_PATH,
"f:foo", SANITIZE_ERR_OK
},
{ "f:\\foo", 0,
"f__foo", SANITIZE_ERR_OK
},
{ "f:\\foo", SANITIZE_ALLOW_PATH,
"f:\\foo", SANITIZE_ERR_OK
},
{ "f:/foo", 0,
"f__foo", SANITIZE_ERR_OK
},
{ "f:/foo", SANITIZE_ALLOW_PATH,
"f:/foo", SANITIZE_ERR_OK
},
#ifndef MSDOS
{ "\\\\?\\C:\\foo", SANITIZE_ALLOW_PATH,
"\\\\?\\C:\\foo", SANITIZE_ERR_OK
},
{ "\\\\?\\C:\\foo", 0,
"____C__foo", SANITIZE_ERR_OK
},
#endif
{ "foo:bar", 0,
"foo_bar", SANITIZE_ERR_OK
},
{ "foo|<>/bar\\\":?*baz", 0,
"foo____bar_____baz", SANITIZE_ERR_OK
},
{ "f:foo::$DATA", 0,
"f_foo__$DATA", SANITIZE_ERR_OK
},
{ "con . air", 0,
"con _ air", SANITIZE_ERR_OK
},
{ "con.air", 0,
"con_air", SANITIZE_ERR_OK
},
{ "con:/x", 0,
"con__x", SANITIZE_ERR_OK
},
{ "file . . . . .. .", 0,
"file", SANITIZE_ERR_OK
},
{ "foo . . ? . . ", 0,
"foo . . _", SANITIZE_ERR_OK
},
{ "com1", 0,
"_com1", SANITIZE_ERR_OK
},
{ "com1", SANITIZE_ALLOW_RESERVED,
"com1", SANITIZE_ERR_OK
},
{ "f:\\com1", 0,
"f__com1", SANITIZE_ERR_OK
},
{ "f:\\com1", SANITIZE_ALLOW_PATH,
"f:\\_com1", SANITIZE_ERR_OK
},
{ "f:\\com1", SANITIZE_ALLOW_RESERVED,
"f__com1", SANITIZE_ERR_OK
},
{ "f:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_COLONS,
"f:_com1", SANITIZE_ERR_OK
},
{ "f:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_PATH,
"f:\\com1", SANITIZE_ERR_OK
},
{ "com1:\\com1", SANITIZE_ALLOW_PATH,
"_com1:\\_com1", SANITIZE_ERR_OK
},
{ "com1:\\com1", SANITIZE_ALLOW_RESERVED | SANITIZE_ALLOW_PATH,
"com1:\\com1", SANITIZE_ERR_OK
},
{ "com1:\\com1", SANITIZE_ALLOW_RESERVED,
"com1__com1", SANITIZE_ERR_OK
},
#ifndef MSDOS
{ "\\com1", SANITIZE_ALLOW_PATH,
"\\_com1", SANITIZE_ERR_OK
},
{ "\\\\com1", SANITIZE_ALLOW_PATH,
"\\\\com1", SANITIZE_ERR_OK
},
{ "\\\\?\\C:\\com1", SANITIZE_ALLOW_PATH,
"\\\\?\\C:\\com1", SANITIZE_ERR_OK
},
#endif
{ "CoM1", 0,
"_CoM1", SANITIZE_ERR_OK
},
{ "CoM1", SANITIZE_ALLOW_RESERVED,
"CoM1", SANITIZE_ERR_OK
},
{ "COM56", 0,
"COM56", SANITIZE_ERR_OK
},
/* At the moment we expect a maximum path length of 259. I assume MSDOS
has variable max path lengths depending on compiler that are shorter
so currently these "good" truncate tests won't run on MSDOS */
#ifndef MSDOS
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
SANITIZE_ALLOW_TRUNCATE,
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFFFF", SANITIZE_ERR_OK
},
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFF\\FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFF\\FFFFF", SANITIZE_ERR_OK
},
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFF\\FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
SANITIZE_ALLOW_TRUNCATE,
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFF_F", SANITIZE_ERR_OK
},
#endif /* !MSDOS */
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
0,
NULL, SANITIZE_ERR_INVALID_PATH
},
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFFF\\FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
SANITIZE_ALLOW_TRUNCATE,
NULL, SANITIZE_ERR_INVALID_PATH
},
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFFFFFFFFFFFFFFFFFFFFFFFF\\FFFFFFFFFFFFFFFFFFFFFFFF",
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
NULL, SANITIZE_ERR_INVALID_PATH
},
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FFF\\FFFFFFFFFFFFFFFFFFFFF:FFFFFFFFFFFFFFFFFFFFFFFF",
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
NULL, SANITIZE_ERR_INVALID_PATH
},
{ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
"FF\\F:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
SANITIZE_ALLOW_TRUNCATE | SANITIZE_ALLOW_PATH,
NULL, SANITIZE_ERR_INVALID_PATH
},
{ NULL, 0,
NULL, SANITIZE_ERR_BAD_ARGUMENT
},
};
size_t i;
for(i = 0; i < sizeof(data) / sizeof(data[0]); ++i) {
char *output = NULL;
char *flagstr = NULL;
char *received_ccstr = NULL;
char *expected_ccstr = NULL;
SANITIZEcode res;
res = sanitize_file_name(&output, data[i].input, data[i].flags);
if(res == data[i].expected_result &&
((!output && !data[i].expected_output) ||
(output && data[i].expected_output &&
!strcmp(output, data[i].expected_output)))) { /* OK */
free(output);
continue;
}
flagstr = getflagstr(data[i].flags);
abort_unless(flagstr, "out of memory");
received_ccstr = getcurlcodestr(res);
abort_unless(received_ccstr, "out of memory");
expected_ccstr = getcurlcodestr(data[i].expected_result);
abort_unless(expected_ccstr, "out of memory");
unitfail++;
fprintf(stderr, "\n"
"%s:%d sanitize_file_name failed.\n"
"input: %s\n"
"flags: %s\n"
"output: %s\n"
"result: %s\n"
"expected output: %s\n"
"expected result: %s\n",
__FILE__, __LINE__,
data[i].input,
flagstr,
(output ? output : "(null)"),
received_ccstr,
(data[i].expected_output ? data[i].expected_output : "(null)"),
expected_ccstr);
free(output);
free(flagstr);
free(received_ccstr);
free(expected_ccstr);
}
} /* END sanitize_file_name */
#else
UNITTEST_START
{
fprintf(stderr, "Skipped test not for this platform\n");
}
#endif /* MSDOS || WIN32 */
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1303.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "connect.h"
#include "memdebug.h" /* LAST include file */
static struct Curl_easy *data;
static CURLcode unit_setup(void)
{
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
data = curl_easy_init();
if(!data) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
return res;
}
static void unit_stop(void)
{
curl_easy_cleanup(data);
curl_global_cleanup();
}
/* BASE is just a define to make us fool around with decently large number so
that we aren't zero-based */
#define BASE 1000000
/* macro to set the pretended current time */
#define NOW(x,y) now.tv_sec = x; now.tv_usec = y
/* macro to set the millisecond based timeouts to use */
#define TIMEOUTS(x,y) data->set.timeout = x; data->set.connecttimeout = y
/*
* To test:
*
* 00/10/01/11 timeouts set
* 0/1 during connect
* T various values on the timeouts
* N various values of now
*/
struct timetest {
int now_s;
int now_us;
int timeout_ms;
int connecttimeout_ms;
bool connecting;
timediff_t result;
const char *comment;
};
UNITTEST_START
{
struct curltime now;
unsigned int i;
const struct timetest run[] = {
/* both timeouts set, not connecting */
{BASE + 4, 0, 10000, 8000, FALSE, 6000, "6 seconds should be left"},
{BASE + 4, 990000, 10000, 8000, FALSE, 5010, "5010 ms should be left"},
{BASE + 10, 0, 10000, 8000, FALSE, -1, "timeout is -1, expired"},
{BASE + 12, 0, 10000, 8000, FALSE, -2000, "-2000, overdue 2 seconds"},
/* both timeouts set, connecting */
{BASE + 4, 0, 10000, 8000, TRUE, 4000, "4 seconds should be left"},
{BASE + 4, 990000, 10000, 8000, TRUE, 3010, "3010 ms should be left"},
{BASE + 8, 0, 10000, 8000, TRUE, -1, "timeout is -1, expired"},
{BASE + 10, 0, 10000, 8000, TRUE, -2000, "-2000, overdue 2 seconds"},
/* no connect timeout set, not connecting */
{BASE + 4, 0, 10000, 0, FALSE, 6000, "6 seconds should be left"},
{BASE + 4, 990000, 10000, 0, FALSE, 5010, "5010 ms should be left"},
{BASE + 10, 0, 10000, 0, FALSE, -1, "timeout is -1, expired"},
{BASE + 12, 0, 10000, 0, FALSE, -2000, "-2000, overdue 2 seconds"},
/* no connect timeout set, connecting */
{BASE + 4, 0, 10000, 0, FALSE, 6000, "6 seconds should be left"},
{BASE + 4, 990000, 10000, 0, FALSE, 5010, "5010 ms should be left"},
{BASE + 10, 0, 10000, 0, FALSE, -1, "timeout is -1, expired"},
{BASE + 12, 0, 10000, 0, FALSE, -2000, "-2000, overdue 2 seconds"},
/* only connect timeout set, not connecting */
{BASE + 4, 0, 0, 10000, FALSE, 0, "no timeout active"},
{BASE + 4, 990000, 0, 10000, FALSE, 0, "no timeout active"},
{BASE + 10, 0, 0, 10000, FALSE, 0, "no timeout active"},
{BASE + 12, 0, 0, 10000, FALSE, 0, "no timeout active"},
/* only connect timeout set, connecting */
{BASE + 4, 0, 0, 10000, TRUE, 6000, "6 seconds should be left"},
{BASE + 4, 990000, 0, 10000, TRUE, 5010, "5010 ms should be left"},
{BASE + 10, 0, 0, 10000, TRUE, -1, "timeout is -1, expired"},
{BASE + 12, 0, 0, 10000, TRUE, -2000, "-2000, overdue 2 seconds"},
/* no timeout set, not connecting */
{BASE + 4, 0, 0, 0, FALSE, 0, "no timeout active"},
{BASE + 4, 990000, 0, 0, FALSE, 0, "no timeout active"},
{BASE + 10, 0, 0, 0, FALSE, 0, "no timeout active"},
{BASE + 12, 0, 0, 0, FALSE, 0, "no timeout active"},
/* no timeout set, connecting */
{BASE + 4, 0, 0, 0, TRUE, 296000, "no timeout active"},
{BASE + 4, 990000, 0, 0, TRUE, 295010, "no timeout active"},
{BASE + 10, 0, 0, 0, TRUE, 290000, "no timeout active"},
{BASE + 12, 0, 0, 0, TRUE, 288000, "no timeout active"},
/* both timeouts set, connecting, connect timeout the longer one */
{BASE + 4, 0, 10000, 12000, TRUE, 6000, "6 seconds should be left"},
};
/* this is the pretended start time of the transfer */
data->progress.t_startsingle.tv_sec = BASE;
data->progress.t_startsingle.tv_usec = 0;
data->progress.t_startop.tv_sec = BASE;
data->progress.t_startop.tv_usec = 0;
for(i = 0; i < sizeof(run)/sizeof(run[0]); i++) {
timediff_t timeout;
NOW(run[i].now_s, run[i].now_us);
TIMEOUTS(run[i].timeout_ms, run[i].connecttimeout_ms);
timeout = Curl_timeleft(data, &now, run[i].connecting);
if(timeout != run[i].result)
fail(run[i].comment);
}
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/Makefile.inc | #***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
###########################################################################
# these files are used in every single unit test program
UNITFILES = curlcheck.h \
../libtest/test.h \
../libtest/first.c
# These are all unit test programs
UNITPROGS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 \
unit1308 unit1309 unit1323 \
unit1330 unit1394 unit1395 unit1396 unit1397 unit1398 \
unit1399 \
unit1600 unit1601 unit1602 unit1603 unit1604 unit1605 unit1606 unit1607 \
unit1608 unit1609 unit1610 unit1611 unit1612 \
unit1620 unit1621 \
unit1650 unit1651 unit1652 unit1653 unit1654 unit1655 \
unit1660 unit1661
unit1300_SOURCES = unit1300.c $(UNITFILES)
unit1300_CPPFLAGS = $(AM_CPPFLAGS)
unit1301_SOURCES = unit1301.c $(UNITFILES)
unit1301_CPPFLAGS = $(AM_CPPFLAGS)
unit1302_SOURCES = unit1302.c $(UNITFILES)
unit1302_CPPFLAGS = $(AM_CPPFLAGS)
unit1303_SOURCES = unit1303.c $(UNITFILES)
unit1303_CPPFLAGS = $(AM_CPPFLAGS)
unit1304_SOURCES = unit1304.c $(UNITFILES)
unit1304_CPPFLAGS = $(AM_CPPFLAGS)
unit1305_SOURCES = unit1305.c $(UNITFILES)
unit1305_CPPFLAGS = $(AM_CPPFLAGS)
unit1307_SOURCES = unit1307.c $(UNITFILES)
unit1307_CPPFLAGS = $(AM_CPPFLAGS)
unit1308_SOURCES = unit1308.c $(UNITFILES)
unit1308_CPPFLAGS = $(AM_CPPFLAGS)
unit1309_SOURCES = unit1309.c $(UNITFILES)
unit1309_CPPFLAGS = $(AM_CPPFLAGS)
unit1323_SOURCES = unit1323.c $(UNITFILES)
unit1323_CPPFLAGS = $(AM_CPPFLAGS)
unit1330_SOURCES = unit1330.c $(UNITFILES)
unit1330_CPPFLAGS = $(AM_CPPFLAGS)
unit1394_SOURCES = unit1394.c $(UNITFILES)
unit1394_CPPFLAGS = $(AM_CPPFLAGS)
unit1394_LDADD = $(top_builddir)/lib/libcurl.la @LIBCURL_LIBS@
unit1394_LDFLAGS = $(top_builddir)/src/libcurltool.la
unit1394_LIBS =
unit1395_SOURCES = unit1395.c $(UNITFILES)
unit1395_CPPFLAGS = $(AM_CPPFLAGS)
unit1396_SOURCES = unit1396.c $(UNITFILES)
unit1396_CPPFLAGS = $(AM_CPPFLAGS)
unit1397_SOURCES = unit1397.c $(UNITFILES)
unit1397_CPPFLAGS = $(AM_CPPFLAGS)
unit1398_SOURCES = unit1398.c $(UNITFILES)
unit1398_CPPFLAGS = $(AM_CPPFLAGS)
unit1399_SOURCES = unit1399.c $(UNITFILES)
unit1399_CPPFLAGS = $(AM_CPPFLAGS)
unit1600_SOURCES = unit1600.c $(UNITFILES)
unit1600_CPPFLAGS = $(AM_CPPFLAGS)
unit1601_SOURCES = unit1601.c $(UNITFILES)
unit1601_CPPFLAGS = $(AM_CPPFLAGS)
unit1602_SOURCES = unit1602.c $(UNITFILES)
unit1602_CPPFLAGS = $(AM_CPPFLAGS)
unit1603_SOURCES = unit1603.c $(UNITFILES)
unit1603_CPPFLAGS = $(AM_CPPFLAGS)
unit1604_SOURCES = unit1604.c $(UNITFILES)
unit1604_CPPFLAGS = $(AM_CPPFLAGS)
unit1605_SOURCES = unit1605.c $(UNITFILES)
unit1605_CPPFLAGS = $(AM_CPPFLAGS)
unit1606_SOURCES = unit1606.c $(UNITFILES)
unit1606_CPPFLAGS = $(AM_CPPFLAGS)
unit1607_SOURCES = unit1607.c $(UNITFILES)
unit1607_CPPFLAGS = $(AM_CPPFLAGS)
unit1608_SOURCES = unit1608.c $(UNITFILES)
unit1608_CPPFLAGS = $(AM_CPPFLAGS)
unit1609_SOURCES = unit1609.c $(UNITFILES)
unit1609_CPPFLAGS = $(AM_CPPFLAGS)
unit1610_SOURCES = unit1610.c $(UNITFILES)
unit1610_CPPFLAGS = $(AM_CPPFLAGS)
unit1611_SOURCES = unit1611.c $(UNITFILES)
unit1611_CPPFLAGS = $(AM_CPPFLAGS)
unit1612_SOURCES = unit1612.c $(UNITFILES)
unit1612_CPPFLAGS = $(AM_CPPFLAGS)
unit1620_SOURCES = unit1620.c $(UNITFILES)
unit1620_CPPFLAGS = $(AM_CPPFLAGS)
unit1621_SOURCES = unit1621.c $(UNITFILES)
unit1621_CPPFLAGS = $(AM_CPPFLAGS)
unit1621_LDADD = $(top_builddir)/src/libcurltool.la $(top_builddir)/lib/libcurl.la
unit1650_SOURCES = unit1650.c $(UNITFILES)
unit1650_CPPFLAGS = $(AM_CPPFLAGS)
unit1651_SOURCES = unit1651.c $(UNITFILES)
unit1651_CPPFLAGS = $(AM_CPPFLAGS)
unit1652_SOURCES = unit1652.c $(UNITFILES)
unit1652_CPPFLAGS = $(AM_CPPFLAGS)
unit1653_SOURCES = unit1653.c $(UNITFILES)
unit1653_CPPFLAGS = $(AM_CPPFLAGS)
unit1654_SOURCES = unit1654.c $(UNITFILES)
unit1654_CPPFLAGS = $(AM_CPPFLAGS)
unit1655_SOURCES = unit1655.c $(UNITFILES)
unit1655_CPPFLAGS = $(AM_CPPFLAGS)
unit1660_SOURCES = unit1660.c $(UNITFILES)
unit1660_CPPFLAGS = $(AM_CPPFLAGS)
unit1661_SOURCES = unit1661.c $(UNITFILES)
unit1661_CPPFLAGS = $(AM_CPPFLAGS)
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1600.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "curl_ntlm_core.h"
static CURL *easy;
static CURLcode unit_setup(void)
{
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy = curl_easy_init();
if(!easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
return res;
}
static void unit_stop(void)
{
curl_easy_cleanup(easy);
curl_global_cleanup();
}
UNITTEST_START
#if defined(USE_NTLM) && (!defined(USE_WINDOWS_SSPI) || \
defined(USE_WIN32_CRYPTO))
unsigned char output[21];
unsigned char *testp = output;
Curl_ntlm_core_mk_nt_hash(easy, "1", output);
verify_memory(testp,
"\x69\x94\x3c\x5e\x63\xb4\xd2\xc1\x04\xdb"
"\xbc\xc1\x51\x38\xb7\x2b\x00\x00\x00\x00\x00", 21);
Curl_ntlm_core_mk_nt_hash(easy, "hello-you-fool", output);
verify_memory(testp,
"\x39\xaf\x87\xa6\x75\x0a\x7a\x00\xba\xa0"
"\xd3\x4f\x04\x9e\xc1\xd0\x00\x00\x00\x00\x00", 21);
/* !checksrc! disable LONGLINE 2 */
Curl_ntlm_core_mk_nt_hash(easy, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", output);
verify_memory(testp,
"\x36\x9d\xae\x06\x84\x7e\xe1\xc1\x4a\x94\x39\xea\x6f\x44\x8c\x65\x00\x00\x00\x00\x00", 21);
#endif
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1601.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "curl_md5.h"
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
UNITTEST_START
#ifndef CURL_DISABLE_CRYPTO_AUTH
const char string1[] = "1";
const char string2[] = "hello-you-fool";
unsigned char output[MD5_DIGEST_LEN];
unsigned char *testp = output;
Curl_md5it(output, (const unsigned char *) string1, strlen(string1));
verify_memory(testp, "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f"
"\x75\x84\x9b", MD5_DIGEST_LEN);
Curl_md5it(output, (const unsigned char *) string2, strlen(string2));
verify_memory(testp, "\x88\x67\x0b\x6d\x5d\x74\x2f\xad\xa5\xcd\xf9\xb6\x82"
"\x87\x5f\x22", MD5_DIGEST_LEN);
#endif
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1396.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
static CURL *hnd;
static CURLcode unit_setup(void)
{
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
return res;
}
static void unit_stop(void)
{
if(hnd)
curl_easy_cleanup(hnd);
curl_global_cleanup();
}
struct test {
const char *in;
int inlen;
const char *out;
int outlen;
};
UNITTEST_START
{
/* unescape, this => that */
const struct test list1[]={
{"%61", 3, "a", 1},
{"%61a", 4, "aa", 2},
{"%61b", 4, "ab", 2},
{"%6 1", 4, "%6 1", 4},
{"%61", 1, "%", 1},
{"%61", 2, "%6", 2},
{"%6%a", 4, "%6%a", 4},
{"%6a", 0, "j", 1},
{"%FF", 0, "\xff", 1},
{"%FF%00%ff", 9, "\xff\x00\xff", 3},
{"%-2", 0, "%-2", 3},
{"%FG", 0, "%FG", 3},
{NULL, 0, NULL, 0} /* end of list marker */
};
/* escape, this => that */
const struct test list2[]={
{"a", 1, "a", 1},
{"/", 1, "%2F", 3},
{"a=b", 3, "a%3Db", 5},
{"a=b", 0, "a%3Db", 5},
{"a=b", 1, "a", 1},
{"a=b", 2, "a%3D", 4},
{"1/./0", 5, "1%2F.%2F0", 9},
{"-._~!#%&", 0, "-._~%21%23%25%26", 16},
{"a", 2, "a%00", 4},
{"a\xff\x01g", 4, "a%FF%01g", 8},
{NULL, 0, NULL, 0} /* end of list marker */
};
int i;
hnd = curl_easy_init();
abort_unless(hnd != NULL, "returned NULL!");
for(i = 0; list1[i].in; i++) {
int outlen;
char *out = curl_easy_unescape(hnd,
list1[i].in, list1[i].inlen,
&outlen);
abort_unless(out != NULL, "returned NULL!");
fail_unless(outlen == list1[i].outlen, "wrong output length returned");
fail_unless(!memcmp(out, list1[i].out, list1[i].outlen),
"bad output data returned");
printf("curl_easy_unescape test %d DONE\n", i);
curl_free(out);
}
for(i = 0; list2[i].in; i++) {
int outlen;
char *out = curl_easy_escape(hnd, list2[i].in, list2[i].inlen);
abort_unless(out != NULL, "returned NULL!");
outlen = (int)strlen(out);
fail_unless(outlen == list2[i].outlen, "wrong output length returned");
fail_unless(!memcmp(out, list2[i].out, list2[i].outlen),
"bad output data returned");
printf("curl_easy_escape test %d DONE (%s)\n", i, out);
curl_free(out);
}
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/README.md | # Unit tests
The goal is to add tests for *all* functions in libcurl. If functions are too
big and complicated, we should split them into smaller and testable ones.
## Build Unit Tests
`./configure --enable-debug` is required for the unit tests to build. To
enable unit tests, there will be a separate static libcurl built that will be
used exclusively for linking unit test programs. Just build everything as
normal, and then you can run the unit test cases as well.
## Run Unit Tests
Unit tests are run as part of the regular test suite. If you have built
everything to run unit tests, to can do 'make test' at the root level. Or you
can `cd tests` and `make` and then invoke individual unit tests with
`./runtests.pl NNNN` where `NNNN` is the specific test number.
## Debug Unit Tests
If a specific test fails you will get told. The test case then has output left
in the log/ subdirectory, but most importantly you can re-run the test again
using gdb by doing `./runtests.pl -g NNNN`. That is, add a `-g` to make it
start up gdb and run the same case using that.
## Write Unit Tests
We put tests that focus on an area or a specific function into a single C
source file. The source file should be named 'unitNNNN.c' where NNNN is a
previously unused number.
Add your test to `tests/unit/Makefile.inc` (if it is a unit test). Add your
test data file name to `tests/data/Makefile.inc`
You also need a separate file called `tests/data/testNNNN` (using the same
number) that describes your test case. See the test1300 file for inspiration
and the `tests/FILEFORMAT.md` documentation.
For the actual C file, here's a very simple example:
~~~c
#include "curlcheck.h"
#include "a libcurl header.h" /* from the lib dir */
static CURLcode unit_setup( void )
{
/* whatever you want done first */
return CURLE_OK;
}
static void unit_stop( void )
{
/* done before shutting down and exiting */
}
UNITTEST_START
/* here you start doing things and checking that the results are good */
fail_unless( size == 0 , "initial size should be zero" );
fail_if( head == NULL , "head should not be initiated to NULL" );
/* you end the test code like this: */
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1653.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "urldata.h"
#include "curl/urlapi.h"
#include "urlapi-int.h"
static CURLU *u;
static CURLcode
unit_setup(void)
{
return CURLE_OK;
}
static void
unit_stop(void)
{
curl_global_cleanup();
}
#define free_and_clear(x) free(x); x = NULL
UNITTEST_START
{
CURLUcode ret;
char *ipv6port = NULL;
char *portnum;
/* Valid IPv6 */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15]");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "Curl_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");
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* Invalid IPv6 */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15|");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret != CURLUE_OK, "Curl_parse_port true on error");
free_and_clear(ipv6port);
curl_url_cleanup(u);
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff;fea7:da15]:80");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret != CURLUE_OK, "Curl_parse_port true on error");
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* Valid IPv6 with zone index and port number */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]:80");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
ret = curl_url_get(u, CURLUPART_PORT, &portnum, 0);
fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error");
fail_unless(portnum && !strcmp(portnum, "80"), "Check portnumber");
curl_free(portnum);
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* Valid IPv6 with zone index without port number */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* Valid IPv6 with port number */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15]:81");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
ret = curl_url_get(u, CURLUPART_PORT, &portnum, 0);
fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error");
fail_unless(portnum && !strcmp(portnum, "81"), "Check portnumber");
curl_free(portnum);
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* Valid IPv6 with syntax error in the port number */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15];81");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret != CURLUE_OK, "Curl_parse_port true on error");
free_and_clear(ipv6port);
curl_url_cleanup(u);
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15]80");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret != CURLUE_OK, "Curl_parse_port true on error");
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* Valid IPv6 with no port after the colon, should use default if a scheme
was used in the URL */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15]:");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, TRUE);
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* Incorrect zone index syntax */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15!25eth3]:80");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret != CURLUE_OK, "Curl_parse_port returned non-error");
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* Non percent-encoded zone index */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("[fe80::250:56ff:fea7:da15%eth3]:80");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_OK, "Curl_parse_port returned error");
free_and_clear(ipv6port);
curl_url_cleanup(u);
/* No scheme and no digits following the colon - not accepted. Because that
makes (a*50):// that looks like a scheme be an acceptable input. */
u = curl_url();
if(!u)
goto fail;
ipv6port = strdup("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaa:");
if(!ipv6port)
goto fail;
ret = Curl_parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_BAD_PORT_NUMBER, "Curl_parse_port did wrong");
fail:
free(ipv6port);
curl_url_cleanup(u);
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1602.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#define ENABLE_CURLX_PRINTF
#include "curlx.h"
#include "hash.h"
#include "memdebug.h" /* LAST include file */
static struct Curl_hash hash_static;
static void mydtor(void *p)
{
int *ptr = (int *)p;
free(ptr);
}
static CURLcode unit_setup(void)
{
return Curl_hash_init(&hash_static, 7, Curl_hash_str,
Curl_str_key_compare, mydtor);
}
static void unit_stop(void)
{
Curl_hash_destroy(&hash_static);
}
UNITTEST_START
int *value;
int *value2;
int *nodep;
size_t klen = sizeof(int);
int key = 20;
int key2 = 25;
value = malloc(sizeof(int));
abort_unless(value != NULL, "Out of memory");
*value = 199;
nodep = Curl_hash_add(&hash_static, &key, klen, value);
if(!nodep)
free(value);
abort_unless(nodep, "insertion into hash failed");
Curl_hash_clean(&hash_static);
/* Attempt to add another key/value pair */
value2 = malloc(sizeof(int));
abort_unless(value2 != NULL, "Out of memory");
*value2 = 204;
nodep = Curl_hash_add(&hash_static, &key2, klen, value2);
if(!nodep)
free(value2);
abort_unless(nodep, "insertion into hash failed");
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1330.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "memdebug.h"
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
UNITTEST_START
char *ptr = malloc(1330);
Curl_safefree(ptr);
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1305.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#define ENABLE_CURLX_PRINTF
#include "curlx.h"
#include "hash.h"
#include "hostip.h"
#include "memdebug.h" /* LAST include file */
static struct Curl_easy *data;
static struct Curl_hash hp;
static char *data_key;
static struct Curl_dns_entry *data_node;
static CURLcode unit_setup(void)
{
int rc;
data = curl_easy_init();
if(!data) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
rc = Curl_mk_dnscache(&hp);
if(rc) {
curl_easy_cleanup(data);
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
return CURLE_OK;
}
static void unit_stop(void)
{
if(data_node) {
Curl_freeaddrinfo(data_node->addr);
free(data_node);
}
free(data_key);
Curl_hash_destroy(&hp);
curl_easy_cleanup(data);
curl_global_cleanup();
}
static struct Curl_addrinfo *fake_ai(void)
{
static struct Curl_addrinfo *ai;
static const char dummy[]="dummy";
size_t namelen = sizeof(dummy); /* including the zero terminator */
ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_in) +
namelen);
if(!ai)
return NULL;
ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
ai->ai_canonname = (void *)((char *)ai->ai_addr +
sizeof(struct sockaddr_in));
memcpy(ai->ai_canonname, dummy, namelen);
ai->ai_family = AF_INET;
ai->ai_addrlen = sizeof(struct sockaddr_in);
return ai;
}
static CURLcode create_node(void)
{
data_key = aprintf("%s:%d", "dummy", 0);
if(!data_key)
return CURLE_OUT_OF_MEMORY;
data_node = calloc(1, sizeof(struct Curl_dns_entry));
if(!data_node)
return CURLE_OUT_OF_MEMORY;
data_node->addr = fake_ai();
if(!data_node->addr)
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
}
UNITTEST_START
struct Curl_dns_entry *nodep;
size_t key_len;
/* Test 1305 exits without adding anything to the hash */
if(strcmp(arg, "1305") != 0) {
CURLcode rc = create_node();
abort_unless(rc == CURLE_OK, "data node creation failed");
key_len = strlen(data_key);
data_node->inuse = 1; /* hash will hold the reference */
nodep = Curl_hash_add(&hp, data_key, key_len + 1, data_node);
abort_unless(nodep, "insertion into hash failed");
/* Freeing will now be done by Curl_hash_destroy */
data_node = NULL;
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1651.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2018 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "x509asn1.h"
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
#if defined(USE_GSKIT) || defined(USE_NSS) || defined(USE_GNUTLS) || \
defined(USE_WOLFSSL) || defined(USE_SCHANNEL)
/* cert captured from gdb when connecting to curl.se on October 26
2018 */
static unsigned char cert[] = {
0x30, 0x82, 0x0F, 0x5B, 0x30, 0x82, 0x0E, 0x43, 0xA0, 0x03, 0x02, 0x01, 0x02,
0x02, 0x0C, 0x08, 0x77, 0x99, 0x2C, 0x6B, 0x67, 0xE1, 0x18, 0xD6, 0x66, 0x66,
0x9E, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01,
0x0B, 0x05, 0x00, 0x30, 0x57, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
0x06, 0x13, 0x02, 0x42, 0x45, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04,
0x0A, 0x13, 0x10, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x53, 0x69, 0x67, 0x6E,
0x20, 0x6E, 0x76, 0x2D, 0x73, 0x61, 0x31, 0x2D, 0x30, 0x2B, 0x06, 0x03, 0x55,
0x04, 0x03, 0x13, 0x24, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x53, 0x69, 0x67,
0x6E, 0x20, 0x43, 0x6C, 0x6F, 0x75, 0x64, 0x53, 0x53, 0x4C, 0x20, 0x43, 0x41,
0x20, 0x2D, 0x20, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x20, 0x2D, 0x20, 0x47,
0x33, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x38, 0x31, 0x30, 0x32, 0x32, 0x31, 0x37,
0x31, 0x38, 0x32, 0x31, 0x5A, 0x17, 0x0D, 0x31, 0x39, 0x30, 0x33, 0x32, 0x31,
0x31, 0x33, 0x34, 0x33, 0x34, 0x34, 0x5A, 0x30, 0x77, 0x31, 0x0B, 0x30, 0x09,
0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11,
0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x0A, 0x43, 0x61, 0x6C, 0x69, 0x66, 0x6F,
0x72, 0x6E, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07,
0x0C, 0x0D, 0x53, 0x61, 0x6E, 0x20, 0x46, 0x72, 0x61, 0x6E, 0x63, 0x69, 0x73,
0x63, 0x6F, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0C,
0x46, 0x61, 0x73, 0x74, 0x6C, 0x79, 0x2C, 0x20, 0x49, 0x6E, 0x63, 0x2E, 0x31,
0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1B, 0x6A, 0x32, 0x2E,
0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C,
0x2E, 0x66, 0x61, 0x73, 0x74, 0x6C, 0x79, 0x2E, 0x6E, 0x65, 0x74, 0x30, 0x82,
0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A,
0x02, 0x82, 0x01, 0x01, 0x00, 0xC2, 0x72, 0xA2, 0x4A, 0xEF, 0x26, 0x42, 0xD7,
0x85, 0x74, 0xC9, 0xB4, 0x9F, 0xE3, 0x31, 0xD1, 0x40, 0x77, 0xC9, 0x4B, 0x4D,
0xFE, 0xC8, 0x75, 0xF3, 0x32, 0x76, 0xAD, 0xF9, 0x08, 0x22, 0x9E, 0xFA, 0x2F,
0xFE, 0xEC, 0x6C, 0xC4, 0xF5, 0x1F, 0x70, 0xC9, 0x8F, 0x07, 0x48, 0x31, 0xAD,
0x75, 0x18, 0xFC, 0x06, 0x5A, 0x4F, 0xDD, 0xFD, 0x05, 0x39, 0x6F, 0x22, 0xF9,
0xAD, 0x62, 0x1A, 0x9E, 0xA6, 0x16, 0x48, 0x75, 0x8F, 0xB8, 0x07, 0x18, 0x25,
0x1A, 0x87, 0x30, 0xB0, 0x3C, 0x6F, 0xE0, 0x9D, 0x90, 0x63, 0x2A, 0x16, 0x1F,
0x0D, 0x10, 0xFC, 0x06, 0x7E, 0xEA, 0x51, 0xE2, 0xB0, 0x6D, 0x42, 0x4C, 0x2C,
0x59, 0xF4, 0x6B, 0x99, 0x3E, 0x82, 0x1D, 0x08, 0x04, 0x2F, 0xA0, 0x63, 0x3C,
0xAA, 0x0E, 0xE1, 0x5D, 0x67, 0x2D, 0xB3, 0xF4, 0x15, 0xD6, 0x16, 0x4E, 0xAA,
0x91, 0x45, 0x6B, 0xC5, 0xA6, 0xED, 0x83, 0xAF, 0xF1, 0xD7, 0x42, 0x5E, 0x9B,
0xC8, 0x39, 0x0C, 0x06, 0x76, 0x7A, 0xB8, 0x3E, 0x16, 0x70, 0xF5, 0xEB, 0x8B,
0x33, 0x5A, 0xA9, 0x03, 0xED, 0x79, 0x0E, 0xAD, 0xBB, 0xC4, 0xF8, 0xDA, 0x93,
0x53, 0x2A, 0xC4, 0xC9, 0x1A, 0xD1, 0xC3, 0x44, 0xD7, 0xC6, 0xD0, 0xC6, 0xAC,
0x13, 0xE3, 0xB5, 0x73, 0x3A, 0xDF, 0x54, 0x15, 0xFB, 0xB4, 0x6B, 0x36, 0x39,
0x18, 0xB5, 0x61, 0x12, 0xF0, 0x37, 0xAB, 0x81, 0x5F, 0x0C, 0xE7, 0xDF, 0xC1,
0xC5, 0x5E, 0x99, 0x67, 0x85, 0xFF, 0xAD, 0xD6, 0x82, 0x09, 0x1F, 0x27, 0xE5,
0x32, 0x52, 0x18, 0xEC, 0x35, 0x2F, 0x6C, 0xC9, 0xE6, 0x87, 0xCE, 0x30, 0xF6,
0xDA, 0x04, 0x3F, 0xA5, 0x8A, 0x0C, 0xAE, 0x5B, 0xB0, 0xEC, 0x29, 0x9B, 0xEE,
0x8F, 0x52, 0x1E, 0xE2, 0x56, 0x19, 0x45, 0x80, 0x3C, 0x02, 0x57, 0x5C, 0x52,
0xD9, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x82, 0x0C, 0x05, 0x30, 0x82, 0x0C,
0x01, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04,
0x03, 0x02, 0x05, 0xA0, 0x30, 0x81, 0x8A, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05,
0x05, 0x07, 0x01, 0x01, 0x04, 0x7E, 0x30, 0x7C, 0x30, 0x42, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x36, 0x68, 0x74, 0x74, 0x70,
0x3A, 0x2F, 0x2F, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x2E, 0x67, 0x6C, 0x6F,
0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x63,
0x61, 0x63, 0x65, 0x72, 0x74, 0x2F, 0x63, 0x6C, 0x6F, 0x75, 0x64, 0x73, 0x73,
0x6C, 0x73, 0x68, 0x61, 0x32, 0x67, 0x33, 0x2E, 0x63, 0x72, 0x74, 0x30, 0x36,
0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x2A, 0x68,
0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x6F, 0x63, 0x73, 0x70, 0x32, 0x2E, 0x67,
0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E, 0x63, 0x6F, 0x6D,
0x2F, 0x63, 0x6C, 0x6F, 0x75, 0x64, 0x73, 0x73, 0x6C, 0x73, 0x68, 0x61, 0x32,
0x67, 0x33, 0x30, 0x56, 0x06, 0x03, 0x55, 0x1D, 0x20, 0x04, 0x4F, 0x30, 0x4D,
0x30, 0x41, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0xA0, 0x32, 0x01, 0x14,
0x30, 0x34, 0x30, 0x32, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02,
0x01, 0x16, 0x26, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3A, 0x2F, 0x2F, 0x77, 0x77,
0x77, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E,
0x63, 0x6F, 0x6D, 0x2F, 0x72, 0x65, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x6F, 0x72,
0x79, 0x2F, 0x30, 0x08, 0x06, 0x06, 0x67, 0x81, 0x0C, 0x01, 0x02, 0x02, 0x30,
0x09, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x82, 0x09,
0x96, 0x06, 0x03, 0x55, 0x1D, 0x11, 0x04, 0x82, 0x09, 0x8D, 0x30, 0x82, 0x09,
0x89, 0x82, 0x1B, 0x6A, 0x32, 0x2E, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2E,
0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x2E, 0x66, 0x61, 0x73, 0x74, 0x6C, 0x79,
0x2E, 0x6E, 0x65, 0x74, 0x82, 0x0D, 0x2A, 0x2E, 0x61, 0x32, 0x70, 0x72, 0x65,
0x73, 0x73, 0x65, 0x2E, 0x66, 0x72, 0x82, 0x19, 0x2A, 0x2E, 0x61, 0x64, 0x76,
0x65, 0x6E, 0x74, 0x69, 0x73, 0x74, 0x62, 0x6F, 0x6F, 0x6B, 0x63, 0x65, 0x6E,
0x74, 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x61, 0x70,
0x69, 0x2E, 0x6C, 0x6F, 0x6C, 0x65, 0x73, 0x70, 0x6F, 0x72, 0x74, 0x73, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x62, 0x61, 0x61, 0x74, 0x63, 0x68,
0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x17, 0x2A, 0x2E, 0x62, 0x69, 0x6F, 0x74, 0x65,
0x63, 0x68, 0x77, 0x65, 0x65, 0x6B, 0x62, 0x6F, 0x73, 0x74, 0x6F, 0x6E, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x62, 0x6F, 0x78, 0x6F, 0x66, 0x73,
0x74, 0x79, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x63,
0x61, 0x73, 0x70, 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x2A, 0x2E,
0x63, 0x68, 0x61, 0x6B, 0x72, 0x61, 0x6C, 0x69, 0x6E, 0x75, 0x78, 0x2E, 0x6F,
0x72, 0x67, 0x82, 0x18, 0x2A, 0x2E, 0x63, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x74,
0x2E, 0x64, 0x73, 0x2E, 0x76, 0x65, 0x72, 0x69, 0x7A, 0x6F, 0x6E, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x15, 0x2A, 0x2E, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63,
0x65, 0x73, 0x68, 0x69, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82,
0x1B, 0x2A, 0x2E, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x68,
0x69, 0x70, 0x69, 0x6E, 0x76, 0x65, 0x73, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x2E,
0x61, 0x75, 0x82, 0x0A, 0x2A, 0x2E, 0x65, 0x63, 0x68, 0x6C, 0x2E, 0x63, 0x6F,
0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x66, 0x69, 0x6C, 0x65, 0x73, 0x74, 0x61, 0x63,
0x6B, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, 0x2E, 0x66, 0x69, 0x6C, 0x65,
0x73, 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x6F, 0x6E, 0x65, 0x6D, 0x6F, 0x62, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x2A, 0x2E, 0x66, 0x69, 0x73, 0x2D, 0x73, 0x6B,
0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x66, 0x69, 0x73, 0x73,
0x6B, 0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x66, 0x70, 0x2E,
0x62, 0x72, 0x61, 0x6E, 0x64, 0x66, 0x6F, 0x6C, 0x64, 0x65, 0x72, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x65, 0x6E, 0x70, 0x6C,
0x75, 0x67, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x2A, 0x2E, 0x66, 0x73, 0x2E,
0x65, 0x6E, 0x70, 0x6C, 0x75, 0x67, 0x2E, 0x69, 0x6E, 0x82, 0x10, 0x2A, 0x2E,
0x66, 0x73, 0x2E, 0x68, 0x65, 0x72, 0x6F, 0x69, 0x6E, 0x65, 0x2E, 0x63, 0x6F,
0x6D, 0x82, 0x18, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6C, 0x65, 0x61, 0x72, 0x6E,
0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F,
0x6D, 0x82, 0x18, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6C, 0x6F, 0x63, 0x61, 0x6C,
0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F,
0x6D, 0x82, 0x12, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6D, 0x69, 0x6E, 0x64, 0x66,
0x6C, 0x61, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, 0x2E, 0x66,
0x73, 0x2E, 0x6F, 0x70, 0x73, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63,
0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x66, 0x73, 0x2E,
0x70, 0x69, 0x78, 0x76, 0x61, 0x6E, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15,
0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x71, 0x61, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F,
0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x17, 0x2A, 0x2E, 0x66,
0x73, 0x2E, 0x74, 0x65, 0x73, 0x74, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E,
0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x09, 0x2A, 0x2E, 0x68, 0x61,
0x78, 0x78, 0x2E, 0x73, 0x65, 0x82, 0x0D, 0x2A, 0x2E, 0x68, 0x6F, 0x6D, 0x65,
0x61, 0x77, 0x61, 0x79, 0x2E, 0x6C, 0x6B, 0x82, 0x0F, 0x2A, 0x2E, 0x69, 0x64,
0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16,
0x2A, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x6D, 0x61,
0x65, 0x73, 0x74, 0x72, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x2A, 0x2E,
0x69, 0x6D, 0x67, 0x2D, 0x74, 0x61, 0x62, 0x6F, 0x6F, 0x6C, 0x61, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x6A, 0x75, 0x6C, 0x69, 0x61, 0x6C, 0x61,
0x6E, 0x67, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x10, 0x2A, 0x2E, 0x6B, 0x69, 0x6E,
0x64, 0x73, 0x6E, 0x61, 0x63, 0x6B, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10,
0x2A, 0x2E, 0x6B, 0x73, 0x73, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x2A, 0x2E, 0x6B, 0x73, 0x74, 0x63, 0x6F, 0x72,
0x72, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x6B, 0x73, 0x74,
0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C,
0x2A, 0x2E, 0x6E, 0x65, 0x77, 0x73, 0x31, 0x32, 0x2E, 0x63, 0x6F, 0x6D, 0x82,
0x1B, 0x2A, 0x2E, 0x70, 0x61, 0x72, 0x74, 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69,
0x66, 0x69, 0x65, 0x72, 0x2E, 0x73, 0x77, 0x69, 0x73, 0x63, 0x6F, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x13, 0x2A, 0x2E, 0x73, 0x68, 0x6F, 0x70, 0x72, 0x61, 0x63,
0x68, 0x65, 0x6C, 0x7A, 0x6F, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x2A,
0x2E, 0x74, 0x61, 0x73, 0x74, 0x79, 0x2E, 0x63, 0x6F, 0x82, 0x0C, 0x2A, 0x2E,
0x74, 0x65, 0x64, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x2A,
0x2E, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x73, 0x2E, 0x66, 0x6F, 0x6C, 0x69,
0x6F, 0x68, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x76, 0x6F,
0x75, 0x63, 0x68, 0x65, 0x72, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x2E, 0x63, 0x6F,
0x2E, 0x75, 0x6B, 0x82, 0x0D, 0x2A, 0x2E, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65,
0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x61, 0x2E, 0x69, 0x63, 0x61, 0x6E,
0x76, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0B, 0x61, 0x32, 0x70, 0x72,
0x65, 0x73, 0x73, 0x65, 0x2E, 0x66, 0x72, 0x82, 0x17, 0x61, 0x64, 0x76, 0x65,
0x6E, 0x74, 0x69, 0x73, 0x74, 0x62, 0x6F, 0x6F, 0x6B, 0x63, 0x65, 0x6E, 0x74,
0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x61, 0x70, 0x69, 0x2D, 0x6D,
0x65, 0x72, 0x72, 0x79, 0x6A, 0x61, 0x6E, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82,
0x12, 0x61, 0x70, 0x69, 0x73, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69,
0x76, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x61, 0x70, 0x70, 0x2D, 0x61,
0x70, 0x69, 0x2E, 0x74, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x61,
0x70, 0x70, 0x2E, 0x62, 0x69, 0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x63,
0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x0F, 0x61, 0x70, 0x70, 0x2E, 0x62, 0x69, 0x72,
0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x65, 0x73, 0x82, 0x1A, 0x61, 0x70, 0x70,
0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x62, 0x69, 0x72, 0x63,
0x68, 0x62, 0x6F, 0x78, 0x2E, 0x63, 0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x17, 0x61,
0x70, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x62, 0x69,
0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x65, 0x73, 0x82, 0x0A, 0x62, 0x61,
0x61, 0x74, 0x63, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x62, 0x65, 0x72,
0x6E, 0x61, 0x72, 0x64, 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x15, 0x62, 0x69, 0x6F, 0x74, 0x65, 0x63, 0x68, 0x77,
0x65, 0x65, 0x6B, 0x62, 0x6F, 0x73, 0x74, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D,
0x82, 0x0E, 0x62, 0x6F, 0x78, 0x6F, 0x66, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x63, 0x61, 0x73, 0x70, 0x65, 0x72, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x0D, 0x63, 0x64, 0x6E, 0x2E, 0x69, 0x72, 0x73, 0x64, 0x6E,
0x2E, 0x6E, 0x65, 0x74, 0x82, 0x0F, 0x63, 0x68, 0x61, 0x6B, 0x72, 0x61, 0x6C,
0x69, 0x6E, 0x75, 0x78, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x13, 0x64, 0x65, 0x76,
0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x68, 0x69, 0x70, 0x2E, 0x63, 0x6F, 0x6D,
0x2E, 0x61, 0x75, 0x82, 0x0B, 0x64, 0x69, 0x67, 0x69, 0x64, 0x61, 0x79, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x22, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6C, 0x4C,
0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x2E, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72,
0x64, 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, 0x6D,
0x82, 0x14, 0x64, 0x72, 0x77, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E,
0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x08, 0x65, 0x63,
0x68, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x66, 0x69, 0x6C, 0x65, 0x73,
0x74, 0x61, 0x63, 0x6B, 0x2E, 0x6F, 0x6E, 0x65, 0x6D, 0x6F, 0x62, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x0D, 0x66, 0x73, 0x2E, 0x65, 0x6E, 0x70, 0x6C, 0x75, 0x67,
0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x66, 0x73, 0x2E, 0x6C, 0x65, 0x61, 0x72,
0x6E, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x16, 0x66, 0x73, 0x2E, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x7A,
0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D,
0x82, 0x14, 0x66, 0x73, 0x2E, 0x6F, 0x70, 0x73, 0x7A, 0x69, 0x6C, 0x6C, 0x69,
0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x66, 0x73,
0x2E, 0x71, 0x61, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E,
0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x66, 0x73, 0x2E, 0x74, 0x65, 0x73, 0x74,
0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F,
0x6D, 0x82, 0x0B, 0x68, 0x6F, 0x6D, 0x65, 0x61, 0x77, 0x61, 0x79, 0x2E, 0x6C,
0x6B, 0x82, 0x12, 0x69, 0x6D, 0x67, 0x2E, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65,
0x72, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x69, 0x6F, 0x82, 0x0E, 0x6B, 0x69, 0x6E,
0x64, 0x73, 0x6E, 0x61, 0x63, 0x6B, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E,
0x6B, 0x73, 0x73, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x63, 0x6F,
0x6D, 0x82, 0x0C, 0x6B, 0x73, 0x74, 0x63, 0x6F, 0x72, 0x72, 0x61, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x0D, 0x6D, 0x65, 0x6E, 0x75, 0x2E, 0x74, 0x72, 0x65, 0x65,
0x7A, 0x2E, 0x69, 0x6F, 0x82, 0x17, 0x6D, 0x6F, 0x62, 0x69, 0x6C, 0x65, 0x61,
0x70, 0x69, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x6E, 0x65, 0x77, 0x73, 0x31, 0x32, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x0B, 0x6F, 0x6D, 0x6E, 0x69, 0x67, 0x6F, 0x6E, 0x2E, 0x63,
0x6F, 0x6D, 0x82, 0x0E, 0x6F, 0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x72,
0x65, 0x76, 0x69, 0x65, 0x77, 0x82, 0x11, 0x70, 0x6F, 0x70, 0x79, 0x6F, 0x75,
0x72, 0x62, 0x75, 0x62, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x18,
0x70, 0x72, 0x6F, 0x64, 0x2E, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72, 0x64, 0x63,
0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x18,
0x72, 0x65, 0x6C, 0x65, 0x61, 0x73, 0x65, 0x2D, 0x70, 0x72, 0x69, 0x6D, 0x65,
0x2E, 0x73, 0x70, 0x6F, 0x6B, 0x65, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x19,
0x72, 0x65, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x6F, 0x72, 0x69, 0x65, 0x73, 0x2E,
0x73, 0x65, 0x6E, 0x73, 0x75, 0x61, 0x70, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x82,
0x0C, 0x72, 0x6C, 0x2E, 0x74, 0x61, 0x6C, 0x69, 0x73, 0x2E, 0x63, 0x6F, 0x6D,
0x82, 0x11, 0x73, 0x68, 0x6F, 0x70, 0x72, 0x61, 0x63, 0x68, 0x65, 0x6C, 0x7A,
0x6F, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x73, 0x74, 0x61, 0x67, 0x69,
0x6E, 0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x73,
0x74, 0x61, 0x74, 0x69, 0x63, 0x2E, 0x70, 0x6C, 0x75, 0x6D, 0x63, 0x61, 0x63,
0x68, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x73, 0x74, 0x61, 0x79, 0x69,
0x6E, 0x67, 0x61, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x6D, 0x73, 0x66, 0x2E, 0x6F,
0x72, 0x67, 0x82, 0x08, 0x74, 0x61, 0x73, 0x74, 0x79, 0x2E, 0x63, 0x6F, 0x82,
0x0C, 0x74, 0x6F, 0x70, 0x73, 0x70, 0x65, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D,
0x82, 0x13, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x73, 0x2E, 0x66, 0x6F, 0x6C,
0x69, 0x6F, 0x68, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x1A, 0x75, 0x73, 0x2D,
0x65, 0x75, 0x2E, 0x66, 0x69, 0x6C, 0x65, 0x73, 0x74, 0x61, 0x63, 0x6B, 0x63,
0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x76,
0x6F, 0x75, 0x63, 0x68, 0x65, 0x72, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x2E, 0x63,
0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x0B, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72,
0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x77, 0x6F, 0x6D, 0x65, 0x6E, 0x73, 0x68,
0x65, 0x61, 0x6C, 0x74, 0x68, 0x2D, 0x6A, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x82,
0x19, 0x77, 0x6F, 0x72, 0x6B, 0x65, 0x72, 0x62, 0x65, 0x65, 0x2E, 0x73, 0x74,
0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D,
0x82, 0x0A, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x67, 0x66, 0x2E, 0x64, 0x6B, 0x82,
0x14, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x76, 0x65, 0x6E, 0x69, 0x72, 0x2D, 0x73,
0x75, 0x69, 0x73, 0x73, 0x65, 0x2E, 0x63, 0x68, 0x82, 0x11, 0x77, 0x77, 0x77,
0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, 0x72, 0x2E, 0x63, 0x6F, 0x2E, 0x6E,
0x7A, 0x82, 0x15, 0x77, 0x77, 0x77, 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61,
0x72, 0x62, 0x6C, 0x75, 0x65, 0x2E, 0x63, 0x6F, 0x2E, 0x6E, 0x7A, 0x82, 0x16,
0x77, 0x77, 0x77, 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, 0x72, 0x62, 0x6C,
0x75, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82, 0x1D, 0x77, 0x77,
0x77, 0x2E, 0x63, 0x68, 0x61, 0x6D, 0x70, 0x69, 0x6F, 0x6E, 0x73, 0x68, 0x6F,
0x63, 0x6B, 0x65, 0x79, 0x6C, 0x65, 0x61, 0x67, 0x75, 0x65, 0x2E, 0x6E, 0x65,
0x74, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x78, 0x74, 0x65, 0x72, 0x72,
0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x7A,
0x75, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65,
0x7A, 0x75, 0x70, 0x2E, 0x64, 0x65, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65,
0x7A, 0x75, 0x70, 0x2E, 0x65, 0x75, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65,
0x7A, 0x75, 0x70, 0x2E, 0x6E, 0x6C, 0x82, 0x11, 0x77, 0x77, 0x77, 0x2E, 0x66,
0x72, 0x61, 0x6E, 0x6B, 0x62, 0x6F, 0x64, 0x79, 0x2E, 0x63, 0x6F, 0x6D, 0x82,
0x0D, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6C, 0x6F, 0x73, 0x73, 0x79, 0x2E, 0x63,
0x6F, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6F, 0x6C, 0x64, 0x63, 0x75,
0x70, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x69, 0x63,
0x61, 0x6E, 0x76, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x77, 0x77,
0x77, 0x2E, 0x6D, 0x6F, 0x6E, 0x69, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16,
0x77, 0x77, 0x77, 0x2E, 0x6F, 0x64, 0x65, 0x6E, 0x73, 0x65, 0x2D, 0x6D, 0x61,
0x72, 0x63, 0x69, 0x70, 0x61, 0x6E, 0x2E, 0x64, 0x6B, 0x82, 0x15, 0x77, 0x77,
0x77, 0x2E, 0x6F, 0x6E, 0x65, 0x63, 0x6C, 0x69, 0x63, 0x6B, 0x64, 0x72, 0x69,
0x76, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x77, 0x77, 0x77, 0x2E, 0x6F,
0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77,
0x82, 0x15, 0x77, 0x77, 0x77, 0x2E, 0x70, 0x6F, 0x70, 0x79, 0x6F, 0x75, 0x72,
0x62, 0x75, 0x62, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x77,
0x77, 0x77, 0x2E, 0x72, 0x61, 0x77, 0x6E, 0x65, 0x74, 0x2E, 0x63, 0x6F, 0x6D,
0x82, 0x0E, 0x77, 0x77, 0x77, 0x2E, 0x73, 0x70, 0x6F, 0x6B, 0x65, 0x6F, 0x2E,
0x63, 0x6F, 0x6D, 0x82, 0x10, 0x77, 0x77, 0x77, 0x2E, 0x74, 0x65, 0x61, 0x72,
0x73, 0x68, 0x65, 0x65, 0x74, 0x2E, 0x63, 0x6F, 0x82, 0x10, 0x77, 0x77, 0x77,
0x2E, 0x74, 0x6F, 0x70, 0x73, 0x70, 0x65, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D,
0x82, 0x16, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x68, 0x69, 0x74, 0x65, 0x6B, 0x65,
0x79, 0x76, 0x69, 0x6C, 0x6C, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x30, 0x1D,
0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06, 0x08, 0x2B, 0x06,
0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05,
0x07, 0x03, 0x02, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04,
0x14, 0xA8, 0x29, 0xFD, 0xA9, 0xA5, 0x1A, 0x1C, 0x37, 0x0B, 0x20, 0x3B, 0x98,
0xB7, 0x25, 0x39, 0xCC, 0xE5, 0x2F, 0xF4, 0x94, 0x30, 0x1F, 0x06, 0x03, 0x55,
0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xA9, 0x2B, 0x87, 0xE1, 0xCE,
0x24, 0x47, 0x3B, 0x1B, 0xBF, 0xCF, 0x85, 0x37, 0x02, 0x55, 0x9D, 0x0D, 0x94,
0x58, 0xE6, 0x30, 0x82, 0x01, 0x04, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01,
0xD6, 0x79, 0x02, 0x04, 0x02, 0x04, 0x81, 0xF5, 0x04, 0x81, 0xF2, 0x00, 0xF0,
0x00, 0x77, 0x00, 0xA4, 0xB9, 0x09, 0x90, 0xB4, 0x18, 0x58, 0x14, 0x87, 0xBB,
0x13, 0xA2, 0xCC, 0x67, 0x70, 0x0A, 0x3C, 0x35, 0x98, 0x04, 0xF9, 0x1B, 0xDF,
0xB8, 0xE3, 0x77, 0xCD, 0x0E, 0xC8, 0x0D, 0xDC, 0x10, 0x00, 0x00, 0x01, 0x66,
0x9C, 0xC8, 0xE7, 0x38, 0x00, 0x00, 0x04, 0x03, 0x00, 0x48, 0x30, 0x46, 0x02,
0x21, 0x00, 0xD9, 0x58, 0x6E, 0xFC, 0x4C, 0x3C, 0xAF, 0xF9, 0x5B, 0x7F, 0xDA,
0x54, 0x95, 0xAF, 0xCF, 0xB3, 0x57, 0xB9, 0x56, 0x2C, 0xE8, 0xE0, 0xB1, 0x20,
0x9B, 0xCB, 0x75, 0xAC, 0x4E, 0x54, 0xE9, 0x9D, 0x02, 0x21, 0x00, 0xE8, 0xF0,
0xC0, 0x49, 0x23, 0x8E, 0x3D, 0x9B, 0xA5, 0x87, 0xA3, 0xBE, 0x6C, 0x21, 0x62,
0xBB, 0xD2, 0x44, 0x5C, 0xE4, 0x7A, 0xCC, 0x46, 0x26, 0x04, 0x19, 0xA4, 0x2D,
0x9B, 0x1C, 0x5D, 0x3A, 0x00, 0x75, 0x00, 0x6F, 0x53, 0x76, 0xAC, 0x31, 0xF0,
0x31, 0x19, 0xD8, 0x99, 0x00, 0xA4, 0x51, 0x15, 0xFF, 0x77, 0x15, 0x1C, 0x11,
0xD9, 0x02, 0xC1, 0x00, 0x29, 0x06, 0x8D, 0xB2, 0x08, 0x9A, 0x37, 0xD9, 0x13,
0x00, 0x00, 0x01, 0x66, 0x9C, 0xC8, 0xE6, 0x20, 0x00, 0x00, 0x04, 0x03, 0x00,
0x46, 0x30, 0x44, 0x02, 0x20, 0x14, 0xC8, 0x9F, 0xAC, 0x27, 0x48, 0xBE, 0x4D,
0x0E, 0xC3, 0x26, 0x2E, 0x34, 0xCA, 0x38, 0xBA, 0x11, 0x3A, 0x68, 0x71, 0x88,
0xEB, 0x24, 0x26, 0x59, 0x3E, 0xAC, 0xA8, 0x63, 0xCC, 0x8A, 0x0A, 0x02, 0x20,
0x0F, 0x22, 0xBF, 0x0D, 0x1F, 0x8A, 0x8D, 0x1D, 0x91, 0x33, 0x3A, 0x40, 0xE4,
0x23, 0x78, 0xFA, 0x22, 0xF5, 0x9B, 0xCB, 0x04, 0x4F, 0x53, 0x2D, 0x20, 0x75,
0x2F, 0x76, 0x8A, 0xB1, 0xCD, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48,
0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00,
0x03, 0x41, 0x0F, 0xF3, 0xA6, 0x62, 0xA2, 0xE5, 0xB4, 0x8D, 0xA8, 0x08, 0x71,
0x7B, 0xB3, 0xE3, 0x51, 0x61, 0x0D, 0xC0, 0x67, 0x6C, 0x3C, 0x9C, 0x00, 0x0B,
0x63, 0x77, 0xB6, 0xB6, 0x11, 0x67, 0x77, 0xA5, 0xE1, 0x49, 0xE0, 0x7F, 0xB7,
0x1D, 0x61, 0xFB, 0x83, 0x9C, 0x83, 0x42, 0xE9, 0x31, 0xCA, 0x51, 0xE3, 0xC1,
0xBD, 0x9B, 0x2F, 0xB5, 0x35, 0x05, 0x72, 0x7F, 0x40, 0xA6, 0x7C, 0xC9, 0xF1,
0x59, 0xA7, 0x15, 0xB8, 0x12, 0xDA, 0xF8, 0xCE, 0x83, 0x61, 0xFC, 0x47, 0x96,
0x9E, 0x74, 0xFE, 0xCD, 0xE4, 0x61, 0x92, 0xF2, 0x2E, 0x0C, 0x08, 0x4B, 0x60,
0x2D, 0xF6, 0x50, 0x07, 0x83, 0xCA, 0xAF, 0xB9, 0x41, 0x33, 0x4A, 0x3E, 0x84,
0xC7, 0x73, 0xC6, 0x1F, 0xFF, 0x7A, 0xDF, 0xAE, 0x47, 0x25, 0x32, 0xEB, 0xC0,
0x43, 0x0C, 0xA6, 0x23, 0x13, 0x46, 0xC3, 0xFA, 0x44, 0xEA, 0x20, 0xEA, 0xCB,
0x18, 0x17, 0x00, 0xB6, 0xE7, 0x6D, 0x8A, 0x14, 0x8C, 0x6A, 0xCA, 0x88, 0x4C,
0xDA, 0xA8, 0xB9, 0x08, 0xAF, 0x39, 0xEE, 0xCF, 0xD7, 0xF7, 0x32, 0xC0, 0xF4,
0xCF, 0x4E, 0x22, 0x38, 0xF7, 0xAF, 0xAE, 0x7D, 0x58, 0x5F, 0xA5, 0x2D, 0x4D,
0xBB, 0x86, 0x10, 0xB3, 0x93, 0x62, 0x64, 0x27, 0xBF, 0xB1, 0xBB, 0x8F, 0x9F,
0xFC, 0x07, 0x3C, 0x4B, 0x16, 0x7A, 0x84, 0x5E, 0xAF, 0xAD, 0x57, 0x9C, 0xFF,
0x7A, 0xA7, 0xE0, 0x90, 0x89, 0x1C, 0xE8, 0xE5, 0x11, 0xF7, 0xB6, 0xDC, 0xCD,
0x5E, 0xF7, 0x30, 0xA2, 0x2E, 0x67, 0x6D, 0x4A, 0x70, 0x26, 0xEA, 0xCD, 0x27,
0x70, 0x77, 0x54, 0x57, 0x09, 0x03, 0x56, 0x4A, 0x33, 0x60, 0x00, 0x27, 0xFE,
0xA7, 0xD7, 0xA9, 0xC4, 0xEC, 0x17, 0x17, 0x8D, 0x87, 0x70, 0x6B, 0x48, 0x88,
0x61, 0x54, 0x4A, 0x2B, 0xB7, 0x6A, 0x12, 0x08, 0xFB,
};
UNITTEST_START
{
CURLcode result;
const char *beg = (const char *)&cert[0];
const char *end = (const char *)&cert[sizeof(cert)];
struct Curl_easy *data = curl_easy_init();
int i;
int byte;
if(!data)
return 2;
result = Curl_extract_certinfo(data, 0, beg, end);
fail_unless(result == CURLE_OK, "Curl_extract_certinfo returned error");
/* a poor man's fuzzing of some initial data to make sure nothing bad
happens */
for(byte = 1 ; byte < 255; byte += 17) {
for(i = 0; i < 45; i++) {
char backup = cert[i];
cert[i] = (unsigned char) (byte & 0xff);
(void) Curl_extract_certinfo(data, 0, beg, end);
cert[i] = backup;
}
}
curl_easy_cleanup(data);
}
UNITTEST_STOP
#else
UNITTEST_START
{
puts("not tested since Curl_extract_certinfo() is not built-in");
}
UNITTEST_STOP
#endif
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1661.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "bufref.h"
static struct bufref bufref;
static int freecount = 0;
static void test_free(void *p)
{
fail_unless(p, "pointer to free may not be NULL");
freecount++;
free(p);
}
static CURLcode unit_setup(void)
{
Curl_bufref_init(&bufref);
return CURLE_OK;
}
static void unit_stop(void)
{
}
UNITTEST_START
{
char *buffer = NULL;
CURLcode result = CURLE_OK;
/**
* testing Curl_bufref_init.
* @assumptions:
* 1: data size will be 0
* 2: reference will be NULL
* 3: destructor will be NULL
*/
fail_unless(!bufref.ptr, "Initial reference must be NULL");
fail_unless(!bufref.len, "Initial length must be NULL");
fail_unless(!bufref.dtor, "Destructor must be NULL");
/**
* testing Curl_bufref_set
*/
buffer = malloc(13);
abort_unless(buffer, "Out of memory");
Curl_bufref_set(&bufref, buffer, 13, test_free);
fail_unless((char *) bufref.ptr == buffer, "Referenced data badly set");
fail_unless(bufref.len == 13, "Data size badly set");
fail_unless(bufref.dtor == test_free, "Destructor badly set");
/**
* testing Curl_bufref_ptr
*/
fail_unless((char *) Curl_bufref_ptr(&bufref) == buffer,
"Wrong pointer value returned");
/**
* testing Curl_bufref_len
*/
fail_unless(Curl_bufref_len(&bufref) == 13, "Wrong data size returned");
/**
* testing Curl_bufref_memdup
*/
result = Curl_bufref_memdup(&bufref, "1661", 3);
abort_unless(result == CURLE_OK, curl_easy_strerror(result));
fail_unless(freecount == 1, "Destructor not called");
fail_unless((char *) bufref.ptr != buffer, "Returned pointer not set");
buffer = (char *) Curl_bufref_ptr(&bufref);
fail_unless(buffer, "Allocated pointer is NULL");
fail_unless(bufref.len == 3, "Wrong data size stored");
fail_unless(!buffer[3], "Duplicated data should have been truncated");
fail_unless(!strcmp(buffer, "166"), "Bad duplicated data");
/**
* testing Curl_bufref_free
*/
Curl_bufref_free(&bufref);
fail_unless(freecount == 1, "Wrong destructor called");
fail_unless(!bufref.ptr, "Initial reference must be NULL");
fail_unless(!bufref.len, "Initial length must be NULL");
fail_unless(!bufref.dtor, "Destructor must be NULL");
}
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1612.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "curl_hmac.h"
#include "curl_md5.h"
static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
}
UNITTEST_START
#ifndef CURL_DISABLE_CRYPTO_AUTH
const char password[] = "Pa55worD";
const char string1[] = "1";
const char string2[] = "hello-you-fool";
unsigned char output[HMAC_MD5_LENGTH];
unsigned char *testp = output;
Curl_hmacit(Curl_HMAC_MD5,
(const unsigned char *) password, strlen(password),
(const unsigned char *) string1, strlen(string1),
output);
verify_memory(testp,
"\xd1\x29\x75\x43\x58\xdc\xab\x78\xdf\xcd\x7f\x2b\x29\x31\x13"
"\x37", HMAC_MD5_LENGTH);
Curl_hmacit(Curl_HMAC_MD5,
(const unsigned char *) password, strlen(password),
(const unsigned char *) string2, strlen(string2),
output);
verify_memory(testp,
"\x75\xf1\xa7\xb9\xf5\x40\xe5\xa4\x98\x83\x9f\x64\x5a\x27\x6d"
"\xd0", HMAC_MD5_LENGTH);
#endif
UNITTEST_STOP
|
0 | repos/gpt4all.zig/src/zig-libcurl/curl/tests | repos/gpt4all.zig/src/zig-libcurl/curl/tests/unit/unit1605.c | /***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include "curlcheck.h"
#include "llist.h"
static CURL *easy;
static CURLcode unit_setup(void)
{
int res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
easy = curl_easy_init();
if(!easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
return res;
}
static void unit_stop(void)
{
curl_easy_cleanup(easy);
curl_global_cleanup();
}
UNITTEST_START
int len;
char *esc;
esc = curl_easy_escape(easy, "", -1);
fail_unless(esc == NULL, "negative string length can't work");
esc = curl_easy_unescape(easy, "%41%41%41%41", -1, &len);
fail_unless(esc == NULL, "negative string length can't work");
UNITTEST_STOP
|
Subsets and Splits