Merge pull request #2512 from Stackdriver/pri
[collectd.git] / src / libcollectdclient / network_parse_test.c
index 9efd4bd..a638642 100644 (file)
@@ -245,10 +245,9 @@ static int test_network_parse() {
     uint8_t buffer[LCC_NETWORK_BUFFER_SIZE_DEFAULT];
     size_t buffer_size = sizeof(buffer);
     if (decode_string(raw_packet_data[i], buffer, &buffer_size)) {
-      fprintf(
-          stderr,
-          "lcc_network_parse(raw_packet_data[%zu]): decoding string failed\n",
-          i);
+      fprintf(stderr, "lcc_network_parse(raw_packet_data[%" PRIsz "]):"
+                      " decoding string failed\n",
+              i);
       return -1;
     }
 
@@ -257,12 +256,13 @@ static int test_network_parse() {
                                                    .writer = nop_writer,
                                                });
     if (status != 0) {
-      fprintf(stderr, "lcc_network_parse(raw_packet_data[%zu]) = %d, want 0\n",
+      fprintf(stderr,
+              "lcc_network_parse(raw_packet_data[%" PRIsz "]) = %d, want 0\n",
               i, status);
       ret = status;
     }
 
-    printf("ok - lcc_network_parse(raw_packet_data[%zu])\n", i);
+    printf("ok - lcc_network_parse(raw_packet_data[%" PRIsz "])\n", i);
   }
 
   return ret;
@@ -376,7 +376,7 @@ static int test_parse_values() {
   }
 
   if (vl.values_len != 3) {
-    fprintf(stderr, "parse_values(): vl.values_len = %zu, want 3\n",
+    fprintf(stderr, "parse_values(): vl.values_len = %" PRIsz ", want 3\n",
             vl.values_len);
     return -1;
   }
@@ -384,7 +384,8 @@ static int test_parse_values() {
   int want_types[] = {LCC_TYPE_GAUGE, LCC_TYPE_DERIVE, LCC_TYPE_GAUGE};
   for (size_t i = 0; i < sizeof(want_types) / sizeof(want_types[0]); i++) {
     if (vl.values_types[i] != want_types[i]) {
-      fprintf(stderr, "parse_values(): vl.values_types[%zu] = %d, want %d\n", i,
+      fprintf(stderr,
+              "parse_values(): vl.values_types[%" PRIsz "] = %d, want %d\n", i,
               vl.values_types[i], want_types[i]);
       ret = -1;
     }
@@ -412,6 +413,7 @@ static int test_parse_values() {
   return ret;
 }
 
+#if HAVE_GCRYPT_H
 static int test_verify_sha256() {
   int ret = 0;
 
@@ -441,7 +443,9 @@ static int test_verify_sha256() {
 
   return ret;
 }
+#endif
 
+#if HAVE_GCRYPT_H
 static int test_decrypt_aes256() {
   char const *iv_str = "4cbe2a747c9f9dcfa0e66f0c2fa74875";
   uint8_t iv[16] = {0};
@@ -480,12 +484,11 @@ static int test_decrypt_aes256() {
 
   return 0;
 }
+#endif
 
 int main(void) {
   int ret = 0;
 
-  printf("libcollectdclient/server_test.c\n");
-
   int status;
   if ((status = test_network_parse())) {
     ret = status;
@@ -500,12 +503,14 @@ int main(void) {
     ret = status;
   }
 
+#if HAVE_GCRYPT_H
   if ((status = test_verify_sha256())) {
     ret = status;
   }
   if ((status = test_decrypt_aes256())) {
     ret = status;
   }
+#endif
 
   return ret;
 }