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
56fe060c
Commit
56fe060c
authored
Aug 28, 2016
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extend test coverage for vmod named arguments and defaults
parent
44fed1db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
4 deletions
+56
-4
m00019.vtc
bin/varnishtest/tests/m00019.vtc
+24
-1
vmod.vcc
lib/libvmod_debug/vmod.vcc
+9
-1
vmod_debug_obj.c
lib/libvmod_debug/vmod_debug_obj.c
+23
-2
No files found.
bin/varnishtest/tests/m00019.vtc
View file @
56fe060c
varnishtest "Test v
ar arg
s"
varnishtest "Test v
mod functions/contructor named arguments and default
s"
server s1 {
rxreq
...
...
@@ -8,6 +8,15 @@ server s1 {
varnish v1 -vcl+backend {
import debug;
sub vcl_init {
new obj0 = debug.obj();
new obj1 = debug.obj("only_argument");
new obj2 = debug.obj("string", one);
new obj3 = debug.obj(string="s_two", number=two);
new obj4 = debug.obj(number=three, string="s_three");
new obj5 = debug.obj(number=three);
}
sub vcl_deliver {
set resp.http.foo1 = debug.argtest("1", 2.1, "3a");
set resp.http.foo2 = debug.argtest("1", two=2.2, three="3b");
...
...
@@ -15,6 +24,13 @@ varnish v1 -vcl+backend {
set resp.http.foo4 = debug.argtest("1", 2.4, three="3d");
set resp.http.foo5 = debug.argtest("1", 2.5);
set resp.http.foo6 = debug.argtest("1", four=6);
set resp.http.obj0 = obj0.string() + ", " + obj0.number();
set resp.http.obj1 = obj1.string() + ", " + obj1.number();
set resp.http.obj2 = obj2.string() + ", " + obj2.number();
set resp.http.obj3 = obj3.string() + ", " + obj3.number();
set resp.http.obj4 = obj4.string() + ", " + obj4.number();
set resp.http.obj5 = obj5.string() + ", " + obj5.number();
}
} -start
...
...
@@ -28,6 +44,13 @@ client c1 {
expect resp.http.foo4 == "1 2.4 3d , 4"
expect resp.http.foo5 == "1 2.5 3 , 4"
expect resp.http.foo6 == "1 2 3 , 6"
expect resp.http.obj0 == "default, one"
expect resp.http.obj1 == "only_argument, one"
expect resp.http.obj2 == "string, one"
expect resp.http.obj3 == "s_two, two"
expect resp.http.obj4 == "s_three, three"
expect resp.http.obj5 == "default, three"
} -run
delay .1
...
...
lib/libvmod_debug/vmod.vcc
View file @
56fe060c
...
...
@@ -71,7 +71,7 @@ $Function BACKEND no_backend()
Fails at backend selection
$Object obj(STRING, ENUM { one, two, three } number="one")
$Object obj(STRING
string="default"
, ENUM { one, two, three } number="one")
Test object
...
...
@@ -81,6 +81,14 @@ $Method VOID .enum(ENUM { phk, des, kristian, mithrandir, martin })
Testing that enums work as part of object and that the parser isn't
(too) buggy.
$Method STRING .string()
getter for string
$Method STRING .number()
getter for number
$Method STRING .foo(STRING why)
Foo indeed.
...
...
lib/libvmod_debug/vmod_debug_obj.c
View file @
56fe060c
...
...
@@ -39,6 +39,7 @@ struct vmod_debug_obj {
unsigned
magic
;
#define VMOD_DEBUG_OBJ_MAGIC 0xccbd9b77
int
foobar
;
const
char
*
string
,
*
number
;
};
VCL_VOID
...
...
@@ -49,14 +50,14 @@ vmod_obj__init(VRT_CTX, struct vmod_debug_obj **op,
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
(
void
)
vcl_name
;
(
void
)
s
;
(
void
)
e
;
AN
(
op
);
AZ
(
*
op
);
ALLOC_OBJ
(
o
,
VMOD_DEBUG_OBJ_MAGIC
);
AN
(
o
);
*
op
=
o
;
o
->
foobar
=
42
;
o
->
string
=
s
;
o
->
number
=
e
;
AN
(
*
op
);
}
...
...
@@ -99,3 +100,23 @@ vmod_obj_date(VRT_CTX, struct vmod_debug_obj *o)
assert
(
o
->
foobar
==
42
);
return
(
21
.
4
);
}
VCL_STRING
__match_proto__
()
vmod_obj_string
(
VRT_CTX
,
struct
vmod_debug_obj
*
o
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
o
,
VMOD_DEBUG_OBJ_MAGIC
);
assert
(
o
->
foobar
==
42
);
return
(
o
->
string
);
}
VCL_STRING
__match_proto__
()
vmod_obj_number
(
VRT_CTX
,
struct
vmod_debug_obj
*
o
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
o
,
VMOD_DEBUG_OBJ_MAGIC
);
assert
(
o
->
foobar
==
42
);
return
(
o
->
number
);
}
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