]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test1522: add debug tracing
authorDaniel Stenberg <daniel@haxx.se>
Wed, 16 Dec 2020 09:39:41 +0000 (10:39 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 17 Dec 2020 15:55:56 +0000 (16:55 +0100)
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

tests/libtest/Makefile.inc
tests/libtest/lib1522.c

index 1628671c7fe3bce5232444a1e7bab10f2c644d89..c23bc5b1a0ff51c29424e68a510a10b0465a6a8b 100644 (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)
index e070e80f47b057abd83384ed9aee1190e3870712..2532a6ca22bd869125618b13d9315817a0f8aab5 100644 (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;