CBSD/bpause.pm

filter: Statementstmt 53.1% 17 / 32 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 37.9% 22 / 58 CC 8 SCAR 38.0
CC
8
Cov
35%
execute
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 44.7
« CBSD/bcheckpoint_create.pm ↑ Summary CBSD/bstart.pm »
1 #
2 # (c) Zane C. Bowers-Hadley <vvelox@vvelox.net>
3 #
4  
5 package Rex::Virtualization::CBSD::bpause;
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '0.0.1'; # VERSION
11  
12 1 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Rex::Helper::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Term::ANSIColor qw(colorstrip);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub execute {
Subroutine execute: not called CC=8 SCAR=42.8
Pod undocumented
17 0 my ( $class, $name, $mode ) = @_;
18  
19 # make sure we have a jname to pass
20 0 ▶ if ( !defined($name) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 0 0 0
21 0 die('No VM name defined');
22 }
23  
24 # set the mode to auto if none is set
25 0 ▶ if ( !defined($mode) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $mode) 0 0 0
26 0 $mode = 'auto';
27 }
28  
29 # make sure mode is something valid
30 0 ▶ if ( ( $mode eq 'auto' )
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "auto" or $mode eq "on" or $mode eq "off") 0 0 0
Condition0%0/6
$mode eq "auto" or $mode eq "on" or $mode eq "off"
l!l&&r!l&&!r
000
$mode eq "auto" or $mode eq "on"
l!l&&r!l&&!r
000
MC/DC0%0/3
$mode eq "auto" or $mode eq "on" or $mode eq "off"
$mode eq "auto" $mode eq "on" $mode eq "off"
Truth table0%0/4
A or B or C
A= $mode eq "auto"B= $mode eq "on"C= $mode eq "off"
ABCresult
1XX1
01X1
0011
0000
31 || ( $mode eq 'on' )
32 || ( $mode eq 'off' ) )
33 {
34 0 die "Mode specified is something other than 'auto', 'on', or 'off'.";
35 }
36  
37 0 Rex::Logger::debug( "CBSD VM start via cbsd brebstart " . $name );
38  
39 # run it
40 0 my $returned = i_run( 'cbsd bpause ' . $name . ' mode=' . $mode, fail_ok => 1 );
41  
42 # the output is colorized
43 0 $returned = colorstrip($returned);
44  
45 # check for failures caused by it not existing
46 0 ▶ if ( $returned =~ /^No\ such/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($returned =~ /^No\ such/) 0 0 0
47 0 die( '"' . $name . '" does not exist' );
48 }
49 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
50 0 die( "Error running 'cbsd brestart " . $name . "'" );
51 }
52  
53 0 return 1;
54 }
55  
56 1 1;
« CBSD/bcheckpoint_create.pm ↑ Summary CBSD/bstart.pm »