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;
}
- int status =
- lcc_network_parse(buffer, buffer_size, (lcc_network_parse_options_t){
- .writer = nop_writer,
- });
+ int status = lcc_network_parse(buffer, buffer_size,
+ (lcc_network_parse_options_t){
+ .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;
}
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;
}
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;
}
return ret;
}
+#if HAVE_GCRYPT_H
static int test_verify_sha256() {
int ret = 0;
return ret;
}
+#endif
+#if HAVE_GCRYPT_H
static int test_decrypt_aes256() {
char const *iv_str = "4cbe2a747c9f9dcfa0e66f0c2fa74875";
uint8_t iv[16] = {0};
int status = decrypt_aes256(
&(buffer_t){
- .data = ciphertext, .len = ciphertext_len,
+ .data = ciphertext,
+ .len = ciphertext_len,
},
iv, iv_len, "admin");
if (status != 0) {
return 0;
}
+#endif
int main(void) {
int ret = 0;
- printf("libcollectdclient/server_test.c\n");
-
int status;
if ((status = test_network_parse())) {
ret = status;
ret = status;
}
+#if HAVE_GCRYPT_H
if ((status = test_verify_sha256())) {
ret = status;
}
if ((status = test_decrypt_aes256())) {
ret = status;
}
+#endif
return ret;
}