« lib/Test/FitNesse/Slim/StatementExecutor.pm
↑ Summary
lib/Test/FitNesse/Slim/ConverterRegistry.pm »
| 1 | package Test::FitNesse::Slim::Server; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 47 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 47 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 47 | ▶ | use Encode qw/ encode /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 47 | ▶ | use File::Temp qw/ tempfile /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 47 | ▶ | use IO::Select; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 47 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 47 | ▶ | use POSIX qw/ WNOHANG /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 47 | ▶ | use Socket qw/ AF_INET inet_pton /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 47 | ▶ | use Test::FitNesse::Slim::List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 47 | ▶ | use Test::FitNesse::Slim::ListExecutor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 49 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=29.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 49 | my($class,%options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 49 | my $self = bless {} => $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | my $max_frame = defined $options{max_frame_bytes} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ? $options{max_frame_bytes} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | : defined $ENV{TEST_SLIM_MAX_FRAME_BYTES} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 49 | ▶ | ? $ENV{TEST_SLIM_MAX_FRAME_BYTES} : 67_108_864; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 49 | ▶ | die "invalid TEST_SLIM_MAX_FRAME_BYTES" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%3/12
defined $max_frame and $max_frame =~ /\A[1-9][0-9]*\z/ and length $max_frame < 10 || length $max_frame == 10 && $max_frame le "1073741824"
defined $max_frame and $max_frame =~ /\A[1-9][0-9]*\z/
length $max_frame < 10 or length $max_frame == 10 and $max_frame le "1073741824"
length $max_frame == 10 and $max_frame le "1073741824"
MC/DC0%0/5
defined $max_frame and $max_frame =~ /\A[1-9][0-9]*\z/ and length $max_frame < 10 || length $max_frame == 10 && $max_frame le "1073741824"
defined $max_frame
$max_frame =~ /\A[1-9][0-9]*\z/
length $max_frame < 10
length $max_frame == 10
$max_frame le "1073741824"
Truth table16%1/6
A and B and C or D and E
A= defined $max_frameB= $max_frame =~ /\A[1-9][0-9]*\z/C= length $max_frame < 10D= length $max_frame == 10E= $max_frame le "1073741824"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | unless defined($max_frame) && $max_frame =~ /\A[1-9][0-9]*\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | && (length($max_frame) < 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | || length($max_frame) == 10 && $max_frame le '1073741824'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 49 | $self->{MAX_FRAME_BYTES} = 0 + $max_frame; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 49 | ▶ | $self->{verbose} = $options{verbose} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 49 | $self->{statement_timeout} = $options{statement_timeout}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $self->{bind_address} = exists($options{bind_address}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 49 | ▶ | ? $options{bind_address} : '127.0.0.1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 49 | ▶ | $self->{bind_address_explicit} = exists($options{bind_address}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | die 'invalid IPv4 bind address: ' . (defined($self->{bind_address}) ? $self->{bind_address} : '<undefined>') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | unless defined($self->{bind_address}) && !ref($self->{bind_address}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 49 | ▶ | && defined inet_pton(AF_INET, $self->{bind_address}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
defined $self->{"bind_address"} and not ref $self->{"bind_address"} and defined inet_pton(2, $self->{"bind_address"})
defined $self->{"bind_address"} and not ref $self->{"bind_address"}
MC/DC66%2/3
defined $self->{"bind_address"} and not ref $self->{"bind_address"} and defined inet_pton(2, $self->{"bind_address"})
defined $self->{"bind_address"}
not ref $self->{"bind_address"}
defined inet_pton(2, $self->{"bind_address"})
Truth table75%3/4
A and not(B) and C
A= defined $self->{"bind_address"}B= not ref $self->{"bind_address"}C= defined inet_pton(2, $self->{"bind_address"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 41 | $self->{EXEC} = $self->_new_executor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 41 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 683 | ▶ | sub _read_exact { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_exact: called CC=7 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 683 | my($self,$fh,$length,$where,$clean_eof) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 683 | my $result = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 683 | my $wanted = $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 683 | ▶ | while ($length > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 823 | my $status = sysread $fh, my($buf), $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 823 | ▶ | if (defined $status) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 823 | ▶ | if ($status == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | ▶ | return if $clean_eof && $result eq ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$clean_eof and $result eq ""
MC/DC50%1/2
$clean_eof and $result eq ""
$clean_eof
$result eq ""
Truth table66%2/3
A and B
A= $clean_eofB= $result eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 4 | die "truncated $where ($wanted bytes expected, " . length($result) . " received)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 815 | $result .= $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 815 | $length -= $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | next if $!{EINTR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | die "sysread: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 675 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 252 | ▶ | sub _write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 252 | my($self,$fh,$buf) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 252 | ▶ | return unless defined $buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 252 | my $length = length $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 252 | ▶ | while ($length > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 252 | my $status = syswrite $fh, $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 252 | ▶ | if (defined $status) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 250 | ▶ | die "syswrite returned zero" if $status == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 250 | $length -= $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 250 | substr($buf, 0, $status) = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | ▶ | next if $!{EINTR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | die "syswrite failed: $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 89 | ▶ | sub _read_message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_message: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 89 | my($self,$fh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 89 | my $digits = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 89 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 608 | my $char = $self->_read_exact($fh,1,"message length",$digits eq ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 607 | ▶ | return unless defined $char; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 603 | ▶ | last if $char eq ":"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 525 | ▶ | die "invalid message length prefix" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$char =~ /\A[0-9]\z/ and length $digits < 32
MC/DC100%2/2
$char =~ /\A[0-9]\z/ and length $digits < 32
$char =~ /\A[0-9]\z/
length $digits < 32
Truth table100%3/3
A and B
A= $char =~ /\A[0-9]\z/B= length $digits < 32
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | unless $char =~ /\A[0-9]\z/ && length($digits) < 32; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 519 | $digits .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 78 | ▶ | die "invalid message length prefix" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | unless $digits =~ /\A[0-9]{6,}\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 77 | (my $significant = $digits) =~ s/^0+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 77 | ▶ | $significant = '0' unless length $significant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 77 | my $maximum = "$self->{MAX_FRAME_BYTES}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 77 | ▶ | die "resource limit: message frame exceeds configured maximum" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
length $significant > length $maximum or length $significant == length $maximum and $significant gt $maximum
length $significant == length $maximum and $significant gt $maximum
MC/DC66%2/3
length $significant > length $maximum or length $significant == length $maximum and $significant gt $maximum
length $significant > length $maximum
length $significant == length $maximum
$significant gt $maximum
Truth table75%3/4
A or B and C
A= length $significant > length $maximumB= length $significant == length $maximumC= $significant gt $maximum
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | if length($significant) > length($maximum) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | || length($significant) == length($maximum) && $significant gt $maximum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 75 | return $self->_read_exact($fh,0 + $significant,"message payload",0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 26 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 26 | my($self,$fh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 26 | $self->_process_session($fh,$fh,'V0.5',1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 9 | ▶ | sub process_pipe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_pipe: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 9 | my($self,$input,$output,$diagnostic_output) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 9 | local $SIG{PIPE} = 'IGNORE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 9 | $self->_process_session($input,$output,'V0.5',0,$diagnostic_output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 35 | ▶ | sub _process_session { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_session: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 35 | my($self,$input,$output,$version,$close_input,$diagnostic_output) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 35 | my $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | my $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 35 | local $self->{EXEC} = $self->_new_executor; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 35 | $ok = eval { $self->_process($input,$output,$version,$diagnostic_output); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 35 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 35 | ▶ | close $input if $close_input && defined fileno($input); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$close_input and defined fileno $input
MC/DC50%1/2
$close_input and defined fileno $input
$close_input
defined fileno $input
Truth table66%2/3
A and B
A= $close_inputB= defined fileno $input
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 35 | ▶ | die $error unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 76 | ▶ | sub _new_executor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new_executor: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 76 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | Test::FitNesse::Slim::ListExecutor->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | statement_timeout => $self->{statement_timeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 76 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 35 | ▶ | sub _process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 35 | my($self,$input,$output,$version,$diagnostic_output) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 35 | $self->_write($output, "Slim -- $version\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 35 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 77 | my $command = $self->_read_message($input); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 72 | ▶ | return unless defined $command; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 68 | ▶ | if (lc($command) eq "bye") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 48 | ▶ | warn "command=[" . length($command) . " bytes]\n" unless $diagnostic_output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | my @instructions = Test::FitNesse::Slim::List->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | $command, limits => { frame_bytes => $self->{MAX_FRAME_BYTES} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 48 | )->list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 43 | ▶ | if ($self->{verbose}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | my $request = Test::FitNesse::Slim::List->new(\@instructions)->serialize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | warn "$0: SLiM request: $request\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 43 | ▶ | my @results = defined($diagnostic_output) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ? $self->_execute_with_tunneling($diagnostic_output, @instructions) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | : $self->execute(@instructions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 43 | my $response = Test::FitNesse::Slim::List->new(\@results)->serialize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 43 | ▶ | warn "$0: SLiM response: $response\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 43 | my $octets = encode "UTF-8", $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | die "resource limit: response frame exceeds configured maximum" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 43 | ▶ | if length($octets) > $self->{MAX_FRAME_BYTES}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 43 | ▶ | warn "response=[" . length($octets) . " bytes]\n" unless $diagnostic_output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 43 | $self->_write($output, sprintf "%06d:%s", length($octets), $octets); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 22 | ▶ | sub _execute_with_tunneling { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_execute_with_tunneling: called CC=26 SCAR=34.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 22 | my($self,$diagnostic_output,@instructions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 22 | my($stdout_capture,$stdout_path) = tempfile(UNLINK => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 22 | my($stderr_capture,$stderr_path) = tempfile(UNLINK => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 22 | ▶ | binmode $stdout_capture or die "binary stdout capture failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 22 | ▶ | binmode $stderr_capture or die "binary stderr capture failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 22 | ▶ | open my $stdout_reader, '<:raw', $stdout_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | or die "open stdout capture reader failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 22 | ▶ | open my $stderr_reader, '<:raw', $stderr_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | or die "open stderr capture reader failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 22 | ▶ | open my $saved_stdout, '>&', \*STDOUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | or die "duplicate fixture stdout failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 22 | ▶ | open my $saved_stderr, '>&', \*STDERR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | or die "duplicate fixture stderr failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 22 | ▶ | binmode $saved_stdout or die "binary saved stdout failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 22 | ▶ | binmode $saved_stderr or die "binary saved stderr failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 22 | my $selected = select; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 22 | select STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 22 | my $stdout_autoflush = $|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 22 | select STDERR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 22 | my $stderr_autoflush = $|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 22 | my(@results,$execution_error,@tunnel_errors); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 22 | my $executed = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 22 | ▶ | open STDOUT, '>&', $stdout_capture or die "redirect fixture stdout failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 22 | ▶ | open STDERR, '>&', $stderr_capture or die "redirect fixture stderr failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 22 | ▶ | binmode STDOUT or die "binary fixture stdout failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 22 | ▶ | binmode STDERR or die "binary fixture stderr failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 22 | select STDOUT; $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 22 | select STDERR; $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 22 | select $selected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 36 | ▶ | @results = $self->{EXEC}->execute_with(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 36 | for my $capture ([$stdout_capture,$stdout_reader,'SOUT'], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | [$stderr_capture,$stderr_reader,'SERR']) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 72 | my($writer,$reader,$channel) = @$capture; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 72 | my $ok = eval { $self->_tunnel_capture($diagnostic_output,$writer,$reader,$channel); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 72 | ▶ | push @tunnel_errors, "$channel: $@" unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 22 | }, @instructions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 22 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 22 | ▶ | $execution_error = $@ unless $executed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 22 | my $restored = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 22 | ▶ | open STDOUT, '>&', $saved_stdout or die "restore fixture stdout failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 22 | ▶ | open STDERR, '>&', $saved_stderr or die "restore fixture stderr failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 22 | select STDOUT; $| = $stdout_autoflush; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 22 | select STDERR; $| = $stderr_autoflush; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 22 | select $selected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 22 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 22 | ▶ | my $restore_error = $@ unless $restored; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 22 | ▶ | die $restore_error if defined $restore_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 22 | for my $capture ([$stdout_capture,$stdout_reader,'SOUT'], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | [$stderr_capture,$stderr_reader,'SERR']) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 44 | my($writer,$reader,$channel) = @$capture; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 44 | my $ok = eval { $self->_tunnel_capture($diagnostic_output,$writer,$reader,$channel); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 44 | ▶ | push @tunnel_errors, "$channel: $@" unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 22 | warn "$0: could not forward tunneled output ($_\n" for @tunnel_errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 22 | ▶ | close $stdout_reader or die "close stdout capture reader failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 22 | ▶ | close $stderr_reader or die "close stderr capture reader failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 22 | ▶ | close $stdout_capture or die "close stdout capture failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 22 | ▶ | close $stderr_capture or die "close stderr capture failed: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 22 | ▶ | die $execution_error if defined $execution_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 22 | return @results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 116 | ▶ | sub _tunnel_capture { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tunnel_capture: called CC=14 SCAR=26.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 116 | my($self,$output,$writer,$capture,$channel) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 116 | my $first_line = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 116 | my $line_started = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 116 | my $offset = tell $capture; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 116 | my @stat = stat $writer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 116 | ▶ | die "stat fixture output capture failed: $!" unless @stat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 116 | my $available = $stat[7] - $offset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 116 | ▶ | return if $available <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 35 | ▶ | if ($available == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | my $byte = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | my $read = sysread $capture, $byte, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | ▶ | die "read fixture output capture failed: $!" unless defined($read) && $read == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $read and $read == 1
MC/DC50%1/2
defined $read and $read == 1
defined $read
$read == 1
Truth table66%2/3
A and B
A= defined $readB= $read == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | ▶ | return if $byte eq "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->_write($output, "$channel.:"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->_write($output, $byte); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $self->_write($output, "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 33 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 176 | my $read = sysread $capture, my($bytes), 8192; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 176 | ▶ | die "read fixture output capture failed: $!" unless defined $read; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 176 | ▶ | last if $read == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 144 | ▶ | while (length $bytes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 148 | ▶ | unless ($line_started) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 21 | ▶ | $self->_write($output, $channel . ($first_line ? '.:' : ' :')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 20 | $line_started = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 147 | my $newline = index($bytes, "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 147 | ▶ | if ($newline < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 133 | $self->_write($output, $bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 133 | $bytes = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 14 | my $line = substr($bytes, 0, $newline + 1, ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 14 | $self->_write($output, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 14 | $line_started = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 14 | $first_line = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # Tunnel partial output as a terminated record so FitNesse can reconstruct it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 32 | ▶ | $self->_write($output, "\n") if $line_started; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 32 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 21 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 21 | my($self,@instructions) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 21 | $self->{EXEC}->execute(@instructions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 31 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=14 SCAR=29.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 31 | my($self,$port) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 31 | ▶ | if (defined($port) && $port eq '1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $port and $port eq 1
MC/DC50%1/2
defined $port and $port eq 1
defined $port
$port eq 1
Truth table66%2/3
A and B
A= defined $portB= $port eq 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | die 'bind_address cannot be used with pipe mode' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 10 | ▶ | if $self->{bind_address_explicit}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 9 | return $self->run_pipe; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 21 | my $lsn = $self->_listen_socket($port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | local $SIG{CHLD} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | 1 while waitpid(-1, WNOHANG) > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 21 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 21 | my $sel = IO::Select->new($lsn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 21 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 132 | my @ready = $sel->can_read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 132 | ▶ | next unless @ready; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 132 | foreach my $fh (@ready) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 132 | ▶ | if ($fh == $lsn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 132 | my $new = $lsn->accept; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 132 | ▶ | unless ($new) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | next if $!{EINTR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | warn "$0: accept failed: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 132 | my $pid = fork(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 132 | ▶ | unless (defined $pid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | warn "$0: fork failed: $!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | close $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 132 | ▶ | if ($pid == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 21 | close $lsn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 21 | $SIG{CHLD} = "DEFAULT"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 21 | my $ok = eval { $self->process($new); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 21 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 7 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 7 | warn "$0: SLiM client failed: $error\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 7 | ▶ | close $new if defined fileno($new); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 21 | ▶ | exit($ok ? 0 : 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 111 | close $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | warn "$0: unexpected input from fd " . fileno($fh) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 25 | ▶ | sub _listen_socket { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_listen_socket: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 25 | my($self,$port) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 25 | my $address = $self->{bind_address}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 25 | my $packed = inet_pton(AF_INET, $address); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 25 | my @octets = unpack 'C4', $packed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | warn "$0: warning: TCP SLiM on $address is unauthenticated; use only on a trusted network\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 25 | ▶ | if $self->{bind_address_explicit} && $octets[0] != 127; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"bind_address_explicit"} and $octets[0] != 127
MC/DC100%2/2
$self->{"bind_address_explicit"} and $octets[0] != 127
$self->{"bind_address_explicit"}
$octets[0] != 127
Truth table100%3/3
A and B
A= $self->{"bind_address_explicit"}B= $octets[0] != 127
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 25 | ▶ | my $listener = IO::Socket::INET->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | # Winsock permits an SO_REUSEADDR socket to bind an occupied endpoint. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # Keep the existing Unix restart behavior without enabling that on Windows. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | ReuseAddr => $^O eq 'MSWin32' ? 0 : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | Listen => 16, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | LocalAddr => $address, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | LocalPort => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | Proto => 'tcp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 25 | ▶ | die "$0: create listen socket on $address:$port failed: $!\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | unless $listener; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 24 | return $listener; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 9 | ▶ | sub run_pipe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_pipe: called CC=10 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 9 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 9 | ▶ | open my $protocol_output, '>&', \*STDOUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | or die "$0: duplicate SLiM stdout failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 9 | ▶ | open my $diagnostic_output, '>&', \*STDERR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | or die "$0: duplicate diagnostic stderr failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 9 | ▶ | binmode $protocol_output or die "$0: binary SLiM stdout failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 9 | ▶ | binmode $diagnostic_output or die "$0: binary diagnostic stderr failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 9 | ▶ | binmode STDIN or die "$0: binary SLiM stdin failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # Keep fd 1 away from SLiM framing even when a fixture, child process, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # native routine writes directly to stdout. The saved handle remains the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # only protocol-output path. FitNesse collects this diagnostic stream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 9 | ▶ | open STDOUT, '>&', STDERR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | or die "$0: redirect fixture stdout failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 9 | ▶ | binmode STDOUT or die "$0: binary fixture stdout redirection failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 9 | my $selected = select STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 9 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 9 | select $selected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 9 | $self->process_pipe(\*STDIN,$protocol_output,$diagnostic_output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 5 | ▶ | close $protocol_output or die "$0: close SLiM stdout failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 5 | ▶ | close $diagnostic_output or die "$0: close diagnostic stderr failed: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 47 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | Test::FitNesse::Slim::Server - Serve FitNesse SLiM sessions over TCP or pipes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | The server owns transport framing and the per-session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | L<Test::FitNesse::Slim::ListExecutor>. TCP connections and the port-1 stdin/stdout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | transport share the same frame reader, SLiM deserializer, executor, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | response serializer. Each accepted connection receives isolated fixture, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | library, and symbol state. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | Pipe protocol bytes are written through a dedicated stdout handle. Fixture | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | stdout and stderr are captured separately and emitted as FitNesse v0.5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | diagnostic records on stderr. TCP diagnostics use the normal process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | diagnostic stream. Transport and resource errors close the affected session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | and are reported on stderr; they do not manufacture a response for an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | incomplete message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | my $server = Test::FitNesse::Slim::Server->new(%options); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | Create a server. C<verbose> enables request/response diagnostics, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | C<statement_timeout> sets an optional per-invocation limit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | C<max_frame_bytes> overrides the outer frame limit, and C<bind_address> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | selects the TCP listener's numeric IPv4 address. The bind address defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | to C<127.0.0.1>; explicitly configured non-loopback addresses produce an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | unauthenticated-listener warning when the TCP listener starts. Binding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | configuration cannot be used with pipe mode. The frame limit may also be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | configured with C<TEST_SLIM_MAX_FRAME_BYTES> and defaults to 64 MiB. Invalid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | limits and bind addresses throw an error during construction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | =head2 run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | $server->run($port); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | my $remote = Test::FitNesse::Slim::Server->new(bind_address => '0.0.0.0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | $remote->run(8099); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | Run the selected transport. Port C<1> serves a single v0.5 pipe session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | over inherited standard input/output. Other valid ports create an IPv4 TCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | listener at C<bind_address> (loopback by default) and serve clients. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | method runs until the pipe session ends or the TCP listener is stopped. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | =head2 process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | Process one connected TCP session on a bidirectional filehandle. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | method is primarily used by the listener and transport tests. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | =head2 process_pipe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | Process one pipe session using distinct input and protocol-output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | filehandles. An optional diagnostic-output handle receives v0.5 tunneling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | records. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | =head2 execute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | Execute decoded instruction array references in the current session. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | is a small integration-test hook; transport sessions normally use the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | internal list executor directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | =head2 run_pipe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | Prepare the standard handles for a FitNesse-managed child and run one pipe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | session. Protocol bytes go to the preserved stdout descriptor; ordinary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | stdout is redirected away from it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | =head1 PROTOCOL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | The outer frame prefix counts UTF-8 payload bytes. Inner SLiM string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | lengths count UTF-16 code units. The server advertises | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | C<Slim -- V0.5\n>. A framed C<bye> ends a session. See | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | C<docs/slim-protocol-malformed-input.md> and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | C<docs/slim-pipe-transport.md> for framing limits and transport policy. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||