| 1 | package Tapper::MCP::Info; | ||||||||||||||||||||||||
| 2 | 28 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||
| 3 | 28 | $Tapper::MCP::Info::VERSION = '5.0.9'; | |||||||||||||||||||||||
| 4 | 28 | ▶ | use 5.010; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 5 | 28 | ▶ | use Moose; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||
| 7 | 28 | extends 'Tapper::MCP'; | |||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||
| 9 | has mcp_info => (is => 'rw', | ||||||||||||||||||||||||
| 10 | isa => 'HashRef', | ||||||||||||||||||||||||
| 11 | 26 | ▶ | default => sub {{}}, | ||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 12 | 28 | ); | |||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||
| 16 | sub set_max_reboot | ||||||||||||||||||||||||
| 17 | 4 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
set_max_reboot: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||
| 18 | 4 | my ($self, $prc_number, $max_reboot) = @_; | |||||||||||||||||||||||
| 19 | 4 | $self->mcp_info->{prc}->[$prc_number]->{max_reboot} = $max_reboot; | |||||||||||||||||||||||
| 20 | 4 | return 0; | |||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||
| 26 | sub get_max_reboot | ||||||||||||||||||||||||
| 27 | 0 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
get_max_reboot: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||
| 28 | 0 | my ($self, $prc_number) = @_; | |||||||||||||||||||||||
| 29 | 0 | ▶ | return $self->mcp_info->{prc}->[$prc_number]->{max_reboot} || 0; | ||||||||||||||||||||||
|
Condition0%0/2
$self->mcp_info->{'prc'}[$prc_number]{'max_reboot'} || 0
MC/DC0%0/1
$self->mcp_info->{'prc'}[$prc_number]{'max_reboot'} || 0
$self->mcp_info->{'prc'}[$prc_number]{'max_reboot'}
Truth table0%0/2
A
A= $self->mcp_info->{'prc'}[$prc_number]{'max_reboot'}
| |||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||
| 34 | sub add_prc | ||||||||||||||||||||||||
| 35 | 34 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
add_prc: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||
| 36 | 34 | my ($self, $prc_number, $timeout) = @_; | |||||||||||||||||||||||
| 37 | 34 | ▶ | return "prc_number not given to add_testprc" if not defined $prc_number; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 38 | 34 | $self->mcp_info->{prc}->[$prc_number]->{timeouts}->{boot} = $timeout; | |||||||||||||||||||||||
| 39 | 34 | return 0; | |||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||
| 43 | sub add_testprogram | ||||||||||||||||||||||||
| 44 | 40 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
add_testprogram: called CC=4 SCAR=14.4
Pod
documented
| |||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||
| 46 | 40 | my ($self, $prc_number, $program) = @_; | |||||||||||||||||||||||
| 47 | 40 | my $grace_period = 60 + 60; # (time between SIGTERM and SIGKILL in PRC) + (grace period for sending the message) | |||||||||||||||||||||||
| 48 | 40 | ▶ | return "prc_number not given to add_testprogram" if not defined $prc_number; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 49 | 40 | ▶ | $program->{timeout} = $program->{timeout_testprogram} || $program->{timeout} || 0; | ||||||||||||||||||||||
|
Condition40%2/5
$program->{'timeout_testprogram'} || $program->{'timeout'} || 0
$program->{"timeout_testprogram"} or $program->{"timeout"}
MC/DC0%0/2
$program->{'timeout_testprogram'} || $program->{'timeout'} || 0
$program->{"timeout_testprogram"}
$program->{"timeout"}
Truth table33%1/3
A or B
A= $program->{"timeout_testprogram"}B= $program->{"timeout"}
| |||||||||||||||||||||||||
| 50 | 40 | delete $program->{precondition_type}; | |||||||||||||||||||||||
| 51 | 40 | push(@{$self->mcp_info->{prc}->[$prc_number]->{programs}}, $program); | |||||||||||||||||||||||
| 52 | 40 | push(@{$self->mcp_info->{prc}->[$prc_number]->{timeouts}->{programs}}, $program->{timeout} + $grace_period); | |||||||||||||||||||||||
| 53 | 40 | return 0; | |||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||
| 57 | # This function exists for convenience in timeout handling. The same could be | ||||||||||||||||||||||||
| 58 | # achieved with get_testprogam and reading timeout values of every element | ||||||||||||||||||||||||
| 59 | # returned. (This comment is not part of pod to prevent it from becoming part | ||||||||||||||||||||||||
| 60 | # of the external documentation.) | ||||||||||||||||||||||||
| 61 | sub get_testprogram_timeouts | ||||||||||||||||||||||||
| 62 | 2 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
get_testprogram_timeouts: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||
| 65 | 2 | my ($self, $prc_number) = @_; | |||||||||||||||||||||||
| 66 | 2 | ▶ | return unless defined $self->mcp_info->{prc}->[$prc_number]->{timeouts}->{programs}; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 67 | 2 | return @{$self->mcp_info->{prc}->[$prc_number]->{timeouts}->{programs}}; | |||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||
| 71 | sub get_testprograms | ||||||||||||||||||||||||
| 72 | 2 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
get_testprograms: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||
| 74 | 2 | my ($self, $prc_number) = @_; | |||||||||||||||||||||||
| 75 | 2 | ▶ | return unless defined $self->mcp_info->{prc}->[$prc_number]->{programs}; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 76 | 2 | return @{$self->mcp_info->{prc}->[$prc_number]->{programs}}; | |||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||
| 82 | sub get_prc_count | ||||||||||||||||||||||||
| 83 | 5 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
get_prc_count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||
| 85 | 5 | my ($self) = @_; | |||||||||||||||||||||||
| 86 | 5 | return $#{$self->mcp_info->{prc}}; | |||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||
| 93 | sub get_boot_timeout | ||||||||||||||||||||||||
| 94 | 2 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
get_boot_timeout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||
| 95 | 2 | my ($self, $prc_number) = @_; | |||||||||||||||||||||||
| 96 | 2 | return $self->mcp_info->{prc}->[$prc_number]->{timeouts}->{boot}; | |||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||
| 100 | sub set_installer_timeout | ||||||||||||||||||||||||
| 101 | 3 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
set_installer_timeout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||
| 102 | 3 | my ($self, $timeout) = @_; | |||||||||||||||||||||||
| 103 | 3 | $self->mcp_info->{installer}{timeouts} = $timeout; | |||||||||||||||||||||||
| 104 | 3 | return 0; | |||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||
| 108 | sub get_installer_timeout | ||||||||||||||||||||||||
| 109 | 7 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
get_installer_timeout: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 110 | 7 | my ($self) = @_; | |||||||||||||||||||||||
| 111 | 7 | ▶ | return $self->mcp_info->{installer}{timeouts} || 0; | ||||||||||||||||||||||
|
Condition100%2/2
$self->mcp_info->{'installer'}{'timeouts'} || 0
MC/DC100%1/1
$self->mcp_info->{'installer'}{'timeouts'} || 0
$self->mcp_info->{'installer'}{'timeouts'}
Truth table100%2/2
A
A= $self->mcp_info->{'installer'}{'timeouts'}
| |||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||
| 115 | sub push_report_msg | ||||||||||||||||||||||||
| 116 | 0 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
push_report_msg: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 117 | 0 | my ($self, $msg) = @_; | |||||||||||||||||||||||
| 118 | 0 | push @{$self->mcp_info->{report}}, $msg; | |||||||||||||||||||||||
| 119 | 0 | return 0; | |||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||
| 123 | sub get_report_array | ||||||||||||||||||||||||
| 124 | 0 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
get_report_array: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||
| 125 | 0 | my ($self) = @_; | |||||||||||||||||||||||
| 126 | 0 | ▶ | return $self->mcp_info->{report} // []; | ||||||||||||||||||||||
|
Condition0%0/2
$self->mcp_info->{"report"} // []
MC/DC0%0/1
$self->mcp_info->{"report"} // []
$self->mcp_info->{"report"}
Truth table0%0/2
A
A= $self->mcp_info->{"report"}
| |||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||
| 130 | sub set_keep_alive_timeout | ||||||||||||||||||||||||
| 131 | 21 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
set_keep_alive_timeout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||
| 132 | 21 | my ($self, $timeout) = @_; | |||||||||||||||||||||||
| 133 | 21 | $self->mcp_info->{keep_alive}{timeout_span} = $timeout; | |||||||||||||||||||||||
| 134 | 21 | return $self->mcp_info->{keep_alive}{timeout_span}; | |||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||
| 138 | sub keep_alive_timeout | ||||||||||||||||||||||||
| 139 | 2 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
keep_alive_timeout: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 140 | 2 | my ($self, $timeout) = @_; | |||||||||||||||||||||||
| 141 | 2 | ▶ | $self->mcp_info->{keep_alive}{timeout_span} = $timeout if defined $timeout; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 142 | 2 | return $self->mcp_info->{keep_alive}{timeout_span}; | |||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||
| 147 | sub test_type | ||||||||||||||||||||||||
| 148 | 49 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
test_type: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||
| 149 | 49 | my ($self, $test_type) = @_; | |||||||||||||||||||||||
| 150 | 49 | ▶ | $self->mcp_info->{test_type} = $test_type if $test_type; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 151 | 49 | ▶ | return $self->mcp_info->{test_type} // ''; | ||||||||||||||||||||||
|
Condition100%2/2
$self->mcp_info->{"test_type"} // ""
MC/DC100%1/1
$self->mcp_info->{"test_type"} // ""
$self->mcp_info->{"test_type"}
Truth table100%2/2
A
A= $self->mcp_info->{"test_type"}
| |||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||
| 155 | sub get_state_config | ||||||||||||||||||||||||
| 156 | 7 | ▶ | { | ||||||||||||||||||||||
|
Subroutine
get_state_config: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||
| 157 | 7 | my ($self) = @_; | |||||||||||||||||||||||
| 158 | my $state = { | ||||||||||||||||||||||||
| 159 | keep_alive => { timeout_span => $self->mcp_info->{keep_alive}{timeout_span}, timeout_date => undef}, | ||||||||||||||||||||||||
| 160 | current_state => 'started', | ||||||||||||||||||||||||
| 161 | results => [], | ||||||||||||||||||||||||
| 162 | install => { timeout_boot_span => $self->get_installer_timeout || $self->cfg->{times}{boot_timeout}, | ||||||||||||||||||||||||
| 163 | timeout_install_span => $self->cfg->{times}{installer_timeout}, | ||||||||||||||||||||||||
| 164 | 7 | ▶ | timeout_current_date => undef, | ||||||||||||||||||||||
|
Condition66%2/3
$self->get_installer_timeout || $self->cfg->{'times'}{'boot_timeout'}
MC/DC0%0/2
$self->get_installer_timeout || $self->cfg->{'times'}{'boot_timeout'}
$self->get_installer_timeout
$self->cfg->{'times'}{'boot_timeout'}
Truth table66%2/3
A || B
A= $self->get_installer_timeoutB= $self->cfg->{'times'}{'boot_timeout'}
| |||||||||||||||||||||||||
| 165 | }, | ||||||||||||||||||||||||
| 166 | prcs => [], | ||||||||||||||||||||||||
| 167 | }; | ||||||||||||||||||||||||
| 168 | 7 | ▶ | if ($self->mcp_info->{prc}->[0]->{max_reboot}) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 169 | 0 | $state->{reboot}->{max_reboot} = $self->mcp_info->{prc}->[0]->{max_reboot}; | |||||||||||||||||||||||
| 170 | 0 | $state->{reboot}->{current} = 0; | |||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||
| 172 | 7 | foreach my $prc ( @{$self->mcp_info->{prc}}) { | |||||||||||||||||||||||
| 173 | my $prc_state = { | ||||||||||||||||||||||||
| 174 | timeout_boot_span => $prc->{timeouts}->{boot} || $self->cfg->{times}{boot_timeout}, | ||||||||||||||||||||||||
| 175 | timeout_current_date => undef, | ||||||||||||||||||||||||
| 176 | current_state => 'preload', | ||||||||||||||||||||||||
| 177 | results => [], | ||||||||||||||||||||||||
| 178 | timeout_testprograms_span => $prc->{timeouts}->{programs}, | ||||||||||||||||||||||||
| 179 | 10 | ▶ | }; | ||||||||||||||||||||||
|
Condition66%2/3
$prc->{'timeouts'}{'boot'} || $self->cfg->{'times'}{'boot_timeout'}
MC/DC0%0/2
$prc->{'timeouts'}{'boot'} || $self->cfg->{'times'}{'boot_timeout'}
$prc->{'timeouts'}{'boot'}
$self->cfg->{'times'}{'boot_timeout'}
Truth table66%2/3
A || B
A= $prc->{'timeouts'}{'boot'}B= $self->cfg->{'times'}{'boot_timeout'}
| |||||||||||||||||||||||||
| 180 | 10 | push @{$state->{prcs}}, $prc_state; | |||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||
| 183 | # when we don't install, PRC 0 starts in state 'boot' | ||||||||||||||||||||||||
| 184 | 7 | ▶ | if ($self->mcp_info->{skip_install}) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 185 | 1 | $state->{prcs}->[0]->{current_state} = 'boot'; | |||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||
| 187 | 7 | return $state; | |||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||
| 191 | 14 | ▶ | sub skip_install { | ||||||||||||||||||||||
|
Subroutine
skip_install: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||
| 192 | 14 | my ($self, $skip_install) = @_; | |||||||||||||||||||||||
| 193 | 14 | ▶ | $self->mcp_info->{skip_install} = $skip_install if $skip_install; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||
| 195 | 14 | return $self->mcp_info->{skip_install}; | |||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||
| 198 | 28 | 1; | |||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||
| 200 | __END__ | ||||||||||||||||||||||||