Commit 452933a3 authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: added a unit test for truncating data that include nulls

parent 693ab4a6
......@@ -1237,3 +1237,49 @@ static const char
TEST_RUNNER
#endif
#ifdef APPEND_TEST
#include "minunit.h"
int tests_run = 0;
static char
*test_append(void)
{
dataentry *entry;
char data_with_null[8];
printf("... testing data append (expect an ALERT)\n");
config.maxdata = DEF_MAXDATA;
entry = calloc(1, sizeof(dataentry));
AN(entry);
entry->data = calloc(1, config.maxdata);
AN(entry->data);
entry->magic = DATA_MAGIC;
dtbl.w_stats.data_truncated = dtbl.w_stats.data_hi = 0;
strcpy(config.log_file, "-");
AZ(LOG_Open("test_append"));
memcpy(data_with_null, "foo\0bar", 8);
append(entry, SLT_VCL_Log, 12345678, data_with_null, 7);
MASSERT(memcmp(entry->data, "&foo\0\0", 6) == 0);
MASSERT(entry->end == 4);
MASSERT(dtbl.w_stats.data_truncated == 1);
MASSERT(dtbl.w_stats.data_hi == 4);
return NULL;
}
static const char
*all_tests(void)
{
mu_run_test(test_append);
return NULL;
}
TEST_RUNNER
#endif
INCLUDES = -I$(VARNISHSRC)/include -I$(VARNISHSRC) -I$(top_srcdir)/include
TESTS = test_parse test_data test_hash test_mq test_spmcq test_config \
test_spmcq_loop.sh test_worker regress.sh
TESTS = test_parse test_data test_hash test_append test_mq test_spmcq \
test_config test_spmcq_loop.sh test_worker regress.sh
check_PROGRAMS = test_parse test_data test_hash test_mq test_spmcq \
test_config test_worker
check_PROGRAMS = test_parse test_data test_hash test_append test_mq \
test_spmcq test_config test_worker
test_parse_SOURCES = \
minunit.h \
......@@ -46,6 +46,28 @@ test_hash_LDADD = \
test_hash_CFLAGS = -DTEST_DRIVER
test_append_SOURCES = \
$(VARNISHSRC)/lib/libvarnish/libvarnish.la \
../child.c \
../trackrdrd.h
test_append_LDADD = \
-ldl \
$(VARNISHSRC)/lib/libvarnish/libvarnish.la \
$(VARNISHSRC)/lib/libvarnishapi/libvarnishapi.la \
../worker.$(OBJEXT) \
../log.$(OBJEXT) \
../spmcq.$(OBJEXT) \
../data.$(OBJEXT) \
../assert.$(OBJEXT) \
../monitor.$(OBJEXT) \
../parse.$(OBJEXT) \
../config.$(OBJEXT) \
../config_common.$(OBJEXT) \
../sandbox.$(OBJEXT)
test_append_CFLAGS = -DAPPEND_TEST
test_mq_SOURCES = \
minunit.h \
test_mq.c \
......
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