| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Protocol::SPDY::Test; |
|
2
|
|
|
|
|
|
|
$Protocol::SPDY::Test::VERSION = '1.001'; |
|
3
|
1
|
|
|
1
|
|
520
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Protocol::SPDY::Constants ':all'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
259
|
|
|
6
|
1
|
|
|
1
|
|
8
|
use Protocol::SPDY::Frame; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Exporter qw(import); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Test::More; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
12
|
|
|
9
|
1
|
|
|
1
|
|
1053
|
use Try::Tiny; |
|
|
1
|
|
|
|
|
1608
|
|
|
|
1
|
|
|
|
|
720
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Protocol::SPDY::Test - helper functions for testing things |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
version 1.001 |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Protocol::SPDY::Test qw(:all); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Provides a few functions that may help when trying to debug |
|
26
|
|
|
|
|
|
|
implementations. Not intended for use in production code. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @EXPORT_OK = qw(control_frame_ok); |
|
31
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
32
|
|
|
|
|
|
|
all => \@EXPORT_OK |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my %frame_test = ( |
|
36
|
|
|
|
|
|
|
SYN_STREAM => sub { |
|
37
|
|
|
|
|
|
|
my $frame = shift; |
|
38
|
|
|
|
|
|
|
my $spec = shift || {}; |
|
39
|
|
|
|
|
|
|
subtest "SYN_STREAM" => sub { |
|
40
|
|
|
|
|
|
|
plan tests => 5 + keys %$spec; |
|
41
|
|
|
|
|
|
|
try { |
|
42
|
|
|
|
|
|
|
cmp_ok($frame->length, '>=', 10, 'length must be >= 12'); |
|
43
|
|
|
|
|
|
|
ok($frame->stream_id, 'have a stream identifier'); |
|
44
|
|
|
|
|
|
|
is($frame->stream_id, 0+$frame->stream_id, 'identifier is numeric'); |
|
45
|
|
|
|
|
|
|
cmp_ok($frame->priority, '>=', 0, 'priority >= 0'); |
|
46
|
|
|
|
|
|
|
cmp_ok($frame->priority, '<=', 3, 'priority <= 3'); |
|
47
|
|
|
|
|
|
|
is($frame->$_, $spec->{$_}, $_ . ' matches') for grep exists $spec->{$_}, qw(stream_id priority associated_stream_id); |
|
48
|
|
|
|
|
|
|
} catch { |
|
49
|
|
|
|
|
|
|
fail('Had exception during subtest: ' . $_); |
|
50
|
|
|
|
|
|
|
}; |
|
51
|
|
|
|
|
|
|
done_testing; |
|
52
|
|
|
|
|
|
|
}; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 control_frame_ok |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Tests whether the given frame is valid. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Takes the following parameters: |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over 4 |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * $frame - the L object to test |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * $spec - the spec to test against, default empty |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * $msg - message to display in test notes |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub control_frame_ok($;$$) { |
|
75
|
6
|
|
|
6
|
1
|
13
|
my $frame = shift; |
|
76
|
6
|
|
50
|
|
|
38
|
my $spec = shift || {}; |
|
77
|
6
|
|
50
|
|
|
30
|
my $msg = shift || ''; |
|
78
|
|
|
|
|
|
|
subtest "Frame validation - " . $msg => sub { |
|
79
|
|
|
|
|
|
|
try { |
|
80
|
6
|
|
|
|
|
299
|
isa_ok($frame, 'Protocol::SPDY::Frame::Control'); |
|
81
|
6
|
|
|
|
|
3137
|
can_ok($frame, qw(is_control is_data length type)); |
|
82
|
6
|
|
|
|
|
3901
|
ok($frame->is_control, 'is_control returns true'); |
|
83
|
6
|
|
|
|
|
2741
|
ok(!$frame->is_data, 'is_data returns false'); |
|
84
|
6
|
|
|
|
|
2748
|
cmp_ok($frame->length, '>=', 0, 'length is nonzero'); |
|
85
|
6
|
|
|
|
|
2919
|
ok(my $type = $frame->type_string, 'have a frame type'); |
|
86
|
6
|
|
|
|
|
2774
|
note 'type is ' . $type; |
|
87
|
|
|
|
|
|
|
try { |
|
88
|
2
|
|
|
|
|
76
|
$frame_test{$type}->($frame, $spec) |
|
89
|
|
|
|
|
|
|
} catch { |
|
90
|
0
|
|
|
|
|
0
|
fail('Had exception during subtest: ' . $_); |
|
91
|
6
|
100
|
|
|
|
1272
|
} if exists $frame_test{$type}; |
|
92
|
|
|
|
|
|
|
} catch { |
|
93
|
0
|
|
|
|
|
0
|
fail('Had exception during subtest: ' . $_); |
|
94
|
6
|
|
|
6
|
|
4579
|
}; |
|
95
|
6
|
|
|
|
|
1553
|
done_testing; |
|
96
|
6
|
|
|
|
|
72
|
}; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |