test1522: add debug tracing

I used this to track down some issues and I figured I could just as well
keep this extra logging in here for future needs.

Closes #6331
This commit is contained in:
Daniel Stenberg 2020-12-16 10:39:41 +01:00
parent a5bc272223
commit ff4d2c2a05
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 22 additions and 12 deletions

View file

@ -481,7 +481,8 @@ lib1520_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1520
nodist_lib1521_SOURCES = lib1521.c $(SUPPORTFILES)
lib1521_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)
lib1522_SOURCES = lib1522.c $(SUPPORTFILES)
lib1522_SOURCES = lib1522.c $(SUPPORTFILES) $(TESTUTIL) $(TSTTRACE)
lib1522_LDADD = $(TESTUTIL_LIBS)
lib1522_CPPFLAGS = $(AM_CPPFLAGS)
lib1523_SOURCES = lib1523.c $(SUPPORTFILES)

View file

@ -23,6 +23,7 @@
/* test case and code based on https://github.com/curl/curl/issues/2847 */
#include "testtrace.h"
#include "testutil.h"
#include "warnless.h"
#include "memdebug.h"
@ -49,25 +50,32 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
int test(char *URL)
{
CURLcode code;
CURLcode res;
struct curl_slist *pHeaderList = NULL;
CURL *pCurl = curl_easy_init();
CURL *curl = curl_easy_init();
memset(g_Data, 'A', sizeof(g_Data)); /* send As! */
curl_easy_setopt(pCurl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
curl_easy_setopt(pCurl, CURLOPT_URL, URL);
curl_easy_setopt(pCurl, CURLOPT_POSTFIELDS, g_Data);
curl_easy_setopt(pCurl, CURLOPT_POSTFIELDSIZE, (long)sizeof(g_Data));
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
curl_easy_setopt(curl, CURLOPT_URL, URL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, g_Data);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)sizeof(g_Data));
libtest_debug_config.nohex = 1;
libtest_debug_config.tracetime = 1;
test_setopt(curl, CURLOPT_DEBUGDATA, &libtest_debug_config);
test_setopt(curl, CURLOPT_DEBUGFUNCTION, libtest_debug_cb);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* Remove "Expect: 100-continue" */
pHeaderList = curl_slist_append(pHeaderList, "Expect:");
curl_easy_setopt(pCurl, CURLOPT_HTTPHEADER, pHeaderList);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, pHeaderList);
code = curl_easy_perform(pCurl);
code = curl_easy_perform(curl);
if(code == CURLE_OK) {
curl_off_t uploadSize;
curl_easy_getinfo(pCurl, CURLINFO_SIZE_UPLOAD_T, &uploadSize);
curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD_T, &uploadSize);
printf("uploadSize = %ld\n", (long)uploadSize);
@ -75,15 +83,16 @@ int test(char *URL)
printf("!!!!!!!!!! PASS\n");
}
else {
printf("!!!!!!!!!! FAIL\n");
printf("sent %d, libcurl says %d\n",
(int)sizeof(g_Data), (int)uploadSize);
}
}
else {
printf("curl_easy_perform() failed. e = %d\n", code);
}
test_cleanup:
curl_slist_free_all(pHeaderList);
curl_easy_cleanup(pCurl);
curl_easy_cleanup(curl);
curl_global_cleanup();
return 0;