Commit 58acaecb authored by Geoff Simmons's avatar Geoff Simmons

implement and test formatters for %{X}i and %{X}o

parent 26ee57b5
......@@ -506,23 +506,24 @@ format_u_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, \
FORMAT_u(client, ReqHeader)
FORMAT_u(backend, BereqHeader)
#if 0
#define FORMAT_Xio(dir, io, hx) \
static void \
format_X##io##_##dir(logline_t *ll, char *name, enum VSL_tag_e tag, \
char **s, size_t *len) \
{ \
(void) tag; \
record_t *rec = GET_HDR(ll, hx, name); \
if (rec) \
RETURN_HDR(rec, name, s, len); \
#define FORMAT_Xio(dir, io, hx) \
void \
format_X##io##_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, \
char **s, size_t *len) \
{ \
(void) tag; \
\
*s = get_hdr(tx, SLT_##hx, name); \
if (s) \
*len = strlen(*s); \
}
FORMAT_Xio(client, i, rx)
FORMAT_Xio(backend, i, tx)
FORMAT_Xio(client, o, tx)
FORMAT_Xio(backend, o, rx)
FORMAT_Xio(client, i, ReqHeader)
FORMAT_Xio(backend, i, BereqHeader)
FORMAT_Xio(client, o, RespHeader)
FORMAT_Xio(backend, o, BerespHeader)
#if 0
FORMAT_tim(Xt, name, )
......
......@@ -84,3 +84,8 @@ formatter_f format_U_backend;
formatter_f format_u_client;
formatter_f format_u_backend;
formatter_f format_Xi_client;
formatter_f format_Xi_backend;
formatter_f format_Xo_client;
formatter_f format_Xo_backend;
......@@ -936,6 +936,60 @@ static const char
return NULL;
}
static const char
*test_format_Xi(void)
{
tx_t tx;
logline_t rec;
chunk_t chunk;
char *str, hdr[] = "Foo";
size_t len;
printf("... testing format_Xi_*()\n");
init_tx_rec_chunk(&tx, &rec, &chunk);
MAN(chunk.data);
set_record_data(&rec, &chunk, "Foo: bar", SLT_ReqHeader);
format_Xi_client(&tx, hdr, SLT__Bogus, &str, &len);
MASSERT(strcmp(str, "bar") == 0);
MASSERT(len == 3);
rec.tag = SLT_BereqHeader;
format_Xi_backend(&tx, hdr, SLT__Bogus, &str, &len);
MASSERT(strcmp(str, "bar") == 0);
MASSERT(len == 3);
return NULL;
}
static const char
*test_format_Xo(void)
{
tx_t tx;
logline_t rec;
chunk_t chunk;
char *str, hdr[] = "Baz";
size_t len;
printf("... testing format_Xo_*()\n");
init_tx_rec_chunk(&tx, &rec, &chunk);
MAN(chunk.data);
set_record_data(&rec, &chunk, "Baz: quux", SLT_RespHeader);
format_Xo_client(&tx, hdr, SLT__Bogus, &str, &len);
MASSERT(strcmp(str, "quux") == 0);
MASSERT(len == 4);
rec.tag = SLT_BerespHeader;
format_Xo_backend(&tx, hdr, SLT__Bogus, &str, &len);
MASSERT(strcmp(str, "quux") == 0);
MASSERT(len == 4);
return NULL;
}
static const char
*all_tests(void)
{
......@@ -960,6 +1014,8 @@ static const char
mu_run_test(test_format_T);
mu_run_test(test_format_U);
mu_run_test(test_format_u);
mu_run_test(test_format_Xi);
mu_run_test(test_format_Xo);
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment