| 1 | package Tapper::MCP::State::Details; | ||||||||||||||||||||||||||||
| 2 | 29 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||
| 3 | 29 | $Tapper::MCP::State::Details::VERSION = '5.0.9'; | |||||||||||||||||||||||||||
| 4 | 29 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 29 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 29 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 29 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 29 | ▶ | use List::Util qw/max min/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 29 | ▶ | use Tapper::Model 'model'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 29 | ▶ | use YAML qw/Dump Load/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | has state_details => (is => 'rw', | ||||||||||||||||||||||||||||
| 14 | 15 | ▶ | default => sub { {current_state => 'invalid'} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 29 | ); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 29 | has persist => (is => 'rw',); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub BUILD | ||||||||||||||||||||||||||||
| 21 | 15 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 15 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 23 | 15 | my $testrun_id = $args->{testrun_id}; | |||||||||||||||||||||||||||
| 24 | 15 | my $result = model('TestrunDB')->resultset('State')->find_or_create({testrun_id => $testrun_id}); | |||||||||||||||||||||||||||
| 25 | 15 | $self->persist($result); | |||||||||||||||||||||||||||
| 26 | 15 | $self->state_details($result->state); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub db_update | ||||||||||||||||||||||||||||
| 34 | 194 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
db_update: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 194 | my ($self) = @_; | |||||||||||||||||||||||||||
| 36 | 194 | $self->persist->state($self->state_details); | |||||||||||||||||||||||||||
| 37 | 194 | $self->persist->update; | |||||||||||||||||||||||||||
| 38 | 194 | return 0; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub results | ||||||||||||||||||||||||||||
| 44 | 28 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
results: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 28 | my ($self, $result) = @_; | |||||||||||||||||||||||||||
| 46 | 28 | ▶ | if ($result) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 20 | push @{$self->state_details->{results}}, $result; | |||||||||||||||||||||||||||
| 48 | 20 | $self->db_update(); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 28 | ▶ | return $self->state_details->{results} if $self->state_details->{results}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub state_init | ||||||||||||||||||||||||||||
| 55 | 16 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
state_init: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 16 | my ($self, $data) = @_; | |||||||||||||||||||||||||||
| 57 | 16 | $self->state_details($data); | |||||||||||||||||||||||||||
| 58 | 16 | $self->state_details->{current_state} = 'started'; | |||||||||||||||||||||||||||
| 59 | 16 | $self->state_details->{results} = []; | |||||||||||||||||||||||||||
| 60 | 16 | ▶ | $self->state_details->{prcs} ||= []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->state_details->{"prcs"} ||= []
MC/DC0%0/1
$self->state_details->{"prcs"} ||= []
$self->state_details->{"prcs"}
Truth table50%1/2
A
A= $self->state_details->{"prcs"}
| |||||||||||||||||||||||||||||
| 61 | 16 | ▶ | $self->state_details->{keep_alive}{timeout_date} = $self->state_details->{keep_alive}{timeout_span} + time if defined $self->state_details->{keep_alive}{timeout_span}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 16 | foreach my $this_prc (@{$self->state_details->{prcs}}) { | |||||||||||||||||||||||||||
| 63 | 38 | ▶ | $this_prc->{results} ||= []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$this_prc->{"results"} ||= []
MC/DC0%0/1
$this_prc->{"results"} ||= []
$this_prc->{"results"}
Truth table50%1/2
A
A= $this_prc->{"results"}
| |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 16 | $self->db_update(); | |||||||||||||||||||||||||||
| 66 | 16 | return 0; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub takeoff | ||||||||||||||||||||||||||||
| 73 | 15 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
takeoff: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 15 | my ($self, $skip_install) = @_; | |||||||||||||||||||||||||||
| 75 | 15 | my $timeout_current_date; | |||||||||||||||||||||||||||
| 76 | 15 | ▶ | if ($skip_install) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 2 | $self->current_state('reboot_test'); | |||||||||||||||||||||||||||
| 78 | 2 | my $prc = $self->state_details->{prcs}->[0]; | |||||||||||||||||||||||||||
| 79 | 2 | $timeout_current_date = $prc->{timeout_current_date} = $prc->{timeout_boot_span} + time(); | |||||||||||||||||||||||||||
| 80 | } else { | ||||||||||||||||||||||||||||
| 81 | 13 | $self->current_state('reboot_install'); | |||||||||||||||||||||||||||
| 82 | 13 | my $install = $self->state_details->{install}; | |||||||||||||||||||||||||||
| 83 | 13 | $timeout_current_date = $install->{timeout_current_date} = $install->{timeout_boot_span} + time(); | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 15 | $self->db_update(); | |||||||||||||||||||||||||||
| 87 | 15 | return ($timeout_current_date); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub current_state | ||||||||||||||||||||||||||||
| 92 | 253 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
current_state: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 253 | my ($self, $state) = @_; | |||||||||||||||||||||||||||
| 94 | 253 | ▶ | if (defined $state) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 60 | $self->state_details->{current_state} = $state; | |||||||||||||||||||||||||||
| 96 | 60 | $self->db_update; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | 253 | ▶ | return $self->state_details->{current_state} if $self->state_details->{current_state}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | sub set_all_prcs_current_state | ||||||||||||||||||||||||||||
| 103 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_all_prcs_current_state: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 3 | my ($self, $state) = @_; | |||||||||||||||||||||||||||
| 105 | 3 | ▶ | if (defined $state) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 3 | ▶ | for ( my $prc_num = 0; $prc_num < @{$self->state_details->{prcs}}; $prc_num++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 3 | $self->state_details->{prcs}[$prc_num]{current_state} = $state; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | 3 | $self->db_update; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | sub keep_alive_timeout_date | ||||||||||||||||||||||||||||
| 115 | 11 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
keep_alive_timeout_date: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 116 | 11 | my ($self, $timeout_date) = @_; | |||||||||||||||||||||||||||
| 117 | 11 | ▶ | if ($self->state_details) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 11 | ▶ | $self->state_details->{keep_alive}{timeout_date} = $timeout_date if defined $timeout_date; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 11 | $self->state_details->{keep_alive}{timeout_date}; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | sub set_keep_alive_timeout_span | ||||||||||||||||||||||||||||
| 127 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_keep_alive_timeout_span: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | 1 | my ($self, $timeout_span) = @_; | |||||||||||||||||||||||||||
| 129 | 1 | $self->state_details->{keep_alive}{timeout_date} = $timeout_span; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | sub keep_alive_timeout_span | ||||||||||||||||||||||||||||
| 134 | 118 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
keep_alive_timeout_span: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | 118 | my ($self) = @_; | |||||||||||||||||||||||||||
| 136 | 118 | return $self->state_details->{keep_alive}{timeout_span}; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | sub installer_timeout_current_date | ||||||||||||||||||||||||||||
| 142 | 30 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
installer_timeout_current_date: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||||||||||||||||||||
| 143 | 30 | my ($self, $timeout_date) = @_; | |||||||||||||||||||||||||||
| 144 | 30 | ▶ | if (defined $timeout_date) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | $self->state_details->{install}{timeout_current_date} = $timeout_date; | |||||||||||||||||||||||||||
| 146 | 0 | $self->db_update; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 30 | return $self->state_details->{install}{timeout_current_date}; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | sub start_install | ||||||||||||||||||||||||||||
| 153 | 10 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
start_install: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 154 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||
| 155 | $self->state_details->{install}->{timeout_current_date} = | ||||||||||||||||||||||||||||
| 156 | 10 | time + $self->state_details->{install}->{timeout_install_span}; | |||||||||||||||||||||||||||
| 157 | 10 | $self->db_update; | |||||||||||||||||||||||||||
| 158 | 10 | return $self->state_details->{install}->{timeout_install_span}; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | sub prc_boot_start | ||||||||||||||||||||||||||||
| 164 | 16 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
prc_boot_start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 165 | 16 | my ($self, $num) = @_; | |||||||||||||||||||||||||||
| 166 | $self->state_details->{prcs}->[$num]->{timeout_current_date} = | ||||||||||||||||||||||||||||
| 167 | 16 | time + $self->state_details->{prcs}->[$num]->{timeout_boot_span}; | |||||||||||||||||||||||||||
| 168 | 16 | $self->db_update; | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 16 | return $self->state_details->{prcs}->[$num]->{timeout_boot_span}; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | sub prc_timeout_current_date | ||||||||||||||||||||||||||||
| 175 | 108 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
prc_timeout_current_date: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 176 | 108 | my ($self, $num) = @_; | |||||||||||||||||||||||||||
| 177 | 108 | return $self->state_details->{prcs}->[$num]->{timeout_current_date}; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | sub prc_results | ||||||||||||||||||||||||||||
| 183 | 11 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
prc_results: called CC=4 SCAR=16.9
Pod
documented
| |||||||||||||||||||||||||||||
| 184 | 11 | my ($self, $num, $msg) = @_; | |||||||||||||||||||||||||||
| 185 | 11 | ▶ | if (not defined $num) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 0 | my @results; | |||||||||||||||||||||||||||
| 187 | 0 | ▶ | for ( my $prc_num=0; $prc_num < @{$self->state_details->{prcs}}; $prc_num++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 0 | push @results, $self->state_details->{prcs}->[$prc_num]->{results}; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 0 | return \@results; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 11 | ▶ | if ($msg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 6 | push @{$self->state_details->{prcs}->[$num]->{results}}, $msg; | |||||||||||||||||||||||||||
| 194 | 6 | $self->db_update; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | 11 | return $self->state_details->{prcs}->[$num]->{results}; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | sub prc_count | ||||||||||||||||||||||||||||
| 201 | 197 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
prc_count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 202 | 197 | return int @{shift->state_details->{prcs}}; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | sub prc_state | ||||||||||||||||||||||||||||
| 208 | 99 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
prc_state: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 209 | 99 | my ($self, $num, $state) = @_; | |||||||||||||||||||||||||||
| 210 | 99 | ▶ | return {} if $num >= $self->prc_count; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 99 | ▶ | if (defined $state) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 28 | $self->state_details->{prcs}->[$num]{current_state} = $state; | |||||||||||||||||||||||||||
| 213 | 28 | $self->db_update; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | 99 | return $self->state_details->{prcs}->[$num]{current_state}; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | sub is_all_prcs_finished | ||||||||||||||||||||||||||||
| 221 | 29 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
is_all_prcs_finished: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 222 | 29 | my ($self) = @_; | |||||||||||||||||||||||||||
| 223 | # check whether this is the last PRC we are waiting for | ||||||||||||||||||||||||||||
| 224 | 29 | my $all_finished = 1; | |||||||||||||||||||||||||||
| 225 | 29 | ▶ | for ( my $prc_num=0; $prc_num < @{$self->state_details->{prcs}}; $prc_num++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 36 | ▶ | if ($self->state_details->{prcs}->[$prc_num]->{current_state} ne 'finished') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 26 | $all_finished = 0; | |||||||||||||||||||||||||||
| 228 | 26 | last; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | 29 | return $all_finished; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | sub prc_next_timeout | ||||||||||||||||||||||||||||
| 237 | 14 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
prc_next_timeout: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||
| 238 | 14 | my ($self, $num) = @_; | |||||||||||||||||||||||||||
| 239 | 14 | my $prc = $self->state_details->{prcs}->[$num]; | |||||||||||||||||||||||||||
| 240 | 14 | my $default_timeout = 60 + 60; # (time between SIGTERM and SIGKILL in PRC) + (grace period for sending the message) | |||||||||||||||||||||||||||
| 241 | 14 | my $next_timeout = $default_timeout; | |||||||||||||||||||||||||||
| 242 | 14 | my $state = $prc->{current_state}; | |||||||||||||||||||||||||||
| 243 | 14 | ▶ | if ($state eq 'preload') { $next_timeout = $prc->{timeout_boot_span}} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 14 | ▶ | if ($state eq 'boot') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | 6 | ▶ | if (ref $prc->{timeout_testprograms_span} eq 'ARRAY' and | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $prc->{"timeout_testprograms_span"} eq "ARRAY" and @{$prc->{"timeout_testprograms_span"};}
MC/DC50%1/2
ref $prc->{"timeout_testprograms_span"} eq "ARRAY" and @{$prc->{"timeout_testprograms_span"};}
ref $prc->{"timeout_testprograms_span"} eq "ARRAY"
@{$prc->{"timeout_testprograms_span"};}
Truth table66%2/3
A and B
A= ref $prc->{"timeout_testprograms_span"} eq "ARRAY"B= @{$prc->{"timeout_testprograms_span"};}
| |||||||||||||||||||||||||||||
| 246 | 3 | @{$prc->{timeout_testprograms_span}}) { | |||||||||||||||||||||||||||
| 247 | 3 | $next_timeout = $prc->{timeout_testprograms_span}->[0]; | |||||||||||||||||||||||||||
| 248 | } else { | ||||||||||||||||||||||||||||
| 249 | 3 | $next_timeout = $default_timeout; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | 14 | ▶ | if ($state eq 'test') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 6 | my $testprogram_number = $prc->{number_current_test}; | |||||||||||||||||||||||||||
| 254 | 6 | ++$testprogram_number; | |||||||||||||||||||||||||||
| 255 | 6 | ▶ | if (ref $prc->{timeout_testprograms_span} eq 'ARRAY' and | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $prc->{"timeout_testprograms_span"} eq "ARRAY" and exists $prc->{"timeout_testprograms_span"}[$testprogram_number]
MC/DC50%1/2
ref $prc->{"timeout_testprograms_span"} eq "ARRAY" and exists $prc->{"timeout_testprograms_span"}[$testprogram_number]
ref $prc->{"timeout_testprograms_span"} eq "ARRAY"
exists $prc->{"timeout_testprograms_span"}[$testprogram_number]
Truth table66%2/3
A and B
A= ref $prc->{"timeout_testprograms_span"} eq "ARRAY"B= exists $prc->{"timeout_testprograms_span"}[$testprogram_number]
| |||||||||||||||||||||||||||||
| 256 | exists $prc->{timeout_testprograms_span}[$testprogram_number]){ | ||||||||||||||||||||||||||||
| 257 | 2 | $prc->{number_current_test} = $testprogram_number; | |||||||||||||||||||||||||||
| 258 | 2 | $next_timeout = $prc->{timeout_testprograms_span}[$testprogram_number]; | |||||||||||||||||||||||||||
| 259 | } else { | ||||||||||||||||||||||||||||
| 260 | 4 | $prc->{current_state} = 'lasttest'; | |||||||||||||||||||||||||||
| 261 | 4 | $next_timeout = $default_timeout; | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | 14 | ▶ | if ($state eq 'lasttest') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | 0 | my $result = { error => 1, | |||||||||||||||||||||||||||
| 266 | msg => "prc_next_timeout called in state testfin. This is a bug. Please report it!"}; | ||||||||||||||||||||||||||||
| 267 | 0 | $self->prc_results($num, $result); | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | 14 | ▶ | if ($state eq 'finished') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 1 | return; | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 13 | $self->state_details->{prcs}->[$num]->{timeout_current_date} = time() + $next_timeout; | |||||||||||||||||||||||||||
| 274 | 13 | $self->db_update; | |||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 13 | return $next_timeout; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | sub prc_current_test_number | ||||||||||||||||||||||||||||
| 281 | 13 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
prc_current_test_number: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 282 | 13 | my ($self, $num, $test_number) = @_; | |||||||||||||||||||||||||||
| 283 | 13 | ▶ | if (defined $test_number) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 284 | 7 | $self->state_details->{prcs}->[$num]{number_current_test} = $test_number; | |||||||||||||||||||||||||||
| 285 | 7 | $self->db_update; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | 13 | return $self->state_details->{prcs}->[$num]{number_current_test}; | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | sub get_min_prc_timeout | ||||||||||||||||||||||||||||
| 292 | 23 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
get_min_prc_timeout: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 293 | 23 | my ($self) = @_; | |||||||||||||||||||||||||||
| 294 | 23 | my $now = time(); | |||||||||||||||||||||||||||
| 295 | 23 | my $timeout = $self->state_details->{prcs}->[0]->{timeout_current_date} - $now; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 23 | ▶ | for ( my $prc_num=1; $prc_num < @{$self->state_details->{prcs}}; $prc_num++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | 41 | ▶ | next unless $self->state_details->{prcs}->[$prc_num]->{timeout_current_date}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | 29 | $timeout = min($timeout, $self->state_details->{prcs}->[$prc_num]->{timeout_current_date} - $now); | |||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | 23 | return $timeout; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 29 | 1; | |||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | __END__ | ||||||||||||||||||||||||||||