http2-server.pl \
http3-server.pl \
memanalyze.pl \
- mk-bundle-hints.sh \
mk-bundle.pl \
negtelnetserver.py \
nghttpx.conf \
HTTP Retry-After header parsing using a date
</name>
<tool>
-lib%TESTNUMBER
+lib1594
</tool>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER
lib1540 lib1541 lib1542 lib1543 lib1545 \
lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \
lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 lib1568 lib1569 lib1571 \
- lib1576 lib1578 \
- lib1591 lib1592 lib1593 lib1594 lib1596 lib1597 lib1598 \
+ lib1576 \
+ lib1591 lib1592 lib1593 lib1594 lib1597 lib1598 \
\
lib1662 \
\
lib505_SOURCES = lib505.c $(SUPPORTFILES) $(MULTIBYTE)
-lib506_SOURCES = lib506.c $(SUPPORTFILES)
+lib506_SOURCES = lib506.c $(SUPPORTFILES) $(TESTUTIL)
+lib506_LDADD = $(TESTUTIL_LIBS)
lib507_SOURCES = lib507.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib507_LDADD = $(TESTUTIL_LIBS)
lib517_SOURCES = lib517.c $(SUPPORTFILES)
-lib518_SOURCES = lib518.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE)
+lib518_SOURCES = lib518.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
+lib518_LDADD = $(TESTUTIL_LIBS)
lib519_SOURCES = lib519.c $(SUPPORTFILES)
lib536_SOURCES = lib536.c $(SUPPORTFILES)
-lib537_SOURCES = lib537.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE)
+lib537_SOURCES = lib537.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
+lib537_LDADD = $(TESTUTIL_LIBS)
lib539_SOURCES = lib539.c $(SUPPORTFILES)
lib567_SOURCES = lib567.c $(SUPPORTFILES)
-lib568_SOURCES = lib568.c $(SUPPORTFILES) $(MULTIBYTE)
+lib568_SOURCES = lib568.c $(SUPPORTFILES) $(TESTUTIL) $(MULTIBYTE)
+lib568_LDADD = $(TESTUTIL_LIBS)
-lib569_SOURCES = lib569.c $(SUPPORTFILES) $(MULTIBYTE)
+lib569_SOURCES = lib569.c $(SUPPORTFILES) $(TESTUTIL) $(MULTIBYTE)
+lib569_LDADD = $(TESTUTIL_LIBS)
-lib570_SOURCES = lib570.c $(SUPPORTFILES)
+lib570_SOURCES = lib570.c $(SUPPORTFILES) $(TESTUTIL)
+lib570_LDADD = $(TESTUTIL_LIBS)
-lib571_SOURCES = lib571.c $(SUPPORTFILES) $(WARNLESS) $(MULTIBYTE)
+lib571_SOURCES = lib571.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(MULTIBYTE)
+lib571_LDADD = $(TESTUTIL_LIBS)
-lib572_SOURCES = lib572.c $(SUPPORTFILES) $(MULTIBYTE)
+lib572_SOURCES = lib572.c $(SUPPORTFILES) $(TESTUTIL) $(MULTIBYTE)
+lib572_LDADD = $(TESTUTIL_LIBS)
lib573_SOURCES = lib573.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) $(TSTTRACE)
lib573_LDADD = $(TESTUTIL_LIBS)
lib586_SOURCES = lib586.c $(SUPPORTFILES)
-lib587_SOURCES = lib554.c $(SUPPORTFILES)
-lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587
+lib587_SOURCES = lib587.c $(SUPPORTFILES)
lib589_SOURCES = lib589.c $(SUPPORTFILES)
lib643_SOURCES = lib643.c $(SUPPORTFILES)
-lib645_SOURCES = lib643.c $(SUPPORTFILES)
-lib645_CPPFLAGS = $(AM_CPPFLAGS) -DLIB645
+lib645_SOURCES = lib645.c $(SUPPORTFILES)
lib650_SOURCES = lib650.c $(SUPPORTFILES)
lib1576_SOURCES = lib1576.c $(SUPPORTFILES)
-lib1578_SOURCES = lib1576.c $(SUPPORTFILES)
-lib1578_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1578
-
lib1591_SOURCES = lib1591.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1591_LDADD = $(TESTUTIL_LIBS)
lib1594_SOURCES = lib1594.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1594_LDADD = $(TESTUTIL_LIBS)
-lib1596_SOURCES = lib1594.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
-lib1596_LDADD = $(TESTUTIL_LIBS)
-lib1596_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1596
-
lib1597_SOURCES = lib1597.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1597_LDADD = $(TESTUTIL_LIBS)
#include "warnless.h"
#include "memdebug.h"
-struct transfer_status {
+struct t1485_transfer_status {
CURL *easy;
curl_off_t out_len;
size_t hd_line;
int http_status;
};
-static size_t header_callback(char *ptr, size_t size, size_t nmemb,
- void *userp)
+static size_t t1485_header_callback(char *ptr, size_t size, size_t nmemb,
+ void *userp)
{
- struct transfer_status *st = (struct transfer_status *)userp;
+ struct t1485_transfer_status *st = (struct t1485_transfer_status *)userp;
const char *hd = ptr;
size_t len = size * nmemb;
CURLcode result;
return len;
}
-static size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t1485_write_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct transfer_status *st = (struct transfer_status *)userp;
+ struct t1485_transfer_status *st = (struct t1485_transfer_status *)userp;
size_t len = size * nmemb;
fwrite(ptr, size, nmemb, stdout);
st->out_len += (curl_off_t)len;
{
CURL *curls = NULL;
CURLcode res = CURLE_OK;
- struct transfer_status st;
+ struct t1485_transfer_status st;
start_test_timing();
st.easy = curls; /* to allow callbacks access */
easy_setopt(curls, CURLOPT_URL, URL);
- easy_setopt(curls, CURLOPT_WRITEFUNCTION, write_callback);
+ easy_setopt(curls, CURLOPT_WRITEFUNCTION, t1485_write_cb);
easy_setopt(curls, CURLOPT_WRITEDATA, &st);
- easy_setopt(curls, CURLOPT_HEADERFUNCTION, header_callback);
+ easy_setopt(curls, CURLOPT_HEADERFUNCTION, t1485_header_callback);
easy_setopt(curls, CURLOPT_HEADERDATA, &st);
easy_setopt(curls, CURLOPT_NOPROGRESS, 1L);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURL *curls = NULL;
#include "warnless.h"
#include "memdebug.h"
+#undef TEST_HANG_TIMEOUT
#define TEST_HANG_TIMEOUT 30 * 1000
/* 500 milliseconds allowed. An extreme number but lets be really conservative
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURL *easy = NULL;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
#define MULTI_PERFORM_HANG_TIMEOUT 60 * 1000
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t1507_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
(void)ptr;
(void)size;
curl_easy_setopt(curl, CURLOPT_PASSWORD, PASSWORD);
#endif
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
- curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, t1507_read_cb);
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, MAILFROM);
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
#define NUM_URLS 4
CURLcode test(char *URL)
easy_setopt(curl, CURLOPT_MAXCONNECTS, 3L);
- /* get NUM_HANDLES easy handles */
+ /* get NUM_URLS easy handles */
for(i = 0; i < NUM_URLS; i++) {
/* specify target */
curl_msnprintf(target_url, sizeof(target_url),
#include "memdebug.h"
+#undef NUM_HANDLES
#define NUM_HANDLES 2
CURLcode test(char *URL)
#include "memdebug.h"
-static char testdata[]="dummy";
-
-struct WriteThis {
+#ifndef LIB1514_C
+#define LIB1514_C
+struct t1514_WriteThis {
char *readptr;
size_t sizeleft;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t1514_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ struct t1514_WriteThis *pooh = (struct t1514_WriteThis *)userp;
if(size*nmemb < 1)
return 0;
return 0; /* no more data left to deliver */
}
+#endif
CURLcode test(char *URL)
{
CURL *curl;
CURLcode result = CURLE_OK;
CURLcode res = CURLE_OK;
- struct WriteThis pooh = { testdata, sizeof(testdata)-1 };
+
+ static char testdata[] = "dummy";
+
+ struct t1514_WriteThis pooh = { testdata, sizeof(testdata)-1 };
global_init(CURL_GLOBAL_ALL);
easy_setopt(curl, CURLOPT_URL, URL);
easy_setopt(curl, CURLOPT_POST, 1L);
/* Purposely omit to set CURLOPT_POSTFIELDSIZE */
- easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ easy_setopt(curl, CURLOPT_READFUNCTION, t1514_read_cb);
easy_setopt(curl, CURLOPT_READDATA, &pooh);
#ifdef LIB1539
/* speak HTTP 1.0 - no chunked! */
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
#define DNS_TIMEOUT 1L
static CURLcode do_one_request(CURLM *m, char *URL, char *resolve)
#include "memdebug.h"
-static char testdata[]="this is what we post to the silly web server\n";
-
-struct WriteThis {
- char *readptr;
+struct t1517_WriteThis {
+ const char *readptr;
size_t sizeleft;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t1517_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ struct t1517_WriteThis *pooh = (struct t1517_WriteThis *)userp;
size_t tocopy = size * nmemb;
/* Wait one second before return POST data *
CURLcode test(char *URL)
{
+ static const char testdata[] =
+ "this is what we post to the silly web server\n";
+
CURL *curl;
CURLcode res = CURLE_OK;
- struct WriteThis pooh;
+ struct t1517_WriteThis pooh;
if(!strcmp(URL, "check")) {
#if (defined(_WIN32) || defined(__CYGWIN__))
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
/* we want to use our own read function */
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t1517_read_cb);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
/* Test inspired by github issue 3340 */
-static size_t writecb(char *buffer, size_t size, size_t nitems,
- void *outstream)
+#ifndef LIB1518_C
+#define LIB1518_C
+static size_t t1518_write_cb(char *buffer, size_t size, size_t nitems,
+ void *outstream)
{
(void)buffer;
(void)size;
(void)outstream;
return 0;
}
+#endif
CURLcode test(char *URL)
{
curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &curlRedirectCount);
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &effectiveUrl);
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirectUrl);
- test_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
+ test_setopt(curl, CURLOPT_WRITEFUNCTION, t1518_write_cb);
curl_mprintf("res %d\n"
"status %ld\n"
#define TO "<recipient@example.com>"
#define FROM "<sender@example.com>"
-static const char *payload_text[] = {
- "From: different\r\n",
- "To: another\r\n",
- "\r\n",
- "\r\n",
- ".\r\n",
- ".\r\n",
- "\r\n",
- ".\r\n",
- "\r\n",
- "body",
- NULL
-};
-
struct upload_status {
int lines_read;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t1520_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
+ static const char *payload_text[] = {
+ "From: different\r\n",
+ "To: another\r\n",
+ "\r\n",
+ "\r\n",
+ ".\r\n",
+ ".\r\n",
+ "\r\n",
+ ".\r\n",
+ "\r\n",
+ "body",
+ NULL
+ };
+
struct upload_status *upload_ctx = (struct upload_status *)userp;
const char *data;
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t1520_read_cb);
test_setopt(curl, CURLOPT_READDATA, &upload_ctx);
test_setopt(curl, CURLOPT_MAIL_FROM, FROM);
test_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list);
#include "warnless.h"
#include "memdebug.h"
-static char g_Data[40 * 1024]; /* POST 40KB */
-
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
curlsocktype purpose)
{
CURLcode test(char *URL)
{
+ static char g_Data[40 * 1024]; /* POST 40KB */
+
CURLcode code = TEST_ERR_MAJOR_BAD;
CURLcode res;
struct curl_slist *pHeaderList = NULL;
return 0;
}
-static size_t write_cb(char *d, size_t n, size_t l, void *p)
+static size_t t1523_write_cb(char *d, size_t n, size_t l, void *p)
{
/* take care of the data here, ignored in this example */
(void)d;
curl_global_init(CURL_GLOBAL_ALL);
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, URL);
- curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, write_cb);
+ curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, t1523_write_cb);
curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, buffer);
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(hnd, CURLOPT_XFERINFOFUNCTION, dload_progress_cb);
#include "memdebug.h"
-static char testdata[] = "Hello Cloud!\n";
+static const char t1525_testdata[] = "Hello Cloud!\n";
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
+static size_t t1525_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
- if(amount < strlen(testdata)) {
- return strlen(testdata);
+ if(amount < strlen(t1525_testdata)) {
+ return strlen(t1525_testdata);
}
(void)stream;
- memcpy(ptr, testdata, strlen(testdata));
- return strlen(testdata);
+ memcpy(ptr, t1525_testdata, strlen(t1525_testdata));
+ return strlen(t1525_testdata);
}
-
CURLcode test(char *URL)
{
CURL *curl = NULL;
test_setopt(curl, CURLOPT_PROXYTYPE, (long)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_READFUNCTION, t1525_read_cb);
test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
- test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata));
+ test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1525_testdata));
res = curl_easy_perform(curl);
#include "memdebug.h"
-static char testdata[] = "Hello Cloud!\n";
+static const char t1526_testdata[] = "Hello Cloud!\n";
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
+static size_t t1526_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
- if(amount < strlen(testdata)) {
- return strlen(testdata);
+ if(amount < strlen(t1526_testdata)) {
+ return strlen(t1526_testdata);
}
(void)stream;
- memcpy(ptr, testdata, strlen(testdata));
- return strlen(testdata);
+ memcpy(ptr, t1526_testdata, strlen(t1526_testdata));
+ return strlen(t1526_testdata);
}
CURLcode test(char *URL)
test_setopt(curl, CURLOPT_PROXYTYPE, (long)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_READFUNCTION, t1526_read_cb);
test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
- test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata));
+ test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1526_testdata));
res = curl_easy_perform(curl);
#include "memdebug.h"
-static char testdata[] = "Hello Cloud!\n";
+static const char t1527_testdata[] = "Hello Cloud!\n";
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
+static size_t t1527_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
- if(amount < strlen(testdata)) {
- return strlen(testdata);
+ if(amount < strlen(t1527_testdata)) {
+ return strlen(t1527_testdata);
}
(void)stream;
- memcpy(ptr, testdata, strlen(testdata));
- return strlen(testdata);
+ memcpy(ptr, t1527_testdata, strlen(t1527_testdata));
+ return strlen(t1527_testdata);
}
-
CURLcode test(char *URL)
{
CURL *curl = NULL;
test_setopt(curl, CURLOPT_PROXYTYPE, (long)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_READFUNCTION, t1527_read_cb);
test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
- test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata));
+ test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1527_testdata));
test_setopt(curl, CURLOPT_HEADEROPT, (long)CURLHEADER_UNIFIED);
res = curl_easy_perform(curl);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-static char const testData[] = ".abc\0xyz";
-static curl_off_t const testDataSize = sizeof(testData) - 1;
-
CURLcode test(char *URL)
{
+ static char const testData[] = ".abc\0xyz";
+ static curl_off_t const testDataSize = sizeof(testData) - 1;
+
CURL *easy;
CURLM *multi_handle;
int still_running; /* keep number of running handles */
size_t remaining_bytes;
};
-
static void reset_data(struct cb_data *data, CURL *curl)
{
data->easy_handle = curl;
data->remaining_bytes = 3;
}
-
-static size_t read_callback(char *ptr, size_t size, size_t nitems,
- void *userdata)
+static size_t t1533_read_cb(char *ptr, size_t size, size_t nitems, void *userp)
{
- struct cb_data *data = (struct cb_data *)userdata;
+ struct cb_data *data = (struct cb_data *)userp;
/* wait until the server has sent all response headers */
if(data->response_received) {
}
}
-
-static size_t write_callback(char *ptr, size_t size, size_t nmemb,
- void *userdata)
+static size_t t1533_write_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct cb_data *data = (struct cb_data *)userdata;
+ struct cb_data *data = (struct cb_data *)userp;
size_t totalsize = nmemb * size;
/* unused parameter */
return totalsize;
}
-
static CURLcode perform_and_check_connections(CURL *curl,
const char *description,
long expected_connections)
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_READFUNCTION, t1533_read_cb);
test_setopt(curl, CURLOPT_READDATA, &data);
- test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
+ test_setopt(curl, CURLOPT_WRITEFUNCTION, t1533_write_cb);
test_setopt(curl, CURLOPT_WRITEDATA, &data);
result = perform_and_check_connections(curl,
#include "warnless.h"
#include "memdebug.h"
-struct transfer_status {
+struct t1540_transfer_status {
CURL *easy;
int halted;
int counter; /* count write callback invokes */
curl_off_t ultotal,
curl_off_t ulnow)
{
- struct transfer_status *st = (struct transfer_status *)userp;
+ struct t1540_transfer_status *st = (struct t1540_transfer_status *)userp;
(void)dltotal;
(void)dlnow;
(void)ultotal;
return 0; /* go on */
}
-static size_t header_callback(char *ptr, size_t size, size_t nmemb,
- void *userp)
+static size_t t1540_header_callback(char *ptr, size_t size, size_t nmemb,
+ void *userp)
{
size_t len = size * nmemb;
(void)userp;
return len;
}
-static size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t1540_write_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct transfer_status *st = (struct transfer_status *)userp;
+ struct t1540_transfer_status *st = (struct t1540_transfer_status *)userp;
size_t len = size * nmemb;
st->counter++;
if(st->counter > 1) {
{
CURL *curls = NULL;
CURLcode res = CURLE_OK;
- struct transfer_status st;
+ struct t1540_transfer_status st;
start_test_timing();
st.easy = curls; /* to allow callbacks access */
easy_setopt(curls, CURLOPT_URL, URL);
- easy_setopt(curls, CURLOPT_WRITEFUNCTION, write_callback);
+ easy_setopt(curls, CURLOPT_WRITEFUNCTION, t1540_write_cb);
easy_setopt(curls, CURLOPT_WRITEDATA, &st);
- easy_setopt(curls, CURLOPT_HEADERFUNCTION, header_callback);
+ easy_setopt(curls, CURLOPT_HEADERFUNCTION, t1540_header_callback);
easy_setopt(curls, CURLOPT_HEADERDATA, &st);
easy_setopt(curls, CURLOPT_XFERINFOFUNCTION, please_continue);
#include "warnless.h"
#include "memdebug.h"
-struct transfer_status {
+struct t1541_transfer_status {
CURL *easy;
int hd_count;
int bd_count;
#define KN(a) a, #a
-static int geterr(const char *name, CURLcode val, int lineno)
+static int t1541_geterr(const char *name, CURLcode val, int lineno)
{
curl_mprintf("CURLINFO_%s returned %d, \"%s\" on line %d\n",
name, val, curl_easy_strerror(val), lineno);
curl_off_t tval;
CURLcode res = curl_easy_getinfo(easy, (CURLINFO)key, &tval);
if(res) {
- geterr(name, res, __LINE__);
+ t1541_geterr(name, res, __LINE__);
}
else
report_time(name, where, tval, tval > 0);
curl_off_t tval;
CURLcode res = curl_easy_getinfo(easy, (CURLINFO)key, &tval);
if(res) {
- geterr(name, res, __LINE__);
+ t1541_geterr(name, res, __LINE__);
}
else
report_time(name, where, tval, !tval);
}
-static size_t header_callback(char *ptr, size_t size, size_t nmemb,
- void *userp)
+static size_t t1541_header_callback(char *ptr, size_t size, size_t nmemb,
+ void *userp)
{
- struct transfer_status *st = (struct transfer_status *)userp;
+ struct t1541_transfer_status *st = (struct t1541_transfer_status *)userp;
size_t len = size * nmemb;
(void)ptr;
return len;
}
-static size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t1541_write_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct transfer_status *st = (struct transfer_status *)userp;
+ struct t1541_transfer_status *st = (struct t1541_transfer_status *)userp;
(void)ptr;
(void)st;
{
CURL *curls = NULL;
CURLcode res = CURLE_OK;
- struct transfer_status st;
+ struct t1541_transfer_status st;
start_test_timing();
st.easy = curls; /* to allow callbacks access */
easy_setopt(curls, CURLOPT_URL, URL);
- easy_setopt(curls, CURLOPT_WRITEFUNCTION, write_callback);
+ easy_setopt(curls, CURLOPT_WRITEFUNCTION, t1541_write_cb);
easy_setopt(curls, CURLOPT_WRITEDATA, &st);
- easy_setopt(curls, CURLOPT_HEADERFUNCTION, header_callback);
+ easy_setopt(curls, CURLOPT_HEADERFUNCTION, t1541_header_callback);
easy_setopt(curls, CURLOPT_HEADERDATA, &st);
easy_setopt(curls, CURLOPT_NOPROGRESS, 0L);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURL *curls = NULL;
#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)
+static int t1553_xferinfo(void *p,
+ curl_off_t dltotal, curl_off_t dlnow,
+ curl_off_t ultotal, curl_off_t ulnow)
{
(void)p;
(void)dlnow;
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_XFERINFOFUNCTION, t1553_xferinfo);
easy_setopt(curls, CURLOPT_NOPROGRESS, 1L);
libtest_debug_config.nohex = 1;
"NULL",
};
-static void test_lock(CURL *handle, curl_lock_data data,
- curl_lock_access laccess, void *useptr)
+static void t1554_test_lock(CURL *handle, curl_lock_data data,
+ curl_lock_access laccess, void *useptr)
{
(void)handle;
(void)data;
curl_mprintf("-> Mutex lock %s\n", ldata_names[data]);
}
-static void test_unlock(CURL *handle, curl_lock_data data, void *useptr)
+static void t1554_test_unlock(CURL *handle, curl_lock_data data, void *useptr)
{
(void)handle;
(void)data;
}
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
- curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock);
- curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock);
+ curl_share_setopt(share, CURLSHOPT_LOCKFUNC, t1554_test_lock);
+ curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, t1554_test_unlock);
/* Loop the transfer and cleanup the handle properly every lap. This will
still reuse connections since the pool is in the shared object! */
#include "memdebug.h"
-static CURL *curl;
+static CURL *t1555_curl;
static int progressCallback(void *arg,
double dltotal,
(void)dlnow;
(void)ultotal;
(void)ulnow;
- res = curl_easy_recv(curl, buffer, 256, &n);
+ res = curl_easy_recv(t1555_curl, buffer, 256, &n);
curl_mprintf("curl_easy_recv returned %d\n", res);
- res = curl_easy_send(curl, buffer, n, &n);
+ res = curl_easy_send(t1555_curl, buffer, n, &n);
curl_mprintf("curl_easy_send returned %d\n", res);
return 1;
global_init(CURL_GLOBAL_ALL);
- easy_init(curl);
+ easy_init(t1555_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, progressCallback);
- easy_setopt(curl, CURLOPT_PROGRESSDATA, NULL);
- easy_setopt(curl, CURLOPT_NOPROGRESS, (long)0);
+ easy_setopt(t1555_curl, CURLOPT_URL, URL);
+ easy_setopt(t1555_curl, CURLOPT_TIMEOUT, (long)7);
+ easy_setopt(t1555_curl, CURLOPT_NOSIGNAL, (long)1);
+ easy_setopt(t1555_curl, CURLOPT_PROGRESSFUNCTION, progressCallback);
+ easy_setopt(t1555_curl, CURLOPT_PROGRESSDATA, NULL);
+ easy_setopt(t1555_curl, CURLOPT_NOPROGRESS, (long)0);
- res = curl_easy_perform(curl);
+ res = curl_easy_perform(t1555_curl);
test_cleanup:
/* undocumented cleanup sequence - type UA */
- curl_easy_cleanup(curl);
+ curl_easy_cleanup(t1555_curl);
curl_global_cleanup();
return res;
int i;
CURLU *urlp = curl_url();
CURLUcode rc;
- CURLUPart part[]= {
+ CURLUPart part[] = {
CURLUPART_SCHEME,
CURLUPART_USER,
CURLUPART_PASSWORD,
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
#define WAKEUP_NUM 10
CURLcode test(char *URL)
#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 CURLcode test_failure = CURLE_OK;
+static CURLcode t1565_test_failure = CURLE_OK;
static CURLM *testmulti = NULL;
static const char *url;
-static void *run_thread(void *ptr)
+static void *t1565_run_thread(void *ptr)
{
CURL *easy = NULL;
CURLcode res = CURLE_OK;
pthread_mutex_lock(&lock);
- if(test_failure) {
+ if(t1565_test_failure) {
pthread_mutex_unlock(&lock);
goto test_cleanup;
}
pthread_mutex_lock(&lock);
- if(!test_failure)
- test_failure = res;
+ if(!t1565_test_failure)
+ t1565_test_failure = res;
pthread_mutex_unlock(&lock);
url = URL;
- result = pthread_create(&tid, NULL, run_thread, NULL);
+ result = pthread_create(&tid, NULL, t1565_run_thread, NULL);
if(!result)
tid_valid = true;
else {
test_cleanup:
pthread_mutex_lock(&lock);
- if(!test_failure)
- test_failure = res;
+ if(!t1565_test_failure)
+ t1565_test_failure = res;
pthread_mutex_unlock(&lock);
if(tid_valid)
curl_easy_cleanup(started_handles[i]);
curl_global_cleanup();
- return test_failure;
+ return t1565_test_failure;
}
#else /* without pthread, this test doesn't work */
#include "memdebug.h"
-static char testdata[] = "request indicates that the client, which made";
+static char t1576_testdata[] = "request indicates that the client, which made";
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
+static size_t t1576_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
- size_t amount = nmemb * size; /* Total bytes curl wants */
- if(amount < strlen(testdata)) {
- return strlen(testdata);
+ size_t amount = nmemb * size; /* Total bytes curl wants */
+ if(amount < strlen(t1576_testdata)) {
+ return strlen(t1576_testdata);
}
(void)stream;
- memcpy(ptr, testdata, strlen(testdata));
- return strlen(testdata);
+ memcpy(ptr, t1576_testdata, strlen(t1576_testdata));
+ return strlen(t1576_testdata);
}
-static int seek_callback(void *ptr, curl_off_t offset, int origin)
+static int t1576_seek_callback(void *ptr, curl_off_t offset, int origin)
{
(void)ptr;
(void)offset;
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
- test_setopt(curl, CURLOPT_SEEKFUNCTION, seek_callback);
- test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(testdata));
+ test_setopt(curl, CURLOPT_READFUNCTION, t1576_read_cb);
+ test_setopt(curl, CURLOPT_SEEKFUNCTION, t1576_seek_callback);
+ test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(t1576_testdata));
test_setopt(curl, CURLOPT_CUSTOMREQUEST, "CURL");
if(testno == 1578) {
#include <stdio.h>
#include "memdebug.h"
-static char testdata[] = "Hello Cloud!\r\n";
static size_t consumed = 0;
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
+static size_t t1591_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
- size_t amount = nmemb * size; /* Total bytes curl wants */
+ static const char testdata[] = "Hello Cloud!\r\n";
+
+ size_t amount = nmemb * size; /* Total bytes curl wants */
if(consumed == strlen(testdata)) {
return 0;
}
- if(amount > strlen(testdata)-consumed) {
+ if(amount > strlen(testdata) - consumed) {
amount = strlen(testdata);
}
/*
* carefully not leak memory on OOM
*/
-static int trailers_callback(struct curl_slist **list, void *userdata)
+static int t1591_trailers_callback(struct curl_slist **list, void *userdata)
{
struct curl_slist *nlist = NULL;
struct curl_slist *nlist2 = NULL;
test_setopt(curl, CURLOPT_URL, URL);
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_UPLOAD, 1L);
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
- test_setopt(curl, CURLOPT_TRAILERFUNCTION, trailers_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t1591_read_cb);
+ test_setopt(curl, CURLOPT_TRAILERFUNCTION, t1591_trailers_callback);
test_setopt(curl, CURLOPT_TRAILERDATA, NULL);
res = curl_easy_perform(curl);
/* We're willing to wait a very generous two seconds for the removal. This is
as low as we can go while still easily supporting SIGALRM timing for the
non-threaded blocking resolver. It doesn't matter that much because when
- the test passes, we never wait this long. We set it much higher to avoid
- issues when running on overloaded CI machines. */
-#define TEST_HANG_TIMEOUT 60 * 1000
+ the test passes, we never wait this long. We set it much higher via
+ the default TEST_HANG_TIMEOUT to avoid issues when running on overloaded
+ CI machines. */
#include "test.h"
#include "testutil.h"
/*
* carefully not leak memory on OOM
*/
-static int trailers_callback(struct curl_slist **list, void *userdata)
+static int t1598_trailers_callback(struct curl_slist **list, void *userdata)
{
struct curl_slist *nlist = NULL;
struct curl_slist *nlist2 = NULL;
}
}
-static const char *post_data = "xxx=yyy&aaa=bbbbb";
-
CURLcode test(char *URL)
{
+ static const char *post_data = "xxx=yyy&aaa=bbbbb";
+
CURL *curl = NULL;
CURLcode res = CURLE_FAILED_INIT;
/* http and proxy header list */
test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(post_data));
test_setopt(curl, CURLOPT_POSTFIELDS, post_data);
- test_setopt(curl, CURLOPT_TRAILERFUNCTION, trailers_callback);
+ test_setopt(curl, CURLOPT_TRAILERFUNCTION, t1598_trailers_callback);
test_setopt(curl, CURLOPT_TRAILERDATA, NULL);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
***************************************************************************/
#include "test.h"
-static char testdata[]="mooaaa";
-
-struct WriteThis {
+struct t1662_WriteThis {
size_t sizeleft;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t1662_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ static const char testdata[] = "mooaaa";
+
+ struct t1662_WriteThis *pooh = (struct t1662_WriteThis *)userp;
size_t len = strlen(testdata);
if(size*nmemb < len)
return 0; /* no more data left to deliver */
}
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
CURL *hnd;
curl_mime *mime1;
curl_mimepart *part1;
- struct WriteThis pooh = { 1 };
+ struct t1662_WriteThis pooh = { 1 };
mime1 = NULL;
mime1 = curl_mime_init(hnd);
if(mime1) {
part1 = curl_mime_addpart(mime1);
- curl_mime_data_cb(part1, -1, read_callback, NULL, NULL, &pooh);
+ curl_mime_data_cb(part1, -1, t1662_read_cb, NULL, NULL, &pooh);
curl_mime_filename(part1, "poetry.txt");
curl_mime_name(part1, "content");
curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1);
#include "warnless.h"
#include "memdebug.h"
-
-
-static const char *chunks[]={
- "one",
- "two",
- "three",
- "four",
- NULL
-};
-
-
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
+static size_t t1901_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
+ static const char *chunks[] = {
+ "one",
+ "two",
+ "three",
+ "four",
+ NULL
+ };
static int ix = 0;
(void)size;
(void)nmemb;
ignores it */
easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 4L);
easy_setopt(curl, CURLOPT_POSTFIELDS, NULL);
- easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ easy_setopt(curl, CURLOPT_READFUNCTION, t1901_read_cb);
easy_setopt(curl, CURLOPT_POST, 1L);
easy_setopt(curl, CURLOPT_VERBOSE, 1L);
easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
define not publicly exposed so we set our own */
#define MAX_INPUT_LENGTH 8000000
-static char testbuf[MAX_INPUT_LENGTH + 2];
-
CURLcode test(char *URL)
{
+ static char testbuf[MAX_INPUT_LENGTH + 2];
+
const struct curl_easyoption *o;
CURL *easy;
int error = 0;
#include "warnless.h"
#include "memdebug.h"
-struct entry {
- const char *name;
- const char *exp;
-};
-
-static const struct entry preload_hosts[] = {
-#if (SIZEOF_TIME_T < 5)
- { "1.example.com", "20370320 01:02:03" },
- { "2.example.com", "20370320 03:02:01" },
- { "3.example.com", "20370319 01:02:03" },
-#else
- { "1.example.com", "25250320 01:02:03" },
- { "2.example.com", "25250320 03:02:01" },
- { "3.example.com", "25250319 01:02:03" },
-#endif
- { "4.example.com", "" },
- { NULL, NULL } /* end of list marker */
-};
-
struct state {
int index;
};
static CURLSTScode hstsread(CURL *easy, struct curl_hstsentry *e,
void *userp)
{
+ struct entry {
+ const char *name;
+ const char *exp;
+ };
+
+ static const struct entry preload_hosts[] = {
+#if (SIZEOF_TIME_T < 5)
+ { "1.example.com", "20370320 01:02:03" },
+ { "2.example.com", "20370320 03:02:01" },
+ { "3.example.com", "20370319 01:02:03" },
+#else
+ { "1.example.com", "25250320 01:02:03" },
+ { "2.example.com", "25250320 03:02:01" },
+ { "3.example.com", "25250319 01:02:03" },
+#endif
+ { "4.example.com", "" },
+ { NULL, NULL } /* end of list marker */
+ };
+
const char *host;
const char *expire;
struct state *s = (struct state *)userp;
#include "memdebug.h"
-static const char *testdata[]={
- "daTE",
- "Server",
- "content-type",
- "content-length",
- "location",
- "set-cookie",
- "silly-thing",
- "fold",
- "blank",
- "Blank2",
- NULL
-};
+#ifndef LIB1940_C
+#define LIB1940_C
-#ifdef LIB1946
-#define HEADER_REQUEST 0
-#else
-#define HEADER_REQUEST -1
-#endif
+static size_t t1940_write_cb(char *data, size_t n, size_t l, void *userp)
+{
+ /* take care of the data here, ignored in this example */
+ (void)data;
+ (void)userp;
+ return n*l;
+}
-static void showem(CURL *easy, unsigned int type)
+static void t1940_showem(CURL *easy, int header_request, unsigned int type)
{
+ static const char *testdata[] = {
+ "daTE",
+ "Server",
+ "content-type",
+ "content-length",
+ "location",
+ "set-cookie",
+ "silly-thing",
+ "fold",
+ "blank",
+ "Blank2",
+ NULL
+ };
+
int i;
struct curl_header *header;
for(i = 0; testdata[i]; i++) {
- if(CURLHE_OK == curl_easy_header(easy, testdata[i], 0, type,
- HEADER_REQUEST, &header)) {
+ if(CURLHE_OK == curl_easy_header(easy, testdata[i], 0,
+ type, header_request, &header)) {
if(header->amount > 1) {
/* more than one, iterate over them */
size_t index = 0;
if(++index == amount)
break;
- if(CURLHE_OK != curl_easy_header(easy, testdata[i], index, type,
- HEADER_REQUEST, &header))
+ if(CURLHE_OK != curl_easy_header(easy, testdata[i], index,
+ type, header_request, &header))
break;
} while(1);
}
}
}
}
+#endif
-static size_t write_cb(char *data, size_t n, size_t l, void *userp)
-{
- /* take care of the data here, ignored in this example */
- (void)data;
- (void)userp;
- return n*l;
-}
CURLcode test(char *URL)
{
CURL *easy = NULL;
CURLcode res = CURLE_OK;
+ int header_request;
+#ifdef LIB1946
+ header_request = 0;
+#else
+ header_request = -1;
+#endif
+
global_init(CURL_GLOBAL_DEFAULT);
easy_init(easy);
easy_setopt(easy, CURLOPT_URL, URL);
easy_setopt(easy, CURLOPT_VERBOSE, 1L);
easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L);
/* ignores any content */
- easy_setopt(easy, CURLOPT_WRITEFUNCTION, write_cb);
+ easy_setopt(easy, CURLOPT_WRITEFUNCTION, t1940_write_cb);
/* if there's a proxy set, use it */
if(libtest_arg2 && *libtest_arg2) {
if(res)
goto test_cleanup;
- showem(easy, CURLH_HEADER);
+ t1940_showem(easy, header_request, CURLH_HEADER);
if(libtest_arg2 && *libtest_arg2) {
/* now show connect headers only */
- showem(easy, CURLH_CONNECT);
+ t1940_showem(easy, header_request, CURLH_CONNECT);
}
- showem(easy, CURLH_1XX);
- showem(easy, CURLH_TRAILER);
+ t1940_showem(easy, header_request, CURLH_1XX);
+ t1940_showem(easy, header_request, CURLH_TRAILER);
test_cleanup:
curl_easy_cleanup(easy);
#include "memdebug.h"
-static void showem(CURL *easy, unsigned int type)
+static void t1945_showem(CURL *easy, unsigned int type)
{
struct curl_header *header = NULL;
struct curl_header *prev = NULL;
}
}
-static size_t write_cb(char *data, size_t n, size_t l, void *userp)
+static size_t t1945_write_cb(char *data, size_t n, size_t l, void *userp)
{
/* take care of the data here, ignored in this example */
(void)data;
curl_easy_setopt(easy, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L);
/* ignores any content */
- curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, write_cb);
+ curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, t1945_write_cb);
/* if there's a proxy set, use it */
if(libtest_arg2 && *libtest_arg2) {
if(res) {
curl_mprintf("badness: %d\n", res);
}
- showem(easy, CURLH_CONNECT|CURLH_HEADER|CURLH_TRAILER|CURLH_1XX);
+ t1945_showem(easy, CURLH_CONNECT|CURLH_HEADER|CURLH_TRAILER|CURLH_1XX);
test_cleanup:
curl_easy_cleanup(easy);
#include "memdebug.h"
-static size_t writecb(char *data, size_t n, size_t l, void *userp)
+static size_t t1947_write_cb(char *data, size_t n, size_t l, void *userp)
{
/* ignore the data */
(void)data;
/* perform a request that involves redirection */
easy_setopt(curl, CURLOPT_URL, URL);
- easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
+ easy_setopt(curl, CURLOPT_WRITEFUNCTION, t1947_write_cb);
easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
if(res) {
#include "memdebug.h"
-static size_t read_callback(char *buffer, size_t size, size_t nitems,
- void *userdata)
+static size_t t1971_read_cb(char *ptr, size_t size, size_t nitems, void *userp)
{
- (void)buffer; /* unused */
+ (void)ptr; /* unused */
(void)size; /* unused */
(void)nitems; /* unused */
- (void)userdata; /* unused */
+ (void)userp; /* unused */
return 0;
}
}
test_setopt(curl, CURLOPT_UPLOAD, 1L);
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t1971_read_cb);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3");
test_setopt(curl, CURLOPT_USERPWD, "xxx");
#include "memdebug.h"
-static size_t read_callback(char *buffer, size_t size, size_t nitems,
- void *userdata)
+static size_t t1975_read_cb(char *ptr, size_t size, size_t nitems, void *userp)
{
- (void)buffer; /* unused */
+ (void)ptr; /* unused */
(void)size; /* unused */
(void)nitems; /* unused */
- (void)userdata; /* unused */
+ (void)userp; /* unused */
return 0;
}
}
test_setopt(curl, CURLOPT_UPLOAD, 1L);
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t1975_read_cb);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_AWS_SIGV4, "aws:amz:us-east-1:s3");
test_setopt(curl, CURLOPT_USERPWD, "xxx");
#ifndef CURL_DISABLE_WEBSOCKETS
#if 0
-static CURLcode send_ping(CURL *curl, const char *send_payload)
+static CURLcode t2301_send_ping(CURL *curl, const char *send_payload)
{
size_t sent;
CURLcode result =
return result;
}
-static CURLcode recv_pong(CURL *curl, const char *expected_payload)
+static CURLcode t2301_recv_pong(CURL *curl, const char *expected_payload)
{
size_t rlen;
unsigned int rflags;
}
/* just close the connection */
-static void websocket_close(CURL *curl)
+static void t2301_websocket_close(CURL *curl)
{
size_t sent;
CURLcode result =
"ws: curl_ws_send returned %d, sent %d\n", result, (int)sent);
}
-static void websocket(CURL *curl)
+static void t2301_websocket(CURL *curl)
{
int i = 0;
curl_mfprintf(stderr, "ws: websocket() starts\n");
do {
- if(send_ping(curl, "foobar"))
+ if(t2301_send_ping(curl, "foobar"))
return;
- if(recv_pong(curl, "foobar"))
+ if(t2301_recv_pong(curl, "foobar"))
return;
sleep(2);
} while(i++ < 10);
- websocket_close(curl);
+ t2301_websocket_close(curl);
}
#endif
-static size_t writecb(char *b, size_t size, size_t nitems, void *p)
+static size_t t2301_write_cb(char *b, size_t size, size_t nitems, void *p)
{
CURL *easy = p;
unsigned char *buffer = (unsigned char *)b;
curl_easy_setopt(curl, CURLOPT_USERAGENT, "webbie-sox/3");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_WS_OPTIONS, (long)CURLWS_RAW_MODE);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, t2301_write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl);
res = curl_easy_perform(curl);
curl_mfprintf(stderr, "curl_easy_perform() returned %d\n", res);
#if 0
if(res == CURLE_OK)
- websocket(curl);
+ t2301_websocket(curl);
#endif
/* always cleanup */
curl_easy_cleanup(curl);
}
-static size_t writecb(char *buffer, size_t size, size_t nitems, void *p)
+static size_t t2302_write_cb(char *buffer, size_t size, size_t nitems, void *p)
{
struct ws_data *ws_data = p;
size_t incoming = nitems;
/* use the callback style */
curl_easy_setopt(curl, CURLOPT_USERAGENT, "webbie-sox/3");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, t2302_write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ws_data);
res = curl_easy_perform(curl);
curl_mfprintf(stderr, "curl_easy_perform() returned %d\n", res);
#ifndef CURL_DISABLE_WEBSOCKETS
-static CURLcode send_ping(CURL *curl, const char *send_payload)
+static CURLcode t2304_send_ping(CURL *curl, const char *send_payload)
{
size_t sent;
CURLcode result =
return result;
}
-static CURLcode recv_pong(CURL *curl, const char *expected_payload)
+static CURLcode t2304_recv_pong(CURL *curl, const char *expected_payload)
{
size_t rlen;
const struct curl_ws_frame *meta;
}
/* just close the connection */
-static void websocket_close(CURL *curl)
+static void t2304_websocket_close(CURL *curl)
{
size_t sent;
CURLcode result =
"ws: curl_ws_send returned %d, sent %u\n", result, (int)sent);
}
-static void websocket(CURL *curl)
+static void t2304_websocket(CURL *curl)
{
int i = 0;
curl_mfprintf(stderr, "ws: websocket() starts\n");
do {
recv_any(curl);
curl_mfprintf(stderr, "Send ping\n");
- if(send_ping(curl, "foobar"))
+ if(t2304_send_ping(curl, "foobar"))
return;
curl_mfprintf(stderr, "Receive pong\n");
- if(recv_pong(curl, "foobar")) {
+ if(t2304_recv_pong(curl, "foobar")) {
curl_mprintf("Connection closed\n");
return;
}
sleep(2);
} while(i++ < 10);
- websocket_close(curl);
+ t2304_websocket_close(curl);
}
CURLcode test(char *URL)
res = curl_easy_perform(curl);
curl_mfprintf(stderr, "curl_easy_perform() returned %d\n", res);
if(res == CURLE_OK)
- websocket(curl);
+ t2304_websocket(curl);
/* always cleanup */
curl_easy_cleanup(curl);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
#ifdef _WIN32
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
-static DWORD WINAPI run_thread(LPVOID ptr)
+static DWORD WINAPI t3026_run_thread(LPVOID ptr)
#else
#include <process.h>
-static unsigned int WINAPI run_thread(void *ptr)
+static unsigned int WINAPI t3026_run_thread(void *ptr)
#endif
{
CURLcode *result = ptr;
curl_win_thread_handle_t th;
results[i] = CURL_LAST; /* initialize with invalid value */
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
- th = CreateThread(NULL, 0, run_thread, &results[i], 0, NULL);
+ th = CreateThread(NULL, 0, t3026_run_thread, &results[i], 0, NULL);
#else
- th = _beginthreadex(NULL, 0, run_thread, &results[i], 0, NULL);
+ th = _beginthreadex(NULL, 0, t3026_run_thread, &results[i], 0, NULL);
#endif
if(!th) {
curl_mfprintf(stderr, "%s:%d Couldn't create thread, errno %lu\n",
#include <pthread.h>
#include <unistd.h>
-static void *run_thread(void *ptr)
+static void *t3026_run_thread(void *ptr)
{
CURLcode *result = ptr;
for(i = 0; i < tid_count; i++) {
int res;
results[i] = CURL_LAST; /* initialize with invalid value */
- res = pthread_create(&tids[i], NULL, run_thread, &results[i]);
+ res = pthread_create(&tids[i], NULL, t3026_run_thread, &results[i]);
if(res) {
curl_mfprintf(stderr, "%s:%d Couldn't create thread, errno %d\n",
__FILE__, __LINE__, res);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURL *curls = NULL;
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
-static void test_lock(CURL *handle, curl_lock_data data,
- curl_lock_access laccess, void *useptr)
+static void t3207_test_lock(CURL *handle, curl_lock_data data,
+ curl_lock_access laccess, void *useptr)
{
curl_mutex_t *mutexes = (curl_mutex_t*) useptr;
(void)handle;
Curl_mutex_acquire(&mutexes[data]);
}
-static void test_unlock(CURL *handle, curl_lock_data data, void *useptr)
+static void t3207_test_unlock(CURL *handle, curl_lock_data data, void *useptr)
{
curl_mutex_t *mutexes = (curl_mutex_t*) useptr;
(void)handle;
for(i = 0; i < CURL_LOCK_DATA_LAST - 1; i++) {
Curl_mutex_init(&mutexes[i]);
}
- curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock);
- curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock);
+ curl_share_setopt(share, CURLSHOPT_LOCKFUNC, t3207_test_lock);
+ curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, t3207_test_unlock);
curl_share_setopt(share, CURLSHOPT_USERDATA, (void *)mutexes);
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURL *curl = NULL;
testcounter = 0;
}
-#else
-#define setupcallbacks(x) Curl_nop_stmt
#endif
if(libtest_arg3 && !strcmp(libtest_arg3, "activeftp"))
test_setopt(curl, CURLOPT_FTPPORT, "-");
+#ifdef LIB585
setupcallbacks(curl);
+#endif
res = curl_easy_perform(curl);
return res;
}
-
-#undef setupcallbacks
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
/*
* Get a single URL without select().
*/
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
/*
* Source code in here hugely as reported in bug report 651460 by
* Christopher R. Palmer.
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
/*
* Source code in here hugely as reported in bug report 651464 by
* Christopher R. Palmer.
*
***************************************************************************/
#include "test.h"
+
+#include "testutil.h"
#include "memdebug.h"
-static const char * const HOSTHEADER = "Host: www.host.foo.com";
#define JAR libtest_arg2
#define THREADS 2
/* struct containing data of a thread */
-struct Tdata {
+struct t506_Tdata {
CURLSH *share;
char *url;
};
-struct userdata {
+struct t506_userdata {
const char *text;
int counter;
};
static int locks[3];
/* lock callback */
-static void test_lock(CURL *handle, curl_lock_data data,
- curl_lock_access laccess, void *useptr)
+static void t506_test_lock(CURL *handle, curl_lock_data data,
+ curl_lock_access laccess, void *useptr)
{
const char *what;
- struct userdata *user = (struct userdata *)useptr;
+ struct t506_userdata *user = (struct t506_userdata *)useptr;
int locknum;
(void)handle;
}
/* unlock callback */
-static void test_unlock(CURL *handle, curl_lock_data data, void *useptr)
+static void t506_test_unlock(CURL *handle, curl_lock_data data, void *useptr)
{
const char *what;
- struct userdata *user = (struct userdata *)useptr;
+ struct t506_userdata *user = (struct t506_userdata *)useptr;
int locknum;
(void)handle;
switch(data) {
user->counter++;
}
-
/* build host entry */
static struct curl_slist *sethost(struct curl_slist *headers)
{
(void)headers;
- return curl_slist_append(NULL, HOSTHEADER);
+ return curl_slist_append(NULL, "Host: www.host.foo.com");
}
-
/* the dummy thread function */
-static void *test_fire(void *ptr)
+static void *t506_test_fire(void *ptr)
{
CURLcode code;
struct curl_slist *headers;
- struct Tdata *tdata = (struct Tdata*)ptr;
+ struct t506_Tdata *tdata = (struct t506_Tdata*)ptr;
CURL *curl;
curl = curl_easy_init();
return NULL;
}
-
-/* build request url */
-static char *suburl(const char *base, int i)
-{
- return curl_maprintf("%s%.4d", base, i);
-}
-
-
/* test function */
CURLcode test(char *URL)
{
CURLSHcode scode = CURLSHE_OK;
CURLcode code = CURLE_OK;
char *url = NULL;
- struct Tdata tdata;
+ struct t506_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;
+ struct t506_userdata user;
user.text = "Pigs in space";
user.counter = 0;
if(CURLSHE_OK == scode) {
curl_mprintf("CURLSHOPT_LOCKFUNC\n");
- scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock);
+ scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, t506_test_lock);
}
if(CURLSHE_OK == scode) {
curl_mprintf("CURLSHOPT_UNLOCKFUNC\n");
- scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock);
+ scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, t506_test_unlock);
}
if(CURLSHE_OK == scode) {
curl_mprintf("CURLSHOPT_USERDATA\n");
for(i = 1; i <= THREADS; i++) {
/* set thread data */
- tdata.url = suburl(URL, i); /* must be curl_free()d */
+ tdata.url = tutil_suburl(URL, i); /* must be curl_free()d */
tdata.share = share;
/* simulate thread, direct call of "thread" function */
curl_mprintf("*** run %d\n",i);
- test_fire(&tdata);
+ t506_test_fire(&tdata);
curl_free(tdata.url);
}
return TEST_ERR_MAJOR_BAD;
}
- url = suburl(URL, i);
+ url = tutil_suburl(URL, i);
headers = sethost(NULL);
test_setopt(curl, CURLOPT_HTTPHEADER, headers);
test_setopt(curl, CURLOPT_URL, url);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
- url = suburl(URL, i);
+ url = tutil_suburl(URL, i);
headers = sethost(NULL);
test_setopt(curl, CURLOPT_HTTPHEADER, headers);
test_setopt(curl, CURLOPT_URL, url);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURL *curls = NULL;
#include "memdebug.h"
-static char testdata[]="this is what we post to the silly web server\n";
-
-struct WriteThis {
- char *readptr;
+struct t508_WriteThis {
+ const char *readptr;
size_t sizeleft;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t508_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ struct t508_WriteThis *pooh = (struct t508_WriteThis *)userp;
if(size*nmemb < 1)
return 0;
CURLcode test(char *URL)
{
+ static const char testdata[] =
+ "this is what we post to the silly web server\n";
+
CURL *curl;
CURLcode res = CURLE_OK;
- struct WriteThis pooh;
+ struct t508_WriteThis pooh;
pooh.readptr = testdata;
pooh.sizeleft = strlen(testdata);
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
/* we want to use our own read function */
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t508_read_cb);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
#include "memdebug.h"
-static const char * const testpost[]={
- "one",
- "two",
- "three",
- "and a final longer crap: four",
- NULL
-};
-
+#ifndef LIB510_C
+#define LIB510_C
-struct WriteThis {
+struct t510_WriteThis {
int counter;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t510_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ static const char * const testpost[] = {
+ "one",
+ "two",
+ "three",
+ "and a final longer crap: four",
+ NULL
+ };
+
+ struct t510_WriteThis *pooh = (struct t510_WriteThis *)userp;
const char *data;
if(size*nmemb < 1)
}
return 0; /* no more data left to deliver */
}
+#endif
CURLcode test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
struct curl_slist *slist = NULL;
- struct WriteThis pooh;
+ struct t510_WriteThis pooh;
pooh.counter = 0;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
test_setopt(curl, CURLOPT_POST, 1L);
/* we want to use our own read function */
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t510_read_cb);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
#include "memdebug.h"
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t513_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
(void)ptr;
(void)size;
test_setopt(curl, CURLOPT_POSTFIELDSIZE, 1L);
/* we want to use our own read function */
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t513_read_cb);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, NULL);
#include "memdebug.h"
-struct dcheck {
- const char *input;
- time_t output;
-};
+CURLcode test(char *URL)
+{
+ struct dcheck {
+ const char *input;
+ time_t output;
+ };
-static const struct dcheck dates[] = {
- {"Sun, 06 Nov 1994 08:49:37 GMT", 784111777 },
- {"Sunday, 06-Nov-94 08:49:37 GMT", 784111777 },
- {"Sun Nov 6 08:49:37 1994", 784111777 },
- {"Sun Nov 6 8:49:37 1994", 784111777 },
- {"Sun Nov 6 8:9:37 1994", 784109377 },
- {"Sun Nov 6 008:09:37 1994", -1 },
- {"Nov Sun 6 8:9:7 1994", 784109347 },
- {"06 Nov 1994 08:49:37 GMT", 784111777 },
- {"06-Nov-94 08:49:37 GMT", 784111777 },
- {"Nov 6 08:49:37 1994", 784111777 },
- {"06 Nov 1994 08:49:37", 784111777 },
- {"06-Nov-94 08:49:37", 784111777 },
- {"1994 Nov 6 08:49:37", 784111777 },
- {"GMT 08:49:37 06-Nov-94 Sunday", 784111777 },
- {"94 6 Nov 08:49:37", 784111777 },
- {"1994 Nov 6", 784080000 },
- {"06-Nov-94", 784080000 },
- {"Sun Nov 6 94", 784080000 },
- {"1994.Nov.6", 784080000 },
- {"Sun/Nov/6/94/GMT", 784080000 },
- {"Sun, 06 Nov 1994 08:49:37 CET", 784108177 },
- {"06 Nov 1994 08:49:37 EST", 784129777 },
- {"Sun, 06 Nov 1994 08:49:37 UT", 784111777 },
- {"Sun, 12 Sep 2004 15:05:58 -0700", 1095026758 },
- {"Sat, 11 Sep 2004 21:32:11 +0200", 1094931131 },
- {"20040912 15:05:58 -0700", 1095026758 },
- {"20040911 +0200", 1094853600 },
- {"Thu, 01-Jan-1970 00:59:59 GMT", 3599 },
- {"Thu, 01-Jan-1970 01:00:00 GMT", 3600 },
- {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 },
- {"Thu, 19-Apr-2007 16:00:00 GMT", 1176998400 },
- {"Wed, 25 Apr 2007 21:02:13 GMT", 1177534933 },
- {"Thu, 19/Apr\\2007 16:00:00 GMT", 1176998400 },
- {"Fri, 1 Jan 2010 01:01:50 GMT", 1262307710 },
- {"Wednesday, 1-Jan-2003 00:00:00 GMT", 1041379200 },
- {", 1-Jan-2003 00:00:00 GMT", 1041379200 },
- {"1-Jan-2003 00:00:00 GMT", 1041379200 },
- {"1-Jan-2003 00:00:00 GMT", 1041379200 },
- {"Wed,18-Apr-07 22:50:12 GMT", 1176936612 },
- {"WillyWonka , 18-Apr-07 22:50:12 GMT", -1 },
- {"WillyWonka , 18-Apr-07 22:50:12", -1 },
- {"WillyWonka , 18-apr-07 22:50:12", -1 },
- {"Mon, 18-Apr-1977 22:50:13 GMT", 230251813 },
- {"Mon, 18-Apr-77 22:50:13 GMT", 230251813 },
- {"Sat, 15-Apr-17\"21:01:22\"GMT", 1492290082 },
- {"Partyday, 18- April-07 22:50:12", -1 },
- {"Partyday, 18 - Apri-07 22:50:12", -1 },
- {"Wednes, 1-Januar-2003 00:00:00 GMT", -1 },
- {"Sat, 15-Apr-17 21:01:22", 1492290082 },
- {"Sat, 15-Apr-17 21:01:22 GMT-2", 1492290082 },
- {"Sat, 15-Apr-17 21:01:22 GMT BLAH", 1492290082 },
- {"Sat, 15-Apr-17 21:01:22 GMT-0400", 1492290082 },
- {"Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", 1492290082 },
- {"Sat, 15-Apr-17 21:01:22 DST", -1 },
- {"Sat, 15-Apr-17 21:01:22 -0400", 1492304482 },
- {"Sat, 15-Apr-17 21:01:22 (hello there)", -1 },
- {"Sat, 15-Apr-17 21:01:22 11:22:33", -1 },
- {"Sat, 15-Apr-17 ::00 21:01:22", -1 },
- {"Sat, 15-Apr-17 boink:z 21:01:22", -1 },
- {"Sat, 15-Apr-17 91:22:33 21:01:22", -1 },
- {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 },
- {"22:50:12 Thu Apr 18 2007 GMT", 1176936612 },
- {"Thu 22:50:12 Apr 18 2007 GMT", 1176936612 },
- {"Thu Apr 22:50:12 18 2007 GMT", 1176936612 },
- {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 },
- {"Thu Apr 18 2007 22:50:12 GMT", 1176936612 },
- {"Thu Apr 18 2007 GMT 22:50:12", 1176936612 },
+ static const struct dcheck dates[] = {
+ {"Sun, 06 Nov 1994 08:49:37 GMT", 784111777 },
+ {"Sunday, 06-Nov-94 08:49:37 GMT", 784111777 },
+ {"Sun Nov 6 08:49:37 1994", 784111777 },
+ {"Sun Nov 6 8:49:37 1994", 784111777 },
+ {"Sun Nov 6 8:9:37 1994", 784109377 },
+ {"Sun Nov 6 008:09:37 1994", -1 },
+ {"Nov Sun 6 8:9:7 1994", 784109347 },
+ {"06 Nov 1994 08:49:37 GMT", 784111777 },
+ {"06-Nov-94 08:49:37 GMT", 784111777 },
+ {"Nov 6 08:49:37 1994", 784111777 },
+ {"06 Nov 1994 08:49:37", 784111777 },
+ {"06-Nov-94 08:49:37", 784111777 },
+ {"1994 Nov 6 08:49:37", 784111777 },
+ {"GMT 08:49:37 06-Nov-94 Sunday", 784111777 },
+ {"94 6 Nov 08:49:37", 784111777 },
+ {"1994 Nov 6", 784080000 },
+ {"06-Nov-94", 784080000 },
+ {"Sun Nov 6 94", 784080000 },
+ {"1994.Nov.6", 784080000 },
+ {"Sun/Nov/6/94/GMT", 784080000 },
+ {"Sun, 06 Nov 1994 08:49:37 CET", 784108177 },
+ {"06 Nov 1994 08:49:37 EST", 784129777 },
+ {"Sun, 06 Nov 1994 08:49:37 UT", 784111777 },
+ {"Sun, 12 Sep 2004 15:05:58 -0700", 1095026758 },
+ {"Sat, 11 Sep 2004 21:32:11 +0200", 1094931131 },
+ {"20040912 15:05:58 -0700", 1095026758 },
+ {"20040911 +0200", 1094853600 },
+ {"Thu, 01-Jan-1970 00:59:59 GMT", 3599 },
+ {"Thu, 01-Jan-1970 01:00:00 GMT", 3600 },
+ {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 },
+ {"Thu, 19-Apr-2007 16:00:00 GMT", 1176998400 },
+ {"Wed, 25 Apr 2007 21:02:13 GMT", 1177534933 },
+ {"Thu, 19/Apr\\2007 16:00:00 GMT", 1176998400 },
+ {"Fri, 1 Jan 2010 01:01:50 GMT", 1262307710 },
+ {"Wednesday, 1-Jan-2003 00:00:00 GMT", 1041379200 },
+ {", 1-Jan-2003 00:00:00 GMT", 1041379200 },
+ {"1-Jan-2003 00:00:00 GMT", 1041379200 },
+ {"1-Jan-2003 00:00:00 GMT", 1041379200 },
+ {"Wed,18-Apr-07 22:50:12 GMT", 1176936612 },
+ {"WillyWonka , 18-Apr-07 22:50:12 GMT", -1 },
+ {"WillyWonka , 18-Apr-07 22:50:12", -1 },
+ {"WillyWonka , 18-apr-07 22:50:12", -1 },
+ {"Mon, 18-Apr-1977 22:50:13 GMT", 230251813 },
+ {"Mon, 18-Apr-77 22:50:13 GMT", 230251813 },
+ {"Sat, 15-Apr-17\"21:01:22\"GMT", 1492290082 },
+ {"Partyday, 18- April-07 22:50:12", -1 },
+ {"Partyday, 18 - Apri-07 22:50:12", -1 },
+ {"Wednes, 1-Januar-2003 00:00:00 GMT", -1 },
+ {"Sat, 15-Apr-17 21:01:22", 1492290082 },
+ {"Sat, 15-Apr-17 21:01:22 GMT-2", 1492290082 },
+ {"Sat, 15-Apr-17 21:01:22 GMT BLAH", 1492290082 },
+ {"Sat, 15-Apr-17 21:01:22 GMT-0400", 1492290082 },
+ {"Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", 1492290082 },
+ {"Sat, 15-Apr-17 21:01:22 DST", -1 },
+ {"Sat, 15-Apr-17 21:01:22 -0400", 1492304482 },
+ {"Sat, 15-Apr-17 21:01:22 (hello there)", -1 },
+ {"Sat, 15-Apr-17 21:01:22 11:22:33", -1 },
+ {"Sat, 15-Apr-17 ::00 21:01:22", -1 },
+ {"Sat, 15-Apr-17 boink:z 21:01:22", -1 },
+ {"Sat, 15-Apr-17 91:22:33 21:01:22", -1 },
+ {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 },
+ {"22:50:12 Thu Apr 18 2007 GMT", 1176936612 },
+ {"Thu 22:50:12 Apr 18 2007 GMT", 1176936612 },
+ {"Thu Apr 22:50:12 18 2007 GMT", 1176936612 },
+ {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 },
+ {"Thu Apr 18 2007 22:50:12 GMT", 1176936612 },
+ {"Thu Apr 18 2007 GMT 22:50:12", 1176936612 },
- {"\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 },
- {"-\"22:50:12 Thu Apr 18 2007 GMT\"", 1176936612 },
- {"*\"Thu 22:50:12 Apr 18 2007 GMT\"", 1176936612 },
- {";\"Thu Apr 22:50:12 18 2007 GMT\"", 1176936612 },
- {".\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 },
- {"\"Thu Apr 18 2007 22:50:12 GMT\"", 1176936612 },
- {"\"Thu Apr 18 2007 GMT 22:50:12\"", 1176936612 },
+ {"\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 },
+ {"-\"22:50:12 Thu Apr 18 2007 GMT\"", 1176936612 },
+ {"*\"Thu 22:50:12 Apr 18 2007 GMT\"", 1176936612 },
+ {";\"Thu Apr 22:50:12 18 2007 GMT\"", 1176936612 },
+ {".\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 },
+ {"\"Thu Apr 18 2007 22:50:12 GMT\"", 1176936612 },
+ {"\"Thu Apr 18 2007 GMT 22:50:12\"", 1176936612 },
- {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 },
- {"15-Sat, Apr-17 21:01:22 GMT", 1492290082 },
- {"15-Sat, Apr 21:01:22 GMT 17", 1492290082 },
- {"15-Sat, Apr 21:01:22 GMT 2017", 1492290082 },
- {"15 Apr 21:01:22 2017", 1492290082 },
- {"15 17 Apr 21:01:22", 1492290082 },
- {"Apr 15 17 21:01:22", 1492290082 },
- {"Apr 15 21:01:22 17", 1492290082 },
- {"2017 April 15 21:01:22", -1 },
- {"15 April 2017 21:01:22", -1 },
- {"98 April 17 21:01:22", -1 },
- {"Thu, 012-Aug-2008 20:49:07 GMT", 1218574147 },
- {"Thu, 999999999999-Aug-2007 20:49:07 GMT", -1 },
- {"Thu, 12-Aug-2007 20:61:99999999999 GMT", -1 },
- {"IAintNoDateFool", -1 },
- {"Thu Apr 18 22:50 2007 GMT", 1176936600 },
- {"20110623 12:34:56", 1308832496 },
- {"20110632 12:34:56", -1 },
- {"20110623 56:34:56", -1 },
- {"20111323 12:34:56", -1 },
- {"20110623 12:34:79", -1 },
- {"Wed, 31 Dec 2008 23:59:60 GMT", 1230768000 },
- {"Wed, 31 Dec 2008 23:59:61 GMT", -1 },
- {"Wed, 31 Dec 2008 24:00:00 GMT", -1 },
- {"Wed, 31 Dec 2008 23:60:59 GMT", -1 },
- {"20110623 12:3", 1308830580 },
- {"20110623 1:3", 1308790980 },
- {"20110623 1:30", 1308792600 },
- {"20110623 12:12:3", 1308831123 },
- {"20110623 01:12:3", 1308791523 },
- {"20110623 01:99:30", -1 },
- {"Thu, 01-Jan-1970 00:00:00 GMT", 0 },
- {"Thu, 31-Dec-1969 23:59:58 GMT", -2 },
- {"Thu, 31-Dec-1969 23:59:59 GMT", 0 }, /* avoids -1 ! */
+ {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 },
+ {"15-Sat, Apr-17 21:01:22 GMT", 1492290082 },
+ {"15-Sat, Apr 21:01:22 GMT 17", 1492290082 },
+ {"15-Sat, Apr 21:01:22 GMT 2017", 1492290082 },
+ {"15 Apr 21:01:22 2017", 1492290082 },
+ {"15 17 Apr 21:01:22", 1492290082 },
+ {"Apr 15 17 21:01:22", 1492290082 },
+ {"Apr 15 21:01:22 17", 1492290082 },
+ {"2017 April 15 21:01:22", -1 },
+ {"15 April 2017 21:01:22", -1 },
+ {"98 April 17 21:01:22", -1 },
+ {"Thu, 012-Aug-2008 20:49:07 GMT", 1218574147 },
+ {"Thu, 999999999999-Aug-2007 20:49:07 GMT", -1 },
+ {"Thu, 12-Aug-2007 20:61:99999999999 GMT", -1 },
+ {"IAintNoDateFool", -1 },
+ {"Thu Apr 18 22:50 2007 GMT", 1176936600 },
+ {"20110623 12:34:56", 1308832496 },
+ {"20110632 12:34:56", -1 },
+ {"20110623 56:34:56", -1 },
+ {"20111323 12:34:56", -1 },
+ {"20110623 12:34:79", -1 },
+ {"Wed, 31 Dec 2008 23:59:60 GMT", 1230768000 },
+ {"Wed, 31 Dec 2008 23:59:61 GMT", -1 },
+ {"Wed, 31 Dec 2008 24:00:00 GMT", -1 },
+ {"Wed, 31 Dec 2008 23:60:59 GMT", -1 },
+ {"20110623 12:3", 1308830580 },
+ {"20110623 1:3", 1308790980 },
+ {"20110623 1:30", 1308792600 },
+ {"20110623 12:12:3", 1308831123 },
+ {"20110623 01:12:3", 1308791523 },
+ {"20110623 01:99:30", -1 },
+ {"Thu, 01-Jan-1970 00:00:00 GMT", 0 },
+ {"Thu, 31-Dec-1969 23:59:58 GMT", -2 },
+ {"Thu, 31-Dec-1969 23:59:59 GMT", 0 }, /* avoids -1 ! */
#if SIZEOF_TIME_T > 4
- {"Sun, 06 Nov 2044 08:49:37 GMT", (time_t) 2362034977 },
- {"Sun, 06 Nov 3144 08:49:37 GMT", 37074617377 },
+ {"Sun, 06 Nov 2044 08:49:37 GMT", (time_t) 2362034977 },
+ {"Sun, 06 Nov 3144 08:49:37 GMT", 37074617377 },
#ifndef HAVE_TIME_T_UNSIGNED
#if 0
- /* causes warning on MSVC */
- {"Sun, 06 Nov 1900 08:49:37 GMT", -2182259423 },
+ /* causes warning on MSVC */
+ {"Sun, 06 Nov 1900 08:49:37 GMT", -2182259423 },
#endif
- {"Sun, 06 Nov 1800 08:49:37 GMT", -5337933023 },
- {"Thu, 01-Jan-1583 00:00:00 GMT", -12212553600 },
+ {"Sun, 06 Nov 1800 08:49:37 GMT", -5337933023 },
+ {"Thu, 01-Jan-1583 00:00:00 GMT", -12212553600 },
#endif
- {"Thu, 01-Jan-1499 00:00:00 GMT", -1 },
+ {"Thu, 01-Jan-1499 00:00:00 GMT", -1 },
#else
- {"Sun, 06 Nov 2044 08:49:37 GMT", -1 },
+ {"Sun, 06 Nov 2044 08:49:37 GMT", -1 },
#endif
#ifndef HAVE_TIME_T_UNSIGNED
- {"Sun, 06 Nov 1968 08:49:37 GMT", -36342623 },
+ {"Sun, 06 Nov 1968 08:49:37 GMT", -36342623 },
#endif
- { NULL, 0 }
-};
+ { NULL, 0 }
+ };
-CURLcode test(char *URL)
-{
int i;
int error = 0;
***************************************************************************/
#include "test.h"
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#include <limits.h>
+#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#error "this test requires FD_SETSIZE"
#endif
-#define SAFETY_MARGIN (16)
+#define T518_SAFETY_MARGIN (16)
+
#define NUM_OPEN (FD_SETSIZE + 10)
-#define NUM_NEEDED (NUM_OPEN + SAFETY_MARGIN)
+#define NUM_NEEDED (NUM_OPEN + T518_SAFETY_MARGIN)
#if defined(_WIN32) || defined(MSDOS)
#define DEV_NULL "NUL"
#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
-static int *testfd = NULL;
-static struct rlimit num_open;
-static char msgbuff[256];
+static int *t518_testfd = NULL;
+static struct rlimit t518_num_open;
+static char t518_msgbuff[256];
-static void store_errmsg(const char *msg, int err)
+static void t518_store_errmsg(const char *msg, int err)
{
if(!err)
- curl_msnprintf(msgbuff, sizeof(msgbuff), "%s", msg);
+ curl_msnprintf(t518_msgbuff, sizeof(t518_msgbuff), "%s", msg);
else
- curl_msnprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg,
- err, strerror(err));
+ curl_msnprintf(t518_msgbuff, sizeof(t518_msgbuff), "%s, errno %d, %s", msg,
+ err, strerror(err));
}
-static void close_file_descriptors(void)
+static void t518_close_file_descriptors(void)
{
- for(num_open.rlim_cur = 0;
- num_open.rlim_cur < num_open.rlim_max;
- num_open.rlim_cur++)
- if(testfd[num_open.rlim_cur] > 0)
- close(testfd[num_open.rlim_cur]);
- free(testfd);
- testfd = NULL;
+ for(t518_num_open.rlim_cur = 0;
+ t518_num_open.rlim_cur < t518_num_open.rlim_max;
+ t518_num_open.rlim_cur++)
+ if(t518_testfd[t518_num_open.rlim_cur] > 0)
+ close(t518_testfd[t518_num_open.rlim_cur]);
+ free(t518_testfd);
+ t518_testfd = NULL;
}
-static int fopen_works(void)
+static int t518_fopen_works(void)
{
FILE *fpa[3];
int i;
for(i = 0; i < 3; i++) {
fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
if(!fpa[i]) {
- store_errmsg("fopen failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t518_store_errmsg("fopen failed", errno);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
ret = 0;
break;
}
return ret;
}
-static void rlim2str(char *buf, size_t len, rlim_t val)
-{
-#ifdef RLIM_INFINITY
- if(val == RLIM_INFINITY) {
- curl_msnprintf(buf, len, "INFINITY");
- return;
- }
-#endif
-#ifdef HAVE_LONGLONG
- if(sizeof(rlim_t) > sizeof(long))
- curl_msnprintf(buf, len, "%llu", (unsigned long long)val);
- else
-#endif
- {
- if(sizeof(rlim_t) < sizeof(long))
- curl_msnprintf(buf, len, "%u", (unsigned int)val);
- else
- curl_msnprintf(buf, len, "%lu", (unsigned long)val);
- }
-}
-
-static int test_rlimit(int keep_open)
+static int t518_test_rlimit(int keep_open)
{
rlim_t nitems, i;
int *memchunk = NULL;
/* get initial open file limits */
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
- store_errmsg("getrlimit() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t518_store_errmsg("getrlimit() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
return -1;
}
/* show initial open file limits */
- rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur);
+ tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur);
curl_mfprintf(stderr, "initial soft limit: %s\n", strbuff);
- rlim2str(strbuff, sizeof(strbuff), rl.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_max);
curl_mfprintf(stderr, "initial hard limit: %s\n", strbuff);
/* show our constants */
rl.rlim_cur = OPEN_MAX;
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
/* on failure don't abort just issue a warning */
- store_errmsg("setrlimit() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- msgbuff[0] = '\0';
+ t518_store_errmsg("setrlimit() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
+ t518_msgbuff[0] = '\0';
}
}
#endif
rl.rlim_cur = rl.rlim_max;
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
/* on failure don't abort just issue a warning */
- store_errmsg("setrlimit() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- msgbuff[0] = '\0';
+ t518_store_errmsg("setrlimit() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
+ t518_msgbuff[0] = '\0';
}
/* get current open file limits */
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
- store_errmsg("getrlimit() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t518_store_errmsg("getrlimit() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
return -3;
}
/* show current open file limits */
- rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur);
+ tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur);
curl_mfprintf(stderr, "current soft limit: %s\n", strbuff);
- rlim2str(strbuff, sizeof(strbuff), rl.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_max);
curl_mfprintf(stderr, "current hard limit: %s\n", strbuff);
} /* (rl.rlim_cur != rl.rlim_max) */
/*
* verify that soft limit is higher than NUM_NEEDED,
* which is the number of file descriptors we would
- * try to open plus SAFETY_MARGIN to not exhaust the
+ * try to open plus T518_SAFETY_MARGIN to not exhaust the
* file descriptor pool
*/
- num_open.rlim_cur = NUM_NEEDED;
+ t518_num_open.rlim_cur = NUM_NEEDED;
if((rl.rlim_cur > 0) &&
#ifdef RLIM_INFINITY
(rl.rlim_cur != RLIM_INFINITY) &&
#endif
- (rl.rlim_cur <= num_open.rlim_cur)) {
- rlim2str(strbuff2, sizeof(strbuff2), rl.rlim_cur);
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
+ (rl.rlim_cur <= t518_num_open.rlim_cur)) {
+ tutil_rlim2str(strbuff2, sizeof(strbuff2), rl.rlim_cur);
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_cur);
curl_msnprintf(strbuff, sizeof(strbuff), "fds needed %s > system limit %s",
- strbuff1, strbuff2);
- store_errmsg(strbuff, 0);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ strbuff1, strbuff2);
+ t518_store_errmsg(strbuff, 0);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
return -4;
}
* avoid a low memory condition once the file descriptors are
* open. System conditions that could make the test fail should
* be addressed in the precheck phase. This chunk of memory shall
- * be always free()ed before exiting the test_rlimit() function so
+ * be always free()ed before exiting the t518_test_rlimit() function so
* that it becomes available to the test.
*/
if(nitems > 0x7fff)
nitems = 0x40000;
do {
- num_open.rlim_max = sizeof(*memchunk) * nitems;
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ t518_num_open.rlim_max = sizeof(*memchunk) * nitems;
+ tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max);
curl_mfprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
if(!memchunk) {
}
} while(nitems && !memchunk);
if(!memchunk) {
- store_errmsg("memchunk, malloc() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t518_store_errmsg("memchunk, malloc() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
return -5;
}
/* set the number of file descriptors we will try to open */
- num_open.rlim_max = NUM_OPEN;
+ t518_num_open.rlim_max = NUM_OPEN;
/* verify that we won't overflow size_t in malloc() */
- if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*testfd)) {
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max);
+ if((size_t)(t518_num_open.rlim_max) > ((size_t)-1) / sizeof(*t518_testfd)) {
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_max);
curl_msnprintf(strbuff, sizeof(strbuff),
"unable to allocate an array for %s "
"file descriptors, would overflow size_t", strbuff1);
- store_errmsg(strbuff, 0);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t518_store_errmsg(strbuff, 0);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
free(memchunk);
return -6;
}
/* allocate array for file descriptors */
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max);
curl_mfprintf(stderr, "allocating array for %s file descriptors\n", strbuff);
- testfd = malloc(sizeof(*testfd) * (size_t)(num_open.rlim_max));
- if(!testfd) {
- store_errmsg("testfd, malloc() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t518_testfd = malloc(sizeof(*t518_testfd) *
+ (size_t)(t518_num_open.rlim_max));
+ if(!t518_testfd) {
+ t518_store_errmsg("testfd, malloc() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
free(memchunk);
return -7;
}
curl_mfprintf(stderr, "initializing testfd array\n");
- for(num_open.rlim_cur = 0;
- num_open.rlim_cur < num_open.rlim_max;
- num_open.rlim_cur++)
- testfd[num_open.rlim_cur] = -1;
+ for(t518_num_open.rlim_cur = 0;
+ t518_num_open.rlim_cur < t518_num_open.rlim_max;
+ t518_num_open.rlim_cur++)
+ t518_testfd[t518_num_open.rlim_cur] = -1;
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max);
curl_mfprintf(stderr, "trying to open %s file descriptors\n", strbuff);
/* open a dummy descriptor */
- testfd[0] = open(DEV_NULL, O_RDONLY);
- if(testfd[0] < 0) {
+ t518_testfd[0] = open(DEV_NULL, O_RDONLY);
+ if(t518_testfd[0] < 0) {
curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
- store_errmsg(strbuff, errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- free(testfd);
- testfd = NULL;
+ t518_store_errmsg(strbuff, errno);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
+ free(t518_testfd);
+ t518_testfd = NULL;
free(memchunk);
return -8;
}
/* create a bunch of file descriptors */
- for(num_open.rlim_cur = 1;
- num_open.rlim_cur < num_open.rlim_max;
- num_open.rlim_cur++) {
+ for(t518_num_open.rlim_cur = 1;
+ t518_num_open.rlim_cur < t518_num_open.rlim_max;
+ t518_num_open.rlim_cur++) {
- testfd[num_open.rlim_cur] = dup(testfd[0]);
+ t518_testfd[t518_num_open.rlim_cur] = dup(t518_testfd[0]);
- if(testfd[num_open.rlim_cur] < 0) {
+ if(t518_testfd[t518_num_open.rlim_cur] < 0) {
- testfd[num_open.rlim_cur] = -1;
+ t518_testfd[t518_num_open.rlim_cur] = -1;
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_cur);
curl_msnprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed",
strbuff1);
curl_mfprintf(stderr, "%s\n", strbuff);
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_cur);
curl_msnprintf(strbuff, sizeof(strbuff),
"fds system limit seems close to %s", strbuff1);
curl_mfprintf(stderr, "%s\n", strbuff);
- num_open.rlim_max = NUM_NEEDED;
+ t518_num_open.rlim_max = NUM_NEEDED;
- rlim2str(strbuff2, sizeof(strbuff2), num_open.rlim_max);
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
+ tutil_rlim2str(strbuff2, sizeof(strbuff2), t518_num_open.rlim_max);
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_cur);
curl_msnprintf(strbuff, sizeof(strbuff),
"fds needed %s > system limit %s", strbuff2, strbuff1);
- store_errmsg(strbuff, 0);
- curl_mfprintf(stderr, "%s\n", msgbuff);
-
- for(num_open.rlim_cur = 0;
- testfd[num_open.rlim_cur] >= 0;
- num_open.rlim_cur++)
- close(testfd[num_open.rlim_cur]);
- free(testfd);
- testfd = NULL;
+ t518_store_errmsg(strbuff, 0);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
+
+ for(t518_num_open.rlim_cur = 0;
+ t518_testfd[t518_num_open.rlim_cur] >= 0;
+ t518_num_open.rlim_cur++)
+ close(t518_testfd[t518_num_open.rlim_cur]);
+ free(t518_testfd);
+ t518_testfd = NULL;
free(memchunk);
return -9;
}
}
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max);
curl_mfprintf(stderr, "%s file descriptors open\n", strbuff);
#if !defined(HAVE_POLL) && !defined(USE_WINSOCK)
* with an indication that select limit would be exceeded.
*/
- num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
- if(num_open.rlim_max > num_open.rlim_cur) {
+ t518_num_open.rlim_cur = FD_SETSIZE - T518_SAFETY_MARGIN;
+ if(t518_num_open.rlim_max > t518_num_open.rlim_cur) {
curl_msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
- FD_SETSIZE);
- store_errmsg(strbuff, 0);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- close_file_descriptors();
+ FD_SETSIZE);
+ t518_store_errmsg(strbuff, 0);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
+ t518_close_file_descriptors();
free(memchunk);
return -10;
}
- num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
+ t518_num_open.rlim_cur = FD_SETSIZE - T518_SAFETY_MARGIN;
for(rl.rlim_cur = 0;
- rl.rlim_cur < num_open.rlim_max;
+ rl.rlim_cur < t518_num_open.rlim_max;
rl.rlim_cur++) {
- if((testfd[rl.rlim_cur] > 0) &&
- ((unsigned int)testfd[rl.rlim_cur] > num_open.rlim_cur)) {
+ if((t518_testfd[rl.rlim_cur] > 0) &&
+ ((unsigned int)t518_testfd[rl.rlim_cur] > t518_num_open.rlim_cur)) {
curl_msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
- FD_SETSIZE);
- store_errmsg(strbuff, 0);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- close_file_descriptors();
+ FD_SETSIZE);
+ t518_store_errmsg(strbuff, 0);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
+ t518_close_file_descriptors();
free(memchunk);
return -11;
}
* if it is capable of fopen()ing some additional files.
*/
- if(!fopen_works()) {
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max);
+ if(!t518_fopen_works()) {
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_max);
curl_msnprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open",
strbuff1);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ curl_mfprintf(stderr, "%s\n", t518_msgbuff);
curl_msnprintf(strbuff, sizeof(strbuff),
"fopen fails with lots of fds open");
- store_errmsg(strbuff, 0);
- close_file_descriptors();
+ t518_store_errmsg(strbuff, 0);
+ t518_close_file_descriptors();
free(memchunk);
return -12;
}
/* close file descriptors unless instructed to keep them */
if(!keep_open) {
- close_file_descriptors();
+ t518_close_file_descriptors();
}
return 0;
if(!strcmp(URL, "check")) {
/* used by the test script to ask if we can run this test or not */
- if(test_rlimit(FALSE)) {
- curl_mfprintf(stdout, "test_rlimit problem: %s\n", msgbuff);
+ if(t518_test_rlimit(FALSE)) {
+ curl_mfprintf(stdout, "test_rlimit problem: %s\n", t518_msgbuff);
return TEST_ERR_FAILURE;
}
return CURLE_OK; /* sure, run this! */
}
- if(test_rlimit(TRUE)) {
+ if(t518_test_rlimit(TRUE)) {
/* failure */
return TEST_ERR_MAJOR_BAD;
}
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
curl_mfprintf(stderr, "curl_global_init() failed\n");
- close_file_descriptors();
+ t518_close_file_descriptors();
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
curl_mfprintf(stderr, "curl_easy_init() failed\n");
- close_file_descriptors();
+ t518_close_file_descriptors();
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_cleanup:
- close_file_descriptors();
+ t518_close_file_descriptors();
curl_easy_cleanup(curl);
curl_global_cleanup();
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-#define NUM_HANDLES 4
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-struct Sockets {
+struct t530_Sockets {
curl_socket_t *sockets;
int count; /* number of sockets actually stored in array */
int max_count; /* max number of sockets that fit in allocated array */
};
-struct ReadWriteSockets {
- struct Sockets read, write;
+struct t530_ReadWriteSockets {
+ struct t530_Sockets read, write;
};
/**
* Remove a file descriptor from a sockets array.
*/
-static void removeFd(struct Sockets *sockets, curl_socket_t fd, int mention)
+static void t530_removeFd(struct t530_Sockets *sockets, curl_socket_t fd,
+ int mention)
{
int i;
* Add a file descriptor to a sockets array.
* Return 0 on success, 1 on error.
*/
-static int addFd(struct Sockets *sockets, curl_socket_t fd, const char *what)
+static int t530_addFd(struct t530_Sockets *sockets, curl_socket_t fd,
+ const char *what)
{
/**
* To ensure we only have each file descriptor once, we remove it then add
* it again.
*/
curl_mfprintf(stderr, "Add socket fd %d for %s\n", (int) fd, what);
- removeFd(sockets, fd, 0);
+ t530_removeFd(sockets, fd, 0);
/*
* Allocate array storage when required.
*/
/**
* Callback invoked by curl to poll reading / writing of a socket.
*/
-static int curlSocketCallback(CURL *easy, curl_socket_t s, int action,
- void *userp, void *socketp)
+static int t530_curlSocketCallback(CURL *easy, curl_socket_t s, int action,
+ void *userp, void *socketp)
{
- struct ReadWriteSockets *sockets = userp;
+ struct t530_ReadWriteSockets *sockets = userp;
(void)easy; /* unused */
(void)socketp; /* unused */
}
if(action == CURL_POLL_IN || action == CURL_POLL_INOUT)
- if(addFd(&sockets->read, s, "read"))
+ if(t530_addFd(&sockets->read, s, "read"))
return -1; /* bail out */
if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
- if(addFd(&sockets->write, s, "write"))
+ if(t530_addFd(&sockets->write, s, "write"))
return -1;
if(action == CURL_POLL_REMOVE) {
- removeFd(&sockets->read, s, 1);
- removeFd(&sockets->write, s, 0);
+ t530_removeFd(&sockets->read, s, 1);
+ t530_removeFd(&sockets->write, s, 0);
}
return 0;
/**
* Callback invoked by curl to set a timeout.
*/
-static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
+static int t530_curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
{
struct timeval *timeout = userp;
/**
* Check for curl completion.
*/
-static int checkForCompletion(CURLM *curl, int *success)
+static int t530_checkForCompletion(CURLM *curl, int *success)
{
int result = 0;
*success = 0;
return result;
}
-static int getMicroSecondTimeout(struct timeval *timeout)
+static int t530_getMicroSecondTimeout(struct timeval *timeout)
{
struct timeval now;
ssize_t result;
/**
* Update a fd_set with all of the sockets in use.
*/
-static void updateFdSet(struct Sockets *sockets, fd_set* fdset,
- curl_socket_t *maxFd)
+static void t530_updateFdSet(struct t530_Sockets *sockets, fd_set* fdset,
+ curl_socket_t *maxFd)
{
int i;
for(i = 0; i < sockets->count; ++i) {
/**
* Invoke curl when a file descriptor is set.
*/
-static int checkFdSet(CURLM *curl,
- struct Sockets *sockets, fd_set *fdset,
- int evBitmask, const char *name)
+static int t530_checkFdSet(CURLM *curl, struct t530_Sockets *sockets,
+ fd_set *fdset, int evBitmask, const char *name)
{
int i;
int result = 0;
{
CURLcode res = CURLE_OK;
CURL *curl = NULL; CURLM *m = NULL;
- struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
+ struct t530_ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
int success = 0;
struct timeval timeout = {0};
timeout.tv_sec = (time_t)-1;
multi_init(m);
- multi_setopt(m, CURLMOPT_SOCKETFUNCTION, curlSocketCallback);
+ multi_setopt(m, CURLMOPT_SOCKETFUNCTION, t530_curlSocketCallback);
multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets);
- multi_setopt(m, CURLMOPT_TIMERFUNCTION, curlTimerCallback);
+ multi_setopt(m, CURLMOPT_TIMERFUNCTION, t530_curlTimerCallback);
multi_setopt(m, CURLMOPT_TIMERDATA, &timeout);
multi_add_handle(m, curl);
goto test_cleanup;
}
- while(!checkForCompletion(m, &success)) {
+ while(!t530_checkForCompletion(m, &success)) {
fd_set readSet, writeSet;
curl_socket_t maxFd = 0;
struct timeval tv = {0};
FD_ZERO(&readSet);
FD_ZERO(&writeSet);
- updateFdSet(&sockets.read, &readSet, &maxFd);
- updateFdSet(&sockets.write, &writeSet, &maxFd);
+ t530_updateFdSet(&sockets.read, &readSet, &maxFd);
+ t530_updateFdSet(&sockets.write, &writeSet, &maxFd);
if(timeout.tv_sec != (time_t)-1) {
- int usTimeout = getMicroSecondTimeout(&timeout);
+ int usTimeout = t530_getMicroSecondTimeout(&timeout);
tv.tv_sec = usTimeout / 1000000;
tv.tv_usec = usTimeout % 1000000;
}
select_test((int)maxFd, &readSet, &writeSet, NULL, &tv);
/* Check the sockets for reading / writing */
- if(checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read")) {
+ if(t530_checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN,
+ "read")) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
- if(checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write")) {
+ if(t530_checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT,
+ "write")) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
- if(timeout.tv_sec != (time_t)-1 && getMicroSecondTimeout(&timeout) == 0) {
+ if(timeout.tv_sec != (time_t)-1 &&
+ t530_getMicroSecondTimeout(&timeout) == 0) {
/* Curl's timer has elapsed. */
if(socket_action(m, CURL_SOCKET_TIMEOUT, 0, "timeout")) {
res = TEST_ERR_BAD_TIMEOUT;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "test.h"
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#include <limits.h>
+#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
#error "this test requires FD_SETSIZE"
#endif
-#define SAFETY_MARGIN (11)
+#define T537_SAFETY_MARGIN (11)
#if defined(_WIN32) || defined(MSDOS)
#define DEV_NULL "NUL"
#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
-static int *testfd = NULL;
-static struct rlimit num_open;
-static char msgbuff[256];
+static int *t537_testfd = NULL;
+static struct rlimit t537_num_open;
+static char t537_msgbuff[256];
-static void store_errmsg(const char *msg, int err)
+static void t537_store_errmsg(const char *msg, int err)
{
if(!err)
- curl_msnprintf(msgbuff, sizeof(msgbuff), "%s", msg);
+ curl_msnprintf(t537_msgbuff, sizeof(t537_msgbuff), "%s", msg);
else
- curl_msnprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg,
- err, strerror(err));
+ curl_msnprintf(t537_msgbuff, sizeof(t537_msgbuff), "%s, errno %d, %s", msg,
+ err, strerror(err));
}
-static void close_file_descriptors(void)
+static void t537_close_file_descriptors(void)
{
- for(num_open.rlim_cur = 0;
- num_open.rlim_cur < num_open.rlim_max;
- num_open.rlim_cur++)
- if(testfd[num_open.rlim_cur] > 0)
- close(testfd[num_open.rlim_cur]);
- free(testfd);
- testfd = NULL;
+ for(t537_num_open.rlim_cur = 0;
+ t537_num_open.rlim_cur < t537_num_open.rlim_max;
+ t537_num_open.rlim_cur++)
+ if(t537_testfd[t537_num_open.rlim_cur] > 0)
+ close(t537_testfd[t537_num_open.rlim_cur]);
+ free(t537_testfd);
+ t537_testfd = NULL;
}
-static int fopen_works(void)
+static int t537_fopen_works(void)
{
FILE *fpa[3];
int i;
for(i = 0; i < 3; i++) {
fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
if(!fpa[i]) {
- store_errmsg("fopen failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t537_store_errmsg("fopen failed", errno);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
ret = 0;
break;
}
return ret;
}
-static void rlim2str(char *buf, size_t len, rlim_t val)
-{
-#ifdef RLIM_INFINITY
- if(val == RLIM_INFINITY) {
- curl_msnprintf(buf, len, "INFINITY");
- return;
- }
-#endif
-#ifdef HAVE_LONGLONG
- if(sizeof(rlim_t) > sizeof(long))
- curl_msnprintf(buf, len, "%llu", (unsigned long long)val);
- else
-#endif
- {
- if(sizeof(rlim_t) < sizeof(long))
- curl_msnprintf(buf, len, "%u", (unsigned int)val);
- else
- curl_msnprintf(buf, len, "%lu", (unsigned long)val);
- }
-}
-
-static int test_rlimit(int keep_open)
+static int t537_test_rlimit(int keep_open)
{
int *tmpfd;
rlim_t nitems, i;
/* get initial open file limits */
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
- store_errmsg("getrlimit() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t537_store_errmsg("getrlimit() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
return -1;
}
/* show initial open file limits */
- rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur);
+ tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur);
curl_mfprintf(stderr, "initial soft limit: %s\n", strbuff);
- rlim2str(strbuff, sizeof(strbuff), rl.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_max);
curl_mfprintf(stderr, "initial hard limit: %s\n", strbuff);
/* If the OS allows a HUGE number of open files, we do not run.
rl.rlim_cur = OPEN_MAX;
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
/* on failure don't abort just issue a warning */
- store_errmsg("setrlimit() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- msgbuff[0] = '\0';
+ t537_store_errmsg("setrlimit() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
+ t537_msgbuff[0] = '\0';
}
}
#endif
rl.rlim_cur = rl.rlim_max;
if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
/* on failure don't abort just issue a warning */
- store_errmsg("setrlimit() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- msgbuff[0] = '\0';
+ t537_store_errmsg("setrlimit() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
+ t537_msgbuff[0] = '\0';
}
/* get current open file limits */
if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
- store_errmsg("getrlimit() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t537_store_errmsg("getrlimit() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
return -3;
}
/* show current open file limits */
- rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur);
+ tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_cur);
curl_mfprintf(stderr, "current soft limit: %s\n", strbuff);
- rlim2str(strbuff, sizeof(strbuff), rl.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), rl.rlim_max);
curl_mfprintf(stderr, "current hard limit: %s\n", strbuff);
} /* (rl.rlim_cur != rl.rlim_max) */
if(nitems > 0x7fff)
nitems = 0x40000;
do {
- num_open.rlim_max = sizeof(*memchunk) * nitems;
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ t537_num_open.rlim_max = sizeof(*memchunk) * nitems;
+ tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max);
curl_mfprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
if(!memchunk) {
}
} while(nitems && !memchunk);
if(!memchunk) {
- store_errmsg("memchunk, malloc() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t537_store_errmsg("memchunk, malloc() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
return -4;
}
#else
if(rl.rlim_cur > 0) {
#endif
- /* soft limit minus SAFETY_MARGIN */
- num_open.rlim_max = rl.rlim_cur - SAFETY_MARGIN;
+ /* soft limit minus T537_SAFETY_MARGIN */
+ t537_num_open.rlim_max = rl.rlim_cur - T537_SAFETY_MARGIN;
}
else {
/* a huge number of file descriptors */
nitems = i;
if(nitems > 0x7fff)
nitems = 0x40000;
- num_open.rlim_max = nitems;
+ t537_num_open.rlim_max = nitems;
}
/* verify that we won't overflow size_t in malloc() */
- if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*testfd)) {
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max);
+ if((size_t)(t537_num_open.rlim_max) > ((size_t)-1) / sizeof(*t537_testfd)) {
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_max);
curl_msnprintf(strbuff, sizeof(strbuff),
"unable to allocate an array for %s "
"file descriptors, would overflow size_t", strbuff1);
- store_errmsg(strbuff, 0);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ t537_store_errmsg(strbuff, 0);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
free(memchunk);
return -5;
}
/* allocate array for file descriptors */
do {
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max);
curl_mfprintf(stderr, "allocating array for %s file descriptors\n",
strbuff);
- testfd = malloc(sizeof(*testfd) * (size_t)(num_open.rlim_max));
- if(!testfd) {
+ t537_testfd = malloc(sizeof(*t537_testfd) *
+ (size_t)(t537_num_open.rlim_max));
+ if(!t537_testfd) {
curl_mfprintf(stderr, "testfd, malloc() failed\n");
- num_open.rlim_max /= 2;
+ t537_num_open.rlim_max /= 2;
}
- } while(num_open.rlim_max && !testfd);
- if(!testfd) {
- store_errmsg("testfd, malloc() failed", errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ } while(t537_num_open.rlim_max && !t537_testfd);
+ if(!t537_testfd) {
+ t537_store_errmsg("testfd, malloc() failed", errno);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
free(memchunk);
return -6;
}
curl_mfprintf(stderr, "initializing testfd array\n");
- for(num_open.rlim_cur = 0;
- num_open.rlim_cur < num_open.rlim_max;
- num_open.rlim_cur++)
- testfd[num_open.rlim_cur] = -1;
+ for(t537_num_open.rlim_cur = 0;
+ t537_num_open.rlim_cur < t537_num_open.rlim_max;
+ t537_num_open.rlim_cur++)
+ t537_testfd[t537_num_open.rlim_cur] = -1;
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max);
curl_mfprintf(stderr, "trying to open %s file descriptors\n", strbuff);
/* open a dummy descriptor */
- testfd[0] = open(DEV_NULL, O_RDONLY);
- if(testfd[0] < 0) {
+ t537_testfd[0] = open(DEV_NULL, O_RDONLY);
+ if(t537_testfd[0] < 0) {
curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
- store_errmsg(strbuff, errno);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- free(testfd);
- testfd = NULL;
+ t537_store_errmsg(strbuff, errno);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
+ free(t537_testfd);
+ t537_testfd = NULL;
free(memchunk);
return -7;
}
/* create a bunch of file descriptors */
- for(num_open.rlim_cur = 1;
- num_open.rlim_cur < num_open.rlim_max;
- num_open.rlim_cur++) {
+ for(t537_num_open.rlim_cur = 1;
+ t537_num_open.rlim_cur < t537_num_open.rlim_max;
+ t537_num_open.rlim_cur++) {
- testfd[num_open.rlim_cur] = dup(testfd[0]);
+ t537_testfd[t537_num_open.rlim_cur] = dup(t537_testfd[0]);
- if(testfd[num_open.rlim_cur] < 0) {
+ if(t537_testfd[t537_num_open.rlim_cur] < 0) {
- testfd[num_open.rlim_cur] = -1;
+ t537_testfd[t537_num_open.rlim_cur] = -1;
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_cur);
curl_msnprintf(strbuff, sizeof(strbuff), "dup() attempt %s failed",
strbuff1);
curl_mfprintf(stderr, "%s\n", strbuff);
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_cur);
curl_msnprintf(strbuff, sizeof(strbuff),
"fds system limit seems close to %s", strbuff1);
curl_mfprintf(stderr, "%s\n", strbuff);
- num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN;
+ t537_num_open.rlim_max = t537_num_open.rlim_cur - T537_SAFETY_MARGIN;
- num_open.rlim_cur -= num_open.rlim_max;
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_cur);
+ t537_num_open.rlim_cur -= t537_num_open.rlim_max;
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_cur);
curl_msnprintf(strbuff, sizeof(strbuff), "closing %s file descriptors",
strbuff1);
curl_mfprintf(stderr, "%s\n", strbuff);
- for(num_open.rlim_cur = num_open.rlim_max;
- testfd[num_open.rlim_cur] >= 0;
- num_open.rlim_cur++) {
- close(testfd[num_open.rlim_cur]);
- testfd[num_open.rlim_cur] = -1;
+ for(t537_num_open.rlim_cur = t537_num_open.rlim_max;
+ t537_testfd[t537_num_open.rlim_cur] >= 0;
+ t537_num_open.rlim_cur++) {
+ close(t537_testfd[t537_num_open.rlim_cur]);
+ t537_testfd[t537_num_open.rlim_cur] = -1;
}
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max);
curl_mfprintf(stderr, "shrinking array for %s file descriptors\n",
strbuff);
/* we don't care if we can't shrink it */
- tmpfd = realloc(testfd, sizeof(*testfd) * (size_t)(num_open.rlim_max));
+ tmpfd = realloc(t537_testfd,
+ sizeof(*t537_testfd) * (size_t)(t537_num_open.rlim_max));
if(tmpfd) {
- testfd = tmpfd;
+ t537_testfd = tmpfd;
tmpfd = NULL;
}
}
}
- rlim2str(strbuff, sizeof(strbuff), num_open.rlim_max);
+ tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max);
curl_mfprintf(stderr, "%s file descriptors open\n", strbuff);
#if !defined(HAVE_POLL) && !defined(USE_WINSOCK)
* with an indication that select limit would be exceeded.
*/
- num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
- if(num_open.rlim_max > num_open.rlim_cur) {
+ t537_num_open.rlim_cur = FD_SETSIZE - T537_SAFETY_MARGIN;
+ if(t537_num_open.rlim_max > t537_num_open.rlim_cur) {
curl_msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
- FD_SETSIZE);
- store_errmsg(strbuff, 0);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- close_file_descriptors();
+ FD_SETSIZE);
+ t537_store_errmsg(strbuff, 0);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
+ t537_close_file_descriptors();
free(memchunk);
return -8;
}
- num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
+ t537_num_open.rlim_cur = FD_SETSIZE - T537_SAFETY_MARGIN;
for(rl.rlim_cur = 0;
- rl.rlim_cur < num_open.rlim_max;
+ rl.rlim_cur < t537_num_open.rlim_max;
rl.rlim_cur++) {
- if((testfd[rl.rlim_cur] > 0) &&
- ((unsigned int)testfd[rl.rlim_cur] > num_open.rlim_cur)) {
+ if((t537_testfd[rl.rlim_cur] > 0) &&
+ ((unsigned int)t537_testfd[rl.rlim_cur] > t537_num_open.rlim_cur)) {
curl_msnprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d",
- FD_SETSIZE);
- store_errmsg(strbuff, 0);
- curl_mfprintf(stderr, "%s\n", msgbuff);
- close_file_descriptors();
+ FD_SETSIZE);
+ t537_store_errmsg(strbuff, 0);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
+ t537_close_file_descriptors();
free(memchunk);
return -9;
}
* if it is capable of fopen()ing some additional files.
*/
- if(!fopen_works()) {
- rlim2str(strbuff1, sizeof(strbuff1), num_open.rlim_max);
+ if(!t537_fopen_works()) {
+ tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_max);
curl_msnprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open",
strbuff1);
- curl_mfprintf(stderr, "%s\n", msgbuff);
+ curl_mfprintf(stderr, "%s\n", t537_msgbuff);
curl_msnprintf(strbuff, sizeof(strbuff),
"fopen fails with lots of fds open");
- store_errmsg(strbuff, 0);
- close_file_descriptors();
+ t537_store_errmsg(strbuff, 0);
+ t537_close_file_descriptors();
free(memchunk);
return -10;
}
/* close file descriptors unless instructed to keep them */
if(!keep_open) {
- close_file_descriptors();
+ t537_close_file_descriptors();
}
return 0;
if(!strcmp(URL, "check")) {
/* used by the test script to ask if we can run this test or not */
- if(test_rlimit(FALSE)) {
- curl_mfprintf(stdout, "test_rlimit problem: %s\n", msgbuff);
+ if(t537_test_rlimit(FALSE)) {
+ curl_mfprintf(stdout, "test_rlimit problem: %s\n", t537_msgbuff);
return TEST_ERR_FAILURE;
}
return CURLE_OK; /* sure, run this! */
}
- if(test_rlimit(TRUE)) {
+ if(t537_test_rlimit(TRUE)) {
/* failure */
return TEST_ERR_MAJOR_BAD;
}
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
curl_mfprintf(stderr, "curl_global_init() failed\n");
- close_file_descriptors();
+ t537_close_file_descriptors();
return TEST_ERR_MAJOR_BAD;
}
curl = curl_easy_init();
if(!curl) {
curl_mfprintf(stderr, "curl_easy_init() failed\n");
- close_file_descriptors();
+ t537_close_file_descriptors();
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
test_cleanup:
- close_file_descriptors();
+ t537_close_file_descriptors();
curl_easy_cleanup(curl);
curl_global_cleanup();
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
#define PROXY libtest_arg2
#define PROXYUSERPWD libtest_arg3
#define HOST test_argv[4]
+#undef NUM_HANDLES
#define NUM_HANDLES 2
static CURL *testeh[NUM_HANDLES];
#include "memdebug.h"
-static char teststring[] =
-{ 'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ',
- 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ',
- 'w', 'i', 't', 'h', ' ', 'a', 'n', ' ',
- 'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L'};
-
CURLcode test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
+ static const char teststring_init[] = {
+ 'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ',
+ 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ',
+ 'w', 'i', 't', 'h', ' ', 'a', 'n', ' ',
+ 'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L'};
+
+ char teststring[sizeof(teststring_init)];
+
+ memcpy(teststring, teststring_init, sizeof(teststring_init));
+
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
curl_mfprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
#define UPLOADTHIS "this is the blurb we want to upload\n"
#ifndef LIB548
-static size_t readcallback(char *ptr,
- size_t size,
- size_t nmemb,
- void *clientp)
+static size_t t547_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp)
{
int *counter = (int *)clientp;
curl_mfprintf(stderr, "READ NOT FINE!\n");
return 0;
}
-static curlioerr ioctlcallback(CURL *handle,
- int cmd,
- void *clientp)
+
+static curlioerr t547_ioctl_callback(CURL *handle, int cmd, void *clientp)
{
int *counter = (int *)clientp;
(void)handle; /* unused */
}
return CURLIOE_OK;
}
-
-
-
#endif
CURLcode test(char *URL)
test_setopt(curl, CURLOPT_POSTFIELDS, UPLOADTHIS);
#else
/* 547 style, which means reading the POST data from a callback */
- test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
+ test_setopt(curl, CURLOPT_IOCTLFUNCTION, t547_ioctl_callback);
test_setopt(curl, CURLOPT_IOCTLDATA, &counter);
- test_setopt(curl, CURLOPT_READFUNCTION, readcallback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t547_read_cb);
test_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose
chunked)! */
#include "warnless.h"
#include "memdebug.h"
-struct testdata {
+struct t552_testdata {
char trace_ascii; /* 1 or 0 */
};
-static
-void dump(const char *text,
- FILE *stream, unsigned char *ptr, size_t size,
- char nohex)
+static void dump(const char *text,
+ FILE *stream, unsigned char *ptr, size_t size,
+ char nohex)
{
size_t i;
size_t c;
fflush(stream);
}
-static
-int my_trace(CURL *handle, curl_infotype type,
- char *data, size_t size,
- void *userp)
+static int my_trace(CURL *handle, curl_infotype type,
+ char *data, size_t size,
+ void *userp)
{
- struct testdata *config = (struct testdata *)userp;
+ struct t552_testdata *config = (struct t552_testdata *)userp;
const char *text;
(void)handle; /* prevent compiler warning */
return 0;
}
-
static size_t current_offset = 0;
static char databuf[70000]; /* MUST be more than 64k OR
MAX_INITIAL_POST_SIZE */
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
+static size_t t552_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t amount = nmemb * size; /* Total bytes curl wants */
size_t available = sizeof(databuf) - current_offset; /* What we have to
return given;
}
-
-static size_t write_callback(char *ptr, size_t size, size_t nmemb,
- void *stream)
+static size_t t552_write_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
int amount = curlx_uztosi(size * nmemb);
curl_mprintf("%.*s", amount, (char *)ptr);
return size * nmemb;
}
-
static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
{
(void)clientp;
return CURLIOE_UNKNOWNCMD;
}
-
-
CURLcode test(char *URL)
{
CURL *curl;
CURLcode res = CURLE_OK;
- struct testdata config;
+ struct t552_testdata config;
size_t i;
static const char fill[] = "test data";
/* Setup read callback */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(databuf));
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t552_read_cb);
/* Write callback */
- test_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
+ test_setopt(curl, CURLOPT_WRITEFUNCTION, t552_write_cb);
/* Ioctl function */
test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
#define NUM_HEADERS 8
#define SIZE_HEADERS 5000
-static char testbuf[SIZE_HEADERS + 100];
-
CURLcode test(char *URL)
{
+ static char testbuf[SIZE_HEADERS + 100];
+
CURL *curl;
CURLcode res = CURLE_FAILED_INIT;
int i;
#include "memdebug.h"
-static char testdata[]=
- "this is what we post to the silly web server\n";
-
-struct WriteThis {
- char *readptr;
+struct t554_WriteThis {
+ const char *readptr;
size_t sizeleft;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t554_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
-#ifdef LIB587
- (void)ptr;
- (void)size;
- (void)nmemb;
- (void)userp;
- return CURL_READFUNC_ABORT;
-#else
-
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ struct t554_WriteThis *pooh = (struct t554_WriteThis *)userp;
if(size*nmemb < 1)
return 0;
}
return 0; /* no more data left to deliver */
-#endif
}
-static CURLcode test_once(char *URL, bool oldstyle)
+static CURLcode t554_test_once(char *URL, bool oldstyle)
{
+ static const char testdata[] =
+ "this is what we post to the silly web server\n";
+
CURL *curl;
CURLcode res = CURLE_OK;
CURLFORMcode formrc;
struct curl_httppost *formpost = NULL;
struct curl_httppost *lastptr = NULL;
- struct WriteThis pooh;
- struct WriteThis pooh2;
+ struct t554_WriteThis pooh;
+ struct t554_WriteThis pooh2;
pooh.readptr = testdata;
pooh.sizeleft = strlen(testdata);
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)pooh.sizeleft);
/* we want to use our own read function */
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t554_read_cb);
/* send a multi-part formpost */
test_setopt(curl, CURLOPT_HTTPPOST, formpost);
return TEST_ERR_MAJOR_BAD;
}
- res = test_once(URL, TRUE); /* old */
+ res = t554_test_once(URL, TRUE); /* old */
if(!res)
- res = test_once(URL, FALSE); /* new */
+ res = t554_test_once(URL, FALSE); /* new */
curl_global_cleanup();
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
+static const char uploadthis[] = "this is the blurb we want to upload\n";
-static const char uploadthis[] =
- "this is the blurb we want to upload\n";
-
-static size_t readcallback(char *ptr,
- size_t size,
- size_t nmemb,
- void *clientp)
+static size_t t555_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp)
{
int *counter = (int *)clientp;
curl_mfprintf(stderr, "READ NOT FINE!\n");
return 0;
}
-static curlioerr ioctlcallback(CURL *handle,
- int cmd,
- void *clientp)
+
+static curlioerr t555_ioctl_callback(CURL *handle, int cmd, void *clientp)
{
int *counter = (int *)clientp;
(void)handle; /* unused */
easy_setopt(curl, CURLOPT_HEADER, 1L);
/* read the POST data from a callback */
- easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback);
+ easy_setopt(curl, CURLOPT_IOCTLFUNCTION, t555_ioctl_callback);
easy_setopt(curl, CURLOPT_IOCTLDATA, &counter);
- easy_setopt(curl, CURLOPT_READFUNCTION, readcallback);
+ easy_setopt(curl, CURLOPT_READFUNCTION, t555_read_cb);
easy_setopt(curl, CURLOPT_READDATA, &counter);
/* We CANNOT do the POST fine without setting the size (or choose
chunked)! */
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
/*
* Simply download an HTTPS file!
*
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURLcode res = CURLE_OK;
#include <fcntl.h>
#endif
+#include "testutil.h"
#include "memdebug.h"
-/* build request url */
-static char *suburl(const char *base, int i)
-{
- return curl_maprintf("%s%.4d", base, i);
-}
-
/*
* Test the Client->Server ANNOUNCE functionality (PUT style)
*/
test_setopt(curl, CURLOPT_URL, URL);
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
sdpf = NULL;
/* Make sure we can do a normal request now */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
/* Now do a POST style one */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
custom_headers = NULL;
/* Make sure we can do a normal request now */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
*
***************************************************************************/
#include "test.h"
-#include "memdebug.h"
-/* build request url */
-static char *suburl(const char *base, int i)
-{
- return curl_maprintf("%s%.4d", base, i);
-}
+#include "testutil.h"
+#include "memdebug.h"
/*
* Test Session ID capture
/* Go through the various Session IDs */
for(i = 0; i < 3; i++) {
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
curl_mfprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
rtsp_session_id = NULL;
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
*
***************************************************************************/
#include "test.h"
-#include "memdebug.h"
-/* build request url */
-static char *suburl(const char *base, int i)
-{
- return curl_maprintf("%s%.4d", base, i);
-}
+#include "testutil.h"
+#include "memdebug.h"
CURLcode test(char *URL)
{
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
"RAW/RAW/UDP;unicast;client_port=3056-3057");
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
# include <fcntl.h>
#endif
+#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
((int)((unsigned char)((p)[3]))))
#define RTP_DATA_SIZE 12
-static const char *RTP_DATA = "$_1234\n\0Rsdf";
static int rtp_packet_count = 0;
static size_t rtp_write(char *ptr, size_t size, size_t nmemb, void *stream)
{
+ static const char *RTP_DATA = "$_1234\n\0Rsdf";
+
char *data = (char *)ptr;
int channel = RTP_PKT_CHANNEL(data);
int message_size;
return size * nmemb;
}
-/* build request url */
-static char *suburl(const char *base, int i)
-{
- return curl_maprintf("%s%.4d", base, i);
-}
-
CURLcode test(char *URL)
{
CURLcode res;
}
test_setopt(curl, CURLOPT_URL, URL);
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
goto test_cleanup;
/* This PLAY starts the interleave */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
goto test_cleanup;
/* The DESCRIBE request will try to consume data after the Content */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
if(res)
goto test_cleanup;
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
#include <fcntl.h>
#endif
+#include "testutil.h"
#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
*/
test_setopt(curl, CURLOPT_URL, URL);
/* SETUP */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
if(res)
goto test_cleanup;
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
paramsf = NULL;
/* Heartbeat GET_PARAMETERS */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
/* POST GET_PARAMETERS */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
/* Make sure we can do a normal request now */
- stream_uri = suburl(URL, request++);
+ stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
/*
* Get a single URL without select().
*/
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT (60 * 1000)
-
static int new_fnmatch(void *ptr,
const char *pattern, const char *string)
{
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
/* 3x download!
* 1. normal
* 2. dup handle
int print_content;
};
-static
-long chunk_bgn(const void *f, void *ptr, int remains)
+static long chunk_bgn(const void *f, void *ptr, int remains)
{
const struct curl_fileinfo *finfo = f;
struct chunk_data *ch_d = ptr;
return CURL_CHUNK_BGN_FUNC_OK;
}
-static
-long chunk_end(void *ptr)
+static long chunk_end(void *ptr)
{
struct chunk_data *ch_d = ptr;
if(ch_d->print_content) {
#include "memdebug.h"
/* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
-static char testdata[]="this is a short string.\n";
+static char t578_testdata[] = "this is a short string.\n";
-static size_t data_size = CURL_ARRAYSIZE(testdata);
+static size_t data_size = CURL_ARRAYSIZE(t578_testdata);
-static int progress_callback(void *clientp, double dltotal, double dlnow,
- double ultotal, double ulnow)
+static int t578_progress_callback(void *clientp, double dltotal, double dlnow,
+ double ultotal, double ulnow)
{
FILE *moo = fopen(libtest_arg2, "wb");
curl_mfprintf(moo, "PASSED, UL data matched data size\n");
else
curl_mfprintf(moo, "Progress callback called with UL %f out of %f\n",
- ulnow, ultotal);
+ ulnow, ultotal);
fclose(moo);
}
return 0;
/* Set the expected POST size */
test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)data_size);
- test_setopt(curl, CURLOPT_POSTFIELDS, testdata);
+ test_setopt(curl, CURLOPT_POSTFIELDS, t578_testdata);
/* we want to use our own progress function */
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
- test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
+ test_setopt(curl, CURLOPT_PROGRESSFUNCTION, t578_progress_callback);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
#include "memdebug.h"
-static const char * const testpost[]={
- "one",
- "two",
- "three",
- "and a final longer crap: four",
- NULL
-};
-
-
-struct WriteThis {
+struct t579_WriteThis {
int counter;
};
started = FALSE;
}
-static int progress_callback(void *clientp, double dltotal, double dlnow,
- double ultotal, double ulnow)
+static int t579_progress_callback(void *clientp, double dltotal, double dlnow,
+ double ultotal, double ulnow)
{
(void)clientp; /* UNUSED */
(void)dltotal; /* UNUSED */
if(!started) {
FILE *moo = fopen(libtest_arg2, "ab");
curl_mfprintf(moo ? moo : stderr, "Progress: start UL %zu/%zu\n",
- last_ul, last_ul_total);
+ last_ul, last_ul_total);
if(moo)
fclose(moo);
else
return 0;
}
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t579_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ static const char * const testpost[] = {
+ "one",
+ "two",
+ "three",
+ "and a final longer crap: four",
+ NULL
+ };
+
+ struct t579_WriteThis *pooh = (struct t579_WriteThis *)userp;
const char *data;
if(size*nmemb < 1)
CURL *curl;
CURLcode res = CURLE_OK;
struct curl_slist *slist = NULL;
- struct WriteThis pooh;
+ struct t579_WriteThis pooh;
pooh.counter = 0;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
test_setopt(curl, CURLOPT_POST, 1L);
/* we want to use our own read function */
- test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(curl, CURLOPT_READFUNCTION, t579_read_cb);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
/* we want to use our own progress function */
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
- test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
+ test_setopt(curl, CURLOPT_PROGRESSFUNCTION, t579_progress_callback);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
-struct Sockets {
+struct t582_Sockets {
curl_socket_t *sockets;
int count; /* number of sockets actually stored in array */
int max_count; /* max number of sockets that fit in allocated array */
};
-struct ReadWriteSockets {
- struct Sockets read, write;
+struct t582_ReadWriteSockets {
+ struct t582_Sockets read, write;
};
/**
* Remove a file descriptor from a sockets array.
*/
-static void removeFd(struct Sockets *sockets, curl_socket_t fd, int mention)
+static void t582_removeFd(struct t582_Sockets *sockets, curl_socket_t fd,
+ int mention)
{
int i;
/**
* Add a file descriptor to a sockets array.
*/
-static void addFd(struct Sockets *sockets, curl_socket_t fd, const char *what)
+static void t582_addFd(struct t582_Sockets *sockets, curl_socket_t fd,
+ const char *what)
{
/**
* To ensure we only have each file descriptor once, we remove it then add
* it again.
*/
curl_mfprintf(stderr, "Add socket fd %d for %s\n", (int) fd, what);
- removeFd(sockets, fd, 0);
+ t582_removeFd(sockets, fd, 0);
/*
* Allocate array storage when required.
*/
/**
* Callback invoked by curl to poll reading / writing of a socket.
*/
-static int curlSocketCallback(CURL *easy, curl_socket_t s, int action,
- void *userp, void *socketp)
+static int t582_curlSocketCallback(CURL *easy, curl_socket_t s, int action,
+ void *userp, void *socketp)
{
- struct ReadWriteSockets *sockets = userp;
+ struct t582_ReadWriteSockets *sockets = userp;
(void)easy; /* unused */
(void)socketp; /* unused */
if(action == CURL_POLL_IN || action == CURL_POLL_INOUT)
- addFd(&sockets->read, s, "read");
+ t582_addFd(&sockets->read, s, "read");
if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT)
- addFd(&sockets->write, s, "write");
+ t582_addFd(&sockets->write, s, "write");
if(action == CURL_POLL_REMOVE) {
- removeFd(&sockets->read, s, 1);
- removeFd(&sockets->write, s, 0);
+ t582_removeFd(&sockets->read, s, 1);
+ t582_removeFd(&sockets->write, s, 0);
}
return 0;
/**
* Callback invoked by curl to set a timeout.
*/
-static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
+static int t582_curlTimerCallback(CURLM *multi, long timeout_ms, void *userp)
{
struct timeval *timeout = userp;
/**
* Check for curl completion.
*/
-static int checkForCompletion(CURLM *curl, int *success)
+static int t582_checkForCompletion(CURLM *curl, int *success)
{
int result = 0;
*success = 0;
return result;
}
-static int getMicroSecondTimeout(struct timeval *timeout)
+static int t582_getMicroSecondTimeout(struct timeval *timeout)
{
struct timeval now;
ssize_t result;
/**
* Update a fd_set with all of the sockets in use.
*/
-static void updateFdSet(struct Sockets *sockets, fd_set* fdset,
- curl_socket_t *maxFd)
+static void t582_updateFdSet(struct t582_Sockets *sockets, fd_set* fdset,
+ curl_socket_t *maxFd)
{
int i;
for(i = 0; i < sockets->count; ++i) {
/**
* Invoke curl when a file descriptor is set.
*/
-static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset,
- int evBitmask, const char *name)
+static void t582_checkFdSet(CURLM *curl, struct t582_Sockets *sockets,
+ fd_set *fdset, int evBitmask, const char *name)
{
int i;
for(i = 0; i < sockets->count; ++i) {
int hd;
struct_stat file_info;
CURLM *m = NULL;
- struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
+ struct t582_ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
int success = 0;
struct timeval timeout = {0};
timeout.tv_sec = (time_t)-1;
multi_init(m);
- multi_setopt(m, CURLMOPT_SOCKETFUNCTION, curlSocketCallback);
+ multi_setopt(m, CURLMOPT_SOCKETFUNCTION, t582_curlSocketCallback);
multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets);
- multi_setopt(m, CURLMOPT_TIMERFUNCTION, curlTimerCallback);
+ multi_setopt(m, CURLMOPT_TIMERFUNCTION, t582_curlTimerCallback);
multi_setopt(m, CURLMOPT_TIMERDATA, &timeout);
multi_add_handle(m, curl);
- while(!checkForCompletion(m, &success)) {
+ while(!t582_checkForCompletion(m, &success)) {
fd_set readSet, writeSet;
curl_socket_t maxFd = 0;
struct timeval tv = {0};
FD_ZERO(&readSet);
FD_ZERO(&writeSet);
- updateFdSet(&sockets.read, &readSet, &maxFd);
- updateFdSet(&sockets.write, &writeSet, &maxFd);
+ t582_updateFdSet(&sockets.read, &readSet, &maxFd);
+ t582_updateFdSet(&sockets.write, &writeSet, &maxFd);
if(timeout.tv_sec != (time_t)-1) {
- int usTimeout = getMicroSecondTimeout(&timeout);
+ int usTimeout = t582_getMicroSecondTimeout(&timeout);
tv.tv_sec = usTimeout / 1000000;
tv.tv_usec = usTimeout % 1000000;
}
select_test((int)maxFd, &readSet, &writeSet, NULL, &tv);
/* Check the sockets for reading / writing */
- checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read");
- checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write");
+ t582_checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read");
+ t582_checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write");
- if(timeout.tv_sec != (time_t)-1 && getMicroSecondTimeout(&timeout) == 0) {
+ if(timeout.tv_sec != (time_t)-1 &&
+ t582_getMicroSecondTimeout(&timeout) == 0) {
/* Curl's timer has elapsed. */
notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout");
}
#define THREADS 2
/* struct containing data of a thread */
-struct Tdata {
+struct t586_Tdata {
CURLSH *share;
char *url;
};
-struct userdata {
+struct t586_userdata {
const char *text;
int counter;
};
/* lock callback */
-static void test_lock(CURL *handle, curl_lock_data data,
- curl_lock_access laccess, void *useptr)
+static void t586_test_lock(CURL *handle, curl_lock_data data,
+ curl_lock_access laccess, void *useptr)
{
const char *what;
- struct userdata *user = (struct userdata *)useptr;
+ struct t586_userdata *user = (struct t586_userdata *)useptr;
(void)handle;
(void)laccess;
}
/* unlock callback */
-static void test_unlock(CURL *handle, curl_lock_data data, void *useptr)
+static void t586_test_unlock(CURL *handle, curl_lock_data data, void *useptr)
{
const char *what;
- struct userdata *user = (struct userdata *)useptr;
+ struct t586_userdata *user = (struct t586_userdata *)useptr;
(void)handle;
switch(data) {
case CURL_LOCK_DATA_SHARE:
}
/* the dummy thread function */
-static void *test_fire(void *ptr)
+static void *t586_test_fire(void *ptr)
{
CURLcode code;
- struct Tdata *tdata = (struct Tdata*)ptr;
+ struct t586_Tdata *tdata = (struct t586_Tdata*)ptr;
CURL *curl;
curl = curl_easy_init();
CURLcode res = CURLE_OK;
CURLSHcode scode = CURLSHE_OK;
char *url;
- struct Tdata tdata;
+ struct t586_Tdata tdata;
CURL *curl;
CURLSH *share;
int i;
- struct userdata user;
+ struct t586_userdata user;
user.text = "Pigs in space";
user.counter = 0;
if(CURLSHE_OK == scode) {
curl_mprintf("CURLSHOPT_LOCKFUNC\n");
- scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, test_lock);
+ scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, t586_test_lock);
}
if(CURLSHE_OK == scode) {
curl_mprintf("CURLSHOPT_UNLOCKFUNC\n");
- scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, test_unlock);
+ scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, t586_test_unlock);
}
if(CURLSHE_OK == scode) {
curl_mprintf("CURLSHOPT_USERDATA\n");
/* simulate thread, direct call of "thread" function */
curl_mprintf("*** run %d\n",i);
- test_fire(&tdata);
+ t586_test_fire(&tdata);
}
--- /dev/null
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "memdebug.h"
+
+struct t587_WriteThis {
+ const char *readptr;
+ size_t sizeleft;
+};
+
+static size_t t587_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
+{
+ (void)ptr;
+ (void)size;
+ (void)nmemb;
+ (void)userp;
+ return CURL_READFUNC_ABORT;
+}
+
+static CURLcode t587_test_once(char *URL, bool oldstyle)
+{
+ static const char testdata[] =
+ "this is what we post to the silly web server\n";
+
+ CURL *curl;
+ CURLcode res = CURLE_OK;
+ CURLFORMcode formrc;
+
+ struct curl_httppost *formpost = NULL;
+ struct curl_httppost *lastptr = NULL;
+ struct t587_WriteThis pooh;
+ struct t587_WriteThis pooh2;
+
+ pooh.readptr = testdata;
+ pooh.sizeleft = strlen(testdata);
+
+ /* Fill in the file upload field */
+ if(oldstyle) {
+ formrc = curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_COPYNAME, "sendfile",
+ CURLFORM_STREAM, &pooh,
+ CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft,
+ CURLFORM_FILENAME, "postit2.c",
+ CURLFORM_END);
+ }
+ else {
+ /* new style */
+ formrc = curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_COPYNAME, "sendfile alternative",
+ CURLFORM_STREAM, &pooh,
+ CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft,
+ CURLFORM_FILENAME, "file name 2",
+ CURLFORM_END);
+ }
+
+ if(formrc)
+ curl_mprintf("curl_formadd(1) = %d\n", (int)formrc);
+
+ /* Now add the same data with another name and make it not look like
+ a file upload but still using the callback */
+
+ pooh2.readptr = testdata;
+ pooh2.sizeleft = strlen(testdata);
+
+ /* Fill in the file upload field */
+ formrc = curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_COPYNAME, "callbackdata",
+ CURLFORM_STREAM, &pooh2,
+ CURLFORM_CONTENTSLENGTH, (long)pooh2.sizeleft,
+ CURLFORM_END);
+
+ if(formrc)
+ curl_mprintf("curl_formadd(2) = %d\n", (int)formrc);
+
+ /* Fill in the filename field */
+ formrc = curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_COPYNAME, "filename",
+ CURLFORM_COPYCONTENTS, "postit2.c",
+ CURLFORM_END);
+ if(formrc)
+ curl_mprintf("curl_formadd(3) = %d\n", (int)formrc);
+
+ /* Fill in a submit field too */
+ formrc = curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_COPYNAME, "submit",
+ CURLFORM_COPYCONTENTS, "send",
+ CURLFORM_CONTENTTYPE, "text/plain",
+ CURLFORM_END);
+
+ if(formrc)
+ curl_mprintf("curl_formadd(4) = %d\n", (int)formrc);
+
+ formrc = curl_formadd(&formpost, &lastptr,
+ CURLFORM_COPYNAME, "somename",
+ CURLFORM_BUFFER, "somefile.txt",
+ CURLFORM_BUFFERPTR, "blah blah",
+ CURLFORM_BUFFERLENGTH, (long)9,
+ CURLFORM_END);
+
+ if(formrc)
+ curl_mprintf("curl_formadd(5) = %d\n", (int)formrc);
+
+ curl = curl_easy_init();
+ if(!curl) {
+ curl_mfprintf(stderr, "curl_easy_init() failed\n");
+ curl_formfree(formpost);
+ 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);
+
+ /* 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, t587_read_cb);
+
+ /* send a multi-part formpost */
+ test_setopt(curl, CURLOPT_HTTPPOST, formpost);
+
+ /* 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 formpost chain */
+ curl_formfree(formpost);
+
+ return res;
+}
+
+CURLcode test(char *URL)
+{
+ CURLcode res;
+
+ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+ curl_mfprintf(stderr, "curl_global_init() failed\n");
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ res = t587_test_once(URL, TRUE); /* old */
+ if(!res)
+ res = t587_test_once(URL, FALSE); /* new */
+
+ curl_global_cleanup();
+
+ return res;
+}
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
CURLcode test(char *URL)
{
CURL *easy = NULL;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
-
/*
* Test case for below scenario:
* - Connect to an FTP server using CONNECT_ONLY option
#include "memdebug.h"
-static int progress_callback(void *clientp, double dltotal,
- double dlnow, double ultotal, double ulnow)
+static int t599_progress_callback(void *clientp, double dltotal,
+ double dlnow, double ultotal, double ulnow)
{
(void)clientp;
(void)ulnow;
/* we want to use our own progress function */
test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
- test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
+ test_setopt(curl, CURLOPT_PROGRESSFUNCTION, t599_progress_callback);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
#include "memdebug.h"
-static char testdata[]=
- "dummy\n";
-
-struct WriteThis {
- char *readptr;
+struct t643_WriteThis {
+ const char *readptr;
curl_off_t sizeleft;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t643_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ struct t643_WriteThis *pooh = (struct t643_WriteThis *)userp;
int eof;
if(size*nmemb < 1)
return 0;
-#ifdef LIB645
- eof = !*pooh->readptr;
-#else
eof = pooh->sizeleft <= 0;
if(!eof)
pooh->sizeleft--;
-#endif
if(!eof) {
*ptr = *pooh->readptr; /* copy one single byte */
return 0; /* no more data left to deliver */
}
-static CURLcode test_once(char *URL, bool oldstyle)
+static CURLcode t643_test_once(char *URL, bool oldstyle)
{
+ static const char testdata[] = "dummy\n";
+
CURL *curl;
CURLcode res = CURLE_OK;
curl_mime *mime = NULL;
curl_mimepart *part = NULL;
- struct WriteThis pooh;
- struct WriteThis pooh2;
+ struct t643_WriteThis pooh;
+ struct t643_WriteThis pooh2;
curl_off_t datasize = -1;
pooh.readptr = testdata;
-#ifndef LIB645
datasize = (curl_off_t)strlen(testdata);
-#endif
pooh.sizeleft = datasize;
curl = curl_easy_init();
if(oldstyle) {
res = curl_mime_name(part, "sendfile");
if(!res)
- res = curl_mime_data_cb(part, datasize, read_callback,
+ res = curl_mime_data_cb(part, datasize, t643_read_cb,
NULL, NULL, &pooh);
if(!res)
res = curl_mime_filename(part, "postit2.c");
/* new style */
res = curl_mime_name(part, "sendfile alternative");
if(!res)
- res = curl_mime_data_cb(part, datasize, read_callback,
+ res = curl_mime_data_cb(part, datasize, t643_read_cb,
NULL, NULL, &pooh);
if(!res)
res = curl_mime_filename(part, "file name 2");
a file upload but still using the callback */
pooh2.readptr = testdata;
-#ifndef LIB645
datasize = (curl_off_t)strlen(testdata);
-#endif
pooh2.sizeleft = datasize;
part = curl_mime_addpart(mime);
/* Fill in the file upload part */
res = curl_mime_name(part, "callbackdata");
if(!res)
- res = curl_mime_data_cb(part, datasize, read_callback,
+ res = curl_mime_data_cb(part, datasize, t643_read_cb,
NULL, NULL, &pooh2);
if(res)
return res;
}
-static CURLcode cyclic_add(void)
+static CURLcode t643_cyclic_add(void)
{
CURL *easy = curl_easy_init();
curl_mime *mime = curl_mime_init(easy);
return TEST_ERR_MAJOR_BAD;
}
- res = test_once(URL, TRUE); /* old */
+ res = t643_test_once(URL, TRUE); /* old */
if(!res)
- res = test_once(URL, FALSE); /* new */
+ res = t643_test_once(URL, FALSE); /* new */
if(!res)
- res = cyclic_add();
+ res = t643_cyclic_add();
curl_global_cleanup();
--- /dev/null
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "memdebug.h"
+
+struct t645_WriteThis {
+ const char *readptr;
+ curl_off_t sizeleft;
+};
+
+static size_t t645_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
+{
+ struct t645_WriteThis *pooh = (struct t645_WriteThis *)userp;
+ int eof;
+
+ if(size*nmemb < 1)
+ return 0;
+
+ eof = !*pooh->readptr;
+
+ 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 */
+}
+
+static CURLcode t645_test_once(char *URL, bool oldstyle)
+{
+ static const char testdata[] = "dummy\n";
+
+ CURL *curl;
+ CURLcode res = CURLE_OK;
+
+ curl_mime *mime = NULL;
+ curl_mimepart *part = NULL;
+ struct t645_WriteThis pooh;
+ struct t645_WriteThis pooh2;
+ curl_off_t datasize = -1;
+
+ pooh.readptr = testdata;
+ pooh.sizeleft = datasize;
+
+ curl = curl_easy_init();
+ if(!curl) {
+ curl_mfprintf(stderr, "curl_easy_init() failed\n");
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ mime = curl_mime_init(curl);
+ if(!mime) {
+ curl_mfprintf(stderr, "curl_mime_init() failed\n");
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ part = curl_mime_addpart(mime);
+ if(!part) {
+ curl_mfprintf(stderr, "curl_mime_addpart(1) failed\n");
+ curl_mime_free(mime);
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ /* Fill in the file upload part */
+ if(oldstyle) {
+ res = curl_mime_name(part, "sendfile");
+ if(!res)
+ res = curl_mime_data_cb(part, datasize, t645_read_cb,
+ NULL, NULL, &pooh);
+ if(!res)
+ res = curl_mime_filename(part, "postit2.c");
+ }
+ else {
+ /* new style */
+ res = curl_mime_name(part, "sendfile alternative");
+ if(!res)
+ res = curl_mime_data_cb(part, datasize, t645_read_cb,
+ NULL, NULL, &pooh);
+ if(!res)
+ res = curl_mime_filename(part, "file name 2");
+ }
+
+ if(res)
+ curl_mprintf("curl_mime_xxx(1) = %s\n", curl_easy_strerror(res));
+
+ /* Now add the same data with another name and make it not look like
+ a file upload but still using the callback */
+
+ pooh2.readptr = testdata;
+ pooh2.sizeleft = datasize;
+
+ part = curl_mime_addpart(mime);
+ if(!part) {
+ curl_mfprintf(stderr, "curl_mime_addpart(2) failed\n");
+ curl_mime_free(mime);
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+ /* Fill in the file upload part */
+ res = curl_mime_name(part, "callbackdata");
+ if(!res)
+ res = curl_mime_data_cb(part, datasize, t645_read_cb,
+ NULL, NULL, &pooh2);
+
+ if(res)
+ curl_mprintf("curl_mime_xxx(2) = %s\n", curl_easy_strerror(res));
+
+ part = curl_mime_addpart(mime);
+ if(!part) {
+ curl_mfprintf(stderr, "curl_mime_addpart(3) failed\n");
+ curl_mime_free(mime);
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ /* Fill in the filename field */
+ res = curl_mime_name(part, "filename");
+ if(!res)
+ res = curl_mime_data(part, "postit2.c",
+ CURL_ZERO_TERMINATED);
+
+ if(res)
+ curl_mprintf("curl_mime_xxx(3) = %s\n", curl_easy_strerror(res));
+
+ /* Fill in a submit field too */
+ part = curl_mime_addpart(mime);
+ if(!part) {
+ curl_mfprintf(stderr, "curl_mime_addpart(4) failed\n");
+ curl_mime_free(mime);
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+ res = curl_mime_name(part, "submit");
+ if(!res)
+ res = curl_mime_data(part, "send",
+ CURL_ZERO_TERMINATED);
+
+ if(res)
+ curl_mprintf("curl_mime_xxx(4) = %s\n", curl_easy_strerror(res));
+
+ part = curl_mime_addpart(mime);
+ if(!part) {
+ curl_mfprintf(stderr, "curl_mime_addpart(5) failed\n");
+ curl_mime_free(mime);
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
+ res = curl_mime_name(part, "somename");
+ if(!res)
+ res = curl_mime_filename(part, "somefile.txt");
+ if(!res)
+ res = curl_mime_data(part, "blah blah", 9);
+
+ if(res)
+ curl_mprintf("curl_mime_xxx(5) = %s\n", curl_easy_strerror(res));
+
+ /* First set the URL that is about to receive our POST. */
+ test_setopt(curl, CURLOPT_URL, URL);
+
+ /* send a multi-part mimepost */
+ test_setopt(curl, CURLOPT_MIMEPOST, mime);
+
+ /* 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 mimepost structure */
+ curl_mime_free(mime);
+
+ return res;
+}
+
+static CURLcode t645_cyclic_add(void)
+{
+ CURL *easy = curl_easy_init();
+ curl_mime *mime = curl_mime_init(easy);
+ curl_mimepart *part = curl_mime_addpart(mime);
+ CURLcode a1 = curl_mime_subparts(part, mime);
+
+ if(a1 == CURLE_BAD_FUNCTION_ARGUMENT) {
+ curl_mime *submime = curl_mime_init(easy);
+ curl_mimepart *subpart = curl_mime_addpart(submime);
+
+ curl_mime_subparts(part, submime);
+ a1 = curl_mime_subparts(subpart, mime);
+ }
+
+ curl_mime_free(mime);
+ curl_easy_cleanup(easy);
+ if(a1 != CURLE_BAD_FUNCTION_ARGUMENT)
+ /* that should have failed */
+ return TEST_ERR_FAILURE;
+
+ return CURLE_OK;
+}
+
+CURLcode test(char *URL)
+{
+ CURLcode res;
+
+ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+ curl_mfprintf(stderr, "curl_global_init() failed\n");
+ return TEST_ERR_MAJOR_BAD;
+ }
+
+ res = t645_test_once(URL, TRUE); /* old */
+ if(!res)
+ res = t645_test_once(URL, FALSE); /* new */
+
+ if(!res)
+ res = t645_cyclic_add();
+
+ curl_global_cleanup();
+
+ return res;
+}
#include "memdebug.h"
-
-static char testdata[] =
- "this is what we post to the silly web server";
-
-static const char testname[] = "fieldname";
-
-
/* This test attempts to use all form API features that are not
* used elsewhere.
*/
char flbuf[32];
long contentlength = 0;
+ static const char testname[] = "fieldname";
+ static char testdata[] =
+ "this is what we post to the silly web server";
+
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
curl_mfprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
#include "memdebug.h"
-static char testbuf[17000]; /* more than 16K */
-
CURLcode test(char *URL)
{
+ static char testbuf[17000]; /* more than 16K */
+
CURL *curl;
CURLcode res = CURLE_OK;
CURLFORMcode formrc;
#include "memdebug.h"
-static char testbuf[17000]; /* more than 16K */
-
CURLcode test(char *URL)
{
+ static char testbuf[17000]; /* more than 16K */
+
CURL *curl = NULL;
CURLcode res = CURLE_OK;
curl_mime *mime = NULL;
#include "memdebug.h"
-static char testdata[]=
- "dummy\n";
-
-struct WriteThis {
- char *readptr;
+struct t654_WriteThis {
+ const char *readptr;
curl_off_t sizeleft;
int freecount;
};
static void free_callback(void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *) userp;
+ struct t654_WriteThis *pooh = (struct t654_WriteThis *) userp;
pooh->freecount++;
}
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t654_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ struct t654_WriteThis *pooh = (struct t654_WriteThis *)userp;
int eof;
if(size*nmemb < 1)
CURLcode test(char *URL)
{
+ static const char testdata[] = "dummy\n";
+
CURL *easy = NULL;
CURL *easy2 = NULL;
curl_mime *mime = NULL;
curl_mimepart *part;
struct curl_slist *hdrs = NULL;
CURLcode res = TEST_ERR_FAILURE;
- struct WriteThis pooh;
+ struct t654_WriteThis pooh;
/*
* Check proper copy/release of mime post data bound to a duplicated
part = curl_mime_addpart(mime);
curl_mime_filedata(part, libtest_arg2);
part = curl_mime_addpart(mime);
- curl_mime_data_cb(part, (curl_off_t) -1, read_callback, NULL, free_callback,
- &pooh);
+ curl_mime_data_cb(part, (curl_off_t) -1, t654_read_cb, NULL,
+ free_callback, &pooh);
/* Bind mime data to its easy handle. */
test_setopt(easy, CURLOPT_MIMEPOST, mime);
static const char *TEST_DATA_STRING = "Test data";
static int cb_count = 0;
-static int
-resolver_alloc_cb_fail(void *resolver_state, void *reserved, void *userdata)
+static int resolver_alloc_cb_fail(void *resolver_state, void *reserved,
+ void *userdata)
{
(void)resolver_state;
(void)reserved;
return 1;
}
-static int
-resolver_alloc_cb_pass(void *resolver_state, void *reserved, void *userdata)
+static int resolver_alloc_cb_pass(void *resolver_state, void *reserved,
+ void *userdata)
{
(void)resolver_state;
(void)reserved;
res = curl_easy_perform(curl);
if(res != CURLE_COULDNT_RESOLVE_HOST) {
curl_mfprintf(stderr, "curl_easy_perform should have returned "
- "CURLE_COULDNT_RESOLVE_HOST but instead returned error %d\n", res);
+ "CURLE_COULDNT_RESOLVE_HOST but instead returned error %d\n",
+ res);
if(res == CURLE_OK)
res = TEST_ERR_FAILURE;
goto test_cleanup;
#include "memdebug.h"
-static char testbuf[17000]; /* more than 16K */
-
CURLcode test(char *URL)
{
+ static char testbuf[17000]; /* more than 16K */
+
CURL *curl = NULL;
CURLcode res = CURLE_OK;
curl_mime *mime = NULL;
#include "memdebug.h"
-static char testdata[]=
- "dummy";
-
-struct WriteThis {
- char *readptr;
+struct t667_WriteThis {
+ const char *readptr;
curl_off_t sizeleft;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t667_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ struct t667_WriteThis *pooh = (struct t667_WriteThis *)userp;
int eof;
if(size*nmemb < 1)
CURLcode test(char *URL)
{
+ static const char testdata[] = "dummy";
+
CURL *easy = NULL;
curl_mime *mime = NULL;
curl_mimepart *part;
CURLcode res = TEST_ERR_FAILURE;
- struct WriteThis pooh;
+ struct t667_WriteThis pooh;
/*
* Check proper handling of mime encoder feature when the part read callback
curl_mime_name(part, "field");
curl_mime_encoder(part, "base64");
/* Using an undefined length forces chunked transfer. */
- curl_mime_data_cb(part, (curl_off_t) -1, read_callback, NULL, NULL, &pooh);
+ curl_mime_data_cb(part, (curl_off_t) -1, t667_read_cb,
+ NULL, NULL, &pooh);
/* Bind mime data to its easy handle. */
test_setopt(easy, CURLOPT_MIMEPOST, mime);
#include "memdebug.h"
-static char testdata[]= "dummy";
-
-struct WriteThis {
- char *readptr;
+struct t668_WriteThis {
+ const char *readptr;
curl_off_t sizeleft;
};
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t668_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct WriteThis *pooh = (struct WriteThis *)userp;
+ struct t668_WriteThis *pooh = (struct t668_WriteThis *)userp;
size_t len = strlen(pooh->readptr);
(void) size; /* Always 1.*/
CURLcode test(char *URL)
{
+ static const char testdata[] = "dummy";
+
CURL *easy = NULL;
curl_mime *mime = NULL;
curl_mimepart *part;
CURLcode res = TEST_ERR_FAILURE;
- struct WriteThis pooh1, pooh2;
+ struct t668_WriteThis pooh1, pooh2;
/*
* Check early end of part data detection.
curl_mime_name(part, "field1");
/* Early end of data detection can be done because the data size is known. */
curl_mime_data_cb(part, (curl_off_t) strlen(testdata),
- read_callback, NULL, NULL, &pooh1);
+ t668_read_cb, NULL, NULL, &pooh1);
part = curl_mime_addpart(mime);
curl_mime_name(part, "field2");
/* Using an undefined length forces chunked transfer and disables early
end of data detection for this part. */
- curl_mime_data_cb(part, (curl_off_t) -1, read_callback, NULL, NULL, &pooh2);
+ curl_mime_data_cb(part, (curl_off_t) -1, t668_read_cb,
+ NULL, NULL, &pooh2);
part = curl_mime_addpart(mime);
curl_mime_name(part, "field3");
/* Regular file part sources early end of data can be detected because
#define PAUSE_TIME 5
-
-static const char testname[] = "field";
-
-struct ReadThis {
+#ifndef LIB670_C
+#define LIB670_C
+struct t670_ReadThis {
CURL *easy;
time_t origin;
int count;
};
-
-static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
+static size_t t670_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
- struct ReadThis *pooh = (struct ReadThis *) userp;
+ struct t670_ReadThis *pooh = (struct t670_ReadThis *) userp;
time_t delta;
if(size * nmemb < 1)
curl_mfprintf(stderr, "Read callback called after EOF\n");
exit(1);
}
+#endif
#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)
+#ifndef LIB670_XFERINFO_C
+#define LIB670_XFERINFO_C
+static int t670_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;
+ struct t670_ReadThis *pooh = (struct t670_ReadThis *) clientp;
(void) dltotal;
(void) dlnow;
return 0;
}
#endif
+#endif
CURLcode test(char *URL)
{
+ static const char testname[] = "field";
+
#if defined(LIB670) || defined(LIB671)
curl_mime *mime = NULL;
curl_mimepart *part;
int still_running = 0;
#endif
- struct ReadThis pooh;
+ struct t670_ReadThis pooh;
CURLcode res = TEST_ERR_FAILURE;
/*
goto test_cleanup;
}
- res = curl_mime_data_cb(part, (curl_off_t) 2, read_callback,
+ res = curl_mime_data_cb(part, (curl_off_t) 2, t670_read_cb,
NULL, NULL, &pooh);
/* Bind mime data to its easy handle. */
}
/* We want to use our own read function. */
- test_setopt(pooh.easy, CURLOPT_READFUNCTION, read_callback);
+ test_setopt(pooh.easy, CURLOPT_READFUNCTION, t670_read_cb);
/* Send a multi-part formpost. */
test_setopt(pooh.easy, CURLOPT_HTTPPOST, formpost);
#else
/* Use the easy interface. */
test_setopt(pooh.easy, CURLOPT_XFERINFODATA, &pooh);
- test_setopt(pooh.easy, CURLOPT_XFERINFOFUNCTION, xferinfo);
+ test_setopt(pooh.easy, CURLOPT_XFERINFOFUNCTION, t670_xferinfo);
test_setopt(pooh.easy, CURLOPT_NOPROGRESS, 0L);
res = curl_easy_perform(pooh.easy);
#endif
#include "warnless.h"
#include "memdebug.h"
-static const char testcmd[] = "A1 IDLE\r\n";
-static char testbuf[1024];
-
CURLcode test(char *URL)
{
+ static const char testcmd[] = "A1 IDLE\r\n";
+ static char testbuf[1024];
+
CURLM *mcurl;
CURL *curl = NULL;
int mrun;
#include "warnless.h"
#include "memdebug.h"
-#define TEST_HANG_TIMEOUT 60 * 1000
#define MAX_EASY_HANDLES 3
static int ntlm_counter[MAX_EASY_HANDLES];
/* This source code is generated by mk-lib1521.pl ! */
-struct testdata {
- char *blaha;
+struct t1521_testdata {
+ char *blaha;
};
#define LO $minlong
name, val, curl_easy_strerror(val), lineno);
}
-static void geterr(const char *name, CURLcode val, int lineno)
+static void t1521_geterr(const char *name, CURLcode val, int lineno)
{
printf("CURLINFO_%s returned %d, \\"%s\\" on line %d\\n",
name, val, curl_easy_strerror(val), lineno);
struct curl_httppost *httppost = NULL;
curl_mime *mimepost = NULL;
FILE *stream = stderr;
- struct testdata object;
+ struct t1521_testdata object;
CURLU *curlu = (CURLU *)&object;
char *charp;
long val;
($_ =~ /^CURLINFO_([^ ]*) *= *CURLINFO_([^ ]*)/)) {
my ($info, $type)=($1, $2);
my $c = " res = curl_easy_getinfo(curl, CURLINFO_$info,";
- my $check = " if(res)\n geterr(\"$info\", res, __LINE__);\n";
+ my $check = " if(res)\n t1521_geterr(\"$info\", res, __LINE__);\n";
if($type eq "STRING") {
print $fh "$c &charp);\n$check";
}
return CURLE_UNSUPPORTED_PROTOCOL; \
}
#endif
+
+/* Set default that each test may override */
+#undef TEST_HANG_TIMEOUT
+#define TEST_HANG_TIMEOUT 60 * 1000
+
+#undef NUM_HANDLES
+#define NUM_HANDLES 4
static time_t epoch_offset; /* for test time tracing */
static int known_offset; /* for test time tracing */
-static
-void libtest_debug_dump(const char *timebuf, const char *text, FILE *stream,
- const unsigned char *ptr, size_t size, int nohex)
+static void libtest_debug_dump(const char *timebuf, const char *text,
+ FILE *stream, const unsigned char *ptr,
+ size_t size, int nohex)
{
size_t i;
size_t c;
(double)(newer.tv_usec-older.tv_usec)/1000000.0;
return (double)(newer.tv_usec-older.tv_usec)/1000000.0;
}
+
+/* build request url */
+char *tutil_suburl(const char *base, int i)
+{
+ return curl_maprintf("%s%.4d", base, i);
+}
+
+#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
+void tutil_rlim2str(char *buf, size_t len, rlim_t val)
+{
+#ifdef RLIM_INFINITY
+ if(val == RLIM_INFINITY) {
+ curl_msnprintf(buf, len, "INFINITY");
+ return;
+ }
+#endif
+#ifdef HAVE_LONGLONG
+ if(sizeof(rlim_t) > sizeof(long))
+ curl_msnprintf(buf, len, "%llu", (unsigned long long)val);
+ else
+#endif
+ {
+ if(sizeof(rlim_t) < sizeof(long))
+ curl_msnprintf(buf, len, "%u", (unsigned int)val);
+ else
+ curl_msnprintf(buf, len, "%lu", (unsigned long)val);
+ }
+}
+#endif
*/
double tutil_tvdiff_secs(struct timeval t1, struct timeval t2);
+/* build request url */
+char *tutil_suburl(const char *base, int i);
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#include <limits.h>
+
+#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
+void tutil_rlim2str(char *buf, size_t len, rlim_t val);
+#endif
+
#endif /* HEADER_CURL_LIBTEST_TESTUTIL_H */
+++ /dev/null
-#!/usr/bin/env bash
-#***************************************************************************
-# _ _ ____ _
-# Project ___| | | | _ \| |
-# / __| | | | |_) | |
-# | (__| |_| | _ <| |___
-# \___|\___/|_| \_\_____|
-#
-# Copyright (C) Viktor Szakats
-#
-# 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.
-#
-# SPDX-License-Identifier: curl
-#
-###########################################################################
-
-detect_in_reused_sources=1
-
-if [ "$detect_in_reused_sources" = '1' ]; then
- # Make symlinks for all re-used sources
- grep -E '^(lib|unit)[0-9]+_SOURCES = ' libtest/Makefile.inc unit/Makefile.inc \
- | sed -E 's@^([a-z]+)/[a-zA-Z.]+:(lib|unit)([0-9]+)_SOURCES = (lib|unit)([0-9]+).+@\1 \2 \3 \5@g' | \
- while read -r l; do
- if [[ "${l}" =~ ([a-z]+)\ ([a-z]+)\ ([0-9]+)\ ([0-9]+) ]]; then
- trg="${BASH_REMATCH[3]}"
- src="${BASH_REMATCH[4]}"
- if [ "${trg}" != "${src}" ]; then
- dir="${BASH_REMATCH[1]}"
- pfx="${BASH_REMATCH[2]}"
- ln -s "${pfx}${src}.c" "${dir}/${pfx}${trg}.c"
- fi
- fi
- done
-fi
-
-# Look for symbols possibly re-used in multiple sources.
-#
-# Falsely picks ups symbols in re-used sources, but guarded for a single use.
-# Misses shadowed variables.
-# shellcheck disable=SC2046
-grep -E '^ *(static|struct) +' $(find libtest unit -maxdepth 1 -name 'lib*.c' -o -name 'unit*.c' -o -name 'mk-*.pl') \
- | grep -E '^(libtest|unit)/' \
- | grep -E '\.(c|pl):(static|struct)( +[a-zA-Z_* ]+)? +[a-zA-Z_][a-zA-Z0-9_]+ *' | sort -u \
- | grep -o -E '[a-zA-Z_][a-zA-Z0-9_]+ *[=;[({]' | tr -d '=;[({ ' \
- | grep -v -E '^(NULL$|sizeof$|CURLE_)' \
- | sort | uniq -c | sort -k 2 | grep -v -E '^ +1 ' \
- | awk '{print " \"" $2 "\","}'
-
-echo '---'
-
-# Extract list of macros that may be re-used by multiple tests.
-#
-# Picks up false-positive when the macro is defined to the same value everywhere.
-# shellcheck disable=SC2046
-grep -E '^ *# *define +' $(find libtest unit -maxdepth 1 -name 'lib*.c' -o -name 'unit*.c' -o -name 'mk-*.pl') \
- | grep -E '^(libtest|unit)/' \
- | grep -o -E '.+\.(c|pl): *# *define +[A-Z_][A-Z0-9_]+' | sort -u \
- | grep -o -E '[A-Z_][A-Z0-9_]+' \
- | sort | uniq -c | sort -k 2 | grep -v -E '^ +1 ' \
- | awk '{print " \"" $2 "\","}'
-
-if [ "$detect_in_reused_sources" = '1' ]; then
- # Delete symlinks for all re-used sources
- find libtest unit -type l -delete
-fi
HEADER
;
-# TODO: Some of these might be subject for de-duplication or sync.
-my @reused_symbols = (
- "ReadThis",
- "ReadWriteSockets",
- "Sockets",
- "Tdata",
- "WriteThis",
- "addFd",
- "checkFdSet",
- "checkForCompletion",
- "close_file_descriptors",
- "curl", # shadow
- "curlSocketCallback",
- "curlTimerCallback",
- "cyclic_add",
- "easy", # unit
- "fopen_works",
- "getMicroSecondTimeout",
- "geterr",
- "hash_static", # unit
- "header_callback",
- "ioctlcallback",
- "msgbuff",
- "mydtor", # unit
- "num_open",
- "progress_callback",
- "read_callback",
- "readcallback",
- "recv_pong",
- "removeFd",
- "rlim2str",
- "run_thread",
- "seek_callback",
- "send_ping",
- "showem",
- "store_errmsg",
- "suburl",
- "test_failure", # shadow
- "test_fire",
- "test_lock",
- "test_once",
- "test_parse", # unit
- "test_rlimit",
- "test_unlock",
- "testbuf",
- "testcase", # unit
- "testdata",
- "testfd",
- "testname",
- "testpost",
- "tests", # unit
- "teststring",
- "trailers_callback",
- "transfer_status",
- "unit_setup", # unit
- "unit_stop", # unit
- "updateFdSet",
- "userdata",
- "websocket",
- "websocket_close",
- "write_callback",
- "write_cb",
- "writecb",
- "xferinfo",
- );
-
-# TODO: Some of these may be #undef-ed manually at the end of each source
-my @reused_macros = (
- "HEADER_REQUEST",
- "NUM_HANDLES",
- "SAFETY_MARGIN",
- "TEST_HANG_TIMEOUT",
- );
-
my $tlist = "";
while(my $line = <$fh>) {
my $src = "$2.c";
# Make common symbols unique across test sources
- foreach my $symb ("test", @reused_symbols) {
+ foreach my $symb ("test", "unit_setup", "unit_stop") {
print "#undef $symb\n";
print "#define $symb ${symb}_$name\n";
}
print "#define $namu\n";
print "#include \"$src\"\n";
print "#undef $namu\n";
-
- # Reset macros re-used by multiple tests
- foreach my $undef ("test", @reused_macros) {
- print "#undef $undef\n";
- }
-
print "\n";
-
$tlist .= " {\"$name\", test_$name},\n";
}
}
main_func = NULL;
{
size_t tmp;
- for(tmp = 0; s_mains[tmp].ptr; ++tmp) {
+ for(tmp = 0; tmp < CURL_ARRAYSIZE(s_mains); ++tmp) {
if(strcmp(main_name, s_mains[tmp].name) == 0) {
main_func = s_mains[tmp].ptr;
break;
# Bundle up individual tests into a single binary. The resulting binary can run
# individual tests by passing their name (without '.c') as the first argument.
-#
-# Usage: mk-bundle.pl [<server_c>]
use strict;
use warnings;
print <<FOOTER
static const struct onemain s_mains[] = {
-${tlist} {NULL, NULL}
-};
+$tlist};
#include "first.c"
FOOTER
#include "curlx/base64.h"
#include "memdebug.h" /* LAST include file */
-static struct Curl_easy *testdata;
+static struct Curl_easy *t1302_easy;
static CURLcode unit_setup(void)
{
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
- testdata = curl_easy_init();
- if(!testdata) {
+ t1302_easy = curl_easy_init();
+ if(!t1302_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
static void unit_stop(void)
{
- curl_easy_cleanup(testdata);
+ curl_easy_cleanup(t1302_easy);
curl_global_cleanup();
}
#include "connect.h"
#include "memdebug.h" /* LAST include file */
-static struct Curl_easy *testdata;
+static struct Curl_easy *t1303_easy;
static CURLcode unit_setup(void)
{
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
- testdata = curl_easy_init();
- if(!testdata) {
+ t1303_easy = curl_easy_init();
+ if(!t1303_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
static void unit_stop(void)
{
- curl_easy_cleanup(testdata);
+ curl_easy_cleanup(t1303_easy);
curl_global_cleanup();
}
/* 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) testdata->set.timeout = x; \
- testdata->set.connecttimeout = y
+#define TIMEOUTS(x,y) t1303_easy->set.timeout = x; \
+ t1303_easy->set.connecttimeout = y
/*
* To test:
};
/* this is the pretended start time of the transfer */
- testdata->progress.t_startsingle.tv_sec = BASE;
- testdata->progress.t_startsingle.tv_usec = 0;
- testdata->progress.t_startop.tv_sec = BASE;
- testdata->progress.t_startop.tv_usec = 0;
+ t1303_easy->progress.t_startsingle.tv_sec = BASE;
+ t1303_easy->progress.t_startsingle.tv_usec = 0;
+ t1303_easy->progress.t_startop.tv_sec = BASE;
+ t1303_easy->progress.t_startop.tv_usec = 0;
for(i = 0; i < CURL_ARRAYSIZE(run); 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(testdata, &now, run[i].connecting);
+ timeout = Curl_timeleft(t1303_easy, &now, run[i].connecting);
if(timeout != run[i].result)
fail(run[i].comment);
}
#include "memdebug.h" /* LAST include file */
-static struct Curl_easy *testdata;
+static struct Curl_easy *t1305_easy;
static struct Curl_dnscache hp;
static char *data_key;
static struct Curl_dns_entry *data_node;
static CURLcode unit_setup(void)
{
- testdata = curl_easy_init();
- if(!testdata) {
+ t1305_easy = curl_easy_init();
+ if(!t1305_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
free(data_key);
Curl_dnscache_destroy(&hp);
- curl_easy_cleanup(testdata);
+ curl_easy_cleanup(t1305_easy);
curl_global_cleanup();
}
#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 },
-
- /* https://codepoints.net/U+00E4 Latin Small Letter A with Diaeresis */
- { "Lindm\xc3\xa4tarv", "Lindm\xc3\xa4tarv", 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) {
UNITTEST_START
{
+ 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 },
+
+ /* https://codepoints.net/U+00E4 Latin Small Letter A with Diaeresis */
+ { "Lindm\xc3\xa4tarv", "Lindm\xc3\xa4tarv", 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}
+ };
+
int i;
enum system machine;
/* only these backends define the tested functions */
#if defined(USE_OPENSSL) || defined(USE_SCHANNEL)
#include "vtls/hostcheck.h"
-struct testcase {
- const char *host;
- const char *pattern;
- bool match;
-};
-
-static struct testcase tests[] = {
- {"", "", FALSE},
- {"a", "", FALSE},
- {"", "b", FALSE},
- {"a", "b", FALSE},
- {"aa", "bb", FALSE},
- {"\xff", "\xff", TRUE},
- {"aa.aa.aa", "aa.aa.bb", FALSE},
- {"aa.aa.aa", "aa.aa.aa", TRUE},
- {"aa.aa.aa", "*.aa.bb", FALSE},
- {"aa.aa.aa", "*.aa.aa", TRUE},
- {"192.168.0.1", "192.168.0.1", TRUE},
- {"192.168.0.1", "*.168.0.1", FALSE},
- {"192.168.0.1", "*.0.1", FALSE},
- {"h.ello", "*.ello", FALSE},
- {"h.ello.", "*.ello", FALSE},
- {"h.ello", "*.ello.", FALSE},
- {"h.e.llo", "*.e.llo", TRUE},
- {"h.e.llo", " *.e.llo", FALSE},
- {" h.e.llo", "*.e.llo", TRUE},
- {"h.e.llo.", "*.e.llo", TRUE},
- {"*.e.llo.", "*.e.llo", TRUE},
- {"************.e.llo.", "*.e.llo", TRUE},
- {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
- "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
- "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
- "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
- ".e.llo.", "*.e.llo", TRUE},
- {"\xfe\xfe.e.llo.", "*.e.llo", TRUE},
- {"h.e.llo.", "*.e.llo.", TRUE},
- {"h.e.llo", "*.e.llo.", TRUE},
- {".h.e.llo", "*.e.llo.", FALSE},
- {"h.e.llo", "*.*.llo.", FALSE},
- {"h.e.llo", "h.*.llo", FALSE},
- {"h.e.llo", "h.e.*", FALSE},
- {"hello", "*.ello", FALSE},
- {"hello", "**llo", FALSE},
- {"bar.foo.example.com", "*.example.com", FALSE},
- {"foo.example.com", "*.example.com", TRUE},
- {"baz.example.net", "b*z.example.net", FALSE},
- {"foobaz.example.net", "*baz.example.net", FALSE},
- {"xn--l8j.example.local", "x*.example.local", FALSE},
- {"xn--l8j.example.net", "*.example.net", TRUE},
- {"xn--l8j.example.net", "*j.example.net", FALSE},
- {"xn--l8j.example.net", "xn--l8j.example.net", TRUE},
- {"xn--l8j.example.net", "xn--l8j.*.net", FALSE},
- {"xl8j.example.net", "*.example.net", TRUE},
- {"fe80::3285:a9ff:fe46:b619", "*::3285:a9ff:fe46:b619", FALSE},
- {"fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619", TRUE},
- {NULL, NULL, FALSE}
-};
UNITTEST_START
{
+ struct testcase {
+ const char *host;
+ const char *pattern;
+ bool match;
+ };
+
+ static struct testcase tests[] = {
+ {"", "", FALSE},
+ {"a", "", FALSE},
+ {"", "b", FALSE},
+ {"a", "b", FALSE},
+ {"aa", "bb", FALSE},
+ {"\xff", "\xff", TRUE},
+ {"aa.aa.aa", "aa.aa.bb", FALSE},
+ {"aa.aa.aa", "aa.aa.aa", TRUE},
+ {"aa.aa.aa", "*.aa.bb", FALSE},
+ {"aa.aa.aa", "*.aa.aa", TRUE},
+ {"192.168.0.1", "192.168.0.1", TRUE},
+ {"192.168.0.1", "*.168.0.1", FALSE},
+ {"192.168.0.1", "*.0.1", FALSE},
+ {"h.ello", "*.ello", FALSE},
+ {"h.ello.", "*.ello", FALSE},
+ {"h.ello", "*.ello.", FALSE},
+ {"h.e.llo", "*.e.llo", TRUE},
+ {"h.e.llo", " *.e.llo", FALSE},
+ {" h.e.llo", "*.e.llo", TRUE},
+ {"h.e.llo.", "*.e.llo", TRUE},
+ {"*.e.llo.", "*.e.llo", TRUE},
+ {"************.e.llo.", "*.e.llo", TRUE},
+ {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+ "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
+ "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
+ "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
+ "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+ ".e.llo.", "*.e.llo", TRUE},
+ {"\xfe\xfe.e.llo.", "*.e.llo", TRUE},
+ {"h.e.llo.", "*.e.llo.", TRUE},
+ {"h.e.llo", "*.e.llo.", TRUE},
+ {".h.e.llo", "*.e.llo.", FALSE},
+ {"h.e.llo", "*.*.llo.", FALSE},
+ {"h.e.llo", "h.*.llo", FALSE},
+ {"h.e.llo", "h.e.*", FALSE},
+ {"hello", "*.ello", FALSE},
+ {"hello", "**llo", FALSE},
+ {"bar.foo.example.com", "*.example.com", FALSE},
+ {"foo.example.com", "*.example.com", TRUE},
+ {"baz.example.net", "b*z.example.net", FALSE},
+ {"foobaz.example.net", "*baz.example.net", FALSE},
+ {"xn--l8j.example.local", "x*.example.local", FALSE},
+ {"xn--l8j.example.net", "*.example.net", TRUE},
+ {"xn--l8j.example.net", "*j.example.net", FALSE},
+ {"xn--l8j.example.net", "xn--l8j.example.net", TRUE},
+ {"xn--l8j.example.net", "xn--l8j.*.net", FALSE},
+ {"xl8j.example.net", "*.example.net", TRUE},
+ {"fe80::3285:a9ff:fe46:b619", "*::3285:a9ff:fe46:b619", FALSE},
+ {"fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619", TRUE},
+ {NULL, NULL, FALSE}
+ };
+
int i;
for(i = 0; tests[i].host; i++) {
if(tests[i].match != Curl_cert_hostcheck(tests[i].pattern,
#pragma GCC diagnostic ignored "-Wformat"
#endif
-static CURLcode unit_setup(void) {return CURLE_OK;}
-static void unit_stop(void) {}
+static CURLcode unit_setup(void)
+{
+ return CURLE_OK;
+}
+
+static void unit_stop(void)
+{
+}
UNITTEST_START
static int usec_magnitude = 1000000;
-static bool unit_setup(void)
+static CURLcode unit_setup(void)
{
return CURLE_OK;
}
static void unit_stop(void)
{
-
}
/*
#include "urldata.h"
#include "curl_ntlm_core.h"
-static CURL *easy;
+static CURL *t1600_easy;
static CURLcode unit_setup(void)
{
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
- easy = curl_easy_init();
- if(!easy) {
+ t1600_easy = curl_easy_init();
+ if(!t1600_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
static void unit_stop(void)
{
- curl_easy_cleanup(easy);
+ curl_easy_cleanup(t1600_easy);
curl_global_cleanup();
}
#include <memdebug.h> /* LAST include file */
-static struct Curl_hash hash_static;
+static struct Curl_hash t1602_hash_static;
-static void mydtor(void *p)
+static void t1602_mydtor(void *p)
{
int *ptr = (int *)p;
free(ptr);
static CURLcode unit_setup(void)
{
- Curl_hash_init(&hash_static, 7, Curl_hash_str,
- curlx_str_key_compare, mydtor);
+ Curl_hash_init(&t1602_hash_static, 7, Curl_hash_str,
+ curlx_str_key_compare, t1602_mydtor);
return CURLE_OK;
}
static void unit_stop(void)
{
- Curl_hash_destroy(&hash_static);
+ Curl_hash_destroy(&t1602_hash_static);
}
UNITTEST_START
value = malloc(sizeof(int));
abort_unless(value != NULL, "Out of memory");
*value = 199;
- nodep = Curl_hash_add(&hash_static, &key, klen, value);
+ nodep = Curl_hash_add(&t1602_hash_static, &key, klen, value);
if(!nodep)
free(value);
abort_unless(nodep, "insertion into hash failed");
- Curl_hash_clean(&hash_static);
+ Curl_hash_clean(&t1602_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);
+ nodep = Curl_hash_add(&t1602_hash_static, &key2, klen, value2);
if(!nodep)
free(value2);
abort_unless(nodep, "insertion into hash failed");
#include "hash.h"
#include <memdebug.h> /* LAST include file */
-static struct Curl_hash hash_static;
+static struct Curl_hash t1603_hash_static;
static const size_t slots = 3;
-static void mydtor(void *p)
+static void t1603_mydtor(void *p)
{
/* Data are statically allocated */
(void)p; /* unused */
static CURLcode unit_setup(void)
{
- Curl_hash_init(&hash_static, slots, Curl_hash_str,
- curlx_str_key_compare, mydtor);
+ Curl_hash_init(&t1603_hash_static, slots, Curl_hash_str,
+ curlx_str_key_compare, t1603_mydtor);
return CURLE_OK;
}
static void unit_stop(void)
{
- Curl_hash_destroy(&hash_static);
+ Curl_hash_destroy(&t1603_hash_static);
}
UNITTEST_START
"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);
+ nodep = Curl_hash_add(&t1603_hash_static, &key1, strlen(key1), &key1);
fail_unless(nodep, "insertion into hash failed");
- nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
fail_unless(nodep == key1, "hash retrieval failed");
- nodep = Curl_hash_add(&hash_static, &key2, strlen(key2), &key2);
+ nodep = Curl_hash_add(&t1603_hash_static, &key2, strlen(key2), &key2);
fail_unless(nodep, "insertion into hash failed");
- nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key2, strlen(key2));
fail_unless(nodep == key2, "hash retrieval failed");
- nodep = Curl_hash_add(&hash_static, &key3, strlen(key3), &key3);
+ nodep = Curl_hash_add(&t1603_hash_static, &key3, strlen(key3), &key3);
fail_unless(nodep, "insertion into hash failed");
- nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
+ nodep = Curl_hash_pick(&t1603_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);
+ nodep = Curl_hash_add(&t1603_hash_static, &key4, strlen(key4), &key4);
fail_unless(nodep, "insertion into hash failed");
- nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+ nodep = Curl_hash_pick(&t1603_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));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
fail_unless(nodep == key1, "hash retrieval failed");
- nodep = Curl_hash_pick(&hash_static, &key2, strlen(key2));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key2, strlen(key2));
fail_unless(nodep == key2, "hash retrieval failed");
- nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key3, strlen(key3));
fail_unless(nodep == key3, "hash retrieval failed");
- nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+ nodep = Curl_hash_pick(&t1603_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));
+ rc = Curl_hash_delete(&t1603_hash_static, &key4, strlen(key4));
fail_unless(rc == 0, "hash delete failed");
- nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
fail_unless(nodep == key1, "hash retrieval failed");
- nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+ nodep = Curl_hash_pick(&t1603_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);
+ nodep = Curl_hash_add(&t1603_hash_static, &key4, strlen(key4), &key4);
fail_unless(nodep, "insertion into hash failed");
- nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+ nodep = Curl_hash_pick(&t1603_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));
+ rc = Curl_hash_delete(&t1603_hash_static, &key1, strlen(key1));
fail_unless(rc == 0, "hash delete failed");
- nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
fail_unless(!nodep, "hash retrieval should have failed");
- nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+ nodep = Curl_hash_pick(&t1603_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));
+ rc = Curl_hash_delete(&t1603_hash_static, &key4, strlen(key4));
fail_unless(rc == 0, "hash delete failed");
- nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key1, strlen(key1));
fail_unless(!nodep, "hash retrieval should have failed");
- nodep = Curl_hash_pick(&hash_static, &key4, strlen(key4));
+ nodep = Curl_hash_pick(&t1603_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));
+ rc = Curl_hash_delete(&t1603_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);
+ nodep = Curl_hash_add(&t1603_hash_static, &key1, strlen(key1), ¬akey);
fail_unless(nodep, "insertion into hash failed");
- nodep = Curl_hash_pick(&hash_static, &key1, strlen(key1));
+ nodep = Curl_hash_pick(&t1603_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));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key2, strlen(key2));
fail_unless(nodep == key2, "hash retrieval failed");
- nodep = Curl_hash_pick(&hash_static, &key3, strlen(key3));
+ nodep = Curl_hash_pick(&t1603_hash_static, &key3, strlen(key3));
fail_unless(nodep == key3, "hash retrieval failed");
/* Add element with own destructor */
- nodep = Curl_hash_add2(&hash_static, &key1, strlen(key1), &key1,
+ nodep = Curl_hash_add2(&t1603_hash_static, &key1, strlen(key1), &key1,
my_elem_dtor);
fail_unless(nodep, "add2 insertion into hash failed");
fail_unless(elem_dtor_calls == 0, "element destructor count should be 0");
/* Add it again, should invoke destructor on first */
- nodep = Curl_hash_add2(&hash_static, &key1, strlen(key1), &key1,
+ nodep = Curl_hash_add2(&t1603_hash_static, &key1, strlen(key1), &key1,
my_elem_dtor);
fail_unless(nodep, "add2 again, insertion into hash failed");
fail_unless(elem_dtor_calls == 1, "element destructor count should be 1");
/* remove, should invoke destructor */
- rc = Curl_hash_delete(&hash_static, &key1, strlen(key1));
+ rc = Curl_hash_delete(&t1603_hash_static, &key1, strlen(key1));
fail_unless(rc == 0, "hash delete failed");
fail_unless(elem_dtor_calls == 2, "element destructor count should be 1");
/* Clean up */
- Curl_hash_clean(&hash_static);
+ Curl_hash_clean(&t1603_hash_static);
UNITTEST_STOP
#include "llist.h"
-static CURL *easy;
+static CURL *t1605_easy;
static CURLcode unit_setup(void)
{
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
- easy = curl_easy_init();
- if(!easy) {
+ t1605_easy = curl_easy_init();
+ if(!t1605_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
static void unit_stop(void)
{
- curl_easy_cleanup(easy);
+ curl_easy_cleanup(t1605_easy);
curl_global_cleanup();
}
int len;
char *esc;
- esc = curl_easy_escape(easy, "", -1);
+ esc = curl_easy_escape(t1605_easy, "", -1);
fail_unless(esc == NULL, "negative string length can't work");
- esc = curl_easy_unescape(easy, "%41%41%41%41", -1, &len);
+ esc = curl_easy_unescape(t1605_easy, "%41%41%41%41", -1, &len);
fail_unless(esc == NULL, "negative string length can't work");
UNITTEST_STOP
#include "speedcheck.h"
#include "urldata.h"
-static struct Curl_easy *easy;
+static struct Curl_easy *t1606_easy;
static CURLcode unit_setup(void)
{
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
- easy = curl_easy_init();
- if(!easy) {
+ t1606_easy = curl_easy_init();
+ if(!t1606_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
static void unit_stop(void)
{
- curl_easy_cleanup(easy);
+ curl_easy_cleanup(t1606_easy);
curl_global_cleanup();
}
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);
+ curl_easy_setopt(t1606_easy, CURLOPT_LOW_SPEED_LIMIT, speed_limit);
+ curl_easy_setopt(t1606_easy, CURLOPT_LOW_SPEED_TIME, time_limit);
+ Curl_speedinit(t1606_easy);
do {
/* fake the current transfer speed */
- easy->progress.current_speed = speed;
- result = Curl_speedcheck(easy, now);
+ t1606_easy->progress.current_speed = speed;
+ result = Curl_speedcheck(t1606_easy, now);
if(result)
break;
/* step the time */
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;
-
- /* whether we expect a permanent or non-permanent cache entry */
- bool permanent;
-
- /* 0 to 9 addresses expected from hostcache */
- const char *address[10];
-};
-
-
/* In builds without IPv6 support CURLOPT_RESOLVE should skip over those
addresses, so we have to do that as well. */
static const char skip = 0;
#define IPV6ONLY(x) &skip
#endif
-/* CURLOPT_RESOLVE address parsing tests */
-static const struct testcase tests[] = {
- /* spaces aren't allowed, for now */
- { "test.com:80:127.0.0.1, 127.0.0.2",
- "test.com", 80, TRUE, { NULL, }
- },
- { "TEST.com:80:,,127.0.0.1,,,127.0.0.2,,,,::1,,,",
- "test.com", 80, TRUE, { "127.0.0.1", "127.0.0.2", IPV6ONLY("::1"), }
- },
- { "test.com:80:::1,127.0.0.1",
- "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
- },
- { "test.com:80:[::1],127.0.0.1",
- "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
- },
- { "test.com:80:::1",
- "test.com", 80, TRUE, { IPV6ONLY("::1"), }
- },
- { "test.com:80:[::1]",
- "test.com", 80, TRUE, { IPV6ONLY("::1"), }
- },
- { "test.com:80:127.0.0.1",
- "test.com", 80, TRUE, { "127.0.0.1", }
- },
- { "test.com:80:,127.0.0.1",
- "test.com", 80, TRUE, { "127.0.0.1", }
- },
- { "test.com:80:127.0.0.1,",
- "test.com", 80, TRUE, { "127.0.0.1", }
- },
- { "test.com:0:127.0.0.1",
- "test.com", 0, TRUE, { "127.0.0.1", }
- },
- { "+test.com:80:127.0.0.1,",
- "test.com", 80, FALSE, { "127.0.0.1", }
- },
-};
-
UNITTEST_START
{
+ struct testcase {
+ /* host:port:address[,address]... */
+ const char *optval;
+
+ /* lowercase host and port to retrieve the addresses from hostcache */
+ const char *host;
+ int port;
+
+ /* whether we expect a permanent or non-permanent cache entry */
+ bool permanent;
+
+ /* 0 to 9 addresses expected from hostcache */
+ const char *address[10];
+ };
+
+ /* CURLOPT_RESOLVE address parsing tests */
+ static const struct testcase tests[] = {
+ /* spaces aren't allowed, for now */
+ { "test.com:80:127.0.0.1, 127.0.0.2",
+ "test.com", 80, TRUE, { NULL, }
+ },
+ { "TEST.com:80:,,127.0.0.1,,,127.0.0.2,,,,::1,,,",
+ "test.com", 80, TRUE, { "127.0.0.1", "127.0.0.2", IPV6ONLY("::1"), }
+ },
+ { "test.com:80:::1,127.0.0.1",
+ "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
+ },
+ { "test.com:80:[::1],127.0.0.1",
+ "test.com", 80, TRUE, { IPV6ONLY("::1"), "127.0.0.1", }
+ },
+ { "test.com:80:::1",
+ "test.com", 80, TRUE, { IPV6ONLY("::1"), }
+ },
+ { "test.com:80:[::1]",
+ "test.com", 80, TRUE, { IPV6ONLY("::1"), }
+ },
+ { "test.com:80:127.0.0.1",
+ "test.com", 80, TRUE, { "127.0.0.1", }
+ },
+ { "test.com:80:,127.0.0.1",
+ "test.com", 80, TRUE, { "127.0.0.1", }
+ },
+ { "test.com:80:127.0.0.1,",
+ "test.com", 80, TRUE, { "127.0.0.1", }
+ },
+ { "test.com:0:127.0.0.1",
+ "test.com", 0, TRUE, { "127.0.0.1", }
+ },
+ { "+test.com:80:127.0.0.1,",
+ "test.com", 80, FALSE, { "127.0.0.1", }
+ },
+ };
+
int i;
struct Curl_multi *multi = NULL;
struct Curl_easy *easy = NULL;
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
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
{
+ 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];
+ };
+
+ 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", }
+ },
+ };
+
int i;
struct Curl_multi *multi = NULL;
struct Curl_easy *easy = NULL;
#include <uint-hash.h>
#include <memdebug.h> /* LAST include file */
-static struct uint_hash hash_static;
+static struct uint_hash t1616_hash_static;
-static void mydtor(unsigned int id, void *elem)
+static void t1616_mydtor(unsigned int id, void *elem)
{
int *ptr = (int *)elem;
(void)id;
static CURLcode unit_setup(void)
{
- Curl_uint_hash_init(&hash_static, 15, mydtor);
+ Curl_uint_hash_init(&t1616_hash_static, 15, t1616_mydtor);
return CURLE_OK;
}
static void unit_stop(void)
{
- Curl_uint_hash_destroy(&hash_static);
+ Curl_uint_hash_destroy(&t1616_hash_static);
}
UNITTEST_START
value = malloc(sizeof(int));
abort_unless(value != NULL, "Out of memory");
*value = 199;
- ok = Curl_uint_hash_set(&hash_static, key, value);
+ ok = Curl_uint_hash_set(&t1616_hash_static, key, value);
if(!ok)
free(value);
abort_unless(ok, "insertion into hash failed");
- v = Curl_uint_hash_get(&hash_static, key);
+ v = Curl_uint_hash_get(&t1616_hash_static, key);
abort_unless(v == value, "lookup present entry failed");
- v = Curl_uint_hash_get(&hash_static, key2);
+ v = Curl_uint_hash_get(&t1616_hash_static, key2);
abort_unless(!v, "lookup missing entry failed");
- Curl_uint_hash_clear(&hash_static);
+ Curl_uint_hash_clear(&t1616_hash_static);
/* Attempt to add another key/value pair */
value2 = malloc(sizeof(int));
abort_unless(value2 != NULL, "Out of memory");
*value2 = 204;
- ok = Curl_uint_hash_set(&hash_static, key2, value2);
+ ok = Curl_uint_hash_set(&t1616_hash_static, key2, value2);
if(!ok)
free(value2);
abort_unless(ok, "insertion into hash failed");
- v = Curl_uint_hash_get(&hash_static, key2);
+ v = Curl_uint_hash_get(&t1616_hash_static, key2);
abort_unless(v == value2, "lookup present entry failed");
- v = Curl_uint_hash_get(&hash_static, key);
+ v = Curl_uint_hash_get(&t1616_hash_static, key);
abort_unless(!v, "lookup missing entry failed");
UNITTEST_STOP
curl_global_cleanup();
}
-static void test_parse(
+static void t1620_parse(
const char *input,
const char *exp_username,
const char *exp_password,
rc = Curl_init_do(empty, empty->conn);
fail_unless(rc == CURLE_OK, "Curl_init_do() failed");
- test_parse("hostname", "hostname", NULL, NULL);
- test_parse("user:password", "user", "password", NULL);
- test_parse("user:password;options", "user", "password", "options");
- test_parse("user:password;options;more", "user", "password", "options;more");
- test_parse("", "", NULL, NULL);
- test_parse(":", "", "", NULL);
- test_parse(":;", "", "", NULL);
- test_parse(":password", "", "password", NULL);
- test_parse(":password;", "", "password", NULL);
- test_parse(";options", "", NULL, "options");
- test_parse("user;options", "user", NULL, "options");
- test_parse("user:;options", "user", "", "options");
- test_parse("user;options:password", "user", "password", "options");
- test_parse("user;options:", "user", "", "options");
+ t1620_parse("hostname", "hostname", NULL, NULL);
+ t1620_parse("user:password", "user", "password", NULL);
+ t1620_parse("user:password;options", "user", "password", "options");
+ t1620_parse("user:password;options;more", "user", "password",
+ "options;more");
+ t1620_parse("", "", NULL, NULL);
+ t1620_parse(":", "", "", NULL);
+ t1620_parse(":;", "", "", NULL);
+ t1620_parse(":password", "", "password", NULL);
+ t1620_parse(":password;", "", "password", NULL);
+ t1620_parse(";options", "", NULL, "options");
+ t1620_parse("user;options", "user", NULL, "options");
+ t1620_parse("user:;options", "user", "", "options");
+ t1620_parse("user;options:password", "user", "password", "options");
+ t1620_parse("user;options:", "user", "", "options");
Curl_freeset(empty);
for(i = (enum dupstring)0; i < STRING_LAST; i++) {
* updated to still be valid.
*/
-static struct Curl_easy *testdata;
+static struct Curl_easy *t1652_easy;
static char input[4096];
static char output[4096];
* 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)
+int debugf_cb(CURL *handle, curl_infotype type, char *buf, size_t size,
+ void *userptr)
{
(void)handle;
(void)type;
return 0;
}
-static CURLcode
-unit_setup(void)
+static CURLcode unit_setup(void)
{
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
- testdata = curl_easy_init();
- if(!testdata) {
+ t1652_easy = curl_easy_init();
+ if(!t1652_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
- curl_easy_setopt(testdata, CURLOPT_DEBUGFUNCTION, debugf_cb);
- curl_easy_setopt(testdata, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(t1652_easy, CURLOPT_DEBUGFUNCTION, debugf_cb);
+ curl_easy_setopt(t1652_easy, CURLOPT_VERBOSE, 1L);
return res;
}
-static void
-unit_stop(void)
+static void unit_stop(void)
{
- curl_easy_cleanup(testdata);
+ curl_easy_cleanup(t1652_easy);
curl_global_cleanup();
}
#endif
#endif
-/* Injecting a simple short string via a format */
-curl_msnprintf(input, sizeof(input), "Simple Test");
-Curl_infof(testdata, "%s", input);
-fail_unless(verify(output, input) == 0, "Simple string test");
-
-/* Injecting a few different variables with a format */
-Curl_infof(testdata, "%s %u testing %lu", input, 42, 43L);
-fail_unless(verify(output, "Simple Test 42 testing 43\n") == 0,
- "Format string");
-
-/* Variations of empty strings */
-Curl_infof(testdata, "");
-fail_unless(strlen(output) == 1, "Empty string");
-Curl_infof(testdata, "%s", (char *)NULL);
-fail_unless(verify(output, "(nil)") == 0, "Passing NULL as string");
-
-/* Note: libcurl's tracebuffer hold 2048 bytes, so the max strlen() we
- * get out of it is 2047, since we need a \0 at the end.
- * Curl_infof() in addition adds a \n at the end, making the effective
- * output 2046 characters.
- * Any input that long or longer will truncated, ending in '...\n'.
- */
-
-/* A string just long enough to not be truncated */
-memset(input, '\0', sizeof(input));
-memset(input, 'A', 2045);
-Curl_infof(testdata, "%s", input);
-fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
-/* output is input + \n */
-fail_unless(strlen(output) == 2046, "No truncation of infof input");
-fail_unless(verify(output, input) == 0, "No truncation of infof input");
-fail_unless(output[sizeof(output) - 1] == '\0',
- "No truncation of infof input");
-
-/* Just over the limit without newline for truncation via '...' */
-memset(input + 2045, 'A', 4);
-Curl_infof(testdata, "%s", input);
-fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
-fail_unless(strlen(output) == 2047, "Truncation of infof input 1");
-fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 1");
-
-/* Just over the limit with newline for truncation via '...' */
-memset(input + 2045, 'A', 4);
-memset(input + 2045 + 4, '\n', 1);
-Curl_infof(testdata, "%s", input);
-fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
-fail_unless(strlen(output) == 2047, "Truncation of infof input 2");
-fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 2");
-
-/* Way over the limit for truncation via '...' */
-memset(input, '\0', sizeof(input));
-memset(input, 'A', sizeof(input) - 1);
-Curl_infof(testdata, "%s", input);
-fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
-fail_unless(strlen(output) == 2047, "Truncation of infof input 3");
-fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 3");
+ /* Injecting a simple short string via a format */
+ curl_msnprintf(input, sizeof(input), "Simple Test");
+ Curl_infof(t1652_easy, "%s", input);
+ fail_unless(verify(output, input) == 0, "Simple string test");
+
+ /* Injecting a few different variables with a format */
+ Curl_infof(t1652_easy, "%s %u testing %lu", input, 42, 43L);
+ fail_unless(verify(output, "Simple Test 42 testing 43\n") == 0,
+ "Format string");
+
+ /* Variations of empty strings */
+ Curl_infof(t1652_easy, "");
+ fail_unless(strlen(output) == 1, "Empty string");
+ Curl_infof(t1652_easy, "%s", (char *)NULL);
+ fail_unless(verify(output, "(nil)") == 0, "Passing NULL as string");
+
+ /* Note: libcurl's tracebuffer hold 2048 bytes, so the max strlen() we
+ * get out of it is 2047, since we need a \0 at the end.
+ * Curl_infof() in addition adds a \n at the end, making the effective
+ * output 2046 characters.
+ * Any input that long or longer will truncated, ending in '...\n'.
+ */
+
+ /* A string just long enough to not be truncated */
+ memset(input, '\0', sizeof(input));
+ memset(input, 'A', 2045);
+ Curl_infof(t1652_easy, "%s", input);
+ fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+ /* output is input + \n */
+ fail_unless(strlen(output) == 2046, "No truncation of infof input");
+ fail_unless(verify(output, input) == 0, "No truncation of infof input");
+ fail_unless(output[sizeof(output) - 1] == '\0',
+ "No truncation of infof input");
+
+ /* Just over the limit without newline for truncation via '...' */
+ memset(input + 2045, 'A', 4);
+ Curl_infof(t1652_easy, "%s", input);
+ fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+ fail_unless(strlen(output) == 2047, "Truncation of infof input 1");
+ fail_unless(output[sizeof(output) - 1] == '\0',
+ "Truncation of infof input 1");
+
+ /* Just over the limit with newline for truncation via '...' */
+ memset(input + 2045, 'A', 4);
+ memset(input + 2045 + 4, '\n', 1);
+ Curl_infof(t1652_easy, "%s", input);
+ fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+ fail_unless(strlen(output) == 2047, "Truncation of infof input 2");
+ fail_unless(output[sizeof(output) - 1] == '\0',
+ "Truncation of infof input 2");
+
+ /* Way over the limit for truncation via '...' */
+ memset(input, '\0', sizeof(input));
+ memset(input, 'A', sizeof(input) - 1);
+ Curl_infof(t1652_easy, "%s", input);
+ fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+ fail_unless(strlen(output) == 2047, "Truncation of infof input 3");
+ fail_unless(output[sizeof(output) - 1] == '\0',
+ "Truncation of infof input 3");
#if defined(CURL_GNUC_DIAG) && !defined(__clang__)
#pragma GCC diagnostic pop
static CURLU *u;
-static CURLcode
-unit_setup(void)
+static CURLcode unit_setup(void)
{
return CURLE_OK;
}
-static void
-unit_stop(void)
+static void unit_stop(void)
{
curl_global_cleanup();
}
#include "urldata.h"
#include "altsvc.h"
-static CURLcode
-unit_setup(void)
+static CURLcode unit_setup(void)
{
return CURLE_OK;
}
-static void
-unit_stop(void)
+static void unit_stop(void)
{
curl_global_cleanup();
}
#include "urldata.h"
#include "hsts.h"
-static CURLcode
-unit_setup(void)
+static CURLcode unit_setup(void)
{
return CURLE_OK;
}
-static void
-unit_stop(void)
+static void unit_stop(void)
{
curl_global_cleanup();
}
curl_global_cleanup();
}
-static void test_parse(
+static void t1663_parse(
const char *input_data,
const char *exp_dev,
const char *exp_iface,
UNITTEST_START
{
- test_parse("dev", "dev", NULL, NULL, CURLE_OK);
- test_parse("if!eth0", NULL, "eth0", NULL, CURLE_OK);
- test_parse("host!myname", NULL, NULL, "myname", CURLE_OK);
- test_parse("ifhost!eth0!myname", NULL, "eth0", "myname", CURLE_OK);
- test_parse("", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
- test_parse("!", "!", NULL, NULL, CURLE_OK);
- test_parse("if!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
- test_parse("if!eth0!blubb", NULL, "eth0!blubb", NULL, CURLE_OK);
- test_parse("host!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
- test_parse("ifhost!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
- test_parse("ifhost!eth0", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
- test_parse("ifhost!eth0!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+ t1663_parse("dev", "dev", NULL, NULL, CURLE_OK);
+ t1663_parse("if!eth0", NULL, "eth0", NULL, CURLE_OK);
+ t1663_parse("host!myname", NULL, NULL, "myname", CURLE_OK);
+ t1663_parse("ifhost!eth0!myname", NULL, "eth0", "myname", CURLE_OK);
+ t1663_parse("", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+ t1663_parse("!", "!", NULL, NULL, CURLE_OK);
+ t1663_parse("if!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+ t1663_parse("if!eth0!blubb", NULL, "eth0!blubb", NULL, CURLE_OK);
+ t1663_parse("host!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+ t1663_parse("ifhost!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+ t1663_parse("ifhost!eth0", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
+ t1663_parse("ifhost!eth0!", NULL, NULL, NULL, CURLE_BAD_FUNCTION_ARGUMENT);
}
UNITTEST_STOP
#include "curl_trc.h"
#include "memdebug.h"
-static CURL *easy;
+static CURL *t2600_easy;
static CURLcode unit_setup(void)
{
CURLcode res = CURLE_OK;
global_init(CURL_GLOBAL_ALL);
- easy = curl_easy_init();
- if(!easy) {
+ t2600_easy = curl_easy_init();
+ if(!t2600_easy) {
curl_global_cleanup();
return CURLE_OUT_OF_MEMORY;
}
curl_global_trace("all");
- curl_easy_setopt(easy, CURLOPT_VERBOSE, 1L);
+ curl_easy_setopt(t2600_easy, CURLOPT_VERBOSE, 1L);
return res;
}
static void unit_stop(void)
{
- curl_easy_cleanup(easy);
+ curl_easy_cleanup(t2600_easy);
curl_global_cleanup();
}
list = curl_slist_append(NULL, tc->resolve_info);
fail_unless(list, "error allocating resolve list entry");
- curl_easy_setopt(easy, CURLOPT_RESOLVE, list);
- curl_easy_setopt(easy, CURLOPT_IPRESOLVE, (long)tc->ip_version);
- curl_easy_setopt(easy, CURLOPT_CONNECTTIMEOUT_MS,
+ curl_easy_setopt(t2600_easy, CURLOPT_RESOLVE, list);
+ curl_easy_setopt(t2600_easy, CURLOPT_IPRESOLVE, (long)tc->ip_version);
+ curl_easy_setopt(t2600_easy, CURLOPT_CONNECTTIMEOUT_MS,
(long)tc->connect_timeout_ms);
- curl_easy_setopt(easy, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS,
+ curl_easy_setopt(t2600_easy, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS,
(long)tc->he_timeout_ms);
- curl_easy_setopt(easy, CURLOPT_URL, tc->url);
+ curl_easy_setopt(t2600_easy, CURLOPT_URL, tc->url);
memset(&tr, 0, sizeof(tr));
tr.cf6.family = "v6";
tr.cf4.family = "v4";
tr.started = curlx_now();
- tr.result = curl_easy_perform(easy);
+ tr.result = curl_easy_perform(t2600_easy);
tr.ended = curlx_now();
- curl_easy_setopt(easy, CURLOPT_RESOLVE, NULL);
+ curl_easy_setopt(t2600_easy, CURLOPT_RESOLVE, NULL);
curl_slist_free_all(list);
list = NULL;
current_tc = NULL;
return CURLE_OK;
}
-static CURLcode unit_stop(void)
+static void unit_stop(void)
{
- return CURLE_OK;
}
#if defined(CURL_GNUC_DIAG) || defined(__clang__)