Commit e91c13e4 authored by Geoff Simmons's avatar Geoff Simmons

cover set objects in the options.vtc test

parent dad12301
......@@ -3,6 +3,9 @@
varnishtest "literal, never_nl, dot_nl, case_sensitive and one_line options"
# Tests from re2 testing/parse_test.cc and testing/re2_test.cc
# regex object
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
......@@ -185,3 +188,136 @@ a"}, one_line=true)) {
}
client c1 -run
# set object
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new literal = re2.set(literal=true);
literal.add("(|)^$.[*+?]{5,10},\\");
literal.compile();
new never1 = re2.set(never_nl=true);
never1.add("(.*)");
never1.compile();
new never2 = re2.set(never_nl=true);
never2.add("(?s)(abc.*def)");
never2.compile();
new never3 = re2.set(never_nl=true);
never3.add({"(abc(.|
)def)"});
never3.compile();
new never4 = re2.set(never_nl=true);
never4.add("(abc[^x]*def)");
never4.compile();
new dot1 = re2.set(dot_nl=true);
dot1.add(".");
dot1.compile();
new dot2 = re2.set(dot_nl=true);
dot2.add("(?-s).");
dot2.compile();
new dot3 = re2.set(dot_nl=true, never_nl=true);
dot3.add(".");
dot3.compile();
new case = re2.set(case_sensitive=true);
case.add("(?i)([wand]{5})");
case.compile();
new not_one = re2.set(posix_syntax=true);
not_one.add("^a$");
not_one.compile();
new one = re2.set(posix_syntax=true, one_line=true);
one.add("^a$");
one.compile();
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (literal.match("(|)^$.[*+?]{5,10},\\")) {
set resp.http.literal = "match";
}
if (never1.match({"abc
def
ghi
"} )) {
set resp.http.never1 = "match";
}
if (never2.match({"abc
def
"} )) {
set resp.http.never2 = "match";
}
if (never3.match({"abc
def
"} )) {
set resp.http.never3 = "match";
}
if (never4.match({"abc
def
"} )) {
set resp.http.never4 = "match";
}
if (never4.match({"abczzzdef
def
"} )) {
set resp.http.never5 = "match";
}
if (dot1.match({"
"} )) {
set resp.http.dot1 = "match";
}
if (dot2.match({"
"} )) {
set resp.http.dot2 = "match";
}
if (dot3.match({"
"} )) {
set resp.http.dot3 = "match";
}
if (case.match("A fish named *Wanda*")) {
set resp.http.case = "match";
}
if (not_one.match({"a
a
a"} )) {
set resp.http.not_one = "match";
}
if (one.match({"a
a
a"} )) {
set resp.http.one = "match";
}
}
}
client c2 {
txreq
rxresp
expect resp.http.literal == "match"
expect resp.http.never1 == "match"
expect resp.http.never2 == <undef>
expect resp.http.never3 == <undef>
expect resp.http.never4 == <undef>
expect resp.http.never5 == "match"
expect resp.http.dot1 == "match"
expect resp.http.dot2 == <undef>
expect resp.http.dot3 == <undef>
expect resp.http.case == "match"
expect resp.http.not_one == "match"
expect resp.http.one == <undef>
} -run
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