summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-12-16 10:39:41 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-12-17 13:54:08 +0100
commit5a7642edbddee5ec6c75d15eb38b16db50744139 (patch)
treed535387ebf1135d84d1ca90ed84473642734ddf4
parent30fc1cc7dbab5ec1fba3105f3563b86497916b2e (diff)
downloadcurl-bagder/debug-1522.tar.gz
test1522: add debug tracingbagder/debug-1522
I used it to track down some issues and I figured I could just as well keep this extra logging for future needs.
-rw-r--r--tests/libtest/Makefile.inc3
-rw-r--r--tests/libtest/lib1522.c31
2 files changed, 22 insertions, 12 deletions
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 1628671c7..c23bc5b1a 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -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)
diff --git a/tests/libtest/lib1522.c b/tests/libtest/lib1522.c
index e070e80f4..2532a6ca2 100644
--- a/tests/libtest/lib1522.c
+++ b/tests/libtest/lib1522.c
@@ -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;