]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: tidy up server main function, whitespace and README
authorViktor Szakats <commit@vsz.me>
Sun, 15 Jun 2025 11:21:22 +0000 (13:21 +0200)
committerViktor Szakats <commit@vsz.me>
Sun, 15 Jun 2025 12:11:21 +0000 (14:11 +0200)
Follow-up to 2c27a67daa1b76859c18d63e4e1f528db05b5e13 #17590

Closes #17625

tests/server/first.c
tests/unit/README.md
tests/unit/curlcheck.h

index 3931b58672d989aed244da8dde730aa84c0f820f..430f3674deee242a49e83105a9d4022d35854657 100644 (file)
@@ -28,6 +28,7 @@ int main(int argc, char **argv)
 {
   entry_func_t entry_func;
   char *entry_name;
+  size_t tmp;
 
   if(argc < 2) {
     fprintf(stderr, "Pass servername as first argument\n");
@@ -36,13 +37,10 @@ int main(int argc, char **argv)
 
   entry_name = argv[1];
   entry_func = NULL;
-  {
-    size_t tmp;
-    for(tmp = 0; tmp < CURL_ARRAYSIZE(s_entries); ++tmp) {
-      if(strcmp(entry_name, s_entries[tmp].name) == 0) {
-        entry_func = s_entries[tmp].ptr;
-        break;
-      }
+  for(tmp = 0; tmp < CURL_ARRAYSIZE(s_entries); ++tmp) {
+    if(strcmp(entry_name, s_entries[tmp].name) == 0) {
+      entry_func = s_entries[tmp].ptr;
+      break;
     }
   }
 
@@ -51,8 +49,5 @@ int main(int argc, char **argv)
     return 99;
   }
 
-  --argc;
-  ++argv;
-
-  return entry_func(argc, argv);
+  return entry_func(argc - 1, argv + 1);
 }
index 82407e941504b264a3eb1819ee1dcbd954234239..aa545205efe7c9ee0c214bf08a33b21539357cad 100644 (file)
@@ -70,20 +70,20 @@ Here's an example using optional initialization and cleanup:
 
     #include "a libcurl header.h" /* from the lib dir */
 
-    static CURLcode unit_setup( void )
+    static CURLcode t9999_setup(void)
     {
       /* whatever you want done first */
       return CURLE_OK;
     }
 
-    static void unit_stop( void )
+    static void t9999_stop(void)
     {
       /* done before shutting down and exiting */
     }
 
     static CURLcode test_unit9999(char *arg)
     {
-      UNITTEST_BEGIN(unit_setup())
+      UNITTEST_BEGIN(t9999_setup())
 
       /* here you start doing things and checking that the results are good */
 
@@ -92,6 +92,6 @@ Here's an example using optional initialization and cleanup:
 
       /* you end the test code like this: */
 
-      UNITTEST_END(unit_stop())
+      UNITTEST_END(t9999_stop())
     }
 ~~~
index 6364e16800c1194e3579f4da20b1ae8475a59ae7..9f9b01f5f53e83d486166b289f39aec9e78477bb 100644 (file)
     }                                                            \
   } while(0)
 
-#define verify_memory(dynamic, check, len)                              \
-  do {                                                                  \
-    if(dynamic && memcmp(dynamic, check, len)) {                        \
-      curl_mfprintf(stderr, "%s:%d Memory buffer FAILED match size %d. " \
-                    "'%s' is not\n", __FILE__, __LINE__, len,           \
-                    hexdump((const unsigned char *)check, len));        \
+#define verify_memory(dynamic, check, len)                                  \
+  do {                                                                      \
+    if(dynamic && memcmp(dynamic, check, len)) {                            \
+      curl_mfprintf(stderr, "%s:%d Memory buffer FAILED match size %d. "    \
+                    "'%s' is not\n", __FILE__, __LINE__, len,               \
+                    hexdump((const unsigned char *)check, len));            \
       curl_mfprintf(stderr, "%s:%d the same as '%s'\n", __FILE__, __LINE__, \
-                    hexdump((const unsigned char *)dynamic, len));      \
-      unitfail++;                                                       \
-    }                                                                   \
+                    hexdump((const unsigned char *)dynamic, len));          \
+      unitfail++;                                                           \
+    }                                                                       \
   } while(0)
 
 /* fail() is for when the test case figured out by itself that a check