Commit 23fda2fa authored by Geoff Simmons's avatar Geoff Simmons

start a new vtc test for compile options

now with tests for allow_empty_class, anchored and bsr=unicode
parent 98cf8943
# -*-mode: vcl; coding: raw-text -*-
# For the bsr test in compile_opts.vtc. Loaded via include, since
# vcl.inline, which is used by vtc, apparently changes \r characters
# to \n.
sub vcl_synth {
set resp.http.r1-1 = r1.match({"a
b"});
set resp.http.r1-2 = r1.match({"a b"});
set resp.http.r1-3 = r1.match({"a
b"});
set resp.http.r1-4 = r1.match({"a b"});
set resp.http.r1-5 = r1.match({"a b"});
set resp.http.r1-6 = r1.match({"ab"});
set resp.http.r1-7 = r1.match({"a
b"});
set resp.http.r2-1 = r2.match("ab");
set resp.http.r2-2 = r2.match({"a
b"});
set resp.http.r2-3 = r2.match({"a b"});
set resp.http.r2-4 = r2.match({"a
b"});
set resp.http.r2-5 = r2.match({"a b"});
set resp.http.r2-6 = r2.match({"a b"});
set resp.http.r2-7 = r2.match({"ab"});
set resp.http.r2-8 = r2.match({"a
b"});
set resp.http.r2-9 = r2.match({"a
b"});
set resp.http.r3-1 = r3.match({"a
b"});
set resp.http.r3-2 = r3.match({"a b"});
set resp.http.r3-3 = r3.match({"a
b"});
set resp.http.r3-4 = r3.match({"a b"});
set resp.http.r3-5 = r3.match({"a b"});
set resp.http.r3-6 = r3.match({"ab"});
set resp.http.r3-7 = r3.match({"a
b"});
set resp.http.r3-8 = r3.match({"a
b"});
set resp.http.r3-9 = r3.match("ab");
set resp.http.r4-1 = r4.match({"a
b"});
set resp.http.r4-2 = r4.match({"a
b"});
set resp.http.r4-3 = r4.match({"a
b"});
set resp.http.r4-4 = r4.match({"a
b"});
set resp.http.r4-5 = r4.match({"a
b"});
set resp.http.r4-6 = r4.match({"a
b"});
set resp.http.r4-7 = r4.match({"a
b"});
set resp.http.r4-8 = r4.match({"a
b"});
set resp.http.r4-9 = r4.match({"a "});
}
# -*-mode: vcl -*-
# Those instructions tell emacs to use utf-8 encoding for this source;
# you might want to set up your editor similarly.
varnishtest "compile options"
# allow_empty_class tests from pcre2 testoutput2
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("a[]b", allow_empty_class=true);
new r2 = pcre2.regex("a[]+b", allow_empty_class=true);
new r3 = pcre2.regex("a[]*+b", allow_empty_class=true);
new r4 = pcre2.regex("a[^]b", allow_empty_class=true);
new r5 = pcre2.regex("a[^]+b", allow_empty_class=true);
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.r1 = r1.match("ab");
set resp.http.r2 = r2.match("ab");
set resp.http.r3 = r3.match("ab");
set resp.http.r4-1 = r4.match("aXb");
set resp.http.r4-2 = r4.match({"a
b"});
set resp.http.r4-3 = r4.match("ab");
set resp.http.r5-1 = r5.match("aXb");
set resp.http.r5-2 = r5.match({"a
X
Xb"});
set resp.http.r5-3 = r5.match("ab");
}
} -start
client c1 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1 == "false"
expect resp.http.r2 == "false"
expect resp.http.r3 == "false"
expect resp.http.r4-1 == "true"
expect resp.http.r4-2 == "true"
expect resp.http.r4-3 == "false"
expect resp.http.r5-1 == "true"
expect resp.http.r5-2 == "true"
expect resp.http.r5-3 == "false"
} -run
varnish v1 -errvcl {vmod pcre2 error: Cannot compile 'a[]b' in r1 constructor: missing terminating ] for character class at offset 4} {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("a[]b");
}
}
varnish v1 -errvcl {vmod pcre2 error: Cannot compile 'a[^]b' in r1 constructor: missing terminating ] for character class at offset 5} {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("a[^]b");
}
}
# anchored
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("the quick brown fox", anchored=true);
new r2 = pcre2.regex("the quick brown fox");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.r1-1 = r1.match("the quick brown fox");
set resp.http.r2-1 = r2.match("the quick brown fox");
set resp.http.r1-2 = r1.match(
"this is a line with the quick brown fox");
set resp.http.r2-2 = r2.match(
"this is a line with the quick brown fox");
}
}
client c1 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1-1 == "true"
expect resp.http.r1-2 == "false"
expect resp.http.r2-1 == "true"
expect resp.http.r2-2 == "true"
} -run
# bsr
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("^a\Rb", bsr=UNICODE);
new r2 = pcre2.regex("^a\R*b", bsr=UNICODE);
new r3 = pcre2.regex("^a\R+b", bsr=UNICODE);
new r4 = pcre2.regex("^a\R{1,3}b", bsr=UNICODE);
}
sub vcl_recv {
return(synth(200));
}
# Load vcl_synth from another file, since vcl.inline, which is
# used by vtc, apparently changes \r characters to \n.
include "${vmod_topbuild}/src/tests/bsr_synth.vcl";
}
client c1 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1-1 == "true"
expect resp.http.r1-2 == "true"
expect resp.http.r1-3 == "true"
expect resp.http.r1-4 == "true"
expect resp.http.r1-5 == "true"
expect resp.http.r1-6 == "true"
expect resp.http.r1-7 == "false"
expect resp.http.r2-1 == "true"
expect resp.http.r2-2 == "true"
expect resp.http.r2-3 == "true"
expect resp.http.r2-4 == "true"
expect resp.http.r2-5 == "true"
expect resp.http.r2-6 == "true"
expect resp.http.r2-7 == "true"
expect resp.http.r2-8 == "true"
expect resp.http.r2-9 == "true"
expect resp.http.r3-1 == "true"
expect resp.http.r3-2 == "true"
expect resp.http.r3-3 == "true"
expect resp.http.r3-4 == "true"
expect resp.http.r3-5 == "true"
expect resp.http.r3-6 == "true"
expect resp.http.r3-7 == "true"
expect resp.http.r3-8 == "true"
expect resp.http.r3-9 == "false"
expect resp.http.r4-1 == "true"
expect resp.http.r4-2 == "true"
expect resp.http.r4-3 == "true"
expect resp.http.r4-4 == "true"
expect resp.http.r4-5 == "true"
expect resp.http.r4-6 == "true"
expect resp.http.r4-7 == "true"
expect resp.http.r4-8 == "false"
expect resp.http.r4-9 == "false"
} -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