r4136 - in trunk/varnish-tools/perl/Varnish-API: . t
sky at projects.linpro.no
sky at projects.linpro.no
Tue Jul 14 19:01:26 CEST 2009
Author: sky
Date: 2009-07-14 19:01:26 +0200 (Tue, 14 Jul 2009)
New Revision: 4136
Added:
trunk/varnish-tools/perl/Varnish-API/t/vsl_tags.t
Modified:
trunk/varnish-tools/perl/Varnish-API/API.xs
trunk/varnish-tools/perl/Varnish-API/t/log.t
Log:
add support for looking up tags
Modified: trunk/varnish-tools/perl/Varnish-API/API.xs
===================================================================
--- trunk/varnish-tools/perl/Varnish-API/API.xs 2009-07-14 06:58:01 UTC (rev 4135)
+++ trunk/varnish-tools/perl/Varnish-API/API.xs 2009-07-14 17:01:26 UTC (rev 4136)
@@ -37,11 +37,13 @@
INCLUDE: const-xs.inc
-int
-VSL_Arg(vd, arg, opt)
- struct VSL_data * vd
- int arg
- const char * opt
+char*
+VSL_tags(tag)
+ int tag
+ CODE:
+ RETVAL = (char*) VSL_tags[tag];
+ OUTPUT:
+ RETVAL
int
VSL_Dispatch(vd, func)
Modified: trunk/varnish-tools/perl/Varnish-API/t/log.t
===================================================================
--- trunk/varnish-tools/perl/Varnish-API/t/log.t 2009-07-14 06:58:01 UTC (rev 4135)
+++ trunk/varnish-tools/perl/Varnish-API/t/log.t 2009-07-14 17:01:26 UTC (rev 4136)
@@ -1,23 +1,28 @@
-use Test::More tests => 4;
+use Test::More tests => 7;
BEGIN { use_ok('Varnish::API') };
use Devel::Peek;
use Sys::Hostname qw(hostname);
-my $host = hostname;
-
-
my $vd = Varnish::API::VSL_New();
-Varnish::API::VSL_OpenLog($vd, $host);
+Varnish::API::VSL_OpenLog($vd, hostname);
+Varnish::API::VSL_Dispatch($vd, sub { ok(1, "dispatch callback called"); return 1});
-Varnish::API::VSL_Dispatch($vd, sub { ok(1); return 1});
-
{
my $i = 0;
Varnish::API::VSL_Dispatch($vd, sub {
- ok(1);
+ $i
+ ? ok(1, "second time return 1 and exit dispatcher")
+ : ok(1, "return 0 and enter the dispatch loop once more");
return $i++;
});
}
+Varnish::API::VSL_Dispatch($vd, sub {
+ my @args = @_;
+ is(@args, 4, "there are 4 arguments");
+ like($args[0], qr /^\w+$/, "First argument is tag text");
+ like($args[1], qr /^\d+$/, "Second is the fd number");
+ });
+
Added: trunk/varnish-tools/perl/Varnish-API/t/vsl_tags.t
===================================================================
--- trunk/varnish-tools/perl/Varnish-API/t/vsl_tags.t (rev 0)
+++ trunk/varnish-tools/perl/Varnish-API/t/vsl_tags.t 2009-07-14 17:01:26 UTC (rev 4136)
@@ -0,0 +1,9 @@
+
+use Test::More tests => 2;
+BEGIN { use_ok('Varnish::API') };
+use Devel::Peek;
+
+
+
+my $foo = Varnish::API::VSL_tags(45);
+is($foo, "Hit");
More information about the varnish-commit
mailing list