Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
06425c23
Commit
06425c23
authored
Nov 13, 2018
by
Nils Goroll
Committed by
Dridi Boukelmoune
Feb 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve argstruct test coverage
Related to #2810 Conflicts: lib/libvmod_debug/vmod.vcc
parent
5fdbd095
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
0 deletions
+114
-0
m00019.vtc
bin/varnishtest/tests/m00019.vtc
+13
-0
vmod.vcc
lib/libvmod_debug/vmod.vcc
+10
-0
vmod_debug_obj.c
lib/libvmod_debug/vmod_debug_obj.c
+91
-0
No files found.
bin/varnishtest/tests/m00019.vtc
View file @
06425c23
...
...
@@ -15,6 +15,10 @@ varnish v1 -vcl+backend {
new obj3 = debug.obj(string="s_two", number=two);
new obj4 = debug.obj(number=three, string="s_three");
new obj5 = debug.obj(number=three);
new oo0 = debug.obj_opt();
new oo1 = debug.obj_opt(s="string");
new oo2 = debug.obj_opt(b=true);
}
sub vcl_deliver {
...
...
@@ -32,6 +36,10 @@ varnish v1 -vcl+backend {
set resp.http.obj3 = obj3.string() + ", " + obj3.number();
set resp.http.obj4 = obj4.string() + ", " + obj4.number();
set resp.http.obj5 = obj5.string() + ", " + obj5.number();
set resp.http.oo0 = oo0.meth_opt(s="s1");
set resp.http.oo1 = oo1.meth_opt(b=false);
set resp.http.oo2 = oo2.meth_opt();
}
} -start
...
...
@@ -53,6 +61,11 @@ client c1 {
expect resp.http.obj3 == "s_two, two"
expect resp.http.obj4 == "s_three, three"
expect resp.http.obj5 == "default, three"
expect resp.http.oo0 == "obj oo0 obj_s *undef* obj_b *undef* met_s s1 met_b *undef*"
expect resp.http.oo1 == "obj oo1 obj_s string obj_b *undef* met_s *undef* met_b false"
expect resp.http.oo2 == "obj oo2 obj_s *undef* obj_b true met_s *undef* met_b *undef*"
} -run
delay .1
...
...
lib/libvmod_debug/vmod.vcc
View file @
06425c23
...
...
@@ -178,3 +178,13 @@ Update counter
$Function VOID vsc_destroy()
Remove a vsc
$Object obj_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK,
[STRING s], [BOOL b])
Test object constructor with all the fancy stuff.
$Method STRING .meth_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK,
[STRING s], [BOOL b])
Test object method with all the fancy stuff.
lib/libvmod_debug/vmod_debug_obj.c
View file @
06425c23
...
...
@@ -152,3 +152,94 @@ xyzzy_obj_test_priv_top(VRT_CTX,
(
void
)
o
;
return
(
xyzzy_test_priv_top
(
ctx
,
priv
,
s
));
}
/* ----------------------------------------------------------------------------
* obj_opt (optional arguments and privs)
*/
struct
xyzzy_debug_obj_opt
{
unsigned
magic
;
#define VMOD_DEBUG_OBJ_OPT_MAGIC 0xccbd9b78
char
*
name
;
struct
xyzzy_obj_opt_meth_opt_arg
args
;
void
*
freeptr
;
};
VCL_VOID
v_matchproto_
()
xyzzy_obj_opt__init
(
VRT_CTX
,
struct
xyzzy_debug_obj_opt
**
op
,
const
char
*
vcl_name
,
struct
xyzzy_obj_opt__init_arg
*
args
)
{
struct
xyzzy_debug_obj_opt
*
o
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
args
);
AN
(
args
->
arg1
);
// priv_call
AN
(
args
->
arg2
);
// priv_vcl
AN
(
args
->
arg3
);
// priv_task
assert
(
args
->
arg1
!=
args
->
arg2
);
assert
(
args
->
arg2
!=
args
->
arg3
);
if
(
args
->
valid_s
)
AN
(
args
->
s
);
AN
(
op
);
AZ
(
*
op
);
ALLOC_OBJ
(
o
,
VMOD_DEBUG_OBJ_OPT_MAGIC
);
AN
(
o
);
*
op
=
o
;
REPLACE
(
o
->
name
,
vcl_name
);
memcpy
(
&
o
->
args
,
args
,
sizeof
o
->
args
);
if
(
args
->
valid_s
)
{
REPLACE
(
o
->
freeptr
,
args
->
s
);
o
->
args
.
s
=
o
->
freeptr
;
}
}
VCL_VOID
v_matchproto_
()
xyzzy_obj_opt__fini
(
struct
xyzzy_debug_obj_opt
**
op
)
{
struct
xyzzy_debug_obj_opt
*
o
;
AN
(
op
);
if
(
*
op
==
NULL
)
return
;
/* init has failed */
TAKE_OBJ_NOTNULL
(
o
,
op
,
VMOD_DEBUG_OBJ_OPT_MAGIC
);
REPLACE
(
o
->
name
,
NULL
);
if
(
o
->
freeptr
)
{
AN
(
o
->
args
.
valid_s
);
REPLACE
(
o
->
freeptr
,
NULL
);
}
FREE_OBJ
(
o
);
AZ
(
o
);
}
VCL_STRING
v_matchproto_
()
xyzzy_obj_opt_meth_opt
(
VRT_CTX
,
struct
xyzzy_debug_obj_opt
*
o
,
struct
xyzzy_obj_opt_meth_opt_arg
*
args
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
o
,
VMOD_DEBUG_OBJ_OPT_MAGIC
);
AN
(
args
);
AN
(
args
->
arg1
);
// priv_call
AN
(
args
->
arg2
);
// priv_vcl
AN
(
args
->
arg3
);
// priv_task
assert
(
args
->
arg1
!=
args
->
arg2
);
assert
(
args
->
arg2
!=
args
->
arg3
);
return
(
VRT_CollectString
(
ctx
,
"obj "
,
o
->
name
,
" obj_s "
,
(
o
->
args
.
valid_s
?
o
->
args
.
s
:
"*undef*"
),
" obj_b "
,
(
o
->
args
.
valid_b
?
(
o
->
args
.
b
?
"true"
:
"false"
)
:
"*undef*"
),
" met_s "
,
(
args
->
valid_s
?
args
->
s
:
"*undef*"
),
" met_b "
,
(
args
->
valid_b
?
(
args
->
b
?
"true"
:
"false"
)
:
"*undef*"
),
vrt_magic_string_end
));
}
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