Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
varnishevent
Commits
88a06a5e
Commit
88a06a5e
authored
Apr 01, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a smarter test for format_t
parent
8034a796
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
18 deletions
+9
-18
format.h
src/format.h
+1
-1
test_format.c
src/test/test_format.c
+8
-17
No files found.
src/format.h
View file @
88a06a5e
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
*
*
*/
*/
/* including source must include varnishevent.h
and vre.h
*/
/* including source must include varnishevent.h */
/* XXX: init as fixed size with length max_reclen + 1 */
/* XXX: init as fixed size with length max_reclen + 1 */
struct
vsb
*
payload
;
struct
vsb
*
payload
;
...
...
src/test/test_format.c
View file @
88a06a5e
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
#include <math.h>
#include <math.h>
#include <time.h>
#include <time.h>
#include "vre.h"
#include "minunit.h"
#include "minunit.h"
#include "../varnishevent.h"
#include "../varnishevent.h"
...
@@ -779,31 +778,23 @@ static const char
...
@@ -779,31 +778,23 @@ static const char
tx_t
tx
;
tx_t
tx
;
logline_t
rec
;
logline_t
rec
;
chunk_t
chunk
;
chunk_t
chunk
;
char
*
str
;
char
*
str
=
NULL
,
strftime_s
[
BUFSIZ
],
fmt
[]
=
"[%d/%b/%Y:%T %z]"
;
const
char
*
error
;
size_t
len
;
size_t
len
;
vre_t
*
time_re
;
struct
tm
*
tm
;
int
n
;
time_t
t
=
1427743146
;
printf
(
"... testing format_t()
\n
"
);
printf
(
"... testing format_t()
\n
"
);
#define HTTP_DATA_REGEX \
"^\\[\\d\\d/Mar/2015:\\d\\d:\\d\\d:\\d\\d [+-]\\d{4}\\]$"
time_re
=
VRE_compile
(
HTTP_DATA_REGEX
,
0
,
&
error
,
&
n
);
VMASSERT
(
time_re
!=
NULL
,
"Error compiling '"
HTTP_DATA_REGEX
"': %s (offset %d)"
,
error
,
n
);
init_tx_rec_chunk
(
&
tx
,
&
rec
,
&
chunk
);
init_tx_rec_chunk
(
&
tx
,
&
rec
,
&
chunk
);
MAN
(
chunk
.
data
);
MAN
(
chunk
.
data
);
set_record_data
(
&
rec
,
&
chunk
,
T1
,
SLT_Timestamp
);
set_record_data
(
&
rec
,
&
chunk
,
T1
,
SLT_Timestamp
);
tm
=
localtime
(
&
t
);
MAN
(
strftime
(
strftime_s
,
config
.
max_reclen
,
fmt
,
tm
));
format_t
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
format_t
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
n
=
VRE_exec
(
time_re
,
str
,
strlen
(
str
),
0
,
0
,
NULL
,
0
,
NULL
);
MAN
(
str
);
VMASSERT
(
n
>
0
,
"'%s' does not match '"
HTTP_DATA_REGEX
"', "
VMASSERT
(
strcmp
(
str
,
strftime_s
)
==
0
,
"'%s' != '%s'"
,
str
,
strftime_s
);
"return code = %d"
,
str
,
n
);
MASSERT
(
len
==
strlen
(
strftime_s
));
MASSERT
(
len
==
28
);
return
NULL
;
return
NULL
;
}
}
...
...
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