summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2024-03-04 22:56:45 +0000
committerHugo Landau <hlandau@openssl.org>2024-03-06 20:44:48 +0000
commit8d8866aff39399dbee2d49c59aca466794c53ba7 (patch)
treec1b76e1195886420f4d5458bbc822de7bcba1a2a /test
parent6a11cd50d52694353d7bb11421490939d92df1b6 (diff)
QUIC QLOG: Fix ANSI
Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Neil Horman <nhorman@openssl.org> (Merged from https://github.com/openssl/openssl/pull/23744)
Diffstat (limited to 'test')
-rw-r--r--test/json_test.c2
-rw-r--r--test/quic_qlog_test.c68
2 files changed, 51 insertions, 19 deletions
diff --git a/test/json_test.c b/test/json_test.c
index 8cde1be2e3..5a054b7c6d 100644
--- a/test/json_test.c
+++ b/test/json_test.c
@@ -89,7 +89,7 @@ enum {
OPK_CALL_D, /* (OSSL_JSON_ENC *, double) */
OPK_CALL_PZ, /* (OSSL_JSON_ENC *, const void *, size_t) */
OPK_ASSERT_ERROR, /* (OSSL_JSON_ENC *, int expect_error) */
- OPK_INIT_FLAGS, /* (uint32_t flags) */
+ OPK_INIT_FLAGS /* (uint32_t flags) */
};
typedef void (*fp_type)(OSSL_JSON_ENC *);
diff --git a/test/quic_qlog_test.c b/test/quic_qlog_test.c
index fb94531733..e54ced2f0e 100644
--- a/test/quic_qlog_test.c
+++ b/test/quic_qlog_test.c
@@ -10,23 +10,55 @@
#include "internal/qlog.h"
#include "testutil.h"
-static const char expected[] =
- "\x1e{\"qlog_version\":\"0.3\",\"qlog_format\":\"JSON-SEQ\",\"title\":"
- "\"test title\",\"description\":\"test description\",\"trace\":{"
- "\"common_fields\":{\"time_format\":\"delta\",\"protocol_type\":"
- "[\"QUIC\"],\"group_id\":\"test group ID\",\"system_info\":{"
- "\"process_id\":123}},\"vantage_point\":{\"type\":\"client\","
- "\"name\":\"OpenSSL/x.y.z\"}}}\n"
-
- "\x1e{\"name\":\"transport:packet_sent\",\"data\":{\"field1\":\"foo\","
- "\"field2\":\"bar\",\"field3\":42,\"field4\":\"1152921504606846976\","
- "\"field5\":\"18446744073709551615\",\"field6\":false,\"field7\":true,"
- "\"field8\":\"01af\",\"field9\":\"55\",\"subgroup\":{\"field10\":\"baz\"},"
- "\"array\":[\"a\",\"b\"]},\"time\":170653117000}\n"
-
- "\x1e{\"name\":\"transport:packet_sent\",\"data\":{\"field1\":\"bar\"},"
- "\"time\":1000}\n"
- ;
+/*
+ * Unfortunately, this must be expressed as an array and not a string literal as
+ * ANSI C only guarantees support for up to 509 characters in a string literal.
+ */
+static const char expected[] = {
+ 30, '{', '"', 'q', 'l', 'o', 'g', '_', 'v', 'e', 'r', 's', 'i', 'o', 'n',
+ '"', ':', '"', '0', '.', '3', '"', ',', '"', 'q', 'l', 'o', 'g', '_', 'f',
+ 'o', 'r', 'm', 'a', 't', '"', ':', '"', 'J', 'S', 'O', 'N', '-', 'S', 'E',
+ 'Q', '"', ',', '"', 't', 'i', 't', 'l', 'e', '"', ':', '"', 't', 'e', 's',
+ 't', ' ', 't', 'i', 't', 'l', 'e', '"', ',', '"', 'd', 'e', 's', 'c', 'r',
+ 'i', 'p', 't', 'i', 'o', 'n', '"', ':', '"', 't', 'e', 's', 't', ' ', 'd',
+ 'e', 's', 'c', 'r', 'i', 'p', 't', 'i', 'o', 'n', '"', ',', '"', 't', 'r',
+ 'a', 'c', 'e', '"', ':', '{', '"', 'c', 'o', 'm', 'm', 'o', 'n', '_', 'f',
+ 'i', 'e', 'l', 'd', 's', '"', ':', '{', '"', 't', 'i', 'm', 'e', '_', 'f',
+ 'o', 'r', 'm', 'a', 't', '"', ':', '"', 'd', 'e', 'l', 't', 'a', '"', ',',
+ '"', 'p', 'r', 'o', 't', 'o', 'c', 'o', 'l', '_', 't', 'y', 'p', 'e', '"',
+ ':', '[', '"', 'Q', 'U', 'I', 'C', '"', ']', ',', '"', 'g', 'r', 'o', 'u',
+ 'p', '_', 'i', 'd', '"', ':', '"', 't', 'e', 's', 't', ' ', 'g', 'r', 'o',
+ 'u', 'p', ' ', 'I', 'D', '"', ',', '"', 's', 'y', 's', 't', 'e', 'm', '_',
+ 'i', 'n', 'f', 'o', '"', ':', '{', '"', 'p', 'r', 'o', 'c', 'e', 's', 's',
+ '_', 'i', 'd', '"', ':', '1', '2', '3', '}', '}', ',', '"', 'v', 'a', 'n',
+ 't', 'a', 'g', 'e', '_', 'p', 'o', 'i', 'n', 't', '"', ':', '{', '"', 't',
+ 'y', 'p', 'e', '"', ':', '"', 'c', 'l', 'i', 'e', 'n', 't', '"', ',', '"',
+ 'n', 'a', 'm', 'e', '"', ':', '"', 'O', 'p', 'e', 'n', 'S', 'S', 'L', '/',
+ 'x', '.', 'y', '.', 'z', '"', '}', '}', '}', 10, 30, '{', '"', 'n', 'a',
+ 'm', 'e', '"', ':', '"', 't', 'r', 'a', 'n', 's', 'p', 'o', 'r', 't', ':',
+ 'p', 'a', 'c', 'k', 'e', 't', '_', 's', 'e', 'n', 't', '"', ',', '"', 'd',
+ 'a', 't', 'a', '"', ':', '{', '"', 'f', 'i', 'e', 'l', 'd', '1', '"', ':',
+ '"', 'f', 'o', 'o', '"', ',', '"', 'f', 'i', 'e', 'l', 'd', '2', '"', ':',
+ '"', 'b', 'a', 'r', '"', ',', '"', 'f', 'i', 'e', 'l', 'd', '3', '"', ':',
+ '4', '2', ',', '"', 'f', 'i', 'e', 'l', 'd', '4', '"', ':', '"', '1', '1',
+ '5', '2', '9', '2', '1', '5', '0', '4', '6', '0', '6', '8', '4', '6', '9',
+ '7', '6', '"', ',', '"', 'f', 'i', 'e', 'l', 'd', '5', '"', ':', '"', '1',
+ '8', '4', '4', '6', '7', '4', '4', '0', '7', '3', '7', '0', '9', '5', '5',
+ '1', '6', '1', '5', '"', ',', '"', 'f', 'i', 'e', 'l', 'd', '6', '"', ':',
+ 'f', 'a', 'l', 's', 'e', ',', '"', 'f', 'i', 'e', 'l', 'd', '7', '"', ':',
+ 't', 'r', 'u', 'e', ',', '"', 'f', 'i', 'e', 'l', 'd', '8', '"', ':', '"',
+ '0', '1', 'a', 'f', '"', ',', '"', 'f', 'i', 'e', 'l', 'd', '9', '"', ':',
+ '"', '5', '5', '"', ',', '"', 's', 'u', 'b', 'g', 'r', 'o', 'u', 'p', '"',
+ ':', '{', '"', 'f', 'i', 'e', 'l', 'd', '1', '0', '"', ':', '"', 'b', 'a',
+ 'z', '"', '}', ',', '"', 'a', 'r', 'r', 'a', 'y', '"', ':', '[', '"', 'a',
+ '"', ',', '"', 'b', '"', ']', '}', ',', '"', 't', 'i', 'm', 'e', '"', ':',
+ '1', '7', '0', '6', '5', '3', '1', '1', '7', '0', '0', '0', '}', 10, 30,
+ '{', '"', 'n', 'a', 'm', 'e', '"', ':', '"', 't', 'r', 'a', 'n', 's', 'p',
+ 'o', 'r', 't', ':', 'p', 'a', 'c', 'k', 'e', 't', '_', 's', 'e', 'n', 't',
+ '"', ',', '"', 'd', 'a', 't', 'a', '"', ':', '{', '"', 'f', 'i', 'e', 'l',
+ 'd', '1', '"', ':', '"', 'b', 'a', 'r', '"', '}', ',', '"', 't', 'i', 'm',
+ 'e', '"', ':', '1', '0', '0', '0', '}', 10
+};
static const unsigned char bin_buf[] = {
0x01, 0xaf
@@ -110,7 +142,7 @@ static int test_qlog(void)
if (!TEST_size_t_gt(buf_len, 0))
goto err;
- if (!TEST_mem_eq(buf, buf_len, expected, sizeof(expected) - 1))
+ if (!TEST_mem_eq(buf, buf_len, expected, sizeof(expected)))
goto err;
testresult = 1;