File Coverage

blib/lib/Test/ZeroCopy.pm
Criterion Covered Total %
statement 6 26 23.0
branch 0 10 0.0
condition 0 14 0.0
subroutine 2 5 40.0
pod 0 2 0.0
total 8 57 14.0


line stmt bran cond sub pod time code
1             package Test::ZeroCopy;
2              
3 1     1   16318 use strict;
  1         2  
  1         64  
4              
5             our $VERSION = '0.110';
6              
7             require XSLoader;
8             XSLoader::load('Test::ZeroCopy', $VERSION);
9              
10 1     1   4 use base 'Test::Builder::Module';
  1         3  
  1         334  
11             our @EXPORT = qw(is_zerocopy isnt_zerocopy);
12              
13              
14             sub _impl {
15 0     0     my $tb = __PACKAGE__->builder;
16              
17 0   0       my $desc = $_[2] || '';
18 0           my $want_zerocopy = $_[3];
19              
20 0           my $addr1 = get_pv_address($_[0]);
21 0           my $addr2 = get_pv_address($_[1]);
22              
23 0 0 0       if (!defined $addr1 || !defined $addr2) {
24 0           $tb->ok(!$want_zerocopy, "$desc: One or both args aren't strings (don't have SvPV values)");
25 0           return;
26             }
27              
28 0           my $len1 = get_pv_cur($_[0]);
29 0           my $len2 = get_pv_cur($_[1]);
30              
31 0 0         $tb->diag(sprintf("ZC: %s%lx+%lx vs %lx+%lx", ($desc ? "$desc: " : ""), $addr1, $len1, $addr2, $len2));
32              
33 0 0 0       if ($addr1 == $addr2 && $len1 == $len2) {
    0 0        
    0 0        
34 0           $tb->ok($want_zerocopy, "$desc => (exact overlap)");
35             } elsif ($addr1 >= $addr2 && $addr1 < ($addr2 + $len2)) {
36 0           $tb->ok($want_zerocopy, "$desc => (first starts inside second)");
37             } elsif ($addr2 >= $addr1 && $addr2 < ($addr1 + $len1)) {
38 0           $tb->ok($want_zerocopy, "$desc => (second starts inside first)");
39             } else {
40 0           $tb->ok(!$want_zerocopy, "$desc => (no overlap)");
41             }
42             }
43              
44             sub is_zerocopy {
45 0     0 0   $_[3] = 1;
46 0           goto &_impl;
47             }
48              
49             sub isnt_zerocopy {
50 0     0 0   $_[3] = 0;
51 0           goto &_impl;
52             }
53              
54              
55             1;
56              
57              
58              
59             __END__