varnishtest "VMOD blob same(), equal(), length() and subblob()"
varnish v1 -vcl {
import blob;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new foo1 = blob.blob(IDENTITY, "foobarbazquux");
new foo2 = blob.blob(IDENTITY, "foobarbazquux");
new hobbes1 = blob.blob(IDENTITY,
{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."});
new hobbes2 = blob.blob(IDENTITY,
{"Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."});
new empty1 = blob.blob(IDENTITY, "");
new empty2 = blob.blob(IDENTITY, "");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (blob.same(foo1.get(), foo1.get())) {
set resp.http.foo1same = "true";
}
if (blob.same(foo2.get(), foo2.get())) {
set resp.http.foo2same = "true";
}
if (blob.same(foo1.get(), foo2.get())) {
set resp.http.foo12same = "true";
}
if (blob.same(foo2.get(), foo1.get())) {
set resp.http.foo21same = "true";
}
if (blob.same(foo1.get(), hobbes1.get())) {
set resp.http.foohobbessame = "true";
}
if (blob.same(foo1.get(), empty1.get())) {
set resp.http.fooemptysame = "true";
}
if (blob.equal(foo1.get(), foo1.get())) {
set resp.http.foo1equal = "true";
}
if (blob.equal(foo1.get(), foo2.get())) {
set resp.http.foo12equal = "true";
}
if (blob.equal(foo2.get(), foo1.get())) {
set resp.http.foo21equal = "true";
}
if (blob.equal(foo1.get(), hobbes1.get())) {
set resp.http.foohobbesequal = "true";
}
if (blob.equal(foo1.get(), empty1.get())) {
set resp.http.fooemptyequal = "true";
}
set resp.http.foo1len = blob.length(foo1.get());
set resp.http.foo2len = blob.length(foo2.get());
if (blob.same(hobbes1.get(), hobbes1.get())) {
set resp.http.hobbes1same = "true";
}
if (blob.same(hobbes2.get(), hobbes2.get())) {
set resp.http.hobbes2same = "true";
}
if (blob.same(hobbes1.get(), hobbes2.get())) {
set resp.http.hobbes12same = "true";
}
if (blob.same(hobbes2.get(), hobbes1.get())) {
set resp.http.hobbes21same = "true";
}
if (blob.same(hobbes1.get(), empty1.get())) {
set resp.http.hobbesemptysame = "true";
}
if (blob.equal(hobbes1.get(), hobbes1.get())) {
set resp.http.hobbes1equal = "true";
}
if (blob.equal(hobbes1.get(), hobbes2.get())) {
set resp.http.hobbes12equal = "true";
}
if (blob.equal(hobbes2.get(), hobbes1.get())) {
set resp.http.hobbes21equal = "true";
}
if (blob.equal(hobbes1.get(), empty1.get())) {
set resp.http.hobbesemptyequal = "true";
}
set resp.http.hobbes1len = blob.length(hobbes1.get());
set resp.http.hobbes2len = blob.length(hobbes2.get());
if (blob.same(empty1.get(), empty1.get())) {
set resp.http.empty1same = "true";
}
if (blob.same(empty2.get(), empty2.get())) {
set resp.http.empty2same = "true";
}
if (blob.same(empty1.get(), empty2.get())) {
set resp.http.empty12same = "true";
}
if (blob.same(empty2.get(), empty1.get())) {
set resp.http.empty21same = "true";
}
if (blob.equal(empty1.get(), empty1.get())) {
set resp.http.empty1equal = "true";
}
if (blob.equal(empty1.get(), empty2.get())) {
set resp.http.empty12equal = "true";
}
if (blob.equal(empty2.get(), empty1.get())) {
set resp.http.empty21equal = "true";
}
set resp.http.empty1len = blob.length(empty1.get());
set resp.http.empty2len = blob.length(empty2.get());
return(deliver);
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.foo1same == "true"
expect resp.http.foo2same == "true"
expect resp.http.foo12same == <undef>
expect resp.http.foo21same == <undef>
expect resp.http.foohobbessame == <undef>
expect resp.http.fooemptysame == <undef>
expect resp.http.foo1equal == "true"
expect resp.http.foo12equal == "true"
expect resp.http.foo21equal == "true"
expect resp.http.foohobbesequal == <undef>
expect resp.http.fooemptyequal == <undef>
expect resp.http.foo1len == "13"
expect resp.http.foo2len == "13"
expect resp.http.hobbes1same == "true"
expect resp.http.hobbes2same == "true"
expect resp.http.hobbes12same == <undef>
expect resp.http.hobbes21same == <undef>
expect resp.http.hobbesemptysame == <undef>
expect resp.http.hobbes1equal == "true"
expect resp.http.hobbes12equal == "true"
expect resp.http.hobbes21equal == "true"
expect resp.http.hobbesemptyequal == <undef>
expect resp.http.hobbes1len == "269"
expect resp.http.hobbes2len == "269"
expect resp.http.empty1same == "true"
expect resp.http.empty2same == "true"
# VMOD blob uses a statically allocated empty blob for empty
# decodings. So the empty blobs from different objects