Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
trackrdrd
Commits
be0564a1
Commit
be0564a1
authored
Sep 10, 2014
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trackrdrd: added a unit test for truncating data that include nulls
parent
2c2f643c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
4 deletions
+72
-4
child.c
trackrdrd/src/child.c
+46
-0
Makefile.am
trackrdrd/src/test/Makefile.am
+26
-4
No files found.
trackrdrd/src/child.c
View file @
be0564a1
...
@@ -1237,3 +1237,49 @@ static const char
...
@@ -1237,3 +1237,49 @@ static const char
TEST_RUNNER
TEST_RUNNER
#endif
#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
\0
bar"
,
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
trackrdrd/src/test/Makefile.am
View file @
be0564a1
INCLUDES
=
-I
$(VARNISHSRC)
/include
-I
$(VARNISHSRC)
-I
$(top_srcdir)
/include
INCLUDES
=
-I
$(VARNISHSRC)
/include
-I
$(VARNISHSRC)
-I
$(top_srcdir)
/include
TESTS
=
test_parse test_data test_hash test_
mq test_spmcq test_config
\
TESTS
=
test_parse test_data test_hash test_
append test_mq test_spmcq
\
test_spmcq_loop.sh test_worker regress.sh
test_
config test_
spmcq_loop.sh test_worker regress.sh
check_PROGRAMS
=
test_parse test_data test_hash test_
mq test_spmcq
\
check_PROGRAMS
=
test_parse test_data test_hash test_
append test_mq
\
test_config test_worker
test_
spmcq test_
config test_worker
test_parse_SOURCES
=
\
test_parse_SOURCES
=
\
minunit.h
\
minunit.h
\
...
@@ -46,6 +46,28 @@ test_hash_LDADD = \
...
@@ -46,6 +46,28 @@ test_hash_LDADD = \
test_hash_CFLAGS
=
-DTEST_DRIVER
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
=
\
test_mq_SOURCES
=
\
minunit.h
\
minunit.h
\
test_mq.c
\
test_mq.c
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment