blib/lib/Langertha/Holmgang/Sim/Linux/Docker.pm

filter: Statementstmt 74.6% 1244 / 1667 Branchbran 53.2% 616 / 1156 Conditioncond 38.6% 403 / 1044 MC/DCmcdc 11.1% 62 / 558 Subroutinesub 91.9% 80 / 87 Podpod 100% 12 / 12 totaltotal 53.4% 2417 / 4524 CC 1066 SCAR 61.5
CC
1066
Cov
59%
_compose
2098.2
docker
935.0
_exec
841.7
CRAP 467.1
« blib/lib/Langertha/Holmgang/Shell.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Http.pm »
1 package Langertha::Holmgang::Sim::Linux::Docker;
2 # ABSTRACT: Docker Engine with Compose v2 on a simulated Linux server — projects, containers, derived state
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Ausgabe von inspect wie Docker (Go json.MarshalIndent): "Key": value, vier Leerzeichen
14 3 my $OUT_JSON = JSON::PP->new->canonical->indent->indent_length(4)->space_after;
15 3 ▶use YAML::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 our $VERSION = '0.001';
18  
19  
20 3 my $JSON = JSON::MaybeXS->new( utf8 => 0, canonical => 1, allow_nonref => 1 );
21  
22 558 ▶sub _L { require Langertha::Holmgang::Sim::Linux; return 'Langertha::Holmgang::Sim::Linux' }
Subroutine _L: called CC=1 SCAR=0.0
23 511 ▶sub _text { my ( $dev, $p ) = @_; return _L()->can('_file_text')->( $dev, $p ) }
Subroutine _text: called CC=1 SCAR=0.0
24 0 ▶sub _gap { push @Langertha::Holmgang::Sim::Linux::GAPS, $_[0]; return ( '', 0 ) }
Subroutine _gap: not called CC=1 SCAR=6.9
25 46 ▶sub _true { JSON::MaybeXS::true() }
Subroutine _true: called CC=1 SCAR=0.0
26 31 ▶sub _false { JSON::MaybeXS::false() }
Subroutine _false: called CC=1 SCAR=0.0
27  
28 3 my @COMPOSE_FILES = qw( compose.yaml compose.yml docker-compose.yml docker-compose.yaml );
29  
30 3 my %SERVICE_KEYS = map { $_ => 1 } qw( image build container_name environment env_file ports expose volumes
31 networks depends_on healthcheck restart user command entrypoint profiles labels extra_hosts working_dir logging
32 deploy cap_add cap_drop read_only tmpfs ulimits stop_grace_period stop_signal hostname domainname dns init
33 privileged security_opt sysctls shm_size platform pull_policy stdin_open tty devices mem_limit memswap_limit
34 cpus cpu_shares network_mode secrets configs links ipc pid group_add oom_score_adj userns_mode scale
35 mac_address runtime external_links annotations attach );
36 3 my %TOP_KEYS = map { $_ => 1 } qw( version name services networks volumes secrets configs include );
37  
38 # --- Zustand ----------------------------------------------------------------------
39  
40  
41 136 ▶sub ensure {
Subroutine ensure: called CC=9 SCAR=22.1
Pod documented
42 136 my ( $dev, $host, $state ) = @_;
43 136 my $d = $dev->{docker};
44 136 ▶ if ( ref $d->{containers} eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $$d{"containers"} eq "HASH") 119 17 136
45 119 _settle($dev); # Neustart-Regel: inzwischen erneut versucht (Docker mit Backoff)
46 119 return;
47 }
48 17 $d->{containers} = {};
49 17 ▶ $d->{seq} //= 0;
Condition50%1/2
$$d{"seq"} //= 0
l!l
017
MC/DC0%0/1
$$d{"seq"} //= 0
$$d{"seq"}
Truth table50%1/2
A
A= $$d{"seq"}
Aresult
11
00
50 17 ▶ for my $p ( sort keys %{ $d->{projects} || {} } ) {
Condition50%1/2
$$d{'projects'} || {}
l!l
170
MC/DC0%0/1
$$d{'projects'} || {}
$$d{'projects'}
Truth table50%1/2
A
A= $$d{'projects'}
Aresult
11
00
51 17 my $pr = $d->{projects}{$p};
52 17 ▶ next if $pr->{stopped};
Branch: 1 branch
BranchTrueFalseTotal
if $$pr{"stopped"} 0 17 17
53 17 ▶ my %over = %{ $pr->{running_files} || {} };
Condition50%1/2
$$pr{'running_files'} || {}
l!l
017
MC/DC0%0/1
$$pr{'running_files'} || {}
$$pr{'running_files'}
Truth table50%1/2
A
A= $$pr{'running_files'}
Aresult
11
00
54 17 local $Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE = \%over;
55 17 my $m = model( $dev, dir => $pr->{dir}, project => $p );
56 17 ▶ next if $m->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $$m{"error"} 2 15 17
57 15 local $Langertha::Holmgang::Sim::Linux::Docker::QUIET = 1;
58 15 up( $dev, $m, {}, $state, $host );
59 }
60 17 for ( values %{ $d->{containers} } ) { $_->{restarts} = 0; $_->{initial} = _true() }
61 17 return;
62 }
63  
64 3 our ( $OVERRIDE, $QUIET );
65  
66 511 ▶sub _file {
Subroutine _file: called CC=3 SCAR=11.4
67 511 my ( $dev, $p ) = @_;
68 511 ▶ return $OVERRIDE->{$p} if $OVERRIDE && exists $OVERRIDE->{$p};
Branch: 1 branch
BranchTrueFalseTotal
if $Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE and exists $$Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE{$p} 0 511 511
Condition66%2/3
$Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE and exists $$Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE{$p}
!ll&&!rl&&r
3082030
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE and exists $$Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE{$p}
$Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE exists $$Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE{$p}
Truth table66%2/3
A and B
A= $Langertha::Holmgang::Sim::Linux::Docker::OVERRIDEB= exists $$Langertha::Holmgang::Sim::Linux::Docker::OVERRIDE{$p}
ABresult
0X0
100
111
69 511 return _text( $dev, $p );
70 }
71  
72 # --- Interpolation und .env -------------------------------------------------------
73  
74  
75 # dotenv: KEY=VAL, export KEY=VAL, 'woertlich', "mit \n und ${X}", # Kommentar
76 45 ▶sub parse_env {
Subroutine parse_env: called CC=10 SCAR=28.0
Pod documented
77 45 my ( $text, $vars, $missing ) = @_;
78 45 my %e;
79 45 ▶ $missing //= [];
Condition50%1/2
$missing //= []
l!l
450
MC/DC0%0/1
$missing //= []
$missing
Truth table50%1/2
A
A= $missing
Aresult
11
00
80 45 ▶ for my $l ( split /\n/, $text // '' ) {
Condition50%1/2
$text // ""
l!l
450
MC/DC0%0/1
$text // ""
$text
Truth table50%1/2
A
A= $text
Aresult
11
00
81 45 ▶ next if $l =~ /\A\s*(?:#|\z)/;
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /\A\s*(?:#|\z)/ 0 45 45
82 45 ▶ my ( $k, $v ) = $l =~ /\A\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_.-]*)\s*=\s*(.*?)\s*\z/ or next;
Branch: 1 branch
BranchTrueFalseTotal
() = $l =~ /\A\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_.-]*)\s*=\s*(.*?)\s*\z/ or next 45 0 45
83 45 ▶ if ( $v =~ /\A'(.*)'\z/ ) { $v = $1 }
Branch: 2 branches
BranchTrueFalseTotal
if ($v =~ /\A'(.*)'\z/) { } 40 5 45
elsif ($v =~ /\A"(.*)"\z/) { } 0 5 5
84 elsif ( $v =~ /\A"(.*)"\z/ ) {
85 0 $v = $1;
86 0 $v =~ s/\\n/\n/g;
87 0 $v =~ s/\\(["\\])/$1/g;
88 0 ▶ my $r = interpolate( $v, { %{ $vars || {} }, %e } );
Condition0%0/2
$vars || {}
l!l
00
MC/DC0%0/1
$vars || {}
$vars
Truth table0%0/2
A
A= $vars
Aresult
11
00
89 0 push @$missing, @{ $r->{missing} };
90 0 $v = $r->{value};
91 }
92 else {
93 5 $v =~ s/\s+#.*\z//;
94 5 ▶ my $r = interpolate( $v, { %{ $vars || {} }, %e } );
Condition50%1/2
$vars || {}
l!l
50
MC/DC0%0/1
$vars || {}
$vars
Truth table50%1/2
A
A= $vars
Aresult
11
00
95 5 push @$missing, @{ $r->{missing} };
96 5 $v = $r->{value};
97 }
98 45 $e{$k} = $v;
99 }
100 45 return \%e;
101 }
102  
103  
104 # ${VAR}, $VAR, ${VAR:-d}, ${VAR-d}, ${VAR:?e}, ${VAR?e}, ${VAR:+x}, $$ -> $
105 973 ▶sub interpolate {
Subroutine interpolate: called CC=8 SCAR=33.2
Pod documented
106 973 my ( $s, $vars ) = @_;
107 973 my ( @missing, $err );
108 973 my $re;
109 232 ▶ my $sub = sub {
Subroutine __ANON__: called CC=24 SCAR=59.1
110 232 my ( $name, $op, $arg ) = @_;
111 232 my $set = exists $vars->{$name};
112 232 my $v = $vars->{$name};
113 232 ▶ if ( defined $op ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $op) 0 232 232
114 0 ▶ $arg = interpolate( $arg, $vars )->{value} if defined $arg && $arg =~ /\$/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg and $arg =~ /\$/ 0 0 0
Condition0%0/3
defined $arg and $arg =~ /\$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $arg and $arg =~ /\$/
defined $arg $arg =~ /\$/
Truth table0%0/3
A and B
A= defined $argB= $arg =~ /\$/
ABresult
0X0
100
111
115 0 ▶ if ( $op eq ':-' ) { return defined $v && length $v ? $v : $arg }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq ":-") 0 0 0
defined $v && length $v ? : 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
116 0 ▶ if ( $op eq '-' ) { return $set ? $v // '' : $arg }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "-") 0 0 0
$set ? : 0 0 0
Condition0%0/2
$v // ""
l!l
00
MC/DC0%0/1
$v // ""
$v
Truth table0%0/2
A
A= $v
Aresult
11
00
117 0 ▶ if ( $op eq ':+' ) { return defined $v && length $v ? $arg : '' }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq ":+") 0 0 0
defined $v && length $v ? : 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
118 0 ▶ if ( $op eq '+' ) { return $set ? $arg : '' }
Branch: 2 branches
BranchTrueFalseTotal
if ($op eq "+") 0 0 0
$set ? : 0 0 0
119 0 ▶ if ( $op eq ':?' || $op eq '?' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq ":?" or $op eq "?") 0 0 0
Condition0%0/3
$op eq ":?" or $op eq "?"
l!l&&r!l&&!r
000
MC/DC0%0/2
$op eq ":?" or $op eq "?"
$op eq ":?" $op eq "?"
Truth table0%0/3
A or B
A= $op eq ":?"B= $op eq "?"
ABresult
1X1
011
000
120 0 ▶ return $v if $op eq '?' ? $set : defined $v && length $v;
Branch: 2 branches
BranchTrueFalseTotal
if $op eq "?" ? $set : defined $v && length $v 0 0 0
$op eq '?' ? : 0 0 0
Condition0%0/3
defined $v and length $v
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and length $v
defined $v length $v
Truth table0%0/3
A and B
A= defined $vB= length $v
ABresult
0X0
100
111
121 0 ▶ $err //= "required variable $name is missing a value: " . ( $arg // '' );
Condition0%0/4
$err //= "required variable $name is missing a value: " . ($arg // "")
l!l
00
$arg // ""
l!l
00
MC/DC0%0/1
$err //= "required variable $name is missing a value: " . ($arg // "")
$err
MC/DC0%0/1
$arg // ""
$arg
Truth table0%0/2
A
A= $err
Aresult
11
00
Truth table0%0/2
A
A= $arg
Aresult
11
00
122 0 return '';
123 }
124 }
125 232 ▶ push @missing, $name unless $set;
Branch: 1 branch
BranchTrueFalseTotal
unless $set 2 230 232
126 232 ▶ return $v // '';
Condition100%2/2
$v // ""
l!l
2302
MC/DC100%1/1
$v // ""
$v
Truth table100%2/2
A
A= $v
Aresult
11
00
127 973 };
128 973 my $out = '';
129 973 pos($s) = 0;
130 973 ▶ while ( pos($s) < length $s ) {
Branch: 1 branch
BranchTrueFalseTotal
if (pos $s < length $s) 1092 973 2065
131 0 ▶ if ( $s =~ /\G\$\$/gc ) { $out .= '$' }
Branch: 5 branches
BranchTrueFalseTotal
if ($s =~ /\G\$\$/cg) { } 0 1092 1092
elsif ($s =~ /\G\$\{((?:peer:)?[A-Za-z_][A-Za-z0-9_]*)(?:(:?[-?+])((?:[^{}]|\{[^{}]*\})*))?\}/cg) { } 230 862 1092
elsif ($s =~ /\G\$([A-Za-z_][A-Za-z0-9_]*)/cg) { } 2 860 862
elsif ($s =~ /\G\$\{([^}]*)\}/cg) { } 0 860 860
elsif ($s =~ /\G([^\$]+|\$)/cg) { } 860 0 860
132 230 elsif ( $s =~ /\G\$\{((?:peer:)?[A-Za-z_][A-Za-z0-9_]*)(?:(:?[-?+])((?:[^{}]|\{[^{}]*\})*))?\}/gc ) { $out .= $sub->( $1, $2, $3 ) }
133 2 elsif ( $s =~ /\G\$([A-Za-z_][A-Za-z0-9_]*)/gc ) { $out .= $sub->( $1, undef, undef ) }
134 0 ▶ elsif ( $s =~ /\G\$\{([^}]*)\}/gc ) { $err //= "invalid interpolation format for \${$1}"; }
Condition0%0/2
$err //= "invalid interpolation format for \${$1}"
l!l
00
MC/DC0%0/1
$err //= "invalid interpolation format for \${$1}"
$err
Truth table0%0/2
A
A= $err
Aresult
11
00
135 860 elsif ( $s =~ /\G([^\$]+|\$)/gc ) { $out .= $1 }
136 }
137 973 return { value => $out, missing => \@missing, error => $err };
138 }
139  
140 # Interpolation ueber eine ganze Datenstruktur (nur Werte, wie Compose)
141 1390 ▶sub _interp_tree {
Subroutine _interp_tree: called CC=6 SCAR=18.0
142 1390 my ( $x, $vars, $acc ) = @_;
143 1390 ▶ if ( ref $x eq 'HASH' ) { return { map { $_ => _interp_tree( $x->{$_}, $vars, $acc ) } keys %$x } }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x eq "HASH") 475 915 1390
144 915 ▶ if ( ref $x eq 'ARRAY' ) { return [ map { _interp_tree( $_, $vars, $acc ) } @$x ] }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $x eq "ARRAY") 221 694 915
145 694 ▶ return $x if !defined $x || ref $x;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $x or ref $x 88 606 694
Condition66%2/3
not defined $x or ref $x
l!l&&r!l&&!r
880606
MC/DC50%1/2
not defined $x or ref $x
not defined $x ref $x
Truth table66%2/3
not(A) or B
A= not defined $xB= ref $x
ABresult
1X1
011
000
146 606 my $r = interpolate( $x, $vars );
147 606 push @{ $acc->{missing} }, @{ $r->{missing} };
148 606 ▶ $acc->{error} //= $r->{error};
Condition33%1/3
$$acc{"error"} //= $$r{"error"}
l!l&&r!l&&!r
00606
MC/DC0%0/2
$$acc{"error"} //= $$r{"error"}
$$acc{"error"} $$r{"error"}
Truth table33%1/3
A //= B
A= $$acc{"error"}B= $$r{"error"}
ABresult
1X1
011
000
149 606 return $r->{value};
150 }
151  
152 # --- Modell eines Projekts ----------------------------------------------------------
153  
154  
155 50 ▶sub model {
Subroutine model: called CC=46 SCAR=45.2
Pod documented
156 50 my ( $dev, %o ) = @_;
157 50 my $dir = $o{dir};
158 50 ▶ my @files = @{ $o{files} || [] };
Condition100%2/2
$o{'files'} || []
l!l
3317
MC/DC100%1/1
$o{'files'} || []
$o{'files'}
Truth table100%2/2
A
A= $o{'files'}
Aresult
11
00
159 50 ▶ if ( !@files ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@files) 43 7 50
160 43 my ($f) = grep { defined _file( $dev, "$dir/$_" ) } @COMPOSE_FILES;
161 43 ▶ return { error => 'no configuration file provided: not found', dir => $dir } unless defined $f;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $f 3 40 43
162 40 @files = ("$dir/$f");
163 # ohne -f liest Compose auch die Override-Datei daneben
164 40 ( my $ov = $f ) =~ s/\.(ya?ml)\z/.override.$1/;
165 40 my ($o) = grep { defined _file( $dev, "$dir/$_" ) } $ov, map { s/\.(ya?ml)\z/.override.$1/r } @COMPOSE_FILES;
166 40 ▶ push @files, "$dir/$o" if defined $o;
Branch: 1 branch
BranchTrueFalseTotal
if defined $o 0 40 40
167 }
168 47 ▶ $dir //= ( $files[0] =~ m{\A(.*)/[^/]+\z} )[0];
Condition33%1/3
$dir //= ($files[0] =~ m[\A(.*)/[^/]+\z])[0]
l!l&&r!l&&!r
4700
MC/DC0%0/2
$dir //= ($files[0] =~ m[\A(.*)/[^/]+\z])[0]
$dir ($files[0] =~ m[\A(.*)/[^/]+\z])[0]
Truth table33%1/3
A //= B
A= $dirB= ($files[0] =~ m[\A(.*)/[^/]+\z])[0]
ABresult
1X1
011
000
169 47 my %m = ( dir => $dir, file => $files[0], warnings => [] );
170 47 ▶ my $envf = $o{env_file} // "$dir/.env";
Condition50%1/2
$o{"env_file"} // "$dir/.env"
l!l
047
MC/DC0%0/1
$o{"env_file"} // "$dir/.env"
$o{"env_file"}
Truth table50%1/2
A
A= $o{"env_file"}
Aresult
11
00
171 47 my @env_missing;
172 47 ▶ my $vars = defined _file( $dev, $envf ) ? parse_env( _file( $dev, $envf ), {}, \@env_missing ) : {};
Branch: 1 branch
BranchTrueFalseTotal
defined _file($dev, $envf) ? : 45 2 47
173 47 my %shell = Langertha::Holmgang::Sim::Linux::shell_env();
174 47 $vars = { %$vars, %shell };
175 47 ▶ $m{shell_env} = {%shell} if %shell;
Branch: 1 branch
BranchTrueFalseTotal
if %shell 0 47 47
176 47 ▶ if ( defined $o{env_file} && !defined _file( $dev, $envf ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $o{"env_file"} and not defined _file($dev, $envf)) 0 47 47
Condition33%1/3
defined $o{"env_file"} and not defined _file($dev, $envf)
!ll&&!rl&&r
4700
MC/DC0%0/2
defined $o{"env_file"} and not defined _file($dev, $envf)
defined $o{"env_file"} not defined _file($dev, $envf)
Truth table33%1/3
A and not(B)
A= defined $o{"env_file"}B= not defined _file($dev, $envf)
ABresult
0X0
100
111
177 0 return { %m, error => "couldn't find env file: $envf" };
178 }
179 47 my $data = {};
180 47 for my $f (@files) {
181 47 my $t = _file( $dev, $f );
182 47 ▶ return { %m, error => "open $f: no such file or directory" } unless defined $t;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $t 0 47 47
183 47 my $bytes = Encode::encode( 'UTF-8', $t );
184 47 my $y = eval { YAML::XS::Load($bytes) };
185 47 ▶ if ( my $e = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 2 45 47
186 2 my ($problem) = $e =~ /The problem:\s*\n\s*\n\s*(.+?)\s*\n/s;
187 2 my ($line) = $e =~ /line:\s*(\d+)/;
188 2 ▶ $problem //= 'did not find expected key';
Condition50%1/2
$problem //= "did not find expected key"
l!l
20
MC/DC0%0/1
$problem //= "did not find expected key"
$problem
Truth table50%1/2
A
A= $problem
Aresult
11
00
189 2 ▶ return { %m, error => "yaml: line " . ( $line // 1 ) . ": $problem" };
Condition50%1/2
$line // 1
l!l
20
MC/DC0%0/1
$line // 1
$line
Truth table50%1/2
A
A= $line
Aresult
11
00
190 }
191 45 ▶ return { %m, error => "validating $f: (root) must be a mapping" } unless ref $y eq 'HASH' || !defined $y;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $y eq "HASH" or not defined $y 0 45 45
Condition33%1/3
ref $y eq "HASH" or not defined $y
l!l&&r!l&&!r
4500
MC/DC0%0/2
ref $y eq "HASH" or not defined $y
ref $y eq "HASH" not defined $y
Truth table33%1/3
A or not(B)
A= ref $y eq "HASH"B= not defined $y
ABresult
1X1
011
000
192 45 ▶ _merge( $data, $y || {}, '' );
Condition50%1/2
$y || {}
l!l
450
MC/DC0%0/1
$y || {}
$y
Truth table50%1/2
A
A= $y
Aresult
11
00
193 }
194 45 my $acc = { missing => [] }; # Ersetzungen in .env selbst bleiben still (wie dotenv)
195 45 $data = _interp_tree( $data, $vars, $acc );
196 45 ▶ return { %m, error => $acc->{error} } if $acc->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $$acc{"error"} 0 45 45
197 45 my %seen;
198 0 push @{ $m{warnings} }, map {"The \"$_\" variable is not set. Defaulting to a blank string."} grep { !$seen{$_}++ } @{ $acc->{missing} };
199 0 push @{ $m{warnings} }, "$files[0]: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion"
200 45 ▶ if exists $data->{version};
Branch: 1 branch
BranchTrueFalseTotal
if exists $$data{"version"} 0 45 45
201 45 for my $k ( sort keys %$data ) {
202 133 ▶ next if $TOP_KEYS{$k} || $k =~ /\Ax-/;
Branch: 1 branch
BranchTrueFalseTotal
if $TOP_KEYS{$k} or $k =~ /\Ax-/ 133 0 133
Condition33%1/3
$TOP_KEYS{$k} or $k =~ /\Ax-/
l!l&&r!l&&!r
13300
MC/DC0%0/2
$TOP_KEYS{$k} or $k =~ /\Ax-/
$TOP_KEYS{$k} $k =~ /\Ax-/
Truth table33%1/3
A or B
A= $TOP_KEYS{$k}B= $k =~ /\Ax-/
ABresult
1X1
011
000
203 0 return { %m, error => "validating $files[0]: (root) additional properties '$k' not allowed" };
204 }
205 45 ▶ my $name = $o{project} // $data->{name} // ( $dir =~ m{([^/]+)\z} )[0] // 'default';
Condition62%5/8
(($o{"project"} // $$data{"name"}) // ($dir =~ m[([^/]+)\z])[0]) // "default"
l!l
450
($o{"project"} // $$data{"name"}) // ($dir =~ m[([^/]+)\z])[0]
l!l&&r!l&&!r
16290
$o{"project"} // $$data{"name"}
l!l&&r!l&&!r
16029
MC/DC0%0/3
(($o{"project"} // $$data{"name"}) // ($dir =~ m[([^/]+)\z])[0]) // "default"
$o{"project"} $$data{"name"} ($dir =~ m[([^/]+)\z])[0]
Truth table50%2/4
A // B // C
A= $o{"project"}B= $$data{"name"}C= ($dir =~ m[([^/]+)\z])[0]
ABCresult
1XX1
01X1
0011
0000
206 45 $name = lc $name;
207 45 $name =~ s/[^a-z0-9_-]//g;
208 45 $m{name} = $name;
209 45 my $svcs = $data->{services};
210 45 ▶ return { %m, error => 'no service selected' } unless ref $svcs eq 'HASH' && %$svcs;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $svcs eq "HASH" and %$svcs 0 45 45
Condition33%1/3
ref $svcs eq "HASH" and %$svcs
!ll&&!rl&&r
0045
MC/DC0%0/2
ref $svcs eq "HASH" and %$svcs
ref $svcs eq "HASH" %$svcs
Truth table33%1/3
A and B
A= ref $svcs eq "HASH"B= %$svcs
ABresult
0X0
100
111
211 45 ▶ my %nets = %{ ref $data->{networks} eq 'HASH' ? $data->{networks} : {} };
Branch: 1 branch
BranchTrueFalseTotal
ref $$data{'networks'} eq 'HASH' ? : 43 2 45
212 45 ▶ my %vols = %{ ref $data->{volumes} eq 'HASH' ? $data->{volumes} : {} };
Branch: 1 branch
BranchTrueFalseTotal
ref $$data{'volumes'} eq 'HASH' ? : 45 0 45
213 45 $m{networks} = { map { $_ => _net_name( $name, $_, $nets{$_} ) } keys %nets };
214 0 ▶ $m{internal} = { map { ( _net_name( $name, $_, $nets{$_} ) => 1 ) } grep { ref $nets{$_} eq 'HASH' && $nets{$_}{internal} } keys %nets };
Condition33%1/3
ref $nets{$_} eq 'HASH' && $nets{$_}{'internal'}
!ll&&!rl&&r
4300
MC/DC0%0/2
ref $nets{$_} eq 'HASH' && $nets{$_}{'internal'}
ref $nets{$_} eq 'HASH' $nets{$_}{'internal'}
Truth table33%1/3
A && B
A= ref $nets{$_} eq 'HASH'B= $nets{$_}{'internal'}
ABresult
0X0
100
111
215 45 $m{volumes} = { map { $_ => _vol_name( $name, $_, $vols{$_} ) } keys %vols };
216 0 ▶ $m{external_volumes} = { map { ( _vol_name( $name, $_, $vols{$_} ) => 1 ) } grep { ref $vols{$_} eq 'HASH' && $vols{$_}{external} } keys %vols };
Condition33%1/3
ref $vols{$_} eq 'HASH' && $vols{$_}{'external'}
!ll&&!rl&&r
4500
MC/DC0%0/2
ref $vols{$_} eq 'HASH' && $vols{$_}{'external'}
ref $vols{$_} eq 'HASH' $vols{$_}{'external'}
Truth table33%1/3
A && B
A= ref $vols{$_} eq 'HASH'B= $vols{$_}{'external'}
ABresult
0X0
100
111
217 0 ▶ my %active_profiles = map { $_ => 1 } @{ $o{profiles} || [] }, grep {length} split /,/, $vars->{COMPOSE_PROFILES} // '';
Condition75%3/4
$o{'profiles'} || []
l!l
2916
$$vars{"COMPOSE_PROFILES"} // ""
l!l
045
MC/DC100%1/1
$o{'profiles'} || []
$o{'profiles'}
MC/DC0%0/1
$$vars{"COMPOSE_PROFILES"} // ""
$$vars{"COMPOSE_PROFILES"}
Truth table100%2/2
A
A= $o{'profiles'}
Aresult
11
00
Truth table50%1/2
A
A= $$vars{"COMPOSE_PROFILES"}
Aresult
11
00
218 45 for my $s ( sort keys %$svcs ) {
219 86 my $c = $svcs->{$s};
220 86 ▶ return { %m, error => "services.$s must be a mapping" } unless ref $c eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $c eq "HASH" 0 86 86
221 86 for my $k ( sort keys %$c ) {
222 467 ▶ next if $SERVICE_KEYS{$k} || $k =~ /\Ax-/;
Branch: 1 branch
BranchTrueFalseTotal
if $SERVICE_KEYS{$k} or $k =~ /\Ax-/ 465 2 467
Condition66%2/3
$SERVICE_KEYS{$k} or $k =~ /\Ax-/
l!l&&r!l&&!r
46502
MC/DC50%1/2
$SERVICE_KEYS{$k} or $k =~ /\Ax-/
$SERVICE_KEYS{$k} $k =~ /\Ax-/
Truth table66%2/3
A or B
A= $SERVICE_KEYS{$k}B= $k =~ /\Ax-/
ABresult
1X1
011
000
223 2 return { %m, error => "validating $files[0]: services.$s additional properties '$k' not allowed" };
224 }
225 84 my $n = eval { _service( $dev, \%m, $s, $c, \%nets, \%vols ) };
226 0 ▶ if ( my $e = $@ ) { $e =~ s/\s+\z//; return { %m, error => $e } }
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 84 84
227 0 ▶ $n->{disabled} = 1 if @{ $n->{profiles} } && !grep { $active_profiles{$_} } @{ $n->{profiles} };
Branch: 1 branch
BranchTrueFalseTotal
if @{$$n{"profiles"};} and not grep({$active_profiles{$_};} @{$$n{"profiles"};}) 0 84 84
Condition33%1/3
@{$$n{"profiles"};} and not grep({$active_profiles{$_};} @{$$n{"profiles"};})
!ll&&!rl&&r
8400
MC/DC0%0/2
@{$$n{"profiles"};} and not grep({$active_profiles{$_};} @{$$n{"profiles"};})
@{$$n{"profiles"};} not grep({$active_profiles{$_};} @{$$n{"profiles"};})
Truth table33%1/3
A and not(B)
A= @{$$n{"profiles"};}B= not grep({$active_profiles{$_};} @{$$n{"profiles"};})
ABresult
0X0
100
111
228 84 $m{services}{$s} = $n;
229 }
230 43 for my $s ( sort keys %{ $m{services} } ) {
231 84 for my $dep ( sort keys %{ $m{services}{$s}{depends_on} } ) {
232 return { %m, error => "service \"$s\" depends on undefined service \"$dep\": invalid compose project" }
233 41 ▶ unless $m{services}{$dep};
Branch: 1 branch
BranchTrueFalseTotal
unless $m{"services"}{$dep} 0 41 41
234 }
235 }
236 43 return \%m;
237 }
238  
239 # Mehrere Dateien wie Compose: Maps werden gemischt, ports/expose/dns angehaengt,
240 # volumes nach Ziel, environment nach Name; sonst ersetzt die spaetere Datei.
241 45 ▶sub _merge {
Subroutine _merge: called CC=15 SCAR=46.6
242 45 my ( $a, $b, $path ) = @_;
243 45 for my $k ( keys %$b ) {
244 133 ▶ my $p = length $path ? "$path.$k" : $k;
Branch: 1 branch
BranchTrueFalseTotal
length $path ? : 0 133 133
245 133 ▶ if ( $p =~ /\Aservices\.[^.]+\.environment\z/ && defined $a->{$k} ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($p =~ /\Aservices\.[^.]+\.environment\z/ and defined $$a{$k}) { } 0 133 133
elsif ($p =~ /\Aservices\.[^.]+\.(?:ports|expose|dns|dns_search|tmpfs|external_links)\z/ and ref $$a{$k} eq 'ARRAY' and ref $$b{$k} eq 'ARRAY') { } 0 133 133
elsif ($p =~ /\Aservices\.[^.]+\.volumes\z/ and ref $$a{$k} eq 'ARRAY' and ref $$b{$k} eq 'ARRAY') { } 0 133 133
elsif (ref $$a{$k} eq 'HASH' and ref $$b{$k} eq 'HASH') { } 0 133 133
Condition33%1/3
$p =~ /\Aservices\.[^.]+\.environment\z/ and defined $$a{$k}
!ll&&!rl&&r
13300
MC/DC0%0/2
$p =~ /\Aservices\.[^.]+\.environment\z/ and defined $$a{$k}
$p =~ /\Aservices\.[^.]+\.environment\z/ defined $$a{$k}
Truth table33%1/3
A and B
A= $p =~ /\Aservices\.[^.]+\.environment\z/B= defined $$a{$k}
ABresult
0X0
100
111
246 0 $a->{$k} = { %{ _env_map( $a->{$k} ) }, %{ _env_map( $b->{$k} ) } };
247 }
248 ▶ elsif ( $p =~ /\Aservices\.[^.]+\.(?:ports|expose|dns|dns_search|tmpfs|external_links)\z/ && ref $a->{$k} eq 'ARRAY' && ref $b->{$k} eq 'ARRAY' ) {
Condition33%2/6
$p =~ /\Aservices\.[^.]+\.(?:ports|expose|dns|dns_search|tmpfs|external_links)\z/ and ref $$a{$k} eq "ARRAY" and ref $$b{$k} eq "ARRAY"
!ll&&!rl&&r
13300
$p =~ /\Aservices\.[^.]+\.(?:ports|expose|dns|dns_search|tmpfs|external_links)\z/ and ref $$a{$k} eq "ARRAY"
!ll&&!rl&&r
13300
MC/DC0%0/3
$p =~ /\Aservices\.[^.]+\.(?:ports|expose|dns|dns_search|tmpfs|external_links)\z/ and ref $$a{$k} eq "ARRAY" and ref $$b{$k} eq "ARRAY"
$p =~ /\Aservices\.[^.]+\.(?:ports|expose|dns|dns_search|tmpfs|external_links)\z/ ref $$a{$k} eq "ARRAY" ref $$b{$k} eq "ARRAY"
Truth table25%1/4
A and B and C
A= $p =~ /\Aservices\.[^.]+\.(?:ports|expose|dns|dns_search|tmpfs|external_links)\z/B= ref $$a{$k} eq "ARRAY"C= ref $$b{$k} eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
249 0 ▶ my %seen = map { ( ref $_ ? $JSON->encode($_) : "$_" ) => 1 } @{ $a->{$k} };
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 0 0
250 0 ▶ push @{ $a->{$k} }, grep { !$seen{ ref $_ ? $JSON->encode($_) : "$_" } } @{ $b->{$k} };
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 0 0
251 }
252 ▶ elsif ( $p =~ /\Aservices\.[^.]+\.volumes\z/ && ref $a->{$k} eq 'ARRAY' && ref $b->{$k} eq 'ARRAY' ) {
Condition33%2/6
$p =~ /\Aservices\.[^.]+\.volumes\z/ and ref $$a{$k} eq "ARRAY" and ref $$b{$k} eq "ARRAY"
!ll&&!rl&&r
13300
$p =~ /\Aservices\.[^.]+\.volumes\z/ and ref $$a{$k} eq "ARRAY"
!ll&&!rl&&r
13300
MC/DC0%0/3
$p =~ /\Aservices\.[^.]+\.volumes\z/ and ref $$a{$k} eq "ARRAY" and ref $$b{$k} eq "ARRAY"
$p =~ /\Aservices\.[^.]+\.volumes\z/ ref $$a{$k} eq "ARRAY" ref $$b{$k} eq "ARRAY"
Truth table25%1/4
A and B and C
A= $p =~ /\Aservices\.[^.]+\.volumes\z/B= ref $$a{$k} eq "ARRAY"C= ref $$b{$k} eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
253 0 ▶ my $tgt = sub { my ($v) = @_; ref $v eq 'HASH' ? $v->{target} // '' : ( split /:/, "$v" )[ ( split /:/, "$v" ) > 1 ? 1 : 0 ] };
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 2 branches
BranchTrueFalseTotal
ref $v eq 'HASH' ? : 0 0 0
split(/:/, "$v", 0) > 1 ? : 0 0 0
Condition0%0/2
$$v{"target"} // ""
l!l
00
MC/DC0%0/1
$$v{"target"} // ""
$$v{"target"}
Truth table0%0/2
A
A= $$v{"target"}
Aresult
11
00
254 0 my %new = map { $tgt->($_) => 1 } @{ $b->{$k} };
255 0 $a->{$k} = [ ( grep { !$new{ $tgt->($_) } } @{ $a->{$k} } ), @{ $b->{$k} } ];
256 }
257 0 ▶ elsif ( ref $a->{$k} eq 'HASH' && ref $b->{$k} eq 'HASH' ) { _merge( $a->{$k}, $b->{$k}, $p ) }
Condition33%1/3
ref $$a{$k} eq "HASH" and ref $$b{$k} eq "HASH"
!ll&&!rl&&r
13300
MC/DC0%0/2
ref $$a{$k} eq "HASH" and ref $$b{$k} eq "HASH"
ref $$a{$k} eq "HASH" ref $$b{$k} eq "HASH"
Truth table33%1/3
A and B
A= ref $$a{$k} eq "HASH"B= ref $$b{$k} eq "HASH"
ABresult
0X0
100
111
258 133 else { $a->{$k} = $b->{$k} }
259 }
260 45 return $a;
261 }
262  
263 0 ▶sub _env_map {
Subroutine _env_map: not called CC=4 SCAR=30.0
264 0 my ($e) = @_;
265 0 ▶ return {%$e} if ref $e eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $e eq "HASH" 0 0 0
266 0 ▶ return { map { /\A([^=]+)(?:=(.*))?\z/s ? ( $1 => $2 ) : () } @$e } if ref $e eq 'ARRAY';
Branch: 2 branches
BranchTrueFalseTotal
if ref $e eq "ARRAY" 0 0 0
/\A([^=]+)(?:=(.*))?\z/s ? : 0 0 0
267 0 return {};
268 }
269  
270 43 ▶sub _net_name {
Subroutine _net_name: called CC=5 SCAR=20.1
271 43 my ( $p, $n, $c ) = @_;
272 43 ▶ $c = {} unless ref $c eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $c eq "HASH" 43 0 43
273 43 ▶ return $c->{name} // $n if $c->{external};
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"external"} 0 43 43
Condition0%0/3
$$c{"name"} // $n
l!l&&r!l&&!r
000
MC/DC0%0/2
$$c{"name"} // $n
$$c{"name"} $n
Truth table0%0/3
A // B
A= $$c{"name"}B= $n
ABresult
1X1
011
000
274 43 ▶ return $c->{name} // "${p}_$n";
Condition50%1/2
$$c{"name"} // "${p}_$n"
l!l
043
MC/DC0%0/1
$$c{"name"} // "${p}_$n"
$$c{"name"}
Truth table50%1/2
A
A= $$c{"name"}
Aresult
11
00
275 }
276  
277 88 ▶sub _vol_name {
Subroutine _vol_name: called CC=5 SCAR=20.1
278 88 my ( $p, $n, $c ) = @_;
279 88 ▶ $c = {} unless ref $c eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $c eq "HASH" 88 0 88
280 88 ▶ return $c->{name} // $n if $c->{external};
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"external"} 0 88 88
Condition0%0/3
$$c{"name"} // $n
l!l&&r!l&&!r
000
MC/DC0%0/2
$$c{"name"} // $n
$$c{"name"} $n
Truth table0%0/3
A // B
A= $$c{"name"}B= $n
ABresult
1X1
011
000
281 88 ▶ return $c->{name} // "${p}_$n";
Condition50%1/2
$$c{"name"} // "${p}_$n"
l!l
088
MC/DC0%0/1
$$c{"name"} // "${p}_$n"
$$c{"name"}
Truth table50%1/2
A
A= $$c{"name"}
Aresult
11
00
282 }
283  
284 84 ▶sub _service {
Subroutine _service: called CC=87 SCAR=62.9
285 84 my ( $dev, $m, $s, $c, $nets, $vols ) = @_;
286 84 my $dir = $m->{dir};
287 84 my %n = ( name => $s );
288 die "service \"$s\" has neither an image nor a build context specified: invalid compose project\n"
289 84 ▶ unless defined $c->{image} || defined $c->{build};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$c{"image"} or defined $$c{"build"} 0 84 84
Condition33%1/3
defined $$c{"image"} or defined $$c{"build"}
l!l&&r!l&&!r
8400
MC/DC0%0/2
defined $$c{"image"} or defined $$c{"build"}
defined $$c{"image"} defined $$c{"build"}
Truth table33%1/3
A or B
A= defined $$c{"image"}B= defined $$c{"build"}
ABresult
1X1
011
000
290 84 $n{image} = $c->{image};
291 84 ▶ die "invalid reference format\n" if defined $n{image} && ( $n{image} =~ /:\z/ || $n{image} =~ /\s/ || $n{image} eq '' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $n{"image"} and $n{"image"} =~ /:\z/ || $n{"image"} =~ /\s/ || $n{"image"} eq "" 0 84 84
Condition33%3/9
defined $n{"image"} and $n{"image"} =~ /:\z/ || $n{"image"} =~ /\s/ || $n{"image"} eq ""
!ll&&!rl&&r
0840
$n{"image"} =~ /:\z/ or $n{"image"} =~ /\s/ or $n{"image"} eq ""
l!l&&r!l&&!r
0084
$n{"image"} =~ /:\z/ or $n{"image"} =~ /\s/
l!l&&r!l&&!r
0084
MC/DC0%0/4
defined $n{"image"} and $n{"image"} =~ /:\z/ || $n{"image"} =~ /\s/ || $n{"image"} eq ""
defined $n{"image"} $n{"image"} =~ /:\z/ $n{"image"} =~ /\s/ $n{"image"} eq ""
Truth table20%1/5
A and B or C or D
A= defined $n{"image"}B= $n{"image"} =~ /:\z/C= $n{"image"} =~ /\s/D= $n{"image"} eq ""
ABCDresult
0XXX0
10000
11XX1
101X1
10011
292 84 ▶ $n{image} .= ':latest' if defined $n{image} && $n{image} !~ m{:[^/]+\z} && $n{image} !~ /@/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $n{"image"} and not $n{"image"} =~ m[:[^/]+\z] and not $n{"image"} =~ /@/ 0 84 84
Condition33%2/6
defined $n{"image"} and not $n{"image"} =~ m[:[^/]+\z] and not $n{"image"} =~ /@/
!ll&&!rl&&r
8400
defined $n{"image"} and not $n{"image"} =~ m[:[^/]+\z]
!ll&&!rl&&r
0840
MC/DC0%0/3
defined $n{"image"} and not $n{"image"} =~ m[:[^/]+\z] and not $n{"image"} =~ /@/
defined $n{"image"} not $n{"image"} =~ m[:[^/]+\z] not $n{"image"} =~ /@/
Truth table25%1/4
A and not(B) and not(C)
A= defined $n{"image"}B= not $n{"image"} =~ m[:[^/]+\z]C= not $n{"image"} =~ /@/
ABCresult
0XX0
10X0
1100
1111
293 84 ▶ $n{build} = 1 if defined $c->{build};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$c{"build"} 0 84 84
294 84 ▶ $n{container_name} = $c->{container_name} if defined $c->{container_name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$c{"container_name"} 0 84 84
295 # Umgebung: env_file (der Reihe nach), dann environment
296 84 my %env;
297 0 ▶ for my $ef ( ref $c->{env_file} eq 'ARRAY' ? @{ $c->{env_file} } : grep {defined} $c->{env_file} ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $$c{'env_file'} eq 'ARRAY' ? : 0 84 84
298 0 ▶ my ( $p, $req ) = ref $ef eq 'HASH' ? ( $ef->{path}, $ef->{required} // 1 ) : ( $ef, 1 );
Branch: 1 branch
BranchTrueFalseTotal
ref $ef eq 'HASH' ? : 0 0 0
Condition0%0/2
$$ef{"required"} // 1
l!l
00
MC/DC0%0/1
$$ef{"required"} // 1
$$ef{"required"}
Truth table0%0/2
A
A= $$ef{"required"}
Aresult
11
00
299 0 ▶ my $abs = $p =~ m{\A/} ? $p : "$dir/" . ( $p =~ s{\A\./}{}r );
Branch: 1 branch
BranchTrueFalseTotal
$p =~ m[\A/] ? : 0 0 0
300 0 my $t = _file( $dev, $abs );
301 0 ▶ if ( !defined $t ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $t) 0 0 0
302 0 ▶ next unless $req;
Branch: 1 branch
BranchTrueFalseTotal
unless $req 0 0 0
303 0 die "env file $abs not found: stat $abs: no such file or directory\n";
304 }
305 0 %env = ( %env, %{ _literal_env($t) } );
306 }
307 84 my $e = $c->{environment};
308 84 ▶ if ( ref $e eq 'HASH' ) { $env{$_} = defined $e->{$_} ? "$e->{$_}" : '' for keys %$e }
Branch: 4 branches
BranchTrueFalseTotal
if (ref $e eq 'HASH') { } 82 2 84
elsif (ref $e eq 'ARRAY') { } 0 2 2
elsif (defined $e) { } 0 2 2
defined $$e{$_} ? : 123 0 123
309 elsif ( ref $e eq 'ARRAY' ) {
310 0 ▶ for (@$e) { my ( $k, $v ) = /\A([^=]+)(?:=(.*))?\z/s or next; $env{$k} = $v // '' }
Branch: 1 branch
BranchTrueFalseTotal
() = /\A([^=]+)(?:=(.*))?\z/s or next 0 0 0
Condition0%0/2
$v // ""
l!l
00
MC/DC0%0/1
$v // ""
$v
Truth table0%0/2
A
A= $v
Aresult
11
00
311 }
312 0 elsif ( defined $e ) { die "services.$s.environment must be a mapping\n" }
313 84 $n{environment} = \%env;
314 # Ports
315 84 my @ports;
316 84 ▶ for my $p ( @{ ref $c->{ports} eq 'ARRAY' ? $c->{ports} : [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $$c{'ports'} eq 'ARRAY' ? : 41 43 84
317 41 ▶ if ( ref $p eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p eq "HASH") 0 41 41
318 push @ports, { host_ip => $p->{host_ip} // '0.0.0.0', published => defined $p->{published} ? "$p->{published}" : '',
319 0 ▶ target => "$p->{target}", protocol => $p->{protocol} // 'tcp' };
Branch: 1 branch
BranchTrueFalseTotal
defined $$p{'published'} ? : 0 0 0
Condition0%0/4
$$p{"host_ip"} // "0.0.0.0"
l!l
00
$$p{"protocol"} // "tcp"
l!l
00
MC/DC0%0/1
$$p{"host_ip"} // "0.0.0.0"
$$p{"host_ip"}
MC/DC0%0/1
$$p{"protocol"} // "tcp"
$$p{"protocol"}
Truth table0%0/2
A
A= $$p{"host_ip"}
Aresult
11
00
Truth table0%0/2
A
A= $$p{"protocol"}
Aresult
11
00
320 0 next;
321 }
322 41 my ( $spec, $proto ) = split m{/}, "$p", 2;
323 41 my @parts = split /:/, $spec;
324 41 ▶ die "services.$s.ports contains an invalid port specification: $p\n" if @parts > 3 || grep { !/\A[\d.\-]*\z/ } @parts;
Branch: 1 branch
BranchTrueFalseTotal
if @parts > 3 or grep {not /\A[\d.\-]*\z/;} @parts 0 41 41
Condition33%1/3
@parts > 3 or grep {not /\A[\d.\-]*\z/;} @parts
l!l&&r!l&&!r
0041
MC/DC0%0/2
@parts > 3 or grep {not /\A[\d.\-]*\z/;} @parts
@parts > 3 grep {not /\A[\d.\-]*\z/;} @parts
Truth table33%1/3
A or B
A= @parts > 3B= grep {not /\A[\d.\-]*\z/;} @parts
ABresult
1X1
011
000
325 41 ▶ my ( $ip, $pub, $tgt ) = @parts == 3 ? @parts : @parts == 2 ? ( '0.0.0.0', @parts ) : ( '0.0.0.0', '', @parts );
Branch: 2 branches
BranchTrueFalseTotal
@parts == 3 ? : 37 4 41
@parts == 2 ? : 4 0 4
326 41 ▶ $ip = '0.0.0.0' if $ip eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $ip eq "" 0 41 41
327 41 ▶ push @ports, { host_ip => $ip, published => $pub, target => $tgt, protocol => $proto // 'tcp' };
Condition50%1/2
$proto // "tcp"
l!l
041
MC/DC0%0/1
$proto // "tcp"
$proto
Truth table50%1/2
A
A= $proto
Aresult
11
00
328 }
329 84 $n{ports} = \@ports;
330 # Volumes
331 84 my @mounts;
332 84 ▶ for my $v ( @{ ref $c->{volumes} eq 'ARRAY' ? $c->{volumes} : [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
ref $$c{'volumes'} eq 'ARRAY' ? : 46 38 84
333 46 my ( $src, $tgt, $ro, $type );
334 46 ▶ if ( ref $v eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq 'HASH') { } 0 46 46
335 0 ( $src, $tgt, $ro, $type ) = ( $v->{source}, $v->{target}, $v->{read_only}, $v->{type} );
336 }
337 else {
338 46 my @p = split /:/, "$v";
339 46 ▶ ( $src, $tgt ) = @p == 1 ? ( undef, $p[0] ) : @p[ 0, 1 ];
Branch: 1 branch
BranchTrueFalseTotal
@p == 1 ? : 0 46 46
340 46 ▶ $ro = 1 if ( $p[2] // '' ) =~ /\bro\b/;
Branch: 1 branch
BranchTrueFalseTotal
if ($p[2] // "") =~ /\bro\b/ 0 46 46
Condition50%1/2
$p[2] // ""
l!l
046
MC/DC0%0/1
$p[2] // ""
$p[2]
Truth table50%1/2
A
A= $p[2]
Aresult
11
00
341 }
342 46 ▶ die "services.$s.volumes: invalid mount config\n" unless defined $tgt && $tgt =~ m{\A/};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tgt and $tgt =~ m[\A/] 0 46 46
Condition33%1/3
defined $tgt and $tgt =~ m[\A/]
!ll&&!rl&&r
0046
MC/DC0%0/2
defined $tgt and $tgt =~ m[\A/]
defined $tgt $tgt =~ m[\A/]
Truth table33%1/3
A and B
A= defined $tgtB= $tgt =~ m[\A/]
ABresult
0X0
100
111
343 0 ▶ if ( !defined $src || $src eq '' ) { push @mounts, { type => 'volume', source => '', target => $tgt, anonymous => 1 }; next }
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $src or $src eq "") 0 46 46
Condition33%1/3
not defined $src or $src eq ""
l!l&&r!l&&!r
0046
MC/DC0%0/2
not defined $src or $src eq ""
not defined $src $src eq ""
Truth table33%1/3
not(A) or B
A= not defined $srcB= $src eq ""
ABresult
1X1
011
000
344 46 ▶ $type //= $src =~ m{\A(?:/|\./|\.\./|~)} ? 'bind' : 'volume';
Branch: 1 branch
BranchTrueFalseTotal
$src =~ m[\A(?:/|\./|\.\./|~)] ? : 3 43 46
Condition50%1/2
$type //= $src =~ m[\A(?:/|\./|\.\./|~)] ? "bind" : "volume"
l!l
046
MC/DC0%0/1
$type //= $src =~ m[\A(?:/|\./|\.\./|~)] ? "bind" : "volume"
$type
Truth table50%1/2
A
A= $type
Aresult
11
00
345 46 ▶ if ( $type eq 'bind' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'bind') { } 3 43 46
346 3 ▶ my $abs = $src =~ m{\A/} ? $src : "$dir/" . ( $src =~ s{\A\./}{}r );
Branch: 1 branch
BranchTrueFalseTotal
$src =~ m[\A/] ? : 0 3 3
347 3 ▶ 1 while $abs =~ s{/[^/]+/\.\./}{/};
Branch: 1 branch
BranchTrueFalseTotal
$abs =~ s[/[^/]+/\.\./][/] and do { '???' } 0 3 3
348 3 $abs =~ s{/+\z}{};
349 3 ▶ push @mounts, { type => 'bind', source => $abs, target => $tgt, ( $ro ? ( read_only => 1 ) : () ) };
Branch: 1 branch
BranchTrueFalseTotal
$ro ? : 0 3 3
350 }
351 else {
352 43 ▶ die "service \"$s\" refers to undefined volume $src: invalid compose project\n" unless exists $vols->{$src};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$vols{$src} 0 43 43
353 43 ▶ push @mounts, { type => 'volume', source => _vol_name( $m->{name} // 'x', $src, $vols->{$src} ), target => $tgt,
Branch: 1 branch
BranchTrueFalseTotal
$ro ? : 0 43 43
Condition50%1/2
$$m{"name"} // "x"
l!l
430
MC/DC0%0/1
$$m{"name"} // "x"
$$m{"name"}
Truth table50%1/2
A
A= $$m{"name"}
Aresult
11
00
354 ( $ro ? ( read_only => 1 ) : () ) };
355 }
356 }
357 84 $n{volumes} = \@mounts;
358 # Netze
359 84 my @nw;
360 84 ▶ if ( ref $c->{networks} eq 'ARRAY' ) { @nw = @{ $c->{networks} } }
Branch: 2 branches
BranchTrueFalseTotal
if (ref $$c{'networks'} eq 'ARRAY') { } 80 4 84
elsif (ref $$c{'networks'} eq 'HASH') { } 0 4 4
361 0 elsif ( ref $c->{networks} eq 'HASH' ) { @nw = sort keys %{ $c->{networks} } }
362 84 ▶ for (@nw) { die "service \"$s\" refers to undefined network $_: invalid compose project\n" unless exists $nets->{$_} || $_ eq 'default' }
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$nets{$_} or $_ eq "default" 0 80 80
Condition33%1/3
exists $$nets{$_} or $_ eq "default"
l!l&&r!l&&!r
8000
MC/DC0%0/2
exists $$nets{$_} or $_ eq "default"
exists $$nets{$_} $_ eq "default"
Truth table33%1/3
A or B
A= exists $$nets{$_}B= $_ eq "default"
ABresult
1X1
011
000
363 84 ▶ @nw = ('default') unless @nw;
Branch: 1 branch
BranchTrueFalseTotal
unless @nw 4 80 84
364 84 $n{networks} = [ sort @nw ];
365 84 ▶ $n{network_mode} = $c->{network_mode} if defined $c->{network_mode};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$c{"network_mode"} 0 84 84
366 # depends_on
367 84 my %dep;
368 84 ▶ if ( ref $c->{depends_on} eq 'ARRAY' ) { $dep{$_} = { condition => 'service_started' } for @{ $c->{depends_on} } }
Branch: 2 branches
BranchTrueFalseTotal
if (ref $$c{'depends_on'} eq 'ARRAY') { } 3 81 84
elsif (ref $$c{'depends_on'} eq 'HASH') { } 38 43 81
369 elsif ( ref $c->{depends_on} eq 'HASH' ) {
370 38 for my $d ( keys %{ $c->{depends_on} } ) {
371 38 my $v = $c->{depends_on}{$d};
372 38 ▶ my $cond = ref $v eq 'HASH' ? $v->{condition} // 'service_started' : 'service_started';
Branch: 1 branch
BranchTrueFalseTotal
ref $v eq 'HASH' ? : 38 0 38
Condition50%1/2
$$v{"condition"} // "service_started"
l!l
380
MC/DC0%0/1
$$v{"condition"} // "service_started"
$$v{"condition"}
Truth table50%1/2
A
A= $$v{"condition"}
Aresult
11
00
373 38 ▶ die "services.$s.depends_on.$d.condition must be one of the following: \"service_started\", \"service_healthy\", \"service_completed_successfully\"\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $cond =~ /\Aservice_(?:started|healthy|completed_successfully)\z/ 0 38 38
374 unless $cond =~ /\Aservice_(?:started|healthy|completed_successfully)\z/;
375 38 $dep{$d} = { condition => $cond };
376 }
377 }
378 84 $n{depends_on} = \%dep;
379 # healthcheck
380 84 ▶ if ( ref $c->{healthcheck} eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $$c{"healthcheck"} eq "HASH") 41 43 84
381 41 my $h = $c->{healthcheck};
382 0 ▶ if ( $h->{disable} ) { $n{healthcheck} = { disable => 1 } }
Branch: 1 branch
BranchTrueFalseTotal
if ($$h{'disable'}) { } 0 41 41
383 else {
384 41 my $t = $h->{test};
385 41 ▶ $t = [ 'CMD-SHELL', $t ] if defined $t && !ref $t;
Branch: 1 branch
BranchTrueFalseTotal
if defined $t and not ref $t 0 41 41
Condition33%1/3
defined $t and not ref $t
!ll&&!rl&&r
0410
MC/DC0%0/2
defined $t and not ref $t
defined $t not ref $t
Truth table33%1/3
A and not(B)
A= defined $tB= not ref $t
ABresult
0X0
100
111
386 41 ▶ $n{healthcheck} = { test => $t, map { defined $h->{$_} ? ( $_ => "$h->{$_}" ) : () } qw( interval timeout retries start_period ) };
Branch: 1 branch
BranchTrueFalseTotal
defined $$h{$_} ? : 41 123 164
387 }
388 }
389 84 ▶ $n{restart} = $c->{restart} // 'no';
Condition100%2/2
$$c{"restart"} // "no"
l!l
3846
MC/DC100%1/1
$$c{"restart"} // "no"
$$c{"restart"}
Truth table100%2/2
A
A= $$c{"restart"}
Aresult
11
00
390 die "services.$s.restart must be one of no, always, on-failure, unless-stopped\n"
391 84 ▶ unless $n{restart} =~ /\A(?:no|always|unless-stopped|on-failure(?::\d+)?)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $n{"restart"} =~ /\A(?:no|always|unless-stopped|on-failure(?::\d+)?)\z/ 0 84 84
392 84 ▶ $n{mem_limit} = "$c->{mem_limit}" if defined $c->{mem_limit};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$c{"mem_limit"} 2 82 84
393 84 ▶ $n{deploy} = $c->{deploy} if ref $c->{deploy} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $$c{"deploy"} eq "HASH" 0 84 84
394 84 for my $k (qw( user command entrypoint working_dir hostname read_only )) {
395 504 ▶ $n{$k} = ref $c->{$k} ? $c->{$k} : "$c->{$k}" if defined $c->{$k};
Branch: 2 branches
BranchTrueFalseTotal
if defined $$c{$k} 0 504 504
ref $$c{$k} ? : 0 0 0
396 }
397 84 ▶ $n{extra_hosts} = $c->{extra_hosts} if defined $c->{extra_hosts};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$c{"extra_hosts"} 0 84 84
398 84 ▶ $n{labels} = $c->{labels} if defined $c->{labels};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$c{"labels"} 0 84 84
399 84 ▶ $n{profiles} = [ @{ ref $c->{profiles} eq 'ARRAY' ? $c->{profiles} : [] } ];
Branch: 1 branch
BranchTrueFalseTotal
ref $$c{'profiles'} eq 'ARRAY' ? : 0 84 84
400 84 return \%n;
401 }
402  
403 0 ▶sub _literal_env {
Subroutine _literal_env: not called CC=6 SCAR=37.4
404 0 my ($t) = @_;
405 0 my %e;
406 0 for my $l ( split /\n/, $t ) {
407 0 ▶ next if $l =~ /\A\s*(?:#|\z)/;
Branch: 1 branch
BranchTrueFalseTotal
if $l =~ /\A\s*(?:#|\z)/ 0 0 0
408 0 ▶ my ( $k, $v ) = $l =~ /\A\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_.-]*)\s*=\s*(.*?)\s*\z/ or next;
Branch: 1 branch
BranchTrueFalseTotal
() = $l =~ /\A\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_.-]*)\s*=\s*(.*?)\s*\z/ or next 0 0 0
409 0 ▶ if ( $v =~ /\A'(.*)'\z/ || $v =~ /\A"(.*)"\z/ ) { $v = $1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /\A'(.*)'\z/ or $v =~ /\A"(.*)"\z/) { } 0 0 0
Condition0%0/3
$v =~ /\A'(.*)'\z/ or $v =~ /\A"(.*)"\z/
l!l&&r!l&&!r
000
MC/DC0%0/2
$v =~ /\A'(.*)'\z/ or $v =~ /\A"(.*)"\z/
$v =~ /\A'(.*)'\z/ $v =~ /\A"(.*)"\z/
Truth table0%0/3
A or B
A= $v =~ /\A'(.*)'\z/B= $v =~ /\A"(.*)"\z/
ABresult
1X1
011
000
410 0 else { $v =~ s/\s+#.*\z// }
411 0 $e{$k} = $v;
412 }
413 0 return \%e;
414 }
415  
416 # Hash der wirksamen Konfiguration (wann ein Container neu erzeugt wird)
417 59 ▶sub _config_hash {
Subroutine _config_hash: called CC=1 SCAR=0.0
418 59 my ($svc) = @_;
419 59 my %c = %$svc;
420 59 delete @c{qw( depends_on profiles disabled name )};
421 59 return substr( Digest::SHA::sha256_hex( Encode::encode( 'UTF-8', $JSON->encode( \%c ) ) ), 0, 16 );
422 }
423  
424 # --- Images -----------------------------------------------------------------------
425  
426 620 ▶sub _image {
Subroutine _image: called CC=3 SCAR=11.0
427 620 my ( $d, $ref ) = @_;
428 620 ▶ return $d->{images}{$ref} if $d->{images} && exists $d->{images}{$ref};
Branch: 1 branch
BranchTrueFalseTotal
if $$d{"images"} and exists $$d{"images"}{$ref} 618 2 620
Condition66%2/3
$$d{"images"} and exists $$d{"images"}{$ref}
!ll&&!rl&&r
02618
MC/DC50%1/2
$$d{"images"} and exists $$d{"images"}{$ref}
$$d{"images"} exists $$d{"images"}{$ref}
Truth table66%2/3
A and B
A= $$d{"images"}B= exists $$d{"images"}{$ref}
ABresult
0X0
100
111
429 2 return undef;
430 }
431  
432 2 ▶sub _pull {
Subroutine _pull: called CC=6 SCAR=18.3
433 2 my ( $d, $ref ) = @_;
434 2 ▶ my $r = ( $d->{registry} || {} )->{$ref};
Condition50%1/2
$$d{'registry'} || {}
l!l
20
MC/DC0%0/1
$$d{'registry'} || {}
$$d{'registry'}
Truth table50%1/2
A
A= $$d{'registry'}
Aresult
11
00
435 2 ▶ if ( !defined $r ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $r) 1 1 2
436 1 my ($repo) = $ref =~ /\A(.+):[^:\/]+\z/;
437 return ( 0, "Error response from daemon: pull access denied for $repo, repository does not exist or may require 'docker login': denied: requested access to the resource is denied" )
438 1 ▶ unless grep { /\A\Q$repo\E:/ } keys %{ $d->{registry} || {} }, keys %{ $d->{images} || {} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {/\A\Q$repo\E:/;} keys %{$$d{"registry"} or {};}, keys %{$$d{"images"} or {};} 0 1 1
Condition50%2/4
$$d{'registry'} || {}
l!l
10
$$d{'images'} || {}
l!l
10
MC/DC0%0/1
$$d{'registry'} || {}
$$d{'registry'}
MC/DC0%0/1
$$d{'images'} || {}
$$d{'images'}
Truth table50%1/2
A
A= $$d{'registry'}
Aresult
11
00
Truth table50%1/2
A
A= $$d{'images'}
Aresult
11
00
439 1 return ( 0, "Error response from daemon: manifest for $ref not found: manifest unknown: manifest unknown" );
440 }
441 1 $d->{images}{$ref} = $r;
442 1 return (1);
443 }
444  
445 # --- Container -----------------------------------------------------------------------
446  
447 205 ▶sub _cname {
Subroutine _cname: called CC=2 SCAR=7.1
448 205 my ( $m, $s ) = @_;
449 205 my $svc = $m->{services}{$s};
450 205 ▶ return $svc->{container_name} // "$m->{name}-$s-1";
Condition50%1/2
$$svc{"container_name"} // qq[$$m{"name"}-$s-1]
l!l
0205
MC/DC0%0/1
$$svc{"container_name"} // qq[$$m{"name"}-$s-1]
$$svc{"container_name"}
Truth table50%1/2
A
A= $$svc{"container_name"}
Aresult
11
00
451 }
452  
453 43 ▶sub _project_containers {
Subroutine _project_containers: called CC=2 SCAR=7.0
454 43 my ( $d, $p ) = @_;
455 43 ▶ return grep { ( $d->{containers}{$_}{project} // '' ) eq $p } sort keys %{ $d->{containers} };
Condition50%1/2
$$d{"containers"}{$_}{"project"} // ""
l!l
510
MC/DC0%0/1
$$d{"containers"}{$_}{"project"} // ""
$$d{"containers"}{$_}{"project"}
Truth table50%1/2
A
A= $$d{"containers"}{$_}{"project"}
Aresult
11
00
456 }
457  
458 # Reihenfolge nach depends_on (Abhaengigkeiten zuerst)
459 31 ▶sub _order {
Subroutine _order: called CC=2 SCAR=6.9
460 31 my ( $m, @want ) = @_;
461 31 my ( @out, %seen );
462 31 my $visit;
463 86 ▶ $visit = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
464 86 my ($s) = @_;
465 86 ▶ return if $seen{$s}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$s}++ 26 60 86
466 60 ▶ $visit->($_) for sort keys %{ $m->{services}{$s}{depends_on} || {} };
Condition50%1/2
$$m{'services'}{$s}{'depends_on'} || {}
l!l
600
MC/DC0%0/1
$$m{'services'}{$s}{'depends_on'} || {}
$$m{'services'}{$s}{'depends_on'}
Truth table50%1/2
A
A= $$m{'services'}{$s}{'depends_on'}
Aresult
11
00
467 60 push @out, $s;
468 31 };
469 31 $visit->($_) for @want;
470 31 return @out;
471 }
472  
473  
474 31 ▶sub up {
Subroutine up: called CC=53 SCAR=43.4
Pod documented
475 31 my ( $dev, $m, $o, $state, $host ) = @_;
476 31 my $d = $dev->{docker};
477 31 ▶ my @want = @{ $o->{services} || [] };
Condition100%2/2
$$o{'services'} || []
l!l
1615
MC/DC100%1/1
$$o{'services'} || []
$$o{'services'}
Truth table100%2/2
A
A= $$o{'services'}
Aresult
11
00
478 31 ▶ for (@want) { return ( [], 0, "no such service: $_" ) unless $m->{services}{$_} }
Branch: 1 branch
BranchTrueFalseTotal
unless $$m{"services"}{$_} 0 3 3
479 31 ▶ @want = grep { !$m->{services}{$_}{disabled} } sort keys %{ $m->{services} } unless @want;
Branch: 1 branch
BranchTrueFalseTotal
unless @want 28 3 31
480 31 ▶ my @order = $o->{no_deps} ? @want : _order( $m, @want );
Branch: 1 branch
BranchTrueFalseTotal
$$o{'no_deps'} ? : 0 31 31
481 # --force-recreate gilt fuer die gewaehlten Dienste; Abhaengigkeiten nur bei
482 # geaenderter Konfiguration (oder --always-recreate-deps), wie Compose v2
483 31 ▶ my %forced = map { $_ => 1 } $o->{force_recreate} ? @want : (), $o->{recreate_deps} ? @order : ();
Branch: 2 branches
BranchTrueFalseTotal
$$o{'force_recreate'} ? : 5 26 31
$$o{'recreate_deps'} ? : 1 30 31
484 31 my ( @l, %fresh );
485 31 my $ok = 1;
486 31 my $err;
487 # Netze
488 31 for my $s (@order) {
489 60 for my $n ( @{ $m->{services}{$s}{networks} } ) {
490 60 ▶ my $full = $n eq 'default' ? "$m->{name}_default" : $m->{networks}{$n};
Branch: 1 branch
BranchTrueFalseTotal
$n eq 'default' ? : 4 56 60
491 60 ▶ next if $d->{networks}{$full};
Branch: 1 branch
BranchTrueFalseTotal
if $$d{"networks"}{$full} 42 18 60
492 18 $d->{networks}{$full} = { project => $m->{name} };
493 18 push @l, " Network $full Creating", " Network $full Created";
494 }
495 60 ▶ for my $v ( grep { $_->{type} eq 'volume' && !$_->{anonymous} } @{ $m->{services}{$s}{volumes} } ) {
Condition66%2/3
$$_{'type'} eq 'volume' && !$$_{'anonymous'}
!ll&&!rl&&r
2031
MC/DC50%1/2
$$_{'type'} eq 'volume' && !$$_{'anonymous'}
$$_{'type'} eq 'volume' !$$_{'anonymous'}
Truth table66%2/3
A && not(B)
A= $$_{'type'} eq 'volume'B= !$$_{'anonymous'}
ABresult
0X0
100
111
496 31 ▶ next if $d->{volumes}{ $v->{source} };
Branch: 1 branch
BranchTrueFalseTotal
if $$d{"volumes"}{$$v{"source"}} 30 1 31
497 1 $d->{volumes}{ $v->{source} } = { project => $m->{name} };
498 1 push @l, " Volume \"$v->{source}\" Creating", " Volume \"$v->{source}\" Created";
499 }
500 }
501 # Waisen
502 31 my %svc_names = map { _cname( $m, $_ ) => 1 } keys %{ $m->{services} };
503 31 my @orph = grep { !$svc_names{$_} } _project_containers( $d, $m->{name} );
504 31 ▶ if (@orph) {
Branch: 1 branch
BranchTrueFalseTotal
if (@orph) 0 31 31
505 0 ▶ if ( $o->{remove_orphans} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$o{'remove_orphans'}) { } 0 0 0
506 0 for my $c (@orph) { push @l, " Container $c Stopping", " Container $c Stopped", " Container $c Removing", " Container $c Removed"; delete $d->{containers}{$c} }
507 }
508 else {
509 0 unshift @l, "WARN[0000] Found orphan containers ([" . join( ' ', @orph ) . "]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.";
510 }
511 }
512 31 SERVICE: for my $s (@order) {
513 60 my $svc = $m->{services}{$s};
514 60 my $name = _cname( $m, $s );
515 0 ▶ if ( $svc->{build} && !defined $svc->{image} ) { _gap("docker compose build ($s)"); return ( \@l, 0, "build is not supported here" ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($$svc{"build"} and not defined $$svc{"image"}) 0 60 60
Condition33%1/3
$$svc{"build"} and not defined $$svc{"image"}
!ll&&!rl&&r
6000
MC/DC0%0/2
$$svc{"build"} and not defined $$svc{"image"}
$$svc{"build"} not defined $$svc{"image"}
Truth table33%1/3
A and not(B)
A= $$svc{"build"}B= not defined $$svc{"image"}
ABresult
0X0
100
111
516 60 my $img = _image( $d, $svc->{image} );
517 60 ▶ if ( !$img ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($img) 2 58 60
518 2 push @l, " $s Pulling";
519 2 my ( $pok, $perr ) = _pull( $d, $svc->{image} );
520 2 ▶ if ( !$pok ) { push @l, " $s Error " . ( $perr =~ s/\AError response from daemon: //r ); return ( \@l, 0, $perr ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($pok) 1 1 2
521 1 push @l, " $s Pulled";
522 1 $img = _image( $d, $svc->{image} );
523 }
524 59 my $hash = _config_hash($svc);
525 59 my $c = $d->{containers}{$name};
526 59 ▶ if ( $c && ( $c->{project} // '' ) ne $m->{name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c and ($$c{"project"} // "") ne $$m{"name"}) 0 59 59
Condition60%3/5
$c and ($$c{"project"} // "") ne $$m{"name"}
!ll&&!rl&&r
33260
$$c{"project"} // ""
l!l
260
MC/DC50%1/2
$c and ($$c{"project"} // "") ne $$m{"name"}
$c $$c{"project"}
Truth table66%2/3
A and B
A= $cB= $$c{"project"}
ABresult
0X0
100
111
527 0 return ( \@l, 0, "Error response from daemon: Conflict. The container name \"/$name\" is already in use by container \"" . _id( $name, $c->{seq} ) . "\". You have to remove (or rename) that container to be able to reuse that name." );
528 }
529 # Warten auf Abhaengigkeiten
530 59 for my $dep ( sort keys %{ $svc->{depends_on} } ) {
531 28 my $cond = $svc->{depends_on}{$dep}{condition};
532 28 my $dc = $d->{containers}{ _cname( $m, $dep ) };
533 28 ▶ if ( $cond eq 'service_healthy' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cond eq "service_healthy") 25 3 28
534 25 push @l, " Container " . _cname( $m, $dep ) . " Waiting";
535 25 ▶ if ( $dc && !_has_hc( $dc->{config}, _image( $d, $dc->{image} ) || {} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dc and not _has_hc($$dc{"config"}, _image($d, $$dc{"image"}) || {})) 0 25 25
Condition40%2/5
$dc and not _has_hc($$dc{"config"}, _image($d, $$dc{"image"}) || {})
!ll&&!rl&&r
0250
_image($d, $$dc{'image'}) || {}
l!l
250
MC/DC0%0/2
$dc and not _has_hc($$dc{"config"}, _image($d, $$dc{"image"}) || {})
$dc not _has_hc($$dc{"config"}, _image($d, $$dc{"image"}) || {})
MC/DC0%0/1
_image($d, $$dc{'image'}) || {}
_image($d, $$dc{'image'})
Truth table33%1/3
A and not(B)
A= $dcB= not _has_hc($$dc{"config"}, _image($d, $$dc{"image"}) || {})
ABresult
0X0
100
111
Truth table50%1/2
A
A= _image($d, $$dc{'image'})
Aresult
11
00
536 0 push @l, " Container " . _cname( $m, $dep ) . " Error";
537 0 $err = "dependency failed to start: container " . _cname( $m, $dep ) . " has no healthcheck configured";
538 0 $ok = 0;
539 0 ▶ _create( $d, $m, $s, $name, $svc, $hash, \@l ) unless $c && $c->{hash} eq $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless $c and $$c{"hash"} eq $hash 0 0 0
Condition0%0/3
$c and $$c{"hash"} eq $hash
!ll&&!rl&&r
000
MC/DC0%0/2
$c and $$c{"hash"} eq $hash
$c $$c{"hash"} eq $hash
Truth table0%0/3
A and B
A= $cB= $$c{"hash"} eq $hash
ABresult
0X0
100
111
540 0 next SERVICE;
541 }
542 25 ▶ if ( !$dc || ( $dc->{health} // '' ) ne 'healthy' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dc or ($$dc{"health"} // "") ne "healthy") 3 22 25
Condition80%4/5
not $dc or ($$dc{"health"} // "") ne "healthy"
l!l&&r!l&&!r
0322
$$dc{"health"} // ""
l!l
223
MC/DC50%1/2
not $dc or ($$dc{"health"} // "") ne "healthy"
not $dc $$dc{"health"}
Truth table66%2/3
not(A) or B
A= not $dcB= $$dc{"health"}
ABresult
1X1
011
000
543 3 push @l, " Container " . _cname( $m, $dep ) . " Error";
544 3 ▶ $err = "dependency failed to start: container " . _cname( $m, $dep ) . ( $dc && $dc->{status} eq 'running' ? ' is unhealthy' : ' exited (1)' );
Branch: 1 branch
BranchTrueFalseTotal
$dc && $$dc{'status'} eq 'running' ? : 0 3 3
Condition33%1/3
$dc and $$dc{"status"} eq "running"
!ll&&!rl&&r
030
MC/DC0%0/2
$dc and $$dc{"status"} eq "running"
$dc $$dc{"status"} eq "running"
Truth table33%1/3
A and B
A= $dcB= $$dc{"status"} eq "running"
ABresult
0X0
100
111
545 3 $ok = 0;
546 3 ▶ _create( $d, $m, $s, $name, $svc, $hash, \@l ) unless $c && $c->{hash} eq $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless $c and $$c{"hash"} eq $hash 1 2 3
Condition66%2/3
$c and $$c{"hash"} eq $hash
!ll&&!rl&&r
102
MC/DC50%1/2
$c and $$c{"hash"} eq $hash
$c $$c{"hash"} eq $hash
Truth table66%2/3
A and B
A= $cB= $$c{"hash"} eq $hash
ABresult
0X0
100
111
547 3 next SERVICE;
548 }
549 22 push @l, " Container " . _cname( $m, $dep ) . " Healthy";
550 }
551 }
552 56 ▶ $c->{config}{depends_on} = $svc->{depends_on} if $c; # Abhaengigkeiten gehoeren dem Projekt, nicht dem Container
Branch: 1 branch
BranchTrueFalseTotal
if $c 24 32 56
553 56 ▶ if ( $c && $c->{hash} eq $hash && $c->{image_id} eq _img_id( $svc->{image}, $img ) && !$forced{$s} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c and $$c{'hash'} eq $hash and $$c{'image_id'} eq _img_id($$svc{'image'}, $img) and not $forced{$s}) { } 12 44 56
elsif ($c) { } 12 32 44
Condition88%8/9
$c and $$c{"hash"} eq $hash and $$c{"image_id"} eq _img_id($$svc{"image"}, $img) and not $forced{$s}
!ll&&!rl&&r
36812
$c and $$c{"hash"} eq $hash and $$c{"image_id"} eq _img_id($$svc{"image"}, $img)
!ll&&!rl&&r
36020
$c and $$c{"hash"} eq $hash
!ll&&!rl&&r
32420
MC/DC75%3/4
$c and $$c{"hash"} eq $hash and $$c{"image_id"} eq _img_id($$svc{"image"}, $img) and not $forced{$s}
$c $$c{"hash"} eq $hash $$c{"image_id"} eq _img_id($$svc{"image"}, $img) not $forced{$s}
Truth table80%4/5
A and B and C and not(D)
A= $cB= $$c{"hash"} eq $hashC= $$c{"image_id"} eq _img_id($$svc{"image"}, $img)D= not $forced{$s}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
554 12 ▶ if ( $c->{status} eq 'running' || $c->{status} eq 'restarting' ) { push @l, " Container $name Running"; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($$c{"status"} eq "running" or $$c{"status"} eq "restarting") 10 2 12
Condition100%3/3
$$c{"status"} eq "running" or $$c{"status"} eq "restarting"
l!l&&r!l&&!r
822
MC/DC100%2/2
$$c{"status"} eq "running" or $$c{"status"} eq "restarting"
$$c{"status"} eq "running" $$c{"status"} eq "restarting"
Truth table100%3/3
A or B
A= $$c{"status"} eq "running"B= $$c{"status"} eq "restarting"
ABresult
1X1
011
000
555 2 push @l, " Container $name Starting";
556 }
557 elsif ($c) {
558 12 push @l, " Container $name Recreate";
559 12 ▶ $c->{restarts}++ if $c->{status} eq 'running' || $c->{status} eq 'restarting';
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"status"} eq "running" or $$c{"status"} eq "restarting" 10 2 12
Condition100%3/3
$$c{"status"} eq "running" or $$c{"status"} eq "restarting"
l!l&&r!l&&!r
912
MC/DC100%2/2
$$c{"status"} eq "running" or $$c{"status"} eq "restarting"
$$c{"status"} eq "running" $$c{"status"} eq "restarting"
Truth table100%3/3
A or B
A= $$c{"status"} eq "running"B= $$c{"status"} eq "restarting"
ABresult
1X1
011
000
560 12 _create( $d, $m, $s, $name, $svc, $hash, \@l, $c->{restarts} );
561 12 push @l, " Container $name Recreated", " Container $name Starting";
562 }
563 else {
564 32 push @l, " Container $name Creating";
565 32 _create( $d, $m, $s, $name, $svc, $hash, \@l );
566 32 push @l, " Container $name Created", " Container $name Starting";
567 }
568 46 $c = $d->{containers}{$name};
569 46 my $e = _start( $dev, $d, $name, $c, \%fresh, $state, $host );
570 46 ▶ $c->{start_error} = $e if defined $e;
Branch: 1 branch
BranchTrueFalseTotal
if defined $e 1 45 46
571 46 ▶ if ($e) { push @l, " Container $name Error"; $err //= $e; $ok = 0; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($e) 1 45 46
Condition33%1/3
$err //= $e
l!l&&r!l&&!r
010
MC/DC0%0/2
$err //= $e
$err $e
Truth table33%1/3
A //= B
A= $errB= $e
ABresult
1X1
011
000
572 45 $fresh{$name} = 1;
573 45 push @l, " Container $name Started";
574 }
575 30 _settle($dev);
576 30 return ( \@l, $ok, $err );
577 }
578  
579 65 ▶sub _img_id { my ( $ref, $img ) = @_; return substr( Digest::SHA::sha256_hex( $ref . $JSON->encode( $img || {} ) ), 0, 12 ) }
Subroutine _img_id: called CC=2 SCAR=7.2
Condition50%1/2
$img || {}
l!l
650
MC/DC0%0/1
$img || {}
$img
Truth table50%1/2
A
A= $img
Aresult
11
00
580 43 ▶sub _id { my ( $name, $seq ) = @_; return substr( Digest::SHA::sha256_hex( "$name/" . ( $seq // 0 ) ), 0, 12 ) }
Subroutine _id: called CC=2 SCAR=7.2
Condition50%1/2
$seq // 0
l!l
430
MC/DC0%0/1
$seq // 0
$seq
Truth table50%1/2
A
A= $seq
Aresult
11
00
581  
582 45 ▶sub _create {
Subroutine _create: called CC=7 SCAR=19.9
583 45 my ( $d, $m, $s, $name, $svc, $hash, $l, $restarts ) = @_;
584 45 ▶ my $img = _image( $d, $svc->{image} ) || {};
Condition50%1/2
_image($d, $$svc{'image'}) || {}
l!l
450
MC/DC0%0/1
_image($d, $$svc{'image'}) || {}
_image($d, $$svc{'image'})
Truth table50%1/2
A
A= _image($d, $$svc{'image'})
Aresult
11
00
585 45 $d->{seq}++;
586 $d->{containers}{$name} = {
587 project => $m->{name}, service => $s, image => $svc->{image}, image_id => _img_id( $svc->{image}, $img ),
588 hash => $hash, seq => $d->{seq}, status => 'created', restarts => $restarts // 0,
589 ( defined _mem_limit($svc) ? ( mem_limit_bytes => _mem_limit($svc) ) : () ),
590 45 ▶ config => { %$svc, networks => [ map { $_ eq 'default' ? "$m->{name}_default" : $m->{networks}{$_} } @{ $svc->{networks} } ],
Branch: 2 branches
BranchTrueFalseTotal
$_ eq 'default' ? : 3 42 45
%{$$m{'internal'} or {};} ? : 0 45 45
591 0 ▶ ( %{ $m->{internal} || {} } ? ( internal_nets => { %{ $m->{internal} } } ) : () ) },
Branch: 1 branch
BranchTrueFalseTotal
defined _mem_limit($svc) ? : 2 43 45
Condition75%3/4
$restarts // 0
l!l
1233
$$m{'internal'} || {}
l!l
450
MC/DC100%1/1
$restarts // 0
$restarts
MC/DC0%0/1
$$m{'internal'} || {}
$$m{'internal'}
Truth table100%2/2
A
A= $restarts
Aresult
11
00
Truth table50%1/2
A
A= $$m{'internal'}
Aresult
11
00
592 };
593 45 return;
594 }
595  
596 # Container starten: Ports, Einhaengungen, Bedingungen des Images. Fehlertext oder undef.
597 51 ▶sub _start {
Subroutine _start: called CC=28 SCAR=36.0
598 51 my ( $dev, $d, $name, $c, $fresh, $state, $host ) = @_;
599 51 my $cfg = $c->{config};
600 51 ▶ my $img = _image( $d, $c->{image} ) || {};
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
510
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
601 # Ports
602 51 for my $p ( @{ $cfg->{ports} } ) {
603 28 ▶ next unless length $p->{published};
Branch: 1 branch
BranchTrueFalseTotal
unless length $$p{"published"} 0 28 28
604 28 my $k = "$p->{host_ip}:$p->{published}";
605 28 ▶ my ($host_proc) = grep { _port_clash( $_, $p->{host_ip}, $p->{published} ) } sort keys %{ $d->{host_ports} || {} };
Condition50%1/2
$$d{'host_ports'} || {}
l!l
280
MC/DC0%0/1
$$d{'host_ports'} || {}
$$d{'host_ports'}
Truth table50%1/2
A
A= $$d{'host_ports'}
Aresult
11
00
606 28 my $id = _id( $name, $c->{seq} );
607 28 ▶ if ( defined $host_proc ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $host_proc) 3 25 28
608 3 $c->{status} = 'created';
609 3 return "Error response from daemon: driver failed programming external connectivity on endpoint $name ($id): failed to bind port $k/tcp: Error starting userland proxy: listen tcp4 $k: bind: address already in use";
610 }
611 25 for my $o ( sort keys %{ $d->{containers} } ) {
612 50 ▶ next if $o eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $o eq $name 25 25 50
613 25 my $oc = $d->{containers}{$o};
614 25 ▶ next unless $oc->{status} eq 'running' || $oc->{status} eq 'restarting';
Branch: 1 branch
BranchTrueFalseTotal
unless $$oc{"status"} eq "running" or $$oc{"status"} eq "restarting" 0 25 25
Condition33%1/3
$$oc{"status"} eq "running" or $$oc{"status"} eq "restarting"
l!l&&r!l&&!r
2500
MC/DC0%0/2
$$oc{"status"} eq "running" or $$oc{"status"} eq "restarting"
$$oc{"status"} eq "running" $$oc{"status"} eq "restarting"
Truth table33%1/3
A or B
A= $$oc{"status"} eq "running"B= $$oc{"status"} eq "restarting"
ABresult
1X1
011
000
615 0 ▶ if ( grep { length $_->{published} && _port_clash( "$_->{host_ip}:$_->{published}", $p->{host_ip}, $p->{published} ) } @{ $oc->{config}{ports} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {length $$_{"published"} and _port_clash(qq[$$_{"host_ip"}:$$_{"published"}], $$p{"host_ip"}, $$p{"published"});} @{$$oc{"config"}{"ports"};}) 0 25 25
Condition0%0/3
length $$_{'published'} && _port_clash("$$_{'host_ip'}:$$_{'published'}", $$p{'host_ip'}, $$p{'published'})
!ll&&!rl&&r
000
MC/DC0%0/2
length $$_{'published'} && _port_clash("$$_{'host_ip'}:$$_{'published'}", $$p{'host_ip'}, $$p{'published'})
length $$_{'published'} _port_clash("$$_{'host_ip'}:$$_{'published'}", $$p{'host_ip'}, $$p{'published'})
Truth table0%0/3
A && B
A= length $$_{'published'}B= _port_clash("$$_{'host_ip'}:$$_{'published'}", $$p{'host_ip'}, $$p{'published'})
ABresult
0X0
100
111
616 0 $c->{status} = 'created';
617 0 return "Error response from daemon: driver failed programming external connectivity on endpoint $name ($id): Bind for $k failed: port is already allocated";
618 }
619 }
620 }
621 # Bind-Mounts: fehlende Verzeichnisse legt Docker als root an
622 48 for my $mt ( grep { $_->{type} eq 'bind' } @{ $cfg->{volumes} } ) {
623 3 ▶ next if _L()->can('_file_entry')->( $dev, $mt->{source} ) || _L()->can('_is_dir')->( $dev, $mt->{source} );
Branch: 1 branch
BranchTrueFalseTotal
if _L()->can("_file_entry")->($dev, $$mt{"source"}) or _L()->can("_is_dir")->($dev, $$mt{"source"}) 2 1 3
Condition66%2/3
_L()->can("_file_entry")->($dev, $$mt{"source"}) or _L()->can("_is_dir")->($dev, $$mt{"source"})
l!l&&r!l&&!r
021
MC/DC50%1/2
_L()->can("_file_entry")->($dev, $$mt{"source"}) or _L()->can("_is_dir")->($dev, $$mt{"source"})
_L()->can("_file_entry")->($dev, $$mt{"source"}) _L()->can("_is_dir")->($dev, $$mt{"source"})
Truth table66%2/3
A or B
A= _L()->can("_file_entry")->($dev, $$mt{"source"})B= _L()->can("_is_dir")->($dev, $$mt{"source"})
ABresult
1X1
011
000
624 1 $dev->{dirs}{ $mt->{source} } = { owner => 'root', group => 'root', mode => '0755' };
625 }
626 48 delete @$c{qw( error early_error )};
627 48 my $bad = _failing_need( $dev, $d, $name, $c, $img, $fresh );
628 48 ▶ if ( $bad && $bad->{transient} && $cfg->{restart} ne 'no' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bad and $$bad{"transient"} and $$cfg{"restart"} ne "no") 0 48 48
Condition83%5/6
$bad and $$bad{"transient"} and $$cfg{"restart"} ne "no"
!ll&&!rl&&r
4620
$bad and $$bad{"transient"}
!ll&&!rl&&r
4062
MC/DC0%0/3
$bad and $$bad{"transient"} and $$cfg{"restart"} ne "no"
$bad $$bad{"transient"} $$cfg{"restart"} ne "no"
Truth table75%3/4
A and B and C
A= $badB= $$bad{"transient"}C= $$cfg{"restart"} ne "no"
ABCresult
0XX0
10X0
1100
1111
629 # Wettlauf beim Start: mit Neustart-Regel laeuft er beim naechsten Versuch
630 0 ▶ $c->{restart_count} = ( $c->{restart_count} // 0 ) + 1;
Condition0%0/2
$$c{"restart_count"} // 0
l!l
00
MC/DC0%0/1
$$c{"restart_count"} // 0
$$c{"restart_count"}
Truth table0%0/2
A
A= $$c{"restart_count"}
Aresult
11
00
631 0 $c->{early_error} = $bad->{log};
632 0 $bad = _failing_need( $dev, $d, $name, $c, $img, {} );
633 }
634 48 ▶ if ($bad) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bad) 8 40 48
635 8 ▶ $c->{error} = $bad->{log} || [];
Condition50%1/2
$$bad{'log'} || []
l!l
80
MC/DC0%0/1
$$bad{'log'} || []
$$bad{'log'}
Truth table50%1/2
A
A= $$bad{'log'}
Aresult
11
00
636 8 ▶ $c->{exit_code} = $bad->{exit} // 1;
Condition100%2/2
$$bad{"exit"} // 1
l!l
17
MC/DC100%1/1
$$bad{"exit"} // 1
$$bad{"exit"}
Truth table100%2/2
A
A= $$bad{"exit"}
Aresult
11
00
637 8 ▶ if ( $bad->{oom} ) { $c->{oom} = _true() } else { delete $c->{oom} }
Branch: 1 branch
BranchTrueFalseTotal
if ($$bad{'oom'}) { } 1 7 8
638 8 delete $c->{data};
639 8 ▶ if ( $cfg->{restart} ne 'no' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$cfg{'restart'} ne 'no') { } 3 5 8
640 3 $c->{status} = 'restarting';
641 3 ▶ $c->{restart_count} = ( $c->{restart_count} // 0 ) + 3;
Condition50%1/2
$$c{"restart_count"} // 0
l!l
03
MC/DC0%0/1
$$c{"restart_count"} // 0
$$c{"restart_count"}
Truth table50%1/2
A
A= $$c{"restart_count"}
Aresult
11
00
642 0 ▶ if ( _has_hc( $cfg, $img ) ) { $c->{health} = 'unhealthy' } else { delete $c->{health} }
Branch: 1 branch
BranchTrueFalseTotal
if (_has_hc($cfg, $img)) { } 0 3 3
643 }
644 else {
645 5 $c->{status} = 'exited';
646 5 delete $c->{health};
647 }
648 8 return undef;
649 }
650 40 $c->{status} = 'running';
651 40 delete $c->{oom};
652 40 delete $c->{initial}; # nur was schon vor dem ersten Befehl lief, laeuft „seit 2 Stunden“
653 40 delete $c->{exit_code};
654 40 $c->{data} = _data_of( $dev, $d, $c, $img );
655 40 ▶ $c->{health} = _health( $dev, $d, $name, $c, $img ) if _has_hc( $cfg, $img );
Branch: 1 branch
BranchTrueFalseTotal
if _has_hc($cfg, $img) 18 22 40
656 40 ▶ delete $c->{health} unless _has_hc( $cfg, $img );
Branch: 1 branch
BranchTrueFalseTotal
unless _has_hc($cfg, $img) 22 18 40
657 40 return undef;
658 }
659  
660 28 ▶sub _port_clash {
Subroutine _port_clash: called CC=7 SCAR=23.2
661 28 my ( $key, $ip, $port ) = @_;
662 28 ▶ my ( $kip, $kp ) = $key =~ /\A(?:(.*):)?(\d+)\z/ or return 0;
Branch: 1 branch
BranchTrueFalseTotal
() = $key =~ /\A(?:(.*):)?(\d+)\z/ or return 0 28 0 28
663 28 ▶ return 0 unless $kp == $port;
Branch: 1 branch
BranchTrueFalseTotal
unless $kp == $port 25 3 28
664 3 ▶ $kip //= '0.0.0.0';
Condition50%1/2
$kip //= "0.0.0.0"
l!l
30
MC/DC0%0/1
$kip //= "0.0.0.0"
$kip
Truth table50%1/2
A
A= $kip
Aresult
11
00
665 3 ▶ return 1 if $kip eq '0.0.0.0' || $ip eq '0.0.0.0' || $kip eq $ip;
Branch: 1 branch
BranchTrueFalseTotal
if $kip eq "0.0.0.0" or $ip eq "0.0.0.0" or $kip eq $ip 3 0 3
Condition33%2/6
$kip eq "0.0.0.0" or $ip eq "0.0.0.0" or $kip eq $ip
l!l&&r!l&&!r
300
$kip eq "0.0.0.0" or $ip eq "0.0.0.0"
l!l&&r!l&&!r
300
MC/DC0%0/3
$kip eq "0.0.0.0" or $ip eq "0.0.0.0" or $kip eq $ip
$kip eq "0.0.0.0" $ip eq "0.0.0.0" $kip eq $ip
Truth table25%1/4
A or B or C
A= $kip eq "0.0.0.0"B= $ip eq "0.0.0.0"C= $kip eq $ip
ABCresult
1XX1
01X1
0011
0000
666 0 return 0;
667 }
668  
669 # Neu rechnen, was von anderen abhaengt (Gesundheit, Daten)
670 153 ▶sub _settle {
Subroutine _settle: called CC=11 SCAR=24.0
671 153 my ($dev) = @_;
672 153 my $d = $dev->{docker};
673 # Container mit Neustart-Regel kommen hoch, sobald ihre Bedingungen halten
674 153 for my $round ( 1 .. 5 ) {
675 154 my $changed = 0;
676 154 for my $n ( sort keys %{ $d->{containers} } ) {
677 250 my $c = $d->{containers}{$n};
678 250 ▶ next unless $c->{status} eq 'restarting';
Branch: 1 branch
BranchTrueFalseTotal
unless $$c{"status"} eq "restarting" 235 15 250
679 15 ▶ next if _failing_need( $dev, $d, $n, $c, _image( $d, $c->{image} ) || {}, {} );
Branch: 1 branch
BranchTrueFalseTotal
if _failing_need($dev, $d, $n, $c, _image($d, $$c{"image"}) || {}, scalar {}) 14 1 15
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
150
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
680 1 _start( $dev, $d, $n, $c, {}, undef, undef );
681 1 $changed = 1;
682 }
683 154 ▶ last unless $changed;
Branch: 1 branch
BranchTrueFalseTotal
unless $changed 153 1 154
684 }
685 153 for my $n ( sort keys %{ $d->{containers} } ) {
686 248 my $c = $d->{containers}{$n};
687 248 ▶ my $img = _image( $d, $c->{image} ) || {};
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
2480
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
688 248 ▶ next unless $c->{status} eq 'running';
Branch: 1 branch
BranchTrueFalseTotal
unless $$c{"status"} eq "running" 50 198 248
689 198 ▶ $c->{health} = _health( $dev, $d, $n, $c, $img ) if _has_hc( $c->{config}, $img );
Branch: 1 branch
BranchTrueFalseTotal
if _has_hc($$c{"config"}, $img) 91 107 198
690 }
691 153 return;
692 }
693  
694 492 ▶sub _env_of {
Subroutine _env_of: called CC=3 SCAR=11.4
695 492 my ( $c, $img ) = @_;
696 492 ▶ return { %{ $img->{env} || {} }, %{ $c->{config}{environment} || {} } };
Condition50%2/4
$$img{'env'} || {}
l!l
0492
$$c{'config'}{'environment'} || {}
l!l
4920
MC/DC0%0/1
$$img{'env'} || {}
$$img{'env'}
MC/DC0%0/1
$$c{'config'}{'environment'} || {}
$$c{'config'}{'environment'}
Truth table50%1/2
A
A= $$img{'env'}
Aresult
11
00
Truth table50%1/2
A
A= $$c{'config'}{'environment'}
Aresult
11
00
697 }
698  
699 148 ▶sub _vars {
Subroutine _vars: called CC=3 SCAR=11.0
700 148 my ( $c, $img, $peer ) = @_;
701 148 my $env = _env_of( $c, $img );
702 148 my %v = %$env;
703 148 ▶ if ($peer) { my $pe = _env_of( $peer->[1], $peer->[2] ); $v{"peer:$_"} = $pe->{$_} for keys %$pe }
Branch: 1 branch
BranchTrueFalseTotal
if ($peer) 47 101 148
704 148 return \%v;
705 }
706  
707 362 ▶sub _expand { my ( $t, $v ) = @_; return interpolate( $t, $v )->{value} }
Subroutine _expand: called CC=1 SCAR=0.0
708  
709  
710 # Container zu einem Namen aus Sicht eines Containers (gemeinsames Netz)
711 40 ▶sub lookup {
Subroutine lookup: called CC=14 SCAR=28.6
Pod documented
712 40 my ( $d, $from, $hostname ) = @_;
713 40 ▶ my $fc = $d->{containers}{$from} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $fc = $$d{"containers"}{$from} or return 40 0 40
714 40 ▶ my %fnet = map { $_ => 1 } @{ $fc->{config}{networks} || [] };
Condition50%1/2
$$fc{'config'}{'networks'} || []
l!l
400
MC/DC0%0/1
$$fc{'config'}{'networks'} || []
$$fc{'config'}{'networks'}
Truth table50%1/2
A
A= $$fc{'config'}{'networks'}
Aresult
11
00
715 40 for my $n ( sort keys %{ $d->{containers} } ) {
716 80 my $c = $d->{containers}{$n};
717 80 ▶ my $same = ( $c->{project} // '' ) eq ( $fc->{project} // '' );
Condition50%2/4
$$c{"project"} // ""
l!l
800
$$fc{"project"} // ""
l!l
800
MC/DC0%0/1
$$c{"project"} // ""
$$c{"project"}
MC/DC0%0/1
$$fc{"project"} // ""
$$fc{"project"}
Truth table50%1/2
A
A= $$c{"project"}
Aresult
11
00
Truth table50%1/2
A
A= $$fc{"project"}
Aresult
11
00
718 next unless $n eq $hostname || ( $c->{config}{hostname} // '' ) eq $hostname
719 80 ▶ || ( $same && ( $c->{service} // '' ) eq $hostname );
Branch: 1 branch
BranchTrueFalseTotal
unless $n eq $hostname or ($$c{"config"}{"hostname"} // "") eq $hostname or $same and ($$c{"service"} // "") eq $hostname 40 40 80
Condition53%7/13
$n eq $hostname or ($$c{"config"}{"hostname"} // "") eq $hostname or $same and ($$c{"service"} // "") eq $hostname
l!l&&r!l&&!r
04040
$n eq $hostname or ($$c{"config"}{"hostname"} // "") eq $hostname
l!l&&r!l&&!r
0080
$$c{"config"}{"hostname"} // ""
l!l
080
$same and ($$c{"service"} // "") eq $hostname
!ll&&!rl&&r
04040
$$c{"service"} // ""
l!l
800
MC/DC0%0/4
$n eq $hostname or ($$c{"config"}{"hostname"} // "") eq $hostname or $same and ($$c{"service"} // "") eq $hostname
$n eq $hostname $$c{"config"}{"hostname"} $same $$c{"service"}
Truth table20%1/5
A or B or C and D
A= $n eq $hostnameB= $$c{"config"}{"hostname"}C= $sameD= $$c{"service"}
ABCDresult
1XXX1
01XX1
00111
000X0
00100
720 40 ▶ next unless grep { $fnet{$_} } @{ $c->{config}{networks} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$fnet{$_};} @{$$c{"config"}{"networks"} or [];} 6 34 40
Condition50%1/2
$$c{'config'}{'networks'} || []
l!l
400
MC/DC0%0/1
$$c{'config'}{'networks'} || []
$$c{'config'}{'networks'}
Truth table50%1/2
A
A= $$c{'config'}{'networks'}
Aresult
11
00
721 34 return ( $n, $c );
722 }
723 6 return;
724 }
725  
726 # Erste verletzte Bedingung des Images: { log, transient } oder undef
727 63 ▶sub _failing_need {
Subroutine _failing_need: called CC=54 SCAR=60.2
728 63 my ( $dev, $d, $name, $c, $img, $fresh ) = @_;
729 63 my $peer;
730 63 ▶ for my $n ( @{ $img->{needs} || [] } ) {
Condition100%2/2
$$img{'needs'} || []
l!l
612
MC/DC100%1/1
$$img{'needs'} || []
$$img{'needs'}
Truth table100%2/2
A
A= $$img{'needs'}
Aresult
11
00
731 148 ▶ next if defined $n->{when_env} && !length( _env_of( $c, $img )->{ $n->{when_env} } // '' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $$n{"when_env"} and not length(_env_of($c, $img)->{$$n{"when_env"}} // "") 0 148 148
Condition20%1/5
defined $$n{"when_env"} and not length(_env_of($c, $img)->{$$n{"when_env"}} // "")
!ll&&!rl&&r
14800
_env_of($c, $img)->{$$n{"when_env"}} // ""
l!l
00
MC/DC0%0/2
defined $$n{"when_env"} and not length(_env_of($c, $img)->{$$n{"when_env"}} // "")
defined $$n{"when_env"} _env_of($c, $img)->{$$n{"when_env"}}
Truth table33%1/3
A and not(B)
A= defined $$n{"when_env"}B= _env_of($c, $img)->{$$n{"when_env"}}
ABresult
0X0
110
101
732 148 my $v = _vars( $c, $img, $peer );
733 148 ▶ my $log = [ map { _expand( $_, $v ) } @{ $n->{log} || [] } ];
Condition50%1/2
$$n{'log'} || []
l!l
1480
MC/DC0%0/1
$$n{'log'} || []
$$n{'log'}
Truth table50%1/2
A
A= $$n{'log'}
Aresult
11
00
734 148 ▶ if ( defined $n->{env} ) {
Branch: 7 branches
BranchTrueFalseTotal
if (defined $$n{'env'}) { } 61 87 148
elsif (defined $$n{'connect'}) { } 40 47 87
elsif (ref $$n{'equals'} eq 'ARRAY') { } 32 15 47
elsif (defined $$n{'writable'}) { } 8 7 15
elsif (defined $$n{'egress'}) { } 0 7 7
elsif (defined $$n{'memory'}) { } 7 0 7
elsif (defined $$n{'mount'}) { } 0 0 0
735 61 my $x = _env_of( $c, $img )->{ $n->{env} };
736 61 ▶ return { log => $log } unless defined $x && length $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x and length $x 3 58 61
Condition66%2/3
defined $x and length $x
!ll&&!rl&&r
0358
MC/DC50%1/2
defined $x and length $x
defined $x length $x
Truth table66%2/3
A and B
A= defined $xB= length $x
ABresult
0X0
100
111
737 }
738 elsif ( defined $n->{connect} ) {
739 40 ▶ my ( $h, $p ) = _expand( $n->{connect}, $v ) =~ /\A(.*):(\d*)\z/ or return { log => $log };
Branch: 1 branch
BranchTrueFalseTotal
() = _expand($$n{"connect"}, $v) =~ /\A(.*):(\d*)\z/ or return {"log", $log} 40 0 40
740 40 ▶ return { log => $log } unless length $h && length $p;
Branch: 1 branch
BranchTrueFalseTotal
unless length $h and length $p 0 40 40
Condition33%1/3
length $h and length $p
!ll&&!rl&&r
0040
MC/DC0%0/2
length $h and length $p
length $h length $p
Truth table33%1/3
A and B
A= length $hB= length $p
ABresult
0X0
100
111
741 0 ▶ if ( $h eq 'localhost' || $h eq '127.0.0.1' ) { return { log => $log } unless grep { $_ == $p } @{ $img->{listens} || [] }; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($h eq "localhost" or $h eq "127.0.0.1") 0 40 40
unless grep {$_ == $p;} @{$$img{"listens"} or [];} 0 0 0
Condition20%1/5
$h eq "localhost" or $h eq "127.0.0.1"
l!l&&r!l&&!r
0040
$$img{'listens'} || []
l!l
00
MC/DC0%0/2
$h eq "localhost" or $h eq "127.0.0.1"
$h eq "localhost" $h eq "127.0.0.1"
MC/DC0%0/1
$$img{'listens'} || []
$$img{'listens'}
Truth table33%1/3
A or B
A= $h eq "localhost"B= $h eq "127.0.0.1"
ABresult
1X1
011
000
Truth table0%0/2
A
A= $$img{'listens'}
Aresult
11
00
742 40 ▶ my $hip = _extra_host( $c, $h ) // ( $h =~ /\A\d+\.\d+\.\d+\.\d+\z/ ? $h : undef ); # extra_hosts, host-gateway, IP
Branch: 1 branch
BranchTrueFalseTotal
$h =~ /\A\d+\.\d+\.\d+\.\d+\z/ ? : 0 40 40
Condition33%1/3
_extra_host($c, $h) // ($h =~ /\A\d+\.\d+\.\d+\.\d+\z/ ? $h : undef)
l!l&&r!l&&!r
0040
MC/DC0%0/2
_extra_host($c, $h) // ($h =~ /\A\d+\.\d+\.\d+\.\d+\z/ ? $h : undef)
_extra_host($c, $h) ($h =~ /\A\d+\.\d+\.\d+\.\d+\z/ ? $h : undef)
Truth table33%1/3
A // B
A= _extra_host($c, $h)B= ($h =~ /\A\d+\.\d+\.\d+\.\d+\z/ ? $h : undef)
ABresult
1X1
011
000
743 40 ▶ if ( defined $hip ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hip) 0 40 40
744 0 ▶ if ( $hip =~ /\A127\./ ) { # im Container ist das der Container selbst
Branch: 1 branch
BranchTrueFalseTotal
if ($hip =~ /\A127\./) { } 0 0 0
745 0 ▶ return { log => $log } unless grep { $_ == $p } @{ $img->{listens} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ == $p;} @{$$img{"listens"} or [];} 0 0 0
Condition0%0/2
$$img{'listens'} || []
l!l
00
MC/DC0%0/1
$$img{'listens'} || []
$$img{'listens'}
Truth table0%0/2
A
A= $$img{'listens'}
Aresult
11
00
746 }
747 0 ▶ else { return { log => $log } unless _host_listens( $dev, $d, $hip, $p ) }
Branch: 1 branch
BranchTrueFalseTotal
unless _host_listens($dev, $d, $hip, $p) 0 0 0
748 0 next;
749 }
750 40 my ( $pn, $pc ) = lookup( $d, $name, $h );
751 40 ▶ return { log => $log } unless $pc;
Branch: 1 branch
BranchTrueFalseTotal
unless $pc 6 34 40
752 34 ▶ my $pimg = _image( $d, $pc->{image} ) || {};
Condition50%1/2
_image($d, $$pc{'image'}) || {}
l!l
340
MC/DC0%0/1
_image($d, $$pc{'image'}) || {}
_image($d, $$pc{'image'})
Truth table50%1/2
A
A= _image($d, $$pc{'image'})
Aresult
11
00
753 34 ▶ return { log => $log } unless $pc->{status} eq 'running' && grep { $_ == $p } @{ $pimg->{listens} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless $$pc{"status"} eq "running" and grep {$_ == $p;} @{$$pimg{"listens"} or [];} 0 34 34
Condition40%2/5
$$pc{"status"} eq "running" and grep {$_ == $p;} @{$$pimg{"listens"} or [];}
!ll&&!rl&&r
0034
$$pimg{'listens'} || []
l!l
340
MC/DC0%0/2
$$pc{"status"} eq "running" and grep {$_ == $p;} @{$$pimg{"listens"} or [];}
$$pc{"status"} eq "running" grep {$_ == $p;} @{$$pimg{"listens"} or [];}
MC/DC0%0/1
$$pimg{'listens'} || []
$$pimg{'listens'}
Truth table33%1/3
A and B
A= $$pc{"status"} eq "running"B= grep {$_ == $p;} @{$$pimg{"listens"} or [];}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$pimg{'listens'}
Aresult
11
00
754 # gerade erst gestartet, ohne auf die Gesundheit zu warten
755 34 ▶ if ( $pimg->{warmup} && $fresh->{$pn} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$pimg{"warmup"} and $$fresh{$pn}) 17 17 34
Condition66%2/3
$$pimg{"warmup"} and $$fresh{$pn}
!ll&&!rl&&r
01717
MC/DC50%1/2
$$pimg{"warmup"} and $$fresh{$pn}
$$pimg{"warmup"} $$fresh{$pn}
Truth table66%2/3
A and B
A= $$pimg{"warmup"}B= $$fresh{$pn}
ABresult
0X0
100
111
756 17 ▶ my $cond = ( $c->{config}{depends_on}{ $pc->{service} } || {} )->{condition} // '';
Condition50%2/4
($$c{"config"}{"depends_on"}{$$pc{"service"}} || {})->{"condition"} // ""
l!l
170
$$c{'config'}{'depends_on'}{$$pc{'service'}} || {}
l!l
170
MC/DC0%0/1
($$c{"config"}{"depends_on"}{$$pc{"service"}} || {})->{"condition"} // ""
$$c{'config'}{'depends_on'}{$$pc{'service'}}
Truth table50%1/2
A
A= $$c{'config'}{'depends_on'}{$$pc{'service'}}
Aresult
11
00
757 17 ▶ return { log => $log, transient => 1 } unless $cond eq 'service_healthy';
Branch: 1 branch
BranchTrueFalseTotal
unless $cond eq "service_healthy" 2 15 17
758 }
759 32 $peer = [ $pn, $pc, $pimg ];
760 }
761 elsif ( ref $n->{equals} eq 'ARRAY' ) {
762 32 my ( $a, $b ) = map { _expand( $_, $v ) } @{ $n->{equals} };
763 32 ▶ return { log => $log } unless defined $a && defined $b && $a eq $b;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $a and defined $b and $a eq $b 0 32 32
Condition33%2/6
defined $a and defined $b and $a eq $b
!ll&&!rl&&r
0032
defined $a and defined $b
!ll&&!rl&&r
0032
MC/DC0%0/3
defined $a and defined $b and $a eq $b
defined $a defined $b $a eq $b
Truth table25%1/4
A and B and C
A= defined $aB= defined $bC= $a eq $b
ABCresult
0XX0
10X0
1100
1111
764 }
765 elsif ( defined $n->{writable} ) {
766 8 ▶ return { log => $log } unless _writable( $dev, $d, $c, $img, $n->{writable} );
Branch: 1 branch
BranchTrueFalseTotal
unless _writable($dev, $d, $c, $img, $$n{"writable"}) 5 3 8
767 }
768 elsif ( defined $n->{egress} ) { # Ziel ausserhalb des Hosts: nur ueber ein Netz, das nicht internal ist
769 0 ▶ my @nw = @{ $c->{config}{networks} || [] };
Condition0%0/2
$$c{'config'}{'networks'} || []
l!l
00
MC/DC0%0/1
$$c{'config'}{'networks'} || []
$$c{'config'}{'networks'}
Truth table0%0/2
A
A= $$c{'config'}{'networks'}
Aresult
11
00
770 0 ▶ my $int = $c->{config}{internal_nets} || {};
Condition0%0/2
$$c{'config'}{'internal_nets'} || {}
l!l
00
MC/DC0%0/1
$$c{'config'}{'internal_nets'} || {}
$$c{'config'}{'internal_nets'}
Truth table0%0/2
A
A= $$c{'config'}{'internal_nets'}
Aresult
11
00
771 0 ▶ return { log => $log } if ( $c->{config}{network_mode} // '' ) eq 'none' || !grep { !$int->{$_} } @nw;
Branch: 1 branch
BranchTrueFalseTotal
if ($$c{"config"}{"network_mode"} // "") eq "none" or not grep({not $$int{$_};} @nw) 0 0 0
Condition0%0/5
($$c{"config"}{"network_mode"} // "") eq "none" or not grep({not $$int{$_};} @nw)
l!l&&r!l&&!r
000
$$c{"config"}{"network_mode"} // ""
l!l
00
MC/DC0%0/2
($$c{"config"}{"network_mode"} // "") eq "none" or not grep({not $$int{$_};} @nw)
$$c{"config"}{"network_mode"} not grep({not $$int{$_};} @nw)
Truth table0%0/3
A or not(B)
A= $$c{"config"}{"network_mode"}B= not grep({not $$int{$_};} @nw)
ABresult
1X1
011
000
772 }
773 elsif ( defined $n->{memory} ) { # braucht so viel Speicher, sonst OOM-Kill (Exit 137)
774 7 my $lim = _mem_limit( $c->{config} );
775 7 ▶ return { log => $log, exit => 137, oom => 1 } if defined $lim && $lim < _bytes( $n->{memory} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $lim and $lim < _bytes($$n{"memory"}) 6 1 7
Condition66%2/3
defined $lim and $lim < _bytes($$n{"memory"})
!ll&&!rl&&r
016
MC/DC50%1/2
defined $lim and $lim < _bytes($$n{"memory"})
defined $lim $lim < _bytes($$n{"memory"})
Truth table66%2/3
A and B
A= defined $limB= $lim < _bytes($$n{"memory"})
ABresult
0X0
100
111
776 }
777 elsif ( defined $n->{mount} ) {
778 0 my ($mt) = _mount_at( $c, $n->{mount} );
779 0 ▶ return { log => $log } unless $mt && $mt->{type} eq 'bind' && defined _text( $dev, $mt->{source} . substr( $n->{mount}, length $mt->{target} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $mt and $$mt{"type"} eq "bind" and defined _text($dev, $$mt{"source"} . substr($$n{"mount"}, length $$mt{"target"})) 0 0 0
Condition0%0/6
$mt and $$mt{"type"} eq "bind" and defined _text($dev, $$mt{"source"} . substr($$n{"mount"}, length $$mt{"target"}))
!ll&&!rl&&r
000
$mt and $$mt{"type"} eq "bind"
!ll&&!rl&&r
000
MC/DC0%0/3
$mt and $$mt{"type"} eq "bind" and defined _text($dev, $$mt{"source"} . substr($$n{"mount"}, length $$mt{"target"}))
$mt $$mt{"type"} eq "bind" defined _text($dev, $$mt{"source"} . substr($$n{"mount"}, length $$mt{"target"}))
Truth table0%0/4
A and B and C
A= $mtB= $$mt{"type"} eq "bind"C= defined _text($dev, $$mt{"source"} . substr($$n{"mount"}, length $$mt{"target"}))
ABCresult
0XX0
10X0
1100
1111
780 }
781 }
782 41 return undef;
783 }
784  
785 # extra_hosts eines Containers: Name -> Adresse (host-gateway = Bruecke docker0)
786 40 ▶sub _extra_host {
Subroutine _extra_host: called CC=6 SCAR=32.3
787 40 my ( $c, $h ) = @_;
788 40 ▶ my $x = $c->{config}{extra_hosts} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $x = $$c{"config"}{"extra_hosts"} or return undef 0 40 40
789 0 ▶ my %m = ref $x eq 'HASH' ? %$x : map { /\A([^:=]+)[:=](.+)\z/ ? ( $1 => $2 ) : () } @$x;
Branch: 2 branches
BranchTrueFalseTotal
ref $x eq 'HASH' ? : 0 0 0
/\A([^:=]+)[:=](.+)\z/ ? : 0 0 0
790 0 ▶ my $ip = $m{$h} // return undef;
Condition0%0/2
$m{$h} // (return undef)
l!l
00
MC/DC0%0/1
$m{$h} // (return undef)
$m{$h}
Truth table0%0/2
A
A= $m{$h}
Aresult
11
00
791 0 ▶ return $ip eq 'host-gateway' ? '172.17.0.1' : $ip;
Branch: 1 branch
BranchTrueFalseTotal
$ip eq 'host-gateway' ? : 0 0 0
792 }
793  
794 # Lauscht auf dem Host ein Dienst auf ip:port (docker.host_listen: { "172.17.0.1:25": postfix })?
795 0 ▶sub _host_listens {
Subroutine _host_listens: not called CC=11 SCAR=48.8
796 0 my ( $dev, $d, $ip, $p ) = @_;
797 0 ▶ for my $k ( sort keys %{ $d->{host_listen} || {} } ) {
Condition0%0/2
$$d{'host_listen'} || {}
l!l
00
MC/DC0%0/1
$$d{'host_listen'} || {}
$$d{'host_listen'}
Truth table0%0/2
A
A= $$d{'host_listen'}
Aresult
11
00
798 0 ▶ my ( $kip, $kp ) = $k =~ /\A(?:(.*):)?(\d+)\z/ or next;
Branch: 1 branch
BranchTrueFalseTotal
() = $k =~ /\A(?:(.*):)?(\d+)\z/ or next 0 0 0
799 0 ▶ next unless $kp == $p && ( !defined $kip || $kip eq '0.0.0.0' || $kip eq $ip );
Branch: 1 branch
BranchTrueFalseTotal
unless $kp == $p and !defined($kip) || $kip eq "0.0.0.0" || $kip eq $ip 0 0 0
Condition0%0/9
$kp == $p and !defined($kip) || $kip eq "0.0.0.0" || $kip eq $ip
!ll&&!rl&&r
000
not defined $kip or $kip eq "0.0.0.0" or $kip eq $ip
l!l&&r!l&&!r
000
not defined $kip or $kip eq "0.0.0.0"
l!l&&r!l&&!r
000
MC/DC0%0/4
$kp == $p and !defined($kip) || $kip eq "0.0.0.0" || $kip eq $ip
$kp == $p not defined $kip $kip eq "0.0.0.0" $kip eq $ip
Truth table0%0/5
A and not(B) or C or D
A= $kp == $pB= not defined $kipC= $kip eq "0.0.0.0"D= $kip eq $ip
ABCDresult
0XXX0
10000
11XX1
101X1
10011
800 0 ▶ my $svc = ( $dev->{services} || {} )->{ $d->{host_listen}{$k} };
Condition0%0/2
$$dev{'services'} || {}
l!l
00
MC/DC0%0/1
$$dev{'services'} || {}
$$dev{'services'}
Truth table0%0/2
A
A= $$dev{'services'}
Aresult
11
00
801 0 ▶ return 1 if !$svc || $svc->{active};
Branch: 1 branch
BranchTrueFalseTotal
if not $svc or $$svc{"active"} 0 0 0
Condition0%0/3
not $svc or $$svc{"active"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $svc or $$svc{"active"}
not $svc $$svc{"active"}
Truth table0%0/3
not(A) or B
A= not $svcB= $$svc{"active"}
ABresult
1X1
011
000
802 }
803 0 return 0;
804 }
805  
806 # Speichergrenze eines Dienstes: mem_limit oder deploy.resources.limits.memory (Bytes)
807 54 ▶sub _mem_limit {
Subroutine _mem_limit: called CC=6 SCAR=19.2
808 54 my ($cfg) = @_;
809 54 ▶ my $l = $cfg->{mem_limit} // ( ( ( $cfg->{deploy} || {} )->{resources} || {} )->{limits} || {} )->{memory};
Condition55%5/9
$$cfg{"mem_limit"} // ((($$cfg{"deploy"} || {})->{"resources"} || {})->{"limits"} || {})->{"memory"}
l!l&&r!l&&!r
11043
(($$cfg{'deploy'} || {})->{'resources'} || {})->{'limits'} || {}
l!l
043
($$cfg{'deploy'} || {})->{'resources'} || {}
l!l
043
$$cfg{'deploy'} || {}
l!l
043
MC/DC50%1/2
$$cfg{"mem_limit"} // ((($$cfg{"deploy"} || {})->{"resources"} || {})->{"limits"} || {})->{"memory"}
$$cfg{"mem_limit"} $$cfg{'deploy'}
Truth table66%2/3
A // B
A= $$cfg{"mem_limit"}B= $$cfg{'deploy'}
ABresult
1X1
011
000
810 54 ▶ return defined $l ? _bytes($l) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $l ? : 11 43 54
811 }
812  
813 18 ▶sub _bytes {
Subroutine _bytes: called CC=2 SCAR=7.1
814 18 my ($v) = @_;
815 18 ▶ my ( $n, $u ) = "$v" =~ /\A\s*([\d.]+)\s*([kmgt]?)i?b?\s*\z/i or return 0;
Branch: 1 branch
BranchTrueFalseTotal
() = "$v" =~ /\A\s*([\d.]+)\s*([kmgt]?)i?b?\s*\z/i or return 0 18 0 18
816 18 return int( $n * ( { '' => 1, k => 1024, m => 1024**2, g => 1024**3, t => 1024**4 }->{ lc $u } ) );
817 }
818  
819 # Laengste Einhaengung, die den Pfad im Container enthaelt
820 34 ▶sub _mount_at {
Subroutine _mount_at: called CC=3 SCAR=11.6
821 34 my ( $c, $path ) = @_;
822 0 my ($mt) = sort { length $b->{target} <=> length $a->{target} }
823 34 ▶ grep { $path eq $_->{target} || index( $path, "$_->{target}/" ) == 0 } @{ $c->{config}{volumes} || [] };
Condition60%3/5
$path eq $$_{'target'} || index($path, "$$_{'target'}/") == 0
l!l&&r!l&&!r
2905
$$c{'config'}{'volumes'} || []
l!l
340
MC/DC50%1/2
$path eq $$_{'target'} || index($path, "$$_{'target'}/") == 0
$path eq $$_{'target'} index($path, "$$_{'target'}/") == 0
MC/DC0%0/1
$$c{'config'}{'volumes'} || []
$$c{'config'}{'volumes'}
Truth table66%2/3
A || B
A= $path eq $$_{'target'}B= index($path, "$$_{'target'}/") == 0
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$c{'config'}{'volumes'}
Aresult
11
00
824 34 return $mt;
825 }
826  
827 8 ▶sub _uid_of {
Subroutine _uid_of: called CC=6 SCAR=22.0
828 8 my ( $c, $img ) = @_;
829 8 ▶ my $u = $c->{config}{user} // $img->{user} // '0';
Condition40%2/5
($$c{"config"}{"user"} // $$img{"user"}) // 0
l!l
80
$$c{"config"}{"user"} // $$img{"user"}
l!l&&r!l&&!r
080
MC/DC0%0/2
($$c{"config"}{"user"} // $$img{"user"}) // 0
$$c{"config"}{"user"} $$img{"user"}
Truth table33%1/3
A // B
A= $$c{"config"}{"user"}B= $$img{"user"}
ABresult
1X1
011
000
830 8 my ( $uid, $gid ) = split /:/, "$u";
831 8 ▶ return ( $uid // 0, $gid // $uid // 0 );
Condition42%3/7
$uid // 0
l!l
80
($gid // $uid) // 0
l!l
80
$gid // $uid
l!l&&r!l&&!r
080
MC/DC0%0/1
$uid // 0
$uid
MC/DC0%0/2
($gid // $uid) // 0
$gid $uid
Truth table50%1/2
A
A= $uid
Aresult
11
00
Truth table33%1/3
A // B
A= $gidB= $uid
ABresult
1X1
011
000
832 }
833  
834 8 ▶sub _writable {
Subroutine _writable: called CC=16 SCAR=33.1
835 8 my ( $dev, $d, $c, $img, $path ) = @_;
836 8 ▶ my $mt = _mount_at( $c, $path ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $mt = _mount_at($c, $path) or return 0 8 0 8
837 8 ▶ return 0 if $mt->{read_only};
Branch: 1 branch
BranchTrueFalseTotal
if $$mt{"read_only"} 0 8 8
838 8 ▶ return 1 if $mt->{type} eq 'volume';
Branch: 1 branch
BranchTrueFalseTotal
if $$mt{"type"} eq "volume" 0 8 8
839 8 my ( $uid, $gid ) = _uid_of( $c, $img );
840 8 ▶ return 1 if $uid =~ /\A0\z|\Aroot\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $uid =~ /\A0\z|\Aroot\z/ 0 8 8
841 8 ▶ my $e = ( $dev->{dirs} || {} )->{ $mt->{source} } // _L()->can('_file_entry')->( $dev, $mt->{source} ) // {};
Condition42%3/7
(($$dev{"dirs"} || {})->{$$mt{"source"}} // _L()->can("_file_entry")->($dev, $$mt{"source"})) // {}
l!l
80
($$dev{"dirs"} || {})->{$$mt{"source"}} // _L()->can("_file_entry")->($dev, $$mt{"source"})
l!l&&r!l&&!r
800
$$dev{'dirs'} || {}
l!l
80
MC/DC0%0/2
(($$dev{"dirs"} || {})->{$$mt{"source"}} // _L()->can("_file_entry")->($dev, $$mt{"source"})) // {}
$$dev{'dirs'} _L()->can("_file_entry")->($dev, $$mt{"source"})
Truth table33%1/3
A // B
A= $$dev{'dirs'}B= _L()->can("_file_entry")->($dev, $$mt{"source"})
ABresult
1X1
011
000
842 8 ▶ my $mode = oct( $e->{mode} // '0755' );
Condition50%1/2
$$e{"mode"} // "0755"
l!l
80
MC/DC0%0/1
$$e{"mode"} // "0755"
$$e{"mode"}
Truth table50%1/2
A
A= $$e{"mode"}
Aresult
11
00
843 8 my $L = _L();
844 8 ▶ my $ouid = $L->can('_uid')->( $dev, $e->{owner} // 'root' );
Condition50%1/2
$$e{"owner"} // "root"
l!l
80
MC/DC0%0/1
$$e{"owner"} // "root"
$$e{"owner"}
Truth table50%1/2
A
A= $$e{"owner"}
Aresult
11
00
845 8 ▶ my $ogid = $L->can('_gid')->( $dev, $e->{group} // 'root' );
Condition50%1/2
$$e{"group"} // "root"
l!l
80
MC/DC0%0/1
$$e{"group"} // "root"
$$e{"group"}
Truth table50%1/2
A
A= $$e{"group"}
Aresult
11
00
846 8 ▶ return ( $mode >> 6 ) & 2 ? 1 : 0 if $ouid == $uid;
Branch: 2 branches
BranchTrueFalseTotal
if $ouid == $uid 3 5 8
$mode >> 6 & 2 ? : 3 0 3
847 5 ▶ return ( $mode >> 3 ) & 2 ? 1 : 0 if $ogid == $gid;
Branch: 2 branches
BranchTrueFalseTotal
if $ogid == $gid 0 5 5
$mode >> 3 & 2 ? : 0 0 0
848 5 ▶ return $mode & 2 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$mode & 2 ? : 0 5 5
849 }
850  
851 40 ▶sub _data_of {
Subroutine _data_of: called CC=12 SCAR=30.5
852 40 my ( $dev, $d, $c, $img ) = @_;
853 40 ▶ return undef unless defined $img->{data_path};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$img{"data_path"} 20 20 40
854 20 my $mt = _mount_at( $c, $img->{data_path} );
855 20 ▶ if ( !$mt || $mt->{anonymous} ) { return $img->{init_data} // 'leer' }
Branch: 1 branch
BranchTrueFalseTotal
if (not $mt or $$mt{"anonymous"}) 1 19 20
Condition60%3/5
not $mt or $$mt{"anonymous"}
l!l&&r!l&&!r
1019
$$img{"init_data"} // "leer"
l!l
01
MC/DC50%1/2
not $mt or $$mt{"anonymous"}
not $mt $$mt{"anonymous"}
MC/DC0%0/1
$$img{"init_data"} // "leer"
$$img{"init_data"}
Truth table66%2/3
not(A) or B
A= not $mtB= $$mt{"anonymous"}
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$img{"init_data"}
Aresult
11
00
856 19 ▶ if ( $mt->{type} eq 'volume' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$mt{"type"} eq "volume") 19 0 19
857 19 ▶ my $v = $d->{volumes}{ $mt->{source} } //= {};
Condition50%1/2
$$d{"volumes"}{$$mt{"source"}} //= {}
l!l
190
MC/DC0%0/1
$$d{"volumes"}{$$mt{"source"}} //= {}
$$d{"volumes"}{$$mt{"source"}}
Truth table50%1/2
A
A= $$d{"volumes"}{$$mt{"source"}}
Aresult
11
00
858 19 ▶ $v->{data} //= $img->{init_data} // 'leer';
Condition75%3/4
$$v{"data"} //= $$img{"init_data"} // "leer"
l!l
181
$$img{"init_data"} // "leer"
l!l
01
MC/DC100%1/1
$$v{"data"} //= $$img{"init_data"} // "leer"
$$v{"data"}
Truth table100%2/2
A
A= $$v{"data"}
Aresult
11
00
859 19 return $v->{data};
860 }
861 0 ▶ my $e = $dev->{dirs}{ $mt->{source} } //= { owner => 'root', group => 'root', mode => '0755' };
Condition0%0/2
$$dev{"dirs"}{$$mt{"source"}} //= {"owner", "root", "group", "root", "mode", "0755"}
l!l
00
MC/DC0%0/1
$$dev{"dirs"}{$$mt{"source"}} //= {"owner", "root", "group", "root", "mode", "0755"}
$$dev{"dirs"}{$$mt{"source"}}
Truth table0%0/2
A
A= $$dev{"dirs"}{$$mt{"source"}}
Aresult
11
00
862 0 ▶ $e->{data} //= $img->{init_data} // 'leer';
Condition0%0/4
$$e{"data"} //= $$img{"init_data"} // "leer"
l!l
00
$$img{"init_data"} // "leer"
l!l
00
MC/DC0%0/1
$$e{"data"} //= $$img{"init_data"} // "leer"
$$e{"data"}
Truth table0%0/2
A
A= $$e{"data"}
Aresult
11
00
863 0 return $e->{data};
864 }
865  
866 306 ▶sub _has_hc {
Subroutine _has_hc: called CC=5 SCAR=16.7
867 306 my ( $cfg, $img ) = @_;
868 306 ▶ return 0 if $cfg->{healthcheck} && $cfg->{healthcheck}{disable};
Branch: 1 branch
BranchTrueFalseTotal
if $$cfg{"healthcheck"} and $$cfg{"healthcheck"}{"disable"} 0 306 306
Condition66%2/3
$$cfg{"healthcheck"} and $$cfg{"healthcheck"}{"disable"}
!ll&&!rl&&r
1541520
MC/DC0%0/2
$$cfg{"healthcheck"} and $$cfg{"healthcheck"}{"disable"}
$$cfg{"healthcheck"} $$cfg{"healthcheck"}{"disable"}
Truth table66%2/3
A and B
A= $$cfg{"healthcheck"}B= $$cfg{"healthcheck"}{"disable"}
ABresult
0X0
100
111
869 306 ▶ return $cfg->{healthcheck} || $img->{healthcheck} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$$cfg{'healthcheck'} || $$img{'healthcheck'} ? : 152 154 306
Condition66%2/3
$$cfg{"healthcheck"} or $$img{"healthcheck"}
l!l&&r!l&&!r
1520154
MC/DC50%1/2
$$cfg{"healthcheck"} or $$img{"healthcheck"}
$$cfg{"healthcheck"} $$img{"healthcheck"}
Truth table66%2/3
A or B
A= $$cfg{"healthcheck"}B= $$img{"healthcheck"}
ABresult
1X1
011
000
870 }
871  
872 # Gesundheit aus dem Test des Healthchecks: healthy | unhealthy
873 109 ▶sub _health {
Subroutine _health: called CC=14 SCAR=33.5
874 109 my ( $dev, $d, $name, $c, $img ) = @_;
875 109 ▶ my $hc = $c->{config}{healthcheck} || { test => $img->{healthcheck} };
Condition50%1/2
$$c{'config'}{'healthcheck'} || {'test', $$img{'healthcheck'}}
l!l
1090
MC/DC0%0/1
$$c{'config'}{'healthcheck'} || {'test', $$img{'healthcheck'}}
$$c{'config'}{'healthcheck'}
Truth table50%1/2
A
A= $$c{'config'}{'healthcheck'}
Aresult
11
00
876 109 my $t = $hc->{test};
877 109 ▶ $t = [ 'CMD-SHELL', $t ] if defined $t && !ref $t;
Branch: 1 branch
BranchTrueFalseTotal
if defined $t and not ref $t 0 109 109
Condition33%1/3
defined $t and not ref $t
!ll&&!rl&&r
01090
MC/DC0%0/2
defined $t and not ref $t
defined $t not ref $t
Truth table33%1/3
A and not(B)
A= defined $tB= not ref $t
ABresult
0X0
100
111
878 109 ▶ return 'unhealthy' unless ref $t eq 'ARRAY' && @$t >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $t eq "ARRAY" and @$t >= 2 0 109 109
Condition33%1/3
ref $t eq "ARRAY" and @$t >= 2
!ll&&!rl&&r
00109
MC/DC0%0/2
ref $t eq "ARRAY" and @$t >= 2
ref $t eq "ARRAY" @$t >= 2
Truth table33%1/3
A and B
A= ref $t eq "ARRAY"B= @$t >= 2
ABresult
0X0
100
111
879 109 my ( $kind, @rest ) = @$t;
880 109 ▶ return 'unhealthy' if $kind eq 'NONE';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "NONE" 0 109 109
881 0 ▶ my $line = $kind eq 'CMD-SHELL' ? $rest[0] : join ' ', map { /\s/ ? "'$_'" : $_ } @rest;
Branch: 2 branches
BranchTrueFalseTotal
$kind eq 'CMD-SHELL' ? : 109 0 109
/\s/ ? : 0 0 0
882 109 ▶ $line = _expand( $line, _env_of( $c, $img ) ) if $kind eq 'CMD-SHELL';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "CMD-SHELL" 109 0 109
883 109 my ( $out, $ok ) = exec_line( $dev, $d, $name, $c, $line );
884 109 ▶ $c->{health_log} = $out if defined $out && length $out;
Branch: 1 branch
BranchTrueFalseTotal
if defined $out and length $out 109 0 109
Condition33%1/3
defined $out and length $out
!ll&&!rl&&r
00109
MC/DC0%0/2
defined $out and length $out
defined $out length $out
Truth table33%1/3
A and B
A= defined $outB= length $out
ABresult
0X0
100
111
885 109 ▶ delete $c->{health_log} if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 109 0 109
886 109 ▶ return $ok ? 'healthy' : 'unhealthy';
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 109 0 109
887 }
888  
889 # --- exec im Container ---------------------------------------------------------------
890  
891  
892 109 ▶sub exec_line {
Subroutine exec_line: called CC=21 SCAR=38.8
Pod documented
893 109 my ( $dev, $d, $name, $c, $line ) = @_;
894 109 my @w = eval { Langertha::Holmgang::Shell::shell_words($line) };
895 109 ▶ return ( "sh: syntax error", 0 ) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 109 109
896 109 my @seq = ( [] );
897 109 for my $t (@w) {
898 0 ▶ if ( ref $t && $t->{op} =~ /\A(;|&&|\|\|)\z/ ) { push @seq, $t->{op}, [] }
Branch: 3 branches
BranchTrueFalseTotal
if (ref $t and $$t{'op'} =~ /\A(;|&&|\|\|)\z/) { } 0 327 327
elsif (ref $t and $$t{'op'} eq '|') { } 0 327 327
elsif (ref $t) { } 0 327 327
Condition33%1/3
ref $t and $$t{"op"} =~ /\A(;|&&|\|\|)\z/
!ll&&!rl&&r
32700
MC/DC0%0/2
ref $t and $$t{"op"} =~ /\A(;|&&|\|\|)\z/
ref $t $$t{"op"} =~ /\A(;|&&|\|\|)\z/
Truth table33%1/3
A and B
A= ref $tB= $$t{"op"} =~ /\A(;|&&|\|\|)\z/
ABresult
0X0
100
111
899 0 ▶ elsif ( ref $t && $t->{op} eq '|' ) { push @{ $seq[-1] }, '|' }
Condition33%1/3
ref $t and $$t{"op"} eq "|"
!ll&&!rl&&r
32700
MC/DC0%0/2
ref $t and $$t{"op"} eq "|"
ref $t $$t{"op"} eq "|"
Truth table33%1/3
A and B
A= ref $tB= $$t{"op"} eq "|"
ABresult
0X0
100
111
900 elsif ( ref $t ) { }
901 327 else { push @{ $seq[-1] }, $t }
902 }
903 109 my ( @out, $ok ) = ();
904 109 $ok = 1;
905 109 my $op = ';';
906 109 ▶ while (@seq) {
Branch: 1 branch
BranchTrueFalseTotal
if (@seq) 109 109 218
907 109 my $cmd = shift @seq;
908 109 ▶ if ( @$cmd && !( $op eq '&&' && !$ok ) && !( $op eq '||' && $ok ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$cmd and not $op eq "&&" && !$ok and not $op eq "||" && $ok) 109 0 109
Condition33%4/12
@$cmd and not $op eq "&&" && !$ok and not $op eq "||" && $ok
!ll&&!rl&&r
00109
@$cmd and not $op eq "&&" && !$ok
!ll&&!rl&&r
00109
$op eq '&&' && !$ok
!ll&&!rl&&r
10900
$op eq '||' && $ok
!ll&&!rl&&r
10900
MC/DC0%0/5
@$cmd and not $op eq "&&" && !$ok and not $op eq "||" && $ok
@$cmd $op eq '&&' !$ok $op eq '||' $ok
Truth table12%1/8
A and not(B && not(C)) and not(D && E)
A= @$cmdB= $op eq '&&'C= !$okD= $op eq '||'E= $ok
ABCDEresult
0XXXX0
111XX0
10X110
110110
10X0X1
10X101
1100X1
110101
909 109 my @argv = @$cmd;
910 109 my $cut = 0;
911 0 ▶ for my $i ( 0 .. $#argv ) { if ( $argv[$i] eq '|' ) { $cut = $i; last } }
Branch: 1 branch
BranchTrueFalseTotal
if ($argv[$i] eq "|") 0 327 327
912 109 ▶ @argv = @argv[ 0 .. $cut - 1 ] if $cut;
Branch: 1 branch
BranchTrueFalseTotal
if $cut 0 109 109
913 109 my ( $o, $k ) = _exec( $dev, $d, $name, $c, \@argv );
914 109 ▶ push @out, $o if defined $o && length $o;
Branch: 1 branch
BranchTrueFalseTotal
if defined $o and length $o 109 0 109
Condition33%1/3
defined $o and length $o
!ll&&!rl&&r
00109
MC/DC0%0/2
defined $o and length $o
defined $o length $o
Truth table33%1/3
A and B
A= defined $oB= length $o
ABresult
0X0
100
111
915 109 $ok = $k;
916 }
917 109 ▶ $op = shift @seq // ';';
Condition50%1/2
shift @seq // ";"
l!l
0109
MC/DC0%0/1
shift @seq // ";"
shift @seq
Truth table50%1/2
A
A= shift @seq
Aresult
11
00
918 }
919 109 ▶ return ( join( "\n", @out ), $ok ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 109 0 109
920 }
921  
922 119 ▶sub _exec {
Subroutine _exec: called CC=76 SCAR=67.4
923 119 my ( $dev, $d, $name, $c, $argv ) = @_;
924 119 ▶ my $img = _image( $d, $c->{image} ) || {};
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
1190
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
925 119 my @a = @$argv;
926 119 ▶ my $cmd = shift @a // return ( '', 1 );
Condition50%1/2
shift @a // (return "", 1)
l!l
1190
MC/DC0%0/1
shift @a // (return "", 1)
shift @a
Truth table50%1/2
A
A= shift @a
Aresult
11
00
927 119 ▶ if ( $cmd eq 'sh' || $cmd eq 'bash' || $cmd eq '/bin/sh' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "sh" or $cmd eq "bash" or $cmd eq "/bin/sh") 0 119 119
Condition33%2/6
$cmd eq "sh" or $cmd eq "bash" or $cmd eq "/bin/sh"
l!l&&r!l&&!r
00119
$cmd eq "sh" or $cmd eq "bash"
l!l&&r!l&&!r
00119
MC/DC0%0/3
$cmd eq "sh" or $cmd eq "bash" or $cmd eq "/bin/sh"
$cmd eq "sh" $cmd eq "bash" $cmd eq "/bin/sh"
Truth table25%1/4
A or B or C
A= $cmd eq "sh"B= $cmd eq "bash"C= $cmd eq "/bin/sh"
ABCresult
1XX1
01X1
0011
0000
928 0 my ($i) = grep { $a[$_] eq '-c' } 0 .. $#a;
929 0 ▶ return exec_line( $dev, $d, $name, $c, _expand( $a[ $i + 1 ] // '', _env_of( $c, $img ) ) ) if defined $i; # die Shell im Container ersetzt $VAR
Branch: 1 branch
BranchTrueFalseTotal
if defined $i 0 0 0
Condition0%0/2
$a[$i + 1] // ""
l!l
00
MC/DC0%0/1
$a[$i + 1] // ""
$a[$i + 1]
Truth table0%0/2
A
A= $a[$i + 1]
Aresult
11
00
930 0 _gap("docker exec $cmd (interaktiv)");
931 0 return ( '', 0 );
932 }
933 119 ▶ return ( '', 1 ) if $cmd eq 'true';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "true" 0 119 119
934 119 ▶ return ( '', 0 ) if $cmd eq 'false';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "false" 0 119 119
935 119 ▶ return ( '', ( $a[0] // 0 ) == 0 ? 1 : 0 ) if $cmd eq 'exit';
Branch: 2 branches
BranchTrueFalseTotal
if $cmd eq "exit" 0 119 119
($a[0] // 0) == 0 ? : 0 0 0
Condition0%0/2
$a[0] // 0
l!l
00
MC/DC0%0/1
$a[0] // 0
$a[0]
Truth table0%0/2
A
A= $a[0]
Aresult
11
00
936 952 ▶ my %tools = map { $_ => 1 } @{ $img->{tools} || [] }, qw( env printenv cat id echo ls ),
Branch: 1 branch
BranchTrueFalseTotal
grep({$_ == 5432;} @{$$img{'listens'} or [];}) ? : 117 2 119
Condition50%1/2
$$img{'tools'} || []
l!l
1190
MC/DC0%0/1
$$img{'tools'} || []
$$img{'tools'}
Truth table50%1/2
A
A= $$img{'tools'}
Aresult
11
00
937 119 ▶ ( grep { $_ == 5432 } @{ $img->{listens} || [] } ) ? 'psql' : ();
Condition50%1/2
$$img{'listens'} || []
l!l
1190
MC/DC0%0/1
$$img{'listens'} || []
$$img{'listens'}
Truth table50%1/2
A
A= $$img{'listens'}
Aresult
11
00
938 119 ( my $base = $cmd ) =~ s{.*/}{};
939 return ( "OCI runtime exec failed: exec failed: unable to start container process: exec: \"$cmd\": executable file not found in \$PATH: unknown", 0 )
940 119 ▶ unless $tools{$base};
Branch: 1 branch
BranchTrueFalseTotal
unless $tools{$base} 1 118 119
941 118 my $env = _env_of( $c, $img );
942 118 ▶ if ( $base eq 'env' || $base eq 'printenv' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base eq "env" or $base eq "printenv") 1 117 118
Condition66%2/3
$base eq "env" or $base eq "printenv"
l!l&&r!l&&!r
01117
MC/DC50%1/2
$base eq "env" or $base eq "printenv"
$base eq "env" $base eq "printenv"
Truth table66%2/3
A or B
A= $base eq "env"B= $base eq "printenv"
ABresult
1X1
011
000
943 1 ▶ return ( $env->{ $a[0] } // '', defined $env->{ $a[0] } ? 1 : 0 ) if $base eq 'printenv' && @a;
Branch: 2 branches
BranchTrueFalseTotal
if $base eq "printenv" and @a 1 0 1
defined $$env{$a[0]} ? : 1 0 1
Condition40%2/5
$base eq "printenv" and @a
!ll&&!rl&&r
001
$$env{$a[0]} // ""
l!l
10
MC/DC0%0/2
$base eq "printenv" and @a
$base eq "printenv" @a
MC/DC0%0/1
$$env{$a[0]} // ""
$$env{$a[0]}
Truth table33%1/3
A and B
A= $base eq "printenv"B= @a
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$env{$a[0]}
Aresult
11
00
944 0 return ( join( "\n", map {"$_=$env->{$_}"} sort keys %$env ), 1 );
945 }
946 0 ▶ if ( $base eq 'echo' ) { return ( join( ' ', @a ), 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($base eq "echo") 0 117 117
947 0 ▶ if ( $base eq 'id' ) { my ( $u, $g ) = _uid_of( $c, $img ); return ( "uid=$u gid=$g", 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($base eq "id") 0 117 117
948 117 ▶ if ( $base eq 'cat' || $base eq 'ls' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base eq "cat" or $base eq "ls") 4 113 117
Condition100%3/3
$base eq "cat" or $base eq "ls"
l!l&&r!l&&!r
22113
MC/DC100%2/2
$base eq "cat" or $base eq "ls"
$base eq "cat" $base eq "ls"
Truth table100%3/3
A or B
A= $base eq "cat"B= $base eq "ls"
ABresult
1X1
011
000
949 4 my ($p) = grep { !/\A-/ } @a;
950 4 ▶ return ( '', 1 ) unless defined $p;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p 0 4 4
951 4 my $mt = _mount_at( $c, $p );
952 4 ▶ if ( $mt && $mt->{type} eq 'bind' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mt and $$mt{"type"} eq "bind") 0 4 4
Condition66%2/3
$mt and $$mt{"type"} eq "bind"
!ll&&!rl&&r
310
MC/DC0%0/2
$mt and $$mt{"type"} eq "bind"
$mt $$mt{"type"} eq "bind"
Truth table66%2/3
A and B
A= $mtB= $$mt{"type"} eq "bind"
ABresult
0X0
100
111
953 0 my $hp = $mt->{source} . substr( $p, length $mt->{target} );
954 0 my $t = _text( $dev, $hp );
955 0 ▶ return ( "$base: $p: Permission denied", 0 ) if defined $t && $base eq 'cat' && !_readable( $dev, $c, $img, $hp );
Branch: 1 branch
BranchTrueFalseTotal
if defined $t and $base eq "cat" and not _readable($dev, $c, $img, $hp) 0 0 0
Condition0%0/6
defined $t and $base eq "cat" and not _readable($dev, $c, $img, $hp)
!ll&&!rl&&r
000
defined $t and $base eq "cat"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $t and $base eq "cat" and not _readable($dev, $c, $img, $hp)
defined $t $base eq "cat" not _readable($dev, $c, $img, $hp)
Truth table0%0/4
A and B and not(C)
A= defined $tB= $base eq "cat"C= not _readable($dev, $c, $img, $hp)
ABCresult
0XX0
10X0
1100
1111
956 0 ▶ return ( $base eq 'cat' ? ( $t =~ s/\n\z//r ) : ( $p =~ s{.*/}{}r ), 1 ) if defined $t;
Branch: 2 branches
BranchTrueFalseTotal
if defined $t 0 0 0
$base eq 'cat' ? : 0 0 0
957 0 ▶ return ( '', 1 ) if $base eq 'ls' && _L()->can('_is_dir')->( $dev, $hp );
Branch: 1 branch
BranchTrueFalseTotal
if $base eq "ls" and _L()->can("_is_dir")->($dev, $hp) 0 0 0
Condition0%0/3
$base eq "ls" and _L()->can("_is_dir")->($dev, $hp)
!ll&&!rl&&r
000
MC/DC0%0/2
$base eq "ls" and _L()->can("_is_dir")->($dev, $hp)
$base eq "ls" _L()->can("_is_dir")->($dev, $hp)
Truth table0%0/3
A and B
A= $base eq "ls"B= _L()->can("_is_dir")->($dev, $hp)
ABresult
0X0
100
111
958 0 return ( "$base: $p: No such file or directory", 0 );
959 }
960 4 my ( $kind, $v ) = _container_fs( $dev, $d, $name, $c, $img, $p );
961 4 ▶ if ( defined $kind ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $kind) 4 0 4
962 4 ▶ return ( $kind eq 'dir' ? join( "\n", @$v ) : $p =~ s{.*/}{}r, 1 ) if $base eq 'ls';
Branch: 2 branches
BranchTrueFalseTotal
if $base eq "ls" 2 2 4
$kind eq 'dir' ? : 2 0 2
963 2 ▶ return ( "cat: $p: Is a directory", 0 ) if $kind eq 'dir';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "dir" 0 2 2
964 2 return ( $v =~ s/\n\z//r, 1 );
965 }
966 0 ▶ if ( $p =~ m{\A/proc/} ) { _gap("docker exec $name $base $p"); return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($p =~ m[\A/proc/]) 0 0 0
967 0 ▶ return ( "$base: " . ( $base eq 'ls' ? "cannot access '$p'" : $p ) . ': No such file or directory', 0 );
Branch: 1 branch
BranchTrueFalseTotal
$base eq 'ls' ? : 0 0 0
968 }
969 113 ▶ if ( $base eq 'psql' ) { return _psql( $d, $name, $c, $img, \@a ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($base eq "psql") 3 110 113
970 110 ▶ if ( $base eq 'pg_isready' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base eq "pg_isready") 109 1 110
971 109 my %o;
972 109 ▶ for ( my $i = 0; $i < @a; $i++ ) { $o{ $a[$i] } = $a[ $i + 1 ] if $a[$i] =~ /\A-[hpUd]\z/ }
Branch: 2 branches
BranchTrueFalseTotal
if ($i < @a) 218 109 327
if $a[$i] =~ /\A-[hpUd]\z/ 109 109 218
973 109 ▶ my $h = $o{-h} // 'localhost';
Condition50%1/2
$o{"-h"} // "localhost"
l!l
0109
MC/DC0%0/1
$o{"-h"} // "localhost"
$o{"-h"}
Truth table50%1/2
A
A= $o{"-h"}
Aresult
11
00
974 109 ▶ my $p = $o{-p} // 5432;
Condition50%1/2
$o{"-p"} // 5432
l!l
0109
MC/DC0%0/1
$o{"-p"} // 5432
$o{"-p"}
Truth table50%1/2
A
A= $o{"-p"}
Aresult
11
00
975 109 my $ok = _reach( $d, $name, $c, $img, $h, $p );
976 109 ▶ return ( "$h:$p - " . ( $ok ? 'accepting connections' : 'no response' ), $ok ? 1 : 0 );
Branch: 2 branches
BranchTrueFalseTotal
$ok ? : 109 0 109
$ok ? : 109 0 109
977 }
978 1 ▶ if ( $base eq 'curl' || $base eq 'wget' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base eq "curl" or $base eq "wget") 1 0 1
Condition33%1/3
$base eq "curl" or $base eq "wget"
l!l&&r!l&&!r
010
MC/DC0%0/2
$base eq "curl" or $base eq "wget"
$base eq "curl" $base eq "wget"
Truth table33%1/3
A or B
A= $base eq "curl"B= $base eq "wget"
ABresult
1X1
011
000
979 1 Langertha::Holmgang::Sim::Linux::_part(q{Http});
980 1 my ($url) = grep { m{\Ahttps?://} } @a;
981 1 ▶ return ( $base eq 'curl' ? 'curl: no URL specified!' : 'wget: missing URL', 0 ) unless defined $url;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $url 0 1 1
$base eq 'curl' ? : 0 0 0
982 1 ▶ my $u = Langertha::Holmgang::Sim::Linux::Http::parse_url($url) // return ( "$base: bad url", 0 );
Condition50%1/2
Langertha::Holmgang::Sim::Linux::Http::parse_url($url) // (return "${base}: bad url", 0)
l!l
10
MC/DC0%0/1
Langertha::Holmgang::Sim::Linux::Http::parse_url($url) // (return "${base}: bad url", 0)
Langertha::Holmgang::Sim::Linux::Http::parse_url($url)
Truth table50%1/2
A
A= Langertha::Holmgang::Sim::Linux::Http::parse_url($url)
Aresult
11
00
983 1 my $res = container_request( $dev, $d, $name, $c, $u );
984 my $fail = $base eq 'curl'
985 0 ▶ ? ( grep {/\A-\w*f/} @a ) : 1;
Branch: 1 branch
BranchTrueFalseTotal
$base eq 'curl' ? : 0 1 1
986 1 ▶ if ( !$res ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res) 0 1 1
987 0 ▶ return $base eq 'curl' ? ( "curl: (7) Failed to connect to $u->{host} port $u->{port} after 0 ms: Couldn't connect to server", 0 )
Branch: 1 branch
BranchTrueFalseTotal
$base eq 'curl' ? : 0 0 0
988 : ( "wget: can't connect to remote host: Connection refused", 0 );
989 }
990 1 ▶ if ( $res->{unresolved} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$res{"unresolved"}) 0 1 1
991 0 ▶ return $base eq 'curl' ? ( "curl: (6) Could not resolve host: $u->{host}", 0 ) : ( "wget: bad address '$u->{host}'", 0 );
Branch: 1 branch
BranchTrueFalseTotal
$base eq 'curl' ? : 0 0 0
992 }
993 1 ▶ my $st = $res->{status} // 200;
Condition50%1/2
$$res{"status"} // 200
l!l
10
MC/DC0%0/1
$$res{"status"} // 200
$$res{"status"}
Truth table50%1/2
A
A= $$res{"status"}
Aresult
11
00
994 1 ▶ if ( $st >= 400 && $fail ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($st >= 400 and $fail) 0 1 1
Condition33%1/3
$st >= 400 and $fail
!ll&&!rl&&r
100
MC/DC0%0/2
$st >= 400 and $fail
$st >= 400 $fail
Truth table33%1/3
A and B
A= $st >= 400B= $fail
ABresult
0X0
100
111
995 0 ▶ return $base eq 'curl' ? ( "curl: (22) The requested URL returned error: $st", 0 ) : ( "wget: server returned error: HTTP/1.1 $st", 0 );
Branch: 1 branch
BranchTrueFalseTotal
$base eq 'curl' ? : 0 0 0
996 }
997 1 my $spider = grep { $_ eq '--spider' } @a;
998 1 ▶ my $quiet = grep { /\A-\w*q/ || $_ eq '--quiet' || /\A-\w*s/ } @a;
Condition66%4/6
/\A-\w*q/ || $_ eq '--quiet' || /\A-\w*s/
l!l&&r!l&&!r
101
/\A-\w*q/ or $_ eq "--quiet"
l!l&&r!l&&!r
101
MC/DC33%1/3
/\A-\w*q/ || $_ eq '--quiet' || /\A-\w*s/
/\A-\w*q/ $_ eq "--quiet" /\A-\w*s/
Truth table50%2/4
A or B || C
A= /\A-\w*q/B= $_ eq "--quiet"C= /\A-\w*s/
ABCresult
1XX1
01X1
0011
0000
999 1 ▶ return ( $spider ? ( $quiet ? '' : 'remote file exists' ) : ( $res->{body} // '' ) =~ s/\n\z//r, 1 );
Branch: 2 branches
BranchTrueFalseTotal
$spider ? : 0 1 1
$quiet ? : 0 0 0
Condition50%1/2
$$res{"body"} // ""
l!l
10
MC/DC0%0/1
$$res{"body"} // ""
$$res{"body"}
Truth table50%1/2
A
A= $$res{"body"}
Aresult
11
00
1000 }
1001 0 ▶ if ( $base eq 'redis-cli' ) { return _reach( $d, $name, $c, $img, 'localhost', 6379 ) ? ( 'PONG', 1 ) : ( 'Could not connect to Redis at 127.0.0.1:6379: Connection refused', 0 ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($base eq "redis-cli") 0 0 0
_reach($d, $name, $c, $img, 'localhost', 6379) ? : 0 0 0
1002 0 ▶ if ( $base eq 'nc' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base eq "nc") 0 0 0
1003 0 my @x = grep { !/\A-/ } @a;
1004 0 ▶ return _reach( $d, $name, $c, $img, $x[0] // 'localhost', $x[1] // 0 ) ? ( '', 1 ) : ( '', 0 );
Branch: 1 branch
BranchTrueFalseTotal
_reach($d, $name, $c, $img, $x[0] // 'localhost', $x[1] // 0) ? : 0 0 0
Condition0%0/4
$x[0] // "localhost"
l!l
00
$x[1] // 0
l!l
00
MC/DC0%0/1
$x[0] // "localhost"
$x[0]
MC/DC0%0/1
$x[1] // 0
$x[1]
Truth table0%0/2
A
A= $x[0]
Aresult
11
00
Truth table0%0/2
A
A= $x[1]
Aresult
11
00
1005 }
1006 0 _gap("docker exec $name $base");
1007 0 return ( '', 0 );
1008 }
1009  
1010 0 ▶sub _readable {
Subroutine _readable: not called CC=11 SCAR=48.8
1011 0 my ( $dev, $c, $img, $hp ) = @_;
1012 0 my ( $uid, $gid ) = _uid_of( $c, $img );
1013 0 ▶ return 1 if $uid =~ /\A0\z|\Aroot\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $uid =~ /\A0\z|\Aroot\z/ 0 0 0
1014 0 ▶ my $e = _L()->can('_file_entry')->( $dev, $hp ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $e = _L()->can("_file_entry")->($dev, $hp) or return 0 0 0 0
1015 0 ▶ my $mode = oct( $e->{mode} // '0644' );
Condition0%0/2
$$e{"mode"} // "0644"
l!l
00
MC/DC0%0/1
$$e{"mode"} // "0644"
$$e{"mode"}
Truth table0%0/2
A
A= $$e{"mode"}
Aresult
11
00
1016 0 my $L = _L();
1017 0 ▶ return ( $mode >> 6 ) & 4 ? 1 : 0 if $L->can('_uid')->( $dev, $e->{owner} // 'root' ) == $uid;
Branch: 2 branches
BranchTrueFalseTotal
if $L->can("_uid")->($dev, $$e{"owner"} // "root") == $uid 0 0 0
$mode >> 6 & 4 ? : 0 0 0
Condition0%0/2
$$e{"owner"} // "root"
l!l
00
MC/DC0%0/1
$$e{"owner"} // "root"
$$e{"owner"}
Truth table0%0/2
A
A= $$e{"owner"}
Aresult
11
00
1018 0 ▶ return ( $mode >> 3 ) & 4 ? 1 : 0 if $L->can('_gid')->( $dev, $e->{group} // 'root' ) == $gid;
Branch: 2 branches
BranchTrueFalseTotal
if $L->can("_gid")->($dev, $$e{"group"} // "root") == $gid 0 0 0
$mode >> 3 & 4 ? : 0 0 0
Condition0%0/2
$$e{"group"} // "root"
l!l
00
MC/DC0%0/1
$$e{"group"} // "root"
$$e{"group"}
Truth table0%0/2
A
A= $$e{"group"}
Aresult
11
00
1019 0 ▶ return $mode & 4 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$mode & 4 ? : 0 0 0
1020 }
1021  
1022 3 my @ROOT = qw( bin boot dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var );
1023 3 my @BIN = qw( cat chmod chown cp date echo grep hostname id ln ls mkdir mv ps pwd rm sed sh sleep tail tar touch uname );
1024 3 my @PG = qw( PG_VERSION base global pg_commit_ts pg_dynshmem pg_hba.conf pg_ident.conf pg_logical pg_multixact pg_notify
1025 pg_replslot pg_serial pg_snapshots pg_stat pg_stat_tmp pg_subtrans pg_tblspc pg_twophase pg_wal pg_xact postgresql.auto.conf
1026 postgresql.conf postmaster.opts postmaster.pid );
1027  
1028 # Dateien im Container, die nicht vom Host eingehaengt sind: ( 'file', text ) | ( 'dir', [namen] ) | ()
1029 4 ▶sub _container_fs {
Subroutine _container_fs: called CC=30 SCAR=46.6
1030 4 my ( $dev, $d, $name, $c, $img, $p ) = @_;
1031 4 ▶ $p =~ s{/+\z}{} if length $p > 1;
Branch: 1 branch
BranchTrueFalseTotal
if length $p > 1 4 0 4
1032 4 ▶ my $ip = '172.18.0.' . ( 1 + ( $c->{seq} // 1 ) );
Condition50%1/2
$$c{"seq"} // 1
l!l
40
MC/DC0%0/1
$$c{"seq"} // 1
$$c{"seq"}
Truth table50%1/2
A
A= $$c{"seq"}
Aresult
11
00
1033 4 ▶ if ( $p eq '/etc/hosts' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p eq "/etc/hosts") 1 3 4
1034 1 my $x = $c->{config}{extra_hosts};
1035 0 ▶ my @eh = ref $x eq 'HASH' ? map {"$x->{$_}\t$_"} sort keys %$x : map { /\A([^:=]+)[:=](.+)\z/ ? "$2\t$1" : () } @{ $x || [] };
Branch: 2 branches
BranchTrueFalseTotal
ref $x eq 'HASH' ? : 0 1 1
/\A([^:=]+)[:=](.+)\z/ ? : 0 0 0
Condition50%1/2
$x || []
l!l
01
MC/DC0%0/1
$x || []
$x
Truth table50%1/2
A
A= $x
Aresult
11
00
1036 1 s/\Ahost-gateway\t/172.17.0.1\t/ for @eh;
1037 1 return ( file => join( "\n", "127.0.0.1\tlocalhost", "::1\tlocalhost ip6-localhost ip6-loopback", @eh, "$ip\t" . _id( $name, $c->{seq} ) ) . "\n" );
1038 }
1039 3 ▶ return ( file => "# Generated by Docker Engine.\n# This file can be edited; Docker Engine will not make further changes once it\n# has been modified.\n\nnameserver 127.0.0.11\noptions ndots:0\n" )
Branch: 1 branch
BranchTrueFalseTotal
if $p eq "/etc/resolv.conf" 1 2 3
1040 if $p eq '/etc/resolv.conf';
1041 2 ▶ if ( $p eq '/etc/os-release' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p eq "/etc/os-release") 0 2 2
1042 0 ▶ return ( file => ( $img->{os} // '' ) =~ /alpine/i
Branch: 1 branch
BranchTrueFalseTotal
($$img{'os'} // '') =~ /alpine/i ? : 0 0 0
Condition0%0/2
$$img{"os"} // ""
l!l
00
MC/DC0%0/1
$$img{"os"} // ""
$$img{"os"}
Truth table0%0/2
A
A= $$img{"os"}
Aresult
11
00
1043 ? qq{NAME="Alpine Linux"\nID=alpine\nVERSION_ID=3.20.3\nPRETTY_NAME="Alpine Linux v3.20"\n}
1044 : qq{PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"\nNAME="Debian GNU/Linux"\nVERSION_ID="12"\nID=debian\n} );
1045 }
1046 2 ▶ return ( dir => [@ROOT] ) if $p eq '/';
Branch: 1 branch
BranchTrueFalseTotal
if $p eq "/" 0 2 2
1047 0 ▶ return ( dir => [ sort { $a cmp $b } keys %{ { map { $_ => 1 } @BIN, @{ $img->{tools} || [] } } } ] ) if $p =~ m{\A/(?:usr/)?(?:local/)?s?bin\z};
Branch: 1 branch
BranchTrueFalseTotal
if $p =~ m[\A/(?:usr/)?(?:local/)?s?bin\z] 0 2 2
Condition0%0/2
$$img{'tools'} || []
l!l
00
MC/DC0%0/1
$$img{'tools'} || []
$$img{'tools'}
Truth table0%0/2
A
A= $$img{'tools'}
Aresult
11
00
1048 # Datenverzeichnis einer Datenbank: an der Stelle des Images oder in einem eingehaengten Volume mit Daten
1049 2 ▶ if ( defined $img->{data_path} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$img{"data_path"}) 2 0 2
1050 2 ▶ my ($base) = grep { $p eq $_ || index( $p, "$_/" ) == 0 } $img->{data_path}, map { $_->{target} } grep { $_->{type} eq 'volume' } @{ $c->{config}{volumes} || [] };
Condition60%3/5
$p eq $_ || index($p, "$_/") == 0
l!l&&r!l&&!r
202
$$c{'config'}{'volumes'} || []
l!l
20
MC/DC50%1/2
$p eq $_ || index($p, "$_/") == 0
$p eq $_ index($p, "$_/") == 0
MC/DC0%0/1
$$c{'config'}{'volumes'} || []
$$c{'config'}{'volumes'}
Truth table66%2/3
A || B
A= $p eq $_B= index($p, "$_/") == 0
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$c{'config'}{'volumes'}
Aresult
11
00
1051 2 ▶ if ( defined $base ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $base) 2 0 2
1052 2 my $mt = _mount_at( $c, $base );
1053 2 ▶ my $data = $mt && $mt->{type} eq 'volume' && !$mt->{anonymous} ? ( $d->{volumes}{ $mt->{source} } || {} )->{data} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$mt && $$mt{'type'} eq 'volume' && !$$mt{'anonymous'} ? : 1 1 2
Condition62%5/8
$mt and $$mt{"type"} eq "volume" and not $$mt{"anonymous"}
!ll&&!rl&&r
101
$mt and $$mt{"type"} eq "volume"
!ll&&!rl&&r
101
$$d{'volumes'}{$$mt{'source'}} || {}
l!l
10
MC/DC33%1/3
$mt and $$mt{"type"} eq "volume" and not $$mt{"anonymous"}
$mt $$mt{"type"} eq "volume" not $$mt{"anonymous"}
MC/DC0%0/1
$$d{'volumes'}{$$mt{'source'}} || {}
$$d{'volumes'}{$$mt{'source'}}
Truth table50%2/4
A and B and not(C)
A= $mtB= $$mt{"type"} eq "volume"C= not $$mt{"anonymous"}
ABCresult
0XX0
10X0
1100
1111
Truth table50%1/2
A
A= $$d{'volumes'}{$$mt{'source'}}
Aresult
11
00
1054 2 ▶ $data //= $base eq $img->{data_path} ? $c->{data} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$base eq $$img{'data_path'} ? : 1 0 1
Condition66%2/3
$data //= $base eq $$img{"data_path"} ? $$c{"data"} : undef
l!l&&r!l&&!r
110
MC/DC0%0/2
$data //= $base eq $$img{"data_path"} ? $$c{"data"} : undef
$data $base eq $$img{"data_path"} ? $$c{"data"} : undef
Truth table66%2/3
A //= B
A= $dataB= $base eq $$img{"data_path"} ? $$c{"data"} : undef
ABresult
1X1
011
000
1055 2 ▶ return () unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 2 2
1056 2 my $rest = substr( $p, length $base );
1057 2 ▶ return ( dir => [@PG] ) if $rest eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $rest eq "" 2 0 2
1058 0 ▶ return ( file => ( ( $img->{version} // '16' ) =~ /\A(\d+)/ )[0] . "\n" ) if $rest eq '/PG_VERSION';
Branch: 1 branch
BranchTrueFalseTotal
if $rest eq "/PG_VERSION" 0 0 0
Condition0%0/2
$$img{"version"} // 16
l!l
00
MC/DC0%0/1
$$img{"version"} // 16
$$img{"version"}
Truth table0%0/2
A
A= $$img{"version"}
Aresult
11
00
1059 0 ▶ return ( dir => [qw( 1 4 5 16384 )] ) if $rest eq '/base';
Branch: 1 branch
BranchTrueFalseTotal
if $rest eq "/base" 0 0 0
1060 }
1061 }
1062 0 return ();
1063 }
1064  
1065 # psql im Container: Tabellen und Zaehlungen aus psql des Images, leere Datenbank ohne Daten
1066 3 ▶sub _psql {
Subroutine _psql: called CC=32 SCAR=50.1
1067 3 my ( $d, $name, $c, $img, $av ) = @_;
1068 3 my @a = @$av;
1069 3 my ( @sql, $list );
1070 3 ▶ for ( my $i = 0; $i < @a; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @a) 6 3 9
1071 6 ▶ if ( $a[$i] eq '-c' || $a[$i] eq '--command' ) { push @sql, $a[ ++$i ] }
Branch: 3 branches
BranchTrueFalseTotal
if ($a[$i] eq '-c' or $a[$i] eq '--command') { } 3 3 6
elsif ($a[$i] =~ /\A-[Udh]\z/) { } 3 0 3
elsif ($a[$i] eq '-l' or $a[$i] eq '--list') { } 0 0 0
Condition66%2/3
$a[$i] eq "-c" or $a[$i] eq "--command"
l!l&&r!l&&!r
303
MC/DC50%1/2
$a[$i] eq "-c" or $a[$i] eq "--command"
$a[$i] eq "-c" $a[$i] eq "--command"
Truth table66%2/3
A or B
A= $a[$i] eq "-c"B= $a[$i] eq "--command"
ABresult
1X1
011
000
1072 3 elsif ( $a[$i] =~ /\A-[Udh]\z/ ) { $i++ }
1073 0 ▶ elsif ( $a[$i] eq '-l' || $a[$i] eq '--list' ) { $list = 1 }
Condition0%0/3
$a[$i] eq "-l" or $a[$i] eq "--list"
l!l&&r!l&&!r
000
MC/DC0%0/2
$a[$i] eq "-l" or $a[$i] eq "--list"
$a[$i] eq "-l" $a[$i] eq "--list"
Truth table0%0/3
A or B
A= $a[$i] eq "-l"B= $a[$i] eq "--list"
ABresult
1X1
011
000
1074 }
1075 return ( 'psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory', 0 )
1076 3 ▶ unless $c->{status} eq 'running' && grep { $_ == 5432 } @{ $img->{listens} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless $$c{"status"} eq "running" and grep {$_ == 5432;} @{$$img{"listens"} or [];} 0 3 3
Condition40%2/5
$$c{"status"} eq "running" and grep {$_ == 5432;} @{$$img{"listens"} or [];}
!ll&&!rl&&r
003
$$img{'listens'} || []
l!l
30
MC/DC0%0/2
$$c{"status"} eq "running" and grep {$_ == 5432;} @{$$img{"listens"} or [];}
$$c{"status"} eq "running" grep {$_ == 5432;} @{$$img{"listens"} or [];}
MC/DC0%0/1
$$img{'listens'} || []
$$img{'listens'}
Truth table33%1/3
A and B
A= $$c{"status"} eq "running"B= grep {$_ == 5432;} @{$$img{"listens"} or [];}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$img{'listens'}
Aresult
11
00
1077 3 ▶ my $spec = $img->{psql} || {};
Condition50%1/2
$$img{'psql'} || {}
l!l
30
MC/DC0%0/1
$$img{'psql'} || {}
$$img{'psql'}
Truth table50%1/2
A
A= $$img{'psql'}
Aresult
11
00
1078 3 ▶ my $leer = !defined $c->{data} || $c->{data} eq ( $img->{init_data} // 'leer' );
Condition60%3/5
!defined($$c{'data'}) || $$c{'data'} eq ($$img{'init_data'} // 'leer')
l!l&&r!l&&!r
021
$$img{"init_data"} // "leer"
l!l
03
MC/DC50%1/2
!defined($$c{'data'}) || $$c{'data'} eq ($$img{'init_data'} // 'leer')
!defined($$c{'data'}) $$c{'data'} eq ($$img{'init_data'} // 'leer')
MC/DC0%0/1
$$img{"init_data"} // "leer"
$$img{"init_data"}
Truth table66%2/3
not(A) || B
A= !defined($$c{'data'})B= $$c{'data'} eq ($$img{'init_data'} // 'leer')
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$img{"init_data"}
Aresult
11
00
1079 3 ▶ my @t = $leer ? () : @{ $spec->{tables} || [] };
Branch: 1 branch
BranchTrueFalseTotal
$leer ? : 2 1 3
Condition50%1/2
$$spec{'tables'} || []
l!l
10
MC/DC0%0/1
$$spec{'tables'} || []
$$spec{'tables'}
Truth table50%1/2
A
A= $$spec{'tables'}
Aresult
11
00
1080 3 ▶ my $db = $spec->{database} // 'postgres';
Condition50%1/2
$$spec{"database"} // "postgres"
l!l
03
MC/DC0%0/1
$$spec{"database"} // "postgres"
$$spec{"database"}
Truth table50%1/2
A
A= $$spec{"database"}
Aresult
11
00
1081 3 my @out;
1082 3 ▶ if ($list) { push @out, ' List of databases', ' Name | Owner | Encoding', '-----------+----------+----------',
Branch: 1 branch
BranchTrueFalseTotal
if ($list) 0 3 3
1083 0 ▶ map {" $_ | postgres | UTF8"} 'postgres', ( $leer ? () : $db ), 'template0', 'template1' }
Branch: 1 branch
BranchTrueFalseTotal
$leer ? : 0 0 0
1084 3 for my $q (@sql) {
1085 0 ▶ if ( $q =~ /\A\s*\\l\s*\z/ ) { push @out, map {" $_ | postgres | UTF8"} 'postgres', ( $leer ? () : $db ), 'template0', 'template1'; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($q =~ /\A\s*\\l\s*\z/) 0 3 3
$leer ? : 0 0 0
1086 3 ▶ if ( $q =~ /\A\s*\\dt\b/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($q =~ /\A\s*\\dt\b/) 1 2 3
1087 0 ▶ push @out, @t ? ( ' List of relations', ' Schema | Name | Type | Owner', map {" public | $_ | table | postgres"} @t ) : 'Did not find any relations.';
Branch: 1 branch
BranchTrueFalseTotal
@t ? : 0 1 1
1088 1 next;
1089 }
1090 2 ▶ if ( $q =~ /\A\s*select\s+count\(\*\)\s+from\s+(?:public\.)?"?(\w+)"?\s*;?\s*\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($q =~ /\A\s*select\s+count\(\*\)\s+from\s+(?:public\.)?"?(\w+)"?\s*;?\s*\z/i) 2 0 2
1091 2 my $tb = $1;
1092 2 ▶ return ( join( "\n", @out, "ERROR: relation \"$tb\" does not exist", "LINE 1: select count(*) from $tb" ), 0 ) unless grep { $_ eq $tb } @t;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $tb;} @t 1 1 2
1093 1 ▶ push @out, ' count ', '-------', sprintf( ' %5d', ( $spec->{counts} || {} )->{$tb} // 0 ), '(1 row)';
Condition50%2/4
($$spec{"counts"} || {})->{$tb} // 0
l!l
10
$$spec{'counts'} || {}
l!l
10
MC/DC0%0/1
($$spec{"counts"} || {})->{$tb} // 0
$$spec{'counts'}
Truth table50%1/2
A
A= $$spec{'counts'}
Aresult
11
00
1094 1 next;
1095 }
1096 0 ▶ if ( $q =~ /\A\s*select\s+1\s*;?\s*\z/i ) { push @out, ' ?column? ', '----------', ' 1', '(1 row)'; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($q =~ /\A\s*select\s+1\s*;?\s*\z/i) 0 0 0
1097 0 ▶ if ( $q =~ /\A\s*select\s+current_user\s*;?\s*\z/i ) { push @out, ' current_user ', '--------------', ' ' . ( $spec->{user} // 'postgres' ), '(1 row)'; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($q =~ /\A\s*select\s+current_user\s*;?\s*\z/i) 0 0 0
Condition0%0/2
$$spec{"user"} // "postgres"
l!l
00
MC/DC0%0/1
$$spec{"user"} // "postgres"
$$spec{"user"}
Truth table0%0/2
A
A= $$spec{"user"}
Aresult
11
00
1098 0 ▶ if ( $q =~ /\A\s*select\s+version\(\)/i ) { push @out, ' PostgreSQL ' . ( $img->{version} // '16.4' ) . ' on x86_64-pc-linux-gnu'; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($q =~ /\A\s*select\s+version\(\)/i) 0 0 0
Condition0%0/2
$$img{"version"} // "16.4"
l!l
00
MC/DC0%0/1
$$img{"version"} // "16.4"
$$img{"version"}
Truth table0%0/2
A
A= $$img{"version"}
Aresult
11
00
1099 0 _gap("docker exec $name psql -c $q");
1100 0 return ( join( "\n", @out ), 0 );
1101 }
1102 2 return ( join( "\n", @out ), 1 );
1103 }
1104  
1105 # Lauscht h:p aus Sicht des Containers?
1106 109 ▶sub _reach {
Subroutine _reach: called CC=9 SCAR=35.7
1107 109 my ( $d, $name, $c, $img, $h, $p ) = @_;
1108 109 ▶ if ( $h eq 'localhost' || $h eq '127.0.0.1' ) { return $c->{status} eq 'running' && grep { $_ == $p } @{ $img->{listens} || [] } }
Branch: 1 branch
BranchTrueFalseTotal
if ($h eq "localhost" or $h eq "127.0.0.1") 109 0 109
Condition37%3/8
$h eq "localhost" or $h eq "127.0.0.1"
l!l&&r!l&&!r
10900
$$c{'status'} eq 'running' && grep({$_ == $p;} @{$$img{'listens'} or [];})
!ll&&!rl&&r
00109
$$img{'listens'} || []
l!l
1090
MC/DC0%0/2
$h eq "localhost" or $h eq "127.0.0.1"
$h eq "localhost" $h eq "127.0.0.1"
MC/DC0%0/2
$$c{'status'} eq 'running' && grep({$_ == $p;} @{$$img{'listens'} or [];})
$$c{'status'} eq 'running' grep({$_ == $p;} @{$$img{'listens'} or [];})
MC/DC0%0/1
$$img{'listens'} || []
$$img{'listens'}
Truth table33%1/3
A or B
A= $h eq "localhost"B= $h eq "127.0.0.1"
ABresult
1X1
011
000
Truth table33%1/3
A && B
A= $$c{'status'} eq 'running'B= grep({$_ == $p;} @{$$img{'listens'} or [];})
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$img{'listens'}
Aresult
11
00
1109 0 ▶ my ( $pn, $pc ) = lookup( $d, $name, $h ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
() = lookup($d, $name, $h) or return 0 0 0 0
1110 0 ▶ my $pimg = _image( $d, $pc->{image} ) || {};
Condition0%0/2
_image($d, $$pc{'image'}) || {}
l!l
00
MC/DC0%0/1
_image($d, $$pc{'image'}) || {}
_image($d, $$pc{'image'})
Truth table0%0/2
A
A= _image($d, $$pc{'image'})
Aresult
11
00
1111 0 ▶ return $pc->{status} eq 'running' && grep { $_ == $p } @{ $pimg->{listens} || [] };
Condition0%0/5
$$pc{'status'} eq 'running' && grep({$_ == $p;} @{$$pimg{'listens'} or [];})
!ll&&!rl&&r
000
$$pimg{'listens'} || []
l!l
00
MC/DC0%0/2
$$pc{'status'} eq 'running' && grep({$_ == $p;} @{$$pimg{'listens'} or [];})
$$pc{'status'} eq 'running' grep({$_ == $p;} @{$$pimg{'listens'} or [];})
MC/DC0%0/1
$$pimg{'listens'} || []
$$pimg{'listens'}
Truth table0%0/3
A && B
A= $$pc{'status'} eq 'running'B= grep({$_ == $p;} @{$$pimg{'listens'} or [];})
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$pimg{'listens'}
Aresult
11
00
1112 }
1113  
1114  
1115 # HTTP aus einem Container an einen Dienst (oder sich selbst)
1116 1 ▶sub container_request {
Subroutine container_request: called CC=9 SCAR=27.5
Pod documented
1117 1 my ( $dev, $d, $name, $c, $u ) = @_;
1118 1 my ( $tn, $tc );
1119 1 ▶ if ( $u->{host} eq 'localhost' || $u->{host} eq '127.0.0.1' ) { ( $tn, $tc ) = ( $name, $c ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($$u{'host'} eq 'localhost' or $$u{'host'} eq '127.0.0.1') { } 1 0 1
Condition33%1/3
$$u{"host"} eq "localhost" or $$u{"host"} eq "127.0.0.1"
l!l&&r!l&&!r
100
MC/DC0%0/2
$$u{"host"} eq "localhost" or $$u{"host"} eq "127.0.0.1"
$$u{"host"} eq "localhost" $$u{"host"} eq "127.0.0.1"
Truth table33%1/3
A or B
A= $$u{"host"} eq "localhost"B= $$u{"host"} eq "127.0.0.1"
ABresult
1X1
011
000
1120 else {
1121 0 ( $tn, $tc ) = lookup( $d, $name, $u->{host} );
1122 0 ▶ return { unresolved => 1 } unless $tc;
Branch: 1 branch
BranchTrueFalseTotal
unless $tc 0 0 0
1123 }
1124 1 ▶ my $img = _image( $d, $tc->{image} ) || {};
Condition50%1/2
_image($d, $$tc{'image'}) || {}
l!l
10
MC/DC0%0/1
_image($d, $$tc{'image'}) || {}
_image($d, $$tc{'image'})
Truth table50%1/2
A
A= _image($d, $$tc{'image'})
Aresult
11
00
1125 1 ▶ return undef unless $tc->{status} eq 'running' && grep { $_ == $u->{port} } @{ $img->{listens} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless $$tc{"status"} eq "running" and grep {$_ == $$u{"port"};} @{$$img{"listens"} or [];} 0 1 1
Condition40%2/5
$$tc{"status"} eq "running" and grep {$_ == $$u{"port"};} @{$$img{"listens"} or [];}
!ll&&!rl&&r
001
$$img{'listens'} || []
l!l
10
MC/DC0%0/2
$$tc{"status"} eq "running" and grep {$_ == $$u{"port"};} @{$$img{"listens"} or [];}
$$tc{"status"} eq "running" grep {$_ == $$u{"port"};} @{$$img{"listens"} or [];}
MC/DC0%0/1
$$img{'listens'} || []
$$img{'listens'}
Truth table33%1/3
A and B
A= $$tc{"status"} eq "running"B= grep {$_ == $$u{"port"};} @{$$img{"listens"} or [];}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$img{'listens'}
Aresult
11
00
1126 1 Langertha::Holmgang::Sim::Linux::_part(q{Http});
1127 return Langertha::Holmgang::Sim::Linux::Http::respond( $img->{http} || {}, { method => 'GET', path => $u->{path},
1128 1 ▶ headers => { host => $u->{host} . ":$u->{port}" } }, $tn );
Condition50%1/2
$$img{'http'} || {}
l!l
10
MC/DC0%0/1
$$img{'http'} || {}
$$img{'http'}
Truth table50%1/2
A
A= $$img{'http'}
Aresult
11
00
1129 }
1130  
1131 # --- HTTP von aussen (veroeffentlichte Ports) ---------------------------------------
1132  
1133  
1134 1 ▶sub serve {
Subroutine serve: called CC=20 SCAR=39.7
Pod documented
1135 1 my ( $state, $to, $req, $from, $depth ) = @_;
1136 1 my $dev = $state->{$to};
1137 1 my $d = $dev->{docker};
1138 1 ensure( $dev, $to, $state );
1139 1 ▶ my $local = defined $from && $from eq $to;
Condition33%1/3
defined $from && $from eq $to
!ll&&!rl&&r
001
MC/DC0%0/2
defined $from && $from eq $to
defined $from $from eq $to
Truth table33%1/3
A && B
A= defined $fromB= $from eq $to
ABresult
0X0
100
111
1140 1 ▶ for my $n ( sort keys %{ $d->{containers} || {} } ) {
Condition50%1/2
$$d{'containers'} || {}
l!l
10
MC/DC0%0/1
$$d{'containers'} || {}
$$d{'containers'}
Truth table50%1/2
A
A= $$d{'containers'}
Aresult
11
00
1141 1 my $c = $d->{containers}{$n};
1142 1 ▶ next unless $c->{status} eq 'running';
Branch: 1 branch
BranchTrueFalseTotal
unless $$c{"status"} eq "running" 0 1 1
1143 1 ▶ for my $p ( @{ $c->{config}{ports} || [] } ) {
Condition50%1/2
$$c{'config'}{'ports'} || []
l!l
10
MC/DC0%0/1
$$c{'config'}{'ports'} || []
$$c{'config'}{'ports'}
Truth table50%1/2
A
A= $$c{'config'}{'ports'}
Aresult
11
00
1144 1 ▶ next unless length $p->{published} && $p->{published} == $req->{port};
Branch: 1 branch
BranchTrueFalseTotal
unless length $$p{"published"} and $$p{"published"} == $$req{"port"} 0 1 1
Condition33%1/3
length $$p{"published"} and $$p{"published"} == $$req{"port"}
!ll&&!rl&&r
001
MC/DC0%0/2
length $$p{"published"} and $$p{"published"} == $$req{"port"}
length $$p{"published"} $$p{"published"} == $$req{"port"}
Truth table33%1/3
A and B
A= length $$p{"published"}B= $$p{"published"} == $$req{"port"}
ABresult
0X0
100
111
1145 1 ▶ next if $p->{host_ip} =~ /\A127\./ && !$local;
Branch: 1 branch
BranchTrueFalseTotal
if $$p{"host_ip"} =~ /\A127\./ and not $local 0 1 1
Condition33%1/3
$$p{"host_ip"} =~ /\A127\./ and not $local
!ll&&!rl&&r
010
MC/DC0%0/2
$$p{"host_ip"} =~ /\A127\./ and not $local
$$p{"host_ip"} =~ /\A127\./ not $local
Truth table33%1/3
A and not(B)
A= $$p{"host_ip"} =~ /\A127\./B= not $local
ABresult
0X0
100
111
1146 1 ▶ next unless $p->{host_ip} eq '0.0.0.0' || $p->{host_ip} eq $req->{ip} || ( $local && $p->{host_ip} =~ /\A127\./ && $req->{ip} =~ /\A127\./ );
Branch: 1 branch
BranchTrueFalseTotal
unless $$p{"host_ip"} eq "0.0.0.0" or $$p{"host_ip"} eq $$req{"ip"} or $local and $$p{"host_ip"} =~ /\A127\./ and $$req{"ip"} =~ /\A127\./ 0 1 1
Condition16%2/12
$$p{"host_ip"} eq "0.0.0.0" or $$p{"host_ip"} eq $$req{"ip"} or $local and $$p{"host_ip"} =~ /\A127\./ and $$req{"ip"} =~ /\A127\./
l!l&&r!l&&!r
100
$$p{"host_ip"} eq "0.0.0.0" or $$p{"host_ip"} eq $$req{"ip"}
l!l&&r!l&&!r
010
$local and $$p{"host_ip"} =~ /\A127\./ and $$req{"ip"} =~ /\A127\./
!ll&&!rl&&r
000
$local and $$p{"host_ip"} =~ /\A127\./
!ll&&!rl&&r
000
MC/DC0%0/5
$$p{"host_ip"} eq "0.0.0.0" or $$p{"host_ip"} eq $$req{"ip"} or $local and $$p{"host_ip"} =~ /\A127\./ and $$req{"ip"} =~ /\A127\./
$$p{"host_ip"} eq "0.0.0.0" $$p{"host_ip"} eq $$req{"ip"} $local $$p{"host_ip"} =~ /\A127\./ $$req{"ip"} =~ /\A127\./
Truth table16%1/6
A or B or C and D and E
A= $$p{"host_ip"} eq "0.0.0.0"B= $$p{"host_ip"} eq $$req{"ip"}C= $localD= $$p{"host_ip"} =~ /\A127\./E= $$req{"ip"} =~ /\A127\./
ABCDEresult
1XXXX1
01XXX1
001111
000XX0
0010X0
001100
1147 1 ▶ my $img = _image( $d, $c->{image} ) || {};
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
10
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
1148 return { error => '(56) Recv failure: Connection reset by peer', code => 56 }
1149 1 ▶ unless grep { $_ == $p->{target} } @{ $img->{listens} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ == $$p{"target"};} @{$$img{"listens"} or [];} 0 1 1
Condition50%1/2
$$img{'listens'} || []
l!l
10
MC/DC0%0/1
$$img{'listens'} || []
$$img{'listens'}
Truth table50%1/2
A
A= $$img{'listens'}
Aresult
11
00
1150 1 Langertha::Holmgang::Sim::Linux::_part(q{Http});
1151 1 ▶ return Langertha::Holmgang::Sim::Linux::Http::respond( $img->{http} || {}, $req, "$to $n" );
Condition50%1/2
$$img{'http'} || {}
l!l
10
MC/DC0%0/1
$$img{'http'} || {}
$$img{'http'}
Truth table50%1/2
A
A= $$img{'http'}
Aresult
11
00
1152 }
1153 }
1154 0 return undef;
1155 }
1156  
1157  
1158 0 ▶sub ss_lines {
Subroutine ss_lines: not called CC=6 SCAR=37.4
Pod documented
1159 0 my ($dev) = @_;
1160 0 my $d = $dev->{docker};
1161 0 my ( @l, $pid );
1162 0 $pid = 4100;
1163 0 ▶ for my $n ( sort keys %{ $d->{containers} || {} } ) {
Condition0%0/2
$$d{'containers'} || {}
l!l
00
MC/DC0%0/1
$$d{'containers'} || {}
$$d{'containers'}
Truth table0%0/2
A
A= $$d{'containers'}
Aresult
11
00
1164 0 my $c = $d->{containers}{$n};
1165 0 ▶ next unless $c->{status} eq 'running';
Branch: 1 branch
BranchTrueFalseTotal
unless $$c{"status"} eq "running" 0 0 0
1166 0 ▶ for my $p ( grep { length $_->{published} } @{ $c->{config}{ports} || [] } ) {
Condition0%0/2
$$c{'config'}{'ports'} || []
l!l
00
MC/DC0%0/1
$$c{'config'}{'ports'} || []
$$c{'config'}{'ports'}
Truth table0%0/2
A
A= $$c{'config'}{'ports'}
Aresult
11
00
1167 0 push @l, sprintf( '%-6s %-7s %-6s %-6s %-25s %-25s %s', 'tcp', 'LISTEN', 0, 4096, "$p->{host_ip}:$p->{published}", '0.0.0.0:*',
1168 'users:(("docker-proxy",pid=' . $pid++ . ',fd=4))' );
1169 }
1170 }
1171 0 return @l;
1172 }
1173  
1174 # --- Kommandozeile ---------------------------------------------------------------------
1175  
1176  
1177 56 ▶sub docker {
Subroutine docker: called CC=59 SCAR=68.4
Pod documented
1178 56 my ( $dev, $av, $ctx, $stdin ) = @_;
1179 56 my $d = $dev->{docker};
1180 56 ensure( $dev, $ctx->{host}, $ctx->{state} );
1181 56 my @a = @$av;
1182 56 ▶ my $sub = shift @a // return ( "Usage: docker [OPTIONS] COMMAND\n\nA self-sufficient runtime for containers", 0 );
Condition50%1/2
shift @a // (return "Usage: docker [OPTIONS] COMMAND\n\nA self-sufficient runtime for containers", 0)
l!l
560
MC/DC0%0/1
shift @a // (return "Usage: docker [OPTIONS] COMMAND\n\nA self-sufficient runtime for containers", 0)
shift @a
Truth table50%1/2
A
A= shift @a
Aresult
11
00
1183 56 ▶ return _compose( $dev, \@a, $ctx ) if $sub eq 'compose';
Branch: 1 branch
BranchTrueFalseTotal
if $sub eq "compose" 33 23 56
1184 0 ▶ if ( $sub eq 'version' || $sub eq '--version' || $sub eq '-v' ) { return ( 'Docker version 26.1.5, build a72d7cd', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "version" or $sub eq "--version" or $sub eq "-v") 0 23 23
Condition33%2/6
$sub eq "version" or $sub eq "--version" or $sub eq "-v"
l!l&&r!l&&!r
0023
$sub eq "version" or $sub eq "--version"
l!l&&r!l&&!r
0023
MC/DC0%0/3
$sub eq "version" or $sub eq "--version" or $sub eq "-v"
$sub eq "version" $sub eq "--version" $sub eq "-v"
Truth table25%1/4
A or B or C
A= $sub eq "version"B= $sub eq "--version"C= $sub eq "-v"
ABCresult
1XX1
01X1
0011
0000
1185 0 ▶ if ( $sub eq 'container' ) { $sub = shift(@a) // ''; $sub = 'ps' if $sub eq 'ls' }
Branch: 2 branches
BranchTrueFalseTotal
if ($sub eq "container") 0 23 23
if $sub eq "ls" 0 0 0
Condition0%0/2
shift @a // ""
l!l
00
MC/DC0%0/1
shift @a // ""
shift @a
Truth table0%0/2
A
A= shift @a
Aresult
11
00
1186 23 ▶ if ( $sub eq 'ps' ) { return _docker_ps( $d, \@a ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "ps") 2 21 23
1187 21 ▶ if ( $sub eq 'logs' ) { return _docker_logs( $d, \@a, 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "logs") 2 19 21
1188 19 ▶ if ( $sub eq 'inspect' ) { return _inspect( $d, \@a ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "inspect") 8 11 19
1189 11 ▶ if ( $sub =~ /\A(?:restart|stop|start|rm|kill)\z/ ) { return _docker_lifecycle( $dev, $d, $sub, \@a, $ctx ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sub =~ /\A(?:restart|stop|start|rm|kill)\z/) 1 10 11
1190 10 ▶ if ( $sub eq 'exec' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "exec") 7 3 10
1191 7 my @x = @a;
1192 0 ▶ while ( @x && $x[0] =~ /\A-/ ) { my $o = shift @x; shift @x if $o =~ /\A-(?:u|e|w|-user|-env|-workdir)\z/ }
Branch: 2 branches
BranchTrueFalseTotal
if (@x and $x[0] =~ /\A-/) 0 7 7
if $o =~ /\A-(?:u|e|w|-user|-env|-workdir)\z/ 0 0 0
Condition33%1/3
@x and $x[0] =~ /\A-/
!ll&&!rl&&r
070
MC/DC0%0/2
@x and $x[0] =~ /\A-/
@x $x[0] =~ /\A-/
Truth table33%1/3
A and B
A= @xB= $x[0] =~ /\A-/
ABresult
0X0
100
111
1193 7 ▶ my $n = shift @x // return ( '"docker exec" requires at least 2 arguments.', 0 );
Condition50%1/2
shift @x // (return "\"docker exec\" requires at least 2 arguments.", 0)
l!l
70
MC/DC0%0/1
shift @x // (return "\"docker exec\" requires at least 2 arguments.", 0)
shift @x
Truth table50%1/2
A
A= shift @x
Aresult
11
00
1194 0 ▶ my $c = $d->{containers}{$n} // ( map { $d->{containers}{$_} } grep { _id( $_, $d->{containers}{$_}{seq} ) =~ /\A\Q$n\E/ } keys %{ $d->{containers} } )[0];
Condition33%1/3
$$d{"containers"}{$n} // (map {$$d{"containers"}{$_};} grep({_id($_, $$d{"containers"}{$_}{"seq"}) =~ /\A\Q$n\E/;} keys %{$$d{"containers"};}))[0]
l!l&&r!l&&!r
700
MC/DC0%0/2
$$d{"containers"}{$n} // (map {$$d{"containers"}{$_};} grep({_id($_, $$d{"containers"}{$_}{"seq"}) =~ /\A\Q$n\E/;} keys %{$$d{"containers"};}))[0]
$$d{"containers"}{$n} (map {$$d{"containers"}{$_};} grep({_id($_, $$d{"containers"}{$_}{"seq"}) =~ /\A\Q$n\E/;} keys %{$$d{"containers"};}))[0]
Truth table33%1/3
A // B
A= $$d{"containers"}{$n}B= (map {$$d{"containers"}{$_};} grep({_id($_, $$d{"containers"}{$_}{"seq"}) =~ /\A\Q$n\E/;} keys %{$$d{"containers"};}))[0]
ABresult
1X1
011
000
1195 7 ▶ return ( "Error response from daemon: No such container: $n", 0 ) unless $c;
Branch: 1 branch
BranchTrueFalseTotal
unless $c 0 7 7
1196 7 ▶ return ( "Error response from daemon: container " . _id( $n, $c->{seq} ) . " is not running", 0 ) unless $c->{status} eq 'running';
Branch: 1 branch
BranchTrueFalseTotal
unless $$c{"status"} eq "running" 0 7 7
1197 7 return _exec( $dev, $d, $n, $c, \@x );
1198 }
1199 3 ▶ if ( $sub eq 'volume' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "volume") 0 3 3
1200 0 ▶ my $v = shift @a // 'ls';
Condition0%0/2
shift @a // "ls"
l!l
00
MC/DC0%0/1
shift @a // "ls"
shift @a
Truth table0%0/2
A
A= shift @a
Aresult
11
00
1201 0 ▶ if ( $v eq 'ls' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v eq "ls") 0 0 0
1202 0 ▶ return ( join( "\n", sprintf( '%-10s%s', 'DRIVER', 'VOLUME NAME' ), map { sprintf( '%-10s%s', 'local', $_ ) } sort keys %{ $d->{volumes} || {} } ), 1 );
Condition0%0/2
$$d{'volumes'} || {}
l!l
00
MC/DC0%0/1
$$d{'volumes'} || {}
$$d{'volumes'}
Truth table0%0/2
A
A= $$d{'volumes'}
Aresult
11
00
1203 }
1204 0 ▶ if ( $v eq 'inspect' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v eq "inspect") 0 0 0
1205 0 my @o;
1206 0 for my $n ( grep { !/\A-/ } @a ) {
1207 0 ▶ return ( "Error response from daemon: get $n: no such volume", 0 ) unless $d->{volumes}{$n};
Branch: 1 branch
BranchTrueFalseTotal
unless $$d{"volumes"}{$n} 0 0 0
1208 push @o, { Name => $n, Driver => 'local', Mountpoint => "/var/lib/docker/volumes/$n/_data", Scope => 'local',
1209 0 ▶ Labels => { ( $d->{volumes}{$n}{project} ? ( 'com.docker.compose.project' => $d->{volumes}{$n}{project} ) : () ) } };
Branch: 1 branch
BranchTrueFalseTotal
$$d{'volumes'}{$n}{'project'} ? : 0 0 0
1210 }
1211 0 return ( $OUT_JSON->encode( \@o ) =~ s/\n\z//r, 1 );
1212 }
1213 0 ▶ if ( $v eq 'rm' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v eq "rm") 0 0 0
1214 0 for my $n ( grep { !/\A-/ } @a ) {
1215 0 ▶ return ( "Error response from daemon: get $n: no such volume", 0 ) unless $d->{volumes}{$n};
Branch: 1 branch
BranchTrueFalseTotal
unless $$d{"volumes"}{$n} 0 0 0
1216 0 ▶ my ($user) = grep { grep { $_->{type} eq 'volume' && $_->{source} eq $n } @{ $d->{containers}{$_}{config}{volumes} || [] } } sort keys %{ $d->{containers} };
Condition0%0/5
$$_{'type'} eq 'volume' && $$_{'source'} eq $n
!ll&&!rl&&r
000
$$d{'containers'}{$_}{'config'}{'volumes'} || []
l!l
00
MC/DC0%0/2
$$_{'type'} eq 'volume' && $$_{'source'} eq $n
$$_{'type'} eq 'volume' $$_{'source'} eq $n
MC/DC0%0/1
$$d{'containers'}{$_}{'config'}{'volumes'} || []
$$d{'containers'}{$_}{'config'}{'volumes'}
Truth table0%0/3
A && B
A= $$_{'type'} eq 'volume'B= $$_{'source'} eq $n
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$d{'containers'}{$_}{'config'}{'volumes'}
Aresult
11
00
1217 0 ▶ return ( "Error response from daemon: remove $n: volume is in use - [" . _id( $user, $d->{containers}{$user}{seq} ) . "]", 0 ) if defined $user;
Branch: 1 branch
BranchTrueFalseTotal
if defined $user 0 0 0
1218 0 delete $d->{volumes}{$n};
1219 }
1220 0 return ( join( "\n", grep { !/\A-/ } @a ), 1 );
1221 }
1222 0 return _gap("docker volume $v");
1223 }
1224 3 ▶ if ( $sub eq 'network' && ( $a[0] // 'ls' ) eq 'ls' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "network" and ($a[0] // "ls") eq "ls") 0 3 3
Condition20%1/5
$sub eq "network" and ($a[0] // "ls") eq "ls"
!ll&&!rl&&r
300
$a[0] // "ls"
l!l
00
MC/DC0%0/2
$sub eq "network" and ($a[0] // "ls") eq "ls"
$sub eq "network" $a[0]
Truth table33%1/3
A and B
A= $sub eq "network"B= $a[0]
ABresult
0X0
100
111
1225 return ( join( "\n", sprintf( '%-14s %-24s %-8s %s', 'NETWORK ID', 'NAME', 'DRIVER', 'SCOPE' ),
1226 0 ▶ map { sprintf( '%-14s %-24s %-8s %s', substr( Digest::SHA::sha1_hex($_), 0, 12 ), $_, 'bridge', 'local' ) } 'bridge', 'host', sort keys %{ $d->{networks} || {} } ), 1 );
Condition0%0/2
$$d{'networks'} || {}
l!l
00
MC/DC0%0/1
$$d{'networks'} || {}
$$d{'networks'}
Truth table0%0/2
A
A= $$d{'networks'}
Aresult
11
00
1227 }
1228 3 ▶ if ( $sub eq 'images' || ( $sub eq 'image' && ( $a[0] // '' ) eq 'ls' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "images" or $sub eq "image" and ($a[0] // "") eq "ls") 0 3 3
Condition25%2/8
$sub eq "images" or $sub eq "image" and ($a[0] // "") eq "ls"
l!l&&r!l&&!r
003
$sub eq "image" and ($a[0] // "") eq "ls"
!ll&&!rl&&r
300
$a[0] // ""
l!l
00
MC/DC0%0/3
$sub eq "images" or $sub eq "image" and ($a[0] // "") eq "ls"
$sub eq "images" $sub eq "image" $a[0]
Truth table25%1/4
A or B and C
A= $sub eq "images"B= $sub eq "image"C= $a[0]
ABCresult
1XX1
0111
00X0
0100
1229 return ( join( "\n", sprintf( '%-44s %-12s %-14s', 'REPOSITORY', 'TAG', 'IMAGE ID' ),
1230 0 ▶ map { my ( $r, $t ) = /\A(.+):([^:]+)\z/; sprintf( '%-44s %-12s %-14s', $r, $t, _img_id( $_, $d->{images}{$_} ) ) } sort keys %{ $d->{images} || {} } ), 1 );
Condition0%0/2
$$d{'images'} || {}
l!l
00
MC/DC0%0/1
$$d{'images'} || {}
$$d{'images'}
Truth table0%0/2
A
A= $$d{'images'}
Aresult
11
00
1231 }
1232 3 ▶ if ( $sub eq 'pull' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "pull") 0 3 3
1233 0 my ($ref) = grep { !/\A-/ } @a;
1234 0 ▶ return ( '"docker pull" requires exactly 1 argument.', 0 ) unless defined $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref 0 0 0
1235 0 ▶ $ref .= ':latest' unless $ref =~ m{:[^/]+\z};
Branch: 1 branch
BranchTrueFalseTotal
unless $ref =~ m[:[^/]+\z] 0 0 0
1236 0 ▶ my $reg = ( $d->{registry} || {} )->{$ref};
Condition0%0/2
$$d{'registry'} || {}
l!l
00
MC/DC0%0/1
$$d{'registry'} || {}
$$d{'registry'}
Truth table0%0/2
A
A= $$d{'registry'}
Aresult
11
00
1237 0 ▶ return ( "Status: Image is up to date for $ref", 1 )
Branch: 1 branch
BranchTrueFalseTotal
if _image($d, $ref) and !$reg || $JSON->encode($reg) eq $JSON->encode(_image($d, $ref)) 0 0 0
Condition0%0/6
_image($d, $ref) and !$reg || $JSON->encode($reg) eq $JSON->encode(_image($d, $ref))
!ll&&!rl&&r
000
not $reg or $JSON->encode($reg) eq $JSON->encode(_image($d, $ref))
l!l&&r!l&&!r
000
MC/DC0%0/3
_image($d, $ref) and !$reg || $JSON->encode($reg) eq $JSON->encode(_image($d, $ref))
_image($d, $ref) not $reg $JSON->encode($reg) eq $JSON->encode(_image($d, $ref))
Truth table0%0/4
A and not(B) or C
A= _image($d, $ref)B= not $regC= $JSON->encode($reg) eq $JSON->encode(_image($d, $ref))
ABCresult
0XX0
1000
11X1
1011
1238 if _image( $d, $ref ) && ( !$reg || $JSON->encode($reg) eq $JSON->encode( _image( $d, $ref ) ) );
1239 0 my ( $ok, $e ) = _pull( $d, $ref );
1240 0 ▶ return ( $e, 0 ) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
1241 0 return ( "Status: Downloaded newer image for $ref", 1 );
1242 }
1243 3 ▶ if ( $sub eq 'stats' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "stats") 1 2 3
1244 1 my @n = grep { $d->{containers}{$_}{status} eq 'running' } sort keys %{ $d->{containers} };
1245 return ( join( "\n", sprintf( '%-14s %-24s %-8s %-22s %-7s', 'CONTAINER ID', 'NAME', 'CPU %', 'MEM USAGE / LIMIT', 'MEM %' ),
1246 1 map { my $c = $d->{containers}{$_}; my $lim = $c->{mem_limit_bytes};
1247 1 ▶ sprintf( '%-14s %-24s %-8s %-22s %-7s', _id( $_, $c->{seq} ), $_, '0.42%', '96.3MiB / ' . ( $lim ? sprintf( '%.0fMiB', $lim / 1048576 ) : '3.84GiB' ),
Branch: 2 branches
BranchTrueFalseTotal
$lim ? : 0 1 1
$lim ? : 0 1 1
1248 $lim ? sprintf( '%.2f%%', 96.3 * 1048576 / $lim * 100 ) : '2.45%' ) } @n ), 1 );
1249 }
1250 2 ▶ if ( $sub eq 'info' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub eq "info") 2 0 2
1251 2 ▶ my @c = values %{ $d->{containers} || {} };
Condition50%1/2
$$d{'containers'} || {}
l!l
20
MC/DC0%0/1
$$d{'containers'} || {}
$$d{'containers'}
Truth table50%1/2
A
A= $$d{'containers'}
Aresult
11
00
1252 return ( join( "\n", 'Client: Docker Engine - Community', ' Version: 26.1.5', '', 'Server:',
1253 2 ' Containers: ' . scalar(@c), ' Running: ' . scalar( grep { $_->{status} eq 'running' } @c ),
1254 2 ▶ ' Stopped: ' . scalar( grep { $_->{status} ne 'running' } @c ), ' Images: ' . scalar( keys %{ $d->{images} || {} } ),
Condition50%1/2
$$d{'images'} || {}
l!l
20
MC/DC0%0/1
$$d{'images'} || {}
$$d{'images'}
Truth table50%1/2
A
A= $$d{'images'}
Aresult
11
00
1255 ' Server Version: 26.1.5', ' Storage Driver: overlay2', ' Logging Driver: json-file', ' Cgroup Driver: systemd',
1256 ' Kernel Version: 6.1.0-26-amd64', ' Operating System: Debian GNU/Linux 12 (bookworm)', ' Docker Root Dir: /var/lib/docker' ), 1 );
1257 }
1258 0 ▶ return _gap("docker $sub") if $sub =~ /\A(?:run|build|cp|top|events|attach|system|login|tag|push|commit|save|load|update)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $sub =~ /\A(?:run|build|cp|top|events|attach|system|login|tag|push|commit|save|load|update)\z/ 0 0 0
1259 0 return ( "docker: '$sub' is not a docker command.\nSee 'docker --help'", 0 );
1260 }
1261  
1262 9 ▶sub _status_text {
Subroutine _status_text: called CC=9 SCAR=25.2
1263 9 my ($c) = @_;
1264 9 ▶ return 'Up 2 hours' . ( defined $c->{health} ? " ($c->{health})" : '' ) if $c->{status} eq 'running' && $c->{initial};
Branch: 2 branches
BranchTrueFalseTotal
if $$c{"status"} eq "running" and $$c{"initial"} 7 2 9
defined $$c{'health'} ? : 4 3 7
Condition66%2/3
$$c{"status"} eq "running" and $$c{"initial"}
!ll&&!rl&&r
207
MC/DC50%1/2
$$c{"status"} eq "running" and $$c{"initial"}
$$c{"status"} eq "running" $$c{"initial"}
Truth table66%2/3
A and B
A= $$c{"status"} eq "running"B= $$c{"initial"}
ABresult
0X0
100
111
1265 2 ▶ return 'Up 3 seconds' . ( defined $c->{health} ? " ($c->{health})" : '' ) if $c->{status} eq 'running';
Branch: 2 branches
BranchTrueFalseTotal
if $$c{"status"} eq "running" 0 2 2
defined $$c{'health'} ? : 0 0 0
1266 2 ▶ return "Restarting (" . ( $c->{exit_code} // 1 ) . ") 4 seconds ago" if $c->{status} eq 'restarting';
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"status"} eq "restarting" 0 2 2
Condition0%0/2
$$c{"exit_code"} // 1
l!l
00
MC/DC0%0/1
$$c{"exit_code"} // 1
$$c{"exit_code"}
Truth table0%0/2
A
A= $$c{"exit_code"}
Aresult
11
00
1267 2 ▶ return "Exited ($c->{exit_code}) 5 seconds ago" if $c->{status} eq 'exited';
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"status"} eq "exited" 0 2 2
1268 2 return 'Created';
1269 }
1270  
1271 9 ▶sub _ports_text {
Subroutine _ports_text: called CC=8 SCAR=21.2
1272 9 my ( $c, $img ) = @_;
1273 9 my @p;
1274 my %pub;
1275 9 ▶ for my $p ( @{ $c->{config}{ports} || [] } ) {
Condition50%1/2
$$c{'config'}{'ports'} || []
l!l
90
MC/DC0%0/1
$$c{'config'}{'ports'} || []
$$c{'config'}{'ports'}
Truth table50%1/2
A
A= $$c{'config'}{'ports'}
Aresult
11
00
1276 5 ▶ next unless length $p->{published};
Branch: 1 branch
BranchTrueFalseTotal
unless length $$p{"published"} 0 5 5
1277 5 $pub{ $p->{target} } = 1;
1278 5 ▶ push @p, ( $p->{host_ip} eq '0.0.0.0' ? '0.0.0.0' : $p->{host_ip} ) . ":$p->{published}->$p->{target}/tcp" if $c->{status} eq 'running';
Branch: 2 branches
BranchTrueFalseTotal
if $$c{"status"} eq "running" 3 2 5
$$p{'host_ip'} eq '0.0.0.0' ? : 0 3 3
1279 }
1280 9 ▶ push @p, map {"$_/tcp"} grep { !$pub{$_} } @{ $img->{listens} || [] } if $c->{status} eq 'running';
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"status"} eq "running" 7 2 9
Condition50%1/2
$$img{'listens'} || []
l!l
70
MC/DC0%0/1
$$img{'listens'} || []
$$img{'listens'}
Truth table50%1/2
A
A= $$img{'listens'}
Aresult
11
00
1281 9 return join ', ', @p;
1282 }
1283  
1284 # Zeile eines Containers fuer ps --format (Felder wie docker/compose)
1285 3 ▶sub _ps_row {
Subroutine _ps_row: called CC=4 SCAR=14.3
1286 3 my ( $d, $n ) = @_;
1287 3 my $c = $d->{containers}{$n};
1288 return {
1289 ID => _id( $n, $c->{seq} ), Names => $n, Name => $n, Image => $c->{image}, Command => '"docker-entrypoint.s…"',
1290 Service => $c->{service}, Project => $c->{project}, Status => _status_text($c), State => $c->{status},
1291 Health => $c->{health} // '', Ports => _ports_text( $c, _image( $d, $c->{image} ) || {} ),
1292 3 ▶ CreatedAt => '2026-10-24 06:00:00 +0200 CEST', RunningFor => 'About an hour ago', ExitCode => $c->{exit_code} // 0,
Condition66%4/6
$$c{"health"} // ""
l!l
12
_image($d, $$c{'image'}) || {}
l!l
30
$$c{"exit_code"} // 0
l!l
03
MC/DC100%1/1
$$c{"health"} // ""
$$c{"health"}
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
MC/DC0%0/1
$$c{"exit_code"} // 0
$$c{"exit_code"}
Truth table100%2/2
A
A= $$c{"health"}
Aresult
11
00
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
Truth table50%1/2
A
A= $$c{"exit_code"}
Aresult
11
00
1293 Labels => "com.docker.compose.project=$c->{project},com.docker.compose.service=$c->{service}",
1294 };
1295 }
1296  
1297  
1298 8 ▶sub gofmt {
Subroutine gofmt: called CC=3 SCAR=11.1
Pod documented
1299 8 my ( $fmt, $rows ) = @_;
1300 8 my $table = $fmt =~ s/\Atable\s+//;
1301 8 $fmt =~ s/\\t/\t/g;
1302 8 $fmt =~ s/\\n/\n/g;
1303 8 my $tree = eval { _tpl_parse($fmt) };
1304 0 ▶ if ( !$tree ) { push @Langertha::Holmgang::Sim::Linux::GAPS, "--format $fmt"; return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless ($tree) 0 8 8
1305 8 my @out = map { _tpl_run( $tree, $_, {} ) } @$rows;
1306 8 ▶ if ($table) {
Branch: 1 branch
BranchTrueFalseTotal
if ($table) 1 7 8
1307 1 ( my $h = $fmt ) =~ s{\{\{\s*(?:json\s+)?\.((?:\w+\.)*(\w+))\s*\}\}}{uc $2}ge;
1308 1 unshift @out, $h;
1309 }
1310 8 return join "\n", @out;
1311 }
1312  
1313 # Go-Vorlagen (Teilmenge): Text, {{.A.B}}, {{json X}}, {{X}} mit $k/$v/., {{range [$k, $v :=] X}}…{{end}},
1314 # {{if X}}…{{else}}…{{end}}, {{println …}}, {{index X "k"}}
1315 8 ▶sub _tpl_parse {
Subroutine _tpl_parse: called CC=13 SCAR=32.1
1316 8 my ($s) = @_;
1317 8 my @stack = ( [] );
1318 8 ▶ while ( length $s ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $s) 26 8 34
1319 26 ▶ if ( $s =~ s/\A\{\{-?\s*(.*?)\s*-?\}\}//s ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($s =~ s/\A\{\{-?\s*(.*?)\s*-?\}\}//s) { } 19 7 26
elsif ($s =~ s/\A((?:(?!\{\{).)+)//s) { } 7 0 7
1320 19 my $a = $1;
1321 19 ▶ if ( $a =~ /\Arange\s+(?:\$(\w+)\s*,\s*\$(\w+)\s*:=\s*|\$(\w+)\s*:=\s*)?(.+)\z/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($a =~ /\Arange\s+(?:\$(\w+)\s*,\s*\$(\w+)\s*:=\s*|\$(\w+)\s*:=\s*)?(.+)\z/) { } 2 17 19
elsif ($a =~ /\Aif\s+(.+)\z/) { } 0 17 17
elsif ($a eq 'else') { } 0 17 17
elsif ($a eq 'end') { } 2 15 17
1322 2 ▶ my $n = { op => 'range', k => $1, v => $2 // $3, x => $4, body => [] };
Condition66%2/3
$2 // $3
l!l&&r!l&&!r
110
MC/DC0%0/2
$2 // $3
$2 $3
Truth table66%2/3
A // B
A= $2B= $3
ABresult
1X1
011
000
1323 2 push @{ $stack[-1] }, $n;
1324 2 push @stack, $n->{body};
1325 }
1326 elsif ( $a =~ /\Aif\s+(.+)\z/ ) {
1327 0 my $n = { op => 'if', x => $1, body => [], else => [] };
1328 0 push @{ $stack[-1] }, $n;
1329 0 push @stack, $n->{body};
1330 0 $n->{_if} = 1;
1331 }
1332 elsif ( $a eq 'else' ) {
1333 0 pop @stack;
1334 0 ▶ my ($n) = grep { ref $_ eq 'HASH' && $_->{op} eq 'if' } reverse @{ $stack[-1] };
Condition0%0/3
ref $_ eq 'HASH' && $$_{'op'} eq 'if'
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ eq 'HASH' && $$_{'op'} eq 'if'
ref $_ eq 'HASH' $$_{'op'} eq 'if'
Truth table0%0/3
A && B
A= ref $_ eq 'HASH'B= $$_{'op'} eq 'if'
ABresult
0X0
100
111
1335 0 ▶ die "else ohne if\n" unless $n;
Branch: 1 branch
BranchTrueFalseTotal
unless $n 0 0 0
1336 0 push @stack, $n->{else};
1337 }
1338 2 ▶ elsif ( $a eq 'end' ) { die "end zu viel\n" if @stack == 1; pop @stack }
Branch: 1 branch
BranchTrueFalseTotal
if @stack == 1 0 2 2
1339 15 else { push @{ $stack[-1] }, { op => 'expr', x => $a } }
1340 }
1341 7 elsif ( $s =~ s/\A((?:(?!\{\{).)+)//s ) { push @{ $stack[-1] }, $1 }
1342 0 else { die "kaputt\n" }
1343 }
1344 8 ▶ die "end fehlt\n" if @stack > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @stack > 1 0 8 8
1345 8 return $stack[0];
1346 }
1347  
1348 18 ▶sub _tpl_val {
Subroutine _tpl_val: called CC=7 SCAR=20.2
1349 18 my ( $x, $dot, $vars ) = @_;
1350 18 $x =~ s/\A\s+|\s+\z//g;
1351 18 ▶ return $1 if $x =~ /\A"(.*)"\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $x =~ /\A"(.*)"\z/ 0 18 18
1352 18 my ( $root, $path );
1353 18 ▶ if ( $x =~ /\A\$(\w+)((?:\.\w+)*)\z/ ) { ( $root, $path ) = ( $vars->{$1}, $2 ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($x =~ /\A\$(\w+)((?:\.\w+)*)\z/) { } 1 17 18
elsif ($x =~ /\A\.((?:\w+\.?)*)\z/) { } 17 0 17
1354 17 elsif ( $x =~ /\A\.((?:\w+\.?)*)\z/ ) { ( $root, $path ) = ( $dot, ".$1" ) }
1355 0 else { die "unbekannt: $x\n" }
1356 18 my $v = $root;
1357 18 ▶ for my $k ( grep { length } split /\./, $path // '' ) { $v = ref $v eq 'HASH' ? $v->{$k} : undef }
Branch: 1 branch
BranchTrueFalseTotal
ref $v eq 'HASH' ? : 26 0 26
Condition50%1/2
$path // ""
l!l
180
MC/DC0%0/1
$path // ""
$path
Truth table50%1/2
A
A= $path
Aresult
11
00
1358 18 return $v;
1359 }
1360  
1361 14 ▶sub _tpl_text {
Subroutine _tpl_text: called CC=6 SCAR=22.1
1362 14 my ($v) = @_;
1363 14 ▶ return '<no value>' unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 14 14
1364 14 ▶ return $v ? 'true' : 'false' if JSON::MaybeXS::is_bool($v);
Branch: 2 branches
BranchTrueFalseTotal
if JSON::MaybeXS::is_bool($v) 2 12 14
$v ? : 1 1 2
1365 12 ▶ return $v unless ref $v;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $v 12 0 12
1366 0 ▶ return '[' . join( ' ', map { _tpl_text($_) } @$v ) . ']' if ref $v eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $v eq "ARRAY" 0 0 0
1367 0 return 'map[' . join( ' ', map { "$_:" . _tpl_text( $v->{$_} ) } sort keys %$v ) . ']';
1368 }
1369  
1370 17 ▶sub _tpl_expr {
Subroutine _tpl_expr: called CC=7 SCAR=21.5
1371 17 my ( $x, $dot, $vars ) = @_;
1372 17 ▶ return $JSON->encode( _tpl_val( $1, $dot, $vars ) // undef ) if $x =~ /\Ajson\s+(.+)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $x =~ /\Ajson\s+(.+)\z/ 2 15 17
Condition100%2/2
_tpl_val($1, $dot, $vars) // undef
l!l
11
MC/DC100%1/1
_tpl_val($1, $dot, $vars) // undef
_tpl_val($1, $dot, $vars)
Truth table100%2/2
A
A= _tpl_val($1, $dot, $vars)
Aresult
11
00
1373 0 ▶ if ( $x =~ /\Aprintln(?:\s+(.*))?\z/ ) { my @a = defined $1 ? split( ' ', $1 ) : (); return join( ' ', map { _tpl_text( _tpl_val( $_, $dot, $vars ) ) } @a ) . "\n" }
Branch: 2 branches
BranchTrueFalseTotal
if ($x =~ /\Aprintln(?:\s+(.*))?\z/) 1 14 15
defined $1 ? : 0 1 1
1374 0 ▶ if ( $x =~ /\Aindex\s+(\S+)\s+"([^"]*)"\z/ ) { my $m = _tpl_val( $1, $dot, $vars ); return _tpl_text( ref $m eq 'HASH' ? $m->{$2} : undef ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($x =~ /\Aindex\s+(\S+)\s+"([^"]*)"\z/) 0 14 14
ref $m eq 'HASH' ? : 0 0 0
1375 14 return _tpl_text( _tpl_val( $x, $dot, $vars ) );
1376 }
1377  
1378 11 ▶sub _tpl_run {
Subroutine _tpl_run: called CC=13 SCAR=28.8
1379 11 my ( $tree, $dot, $vars ) = @_;
1380 11 my $out = '';
1381 11 for my $n (@$tree) {
1382 27 ▶ if ( !ref $n ) { $out .= $n; next }
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $n) 8 19 27
1383 19 ▶ if ( $n->{op} eq 'expr' ) { $out .= _tpl_expr( $n->{x}, $dot, $vars ); next }
Branch: 1 branch
BranchTrueFalseTotal
if ($$n{"op"} eq "expr") 17 2 19
1384 2 ▶ if ( $n->{op} eq 'if' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$n{"op"} eq "if") 0 2 2
1385 0 my $v = _tpl_val( $n->{x}, $dot, $vars );
1386 0 ▶ my $t = ref $v eq 'ARRAY' ? @$v : ref $v eq 'HASH' ? %$v : $v;
Branch: 2 branches
BranchTrueFalseTotal
ref $v eq 'ARRAY' ? : 0 0 0
ref $v eq 'HASH' ? : 0 0 0
1387 0 ▶ $out .= _tpl_run( $t ? $n->{body} : $n->{else}, $dot, $vars );
Branch: 1 branch
BranchTrueFalseTotal
$t ? : 0 0 0
1388 0 next;
1389 }
1390 2 my $v = _tpl_val( $n->{x}, $dot, $vars );
1391 2 ▶ my @it = ref $v eq 'HASH' ? map { [ $_, $v->{$_} ] } sort keys %$v : ref $v eq 'ARRAY' ? map { [ $_, $v->[$_] ] } 0 .. $#$v : ();
Branch: 2 branches
BranchTrueFalseTotal
ref $v eq 'HASH' ? : 1 1 2
ref $v eq 'ARRAY' ? : 1 0 1
1392 2 for my $i (@it) {
1393 2 my %v2 = %$vars;
1394 2 ▶ if ( defined $n->{k} ) { $v2{ $n->{k} } = $i->[0]; $v2{ $n->{v} } = $i->[1] }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $$n{'k'}) { } 1 1 2
elsif (defined $$n{'v'}) { } 0 1 1
1395 0 elsif ( defined $n->{v} ) { $v2{ $n->{v} } = $i->[1] }
1396 2 $out .= _tpl_run( $n->{body}, $i->[1], \%v2 );
1397 }
1398 }
1399 11 return $out;
1400 }
1401  
1402 4 ▶sub _ps_filter {
Subroutine _ps_filter: called CC=18 SCAR=50.8
1403 4 my ( $d, $n, $filters ) = @_;
1404 4 my $c = $d->{containers}{$n};
1405 4 for my $f (@$filters) {
1406 2 my ( $k, $v ) = split /=/, $f, 2;
1407 2 ▶ $v //= '';
Condition50%1/2
$v //= ""
l!l
20
MC/DC0%0/1
$v //= ""
$v
Truth table50%1/2
A
A= $v
Aresult
11
00
1408 2 ▶ if ( $k eq 'name' ) { return 0 unless $n =~ /$v/ }
Branch: 6 branches
BranchTrueFalseTotal
if ($k eq 'name') { } 2 0 2
elsif ($k eq 'status') { } 0 0 0
elsif ($k eq 'health') { } 0 0 0
elsif ($k eq 'label') { } 0 0 0
elsif ($k eq 'ancestor') { } 0 0 0
unless $n =~ /$v/ 1 1 2
1409 0 ▶ elsif ( $k eq 'status' ) { return 0 unless $c->{status} eq $v || ( $v eq 'running' && 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless $$c{"status"} eq $v or $v eq "running" and 0 0 0 0
Condition0%0/5
$$c{"status"} eq $v or $v eq "running" and 0
l!l&&r!l&&!r
000
$v eq "running" and 0
!ll
00
MC/DC0%0/2
$$c{"status"} eq $v or $v eq "running" and 0
$$c{"status"} eq $v $v eq "running"
Truth table0%0/3
A or B
A= $$c{"status"} eq $vB= $v eq "running"
ABresult
1X1
011
000
1410 0 ▶ elsif ( $k eq 'health' ) { return 0 unless ( $c->{health} // 'none' ) eq $v }
Branch: 1 branch
BranchTrueFalseTotal
unless ($$c{"health"} // "none") eq $v 0 0 0
Condition0%0/2
$$c{"health"} // "none"
l!l
00
MC/DC0%0/1
$$c{"health"} // "none"
$$c{"health"}
Truth table0%0/2
A
A= $$c{"health"}
Aresult
11
00
1411 elsif ( $k eq 'label' ) {
1412 0 my ( $lk, $lv ) = split /=/, $v, 2;
1413 0 my %l = ( 'com.docker.compose.project' => $c->{project}, 'com.docker.compose.service' => $c->{service} );
1414 0 ▶ return 0 unless exists $l{$lk} && ( !defined $lv || $l{$lk} eq $lv );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $l{$lk} and !defined($lv) || $l{$lk} eq $lv 0 0 0
Condition0%0/6
exists $l{$lk} and !defined($lv) || $l{$lk} eq $lv
!ll&&!rl&&r
000
not defined $lv or $l{$lk} eq $lv
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $l{$lk} and !defined($lv) || $l{$lk} eq $lv
exists $l{$lk} not defined $lv $l{$lk} eq $lv
Truth table0%0/4
A and not(B) or C
A= exists $l{$lk}B= not defined $lvC= $l{$lk} eq $lv
ABCresult
0XX0
1000
11X1
1011
1415 }
1416 0 ▶ elsif ( $k eq 'ancestor' ) { return 0 unless index( $c->{image}, $v ) == 0 }
Branch: 1 branch
BranchTrueFalseTotal
unless index($$c{"image"}, $v) == 0 0 0 0
1417 0 else { push @Langertha::Holmgang::Sim::Linux::GAPS, "docker ps --filter $f" }
1418 }
1419 3 return 1;
1420 }
1421  
1422 2 ▶sub _docker_ps {
Subroutine _docker_ps: called CC=23 SCAR=41.9
1423 2 my ( $d, $a ) = @_;
1424 2 my ( $all, $quiet, $fmt, @filters );
1425 2 my @x = @$a;
1426 2 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 4 2 6
1427 4 my $v = shift @x;
1428 4 ▶ if ( $v eq '-a' || $v eq '--all' ) { $all = 1 }
Branch: 8 branches
BranchTrueFalseTotal
if ($v eq '-a' or $v eq '--all') { } 2 2 4
elsif ($v eq '-q' or $v eq '--quiet') { } 0 2 2
elsif ($v eq '-aq' or $v eq '-qa') { } 0 2 2
elsif ($v eq '--format') { } 1 1 2
elsif ($v =~ /\A--format=(.*)\z/s) { } 0 1 1
elsif ($v eq '-f' or $v eq '--filter') { } 1 0 1
elsif ($v =~ /\A--filter=(.*)\z/) { } 0 0 0
elsif ($v eq '--no-trunc' or $v eq '-s' or $v eq '--size') { } 0 0 0
Condition66%2/3
$v eq "-a" or $v eq "--all"
l!l&&r!l&&!r
202
MC/DC50%1/2
$v eq "-a" or $v eq "--all"
$v eq "-a" $v eq "--all"
Truth table66%2/3
A or B
A= $v eq "-a"B= $v eq "--all"
ABresult
1X1
011
000
1429 0 ▶ elsif ( $v eq '-q' || $v eq '--quiet' ) { $quiet = 1 }
Condition33%1/3
$v eq "-q" or $v eq "--quiet"
l!l&&r!l&&!r
002
MC/DC0%0/2
$v eq "-q" or $v eq "--quiet"
$v eq "-q" $v eq "--quiet"
Truth table33%1/3
A or B
A= $v eq "-q"B= $v eq "--quiet"
ABresult
1X1
011
000
1430 0 ▶ elsif ( $v eq '-aq' || $v eq '-qa' ) { $all = $quiet = 1 }
Condition33%1/3
$v eq "-aq" or $v eq "-qa"
l!l&&r!l&&!r
002
MC/DC0%0/2
$v eq "-aq" or $v eq "-qa"
$v eq "-aq" $v eq "-qa"
Truth table33%1/3
A or B
A= $v eq "-aq"B= $v eq "-qa"
ABresult
1X1
011
000
1431 1 elsif ( $v eq '--format' ) { $fmt = shift @x }
1432 0 elsif ( $v =~ /\A--format=(.*)\z/s ) { $fmt = $1 }
1433 1 ▶ elsif ( $v eq '-f' || $v eq '--filter' ) { push @filters, shift(@x) // '' }
Condition40%2/5
$v eq "-f" or $v eq "--filter"
l!l&&r!l&&!r
010
shift @x // ""
l!l
10
MC/DC0%0/2
$v eq "-f" or $v eq "--filter"
$v eq "-f" $v eq "--filter"
MC/DC0%0/1
shift @x // ""
shift @x
Truth table33%1/3
A or B
A= $v eq "-f"B= $v eq "--filter"
ABresult
1X1
011
000
Truth table50%1/2
A
A= shift @x
Aresult
11
00
1434 0 elsif ( $v =~ /\A--filter=(.*)\z/ ) { push @filters, $1 }
1435 ▶ elsif ( $v eq '--no-trunc' || $v eq '-s' || $v eq '--size' ) { }
Condition0%0/6
$v eq "--no-trunc" or $v eq "-s" or $v eq "--size"
l!l&&r!l&&!r
000
$v eq "--no-trunc" or $v eq "-s"
l!l&&r!l&&!r
000
MC/DC0%0/3
$v eq "--no-trunc" or $v eq "-s" or $v eq "--size"
$v eq "--no-trunc" $v eq "-s" $v eq "--size"
Truth table0%0/4
A or B or C
A= $v eq "--no-trunc"B= $v eq "-s"C= $v eq "--size"
ABCresult
1XX1
01X1
0011
0000
1436 0 else { return ( "unknown flag: $v\nSee 'docker ps --help'.", 0 ) }
1437 }
1438 4 ▶ my @n = grep { ( $all || $d->{containers}{$_}{status} =~ /\A(?:running|restarting)\z/ ) && _ps_filter( $d, $_, \@filters ) }
Condition50%3/6
($all || $$d{'containers'}{$_}{'status'} =~ /\A(?:running|restarting)\z/) && _ps_filter($d, $_, \@filters)
!ll&&!rl&&r
013
$all or $$d{"containers"}{$_}{"status"} =~ /\A(?:running|restarting)\z/
l!l&&r!l&&!r
400
MC/DC33%1/3
($all || $$d{'containers'}{$_}{'status'} =~ /\A(?:running|restarting)\z/) && _ps_filter($d, $_, \@filters)
$all $$d{"containers"}{$_}{"status"} =~ /\A(?:running|restarting)\z/ _ps_filter($d, $_, \@filters)
Truth table40%2/5
A or B && C
A= $allB= $$d{"containers"}{$_}{"status"} =~ /\A(?:running|restarting)\z/C= _ps_filter($d, $_, \@filters)
ABCresult
00X0
1X00
0100
1X11
0111
1439 2 sort keys %{ $d->{containers} };
1440 0 ▶ return ( join( "\n", map { _id( $_, $d->{containers}{$_}{seq} ) } @n ), 1 ) if $quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $quiet 0 2 2
1441 2 ▶ return ( gofmt( $fmt, [ map { _ps_row( $d, $_ ) } @n ] ), 1 ) if defined $fmt;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fmt 1 1 2
1442 1 my @l = ( sprintf( '%-14s %-44s %-24s %-16s %-28s %-36s %s', 'CONTAINER ID', 'IMAGE', 'COMMAND', 'CREATED', 'STATUS', 'PORTS', 'NAMES' ) );
1443 1 for (@n) {
1444 2 my $c = $d->{containers}{$_};
1445 push @l, sprintf( '%-14s %-44s %-24s %-16s %-28s %-36s %s', _id( $_, $c->{seq} ), $c->{image}, '"docker-entrypoint.s…"',
1446 2 ▶ 'About an hour ago', _status_text($c), _ports_text( $c, _image( $d, $c->{image} ) || {} ), $_ );
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
20
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
1447 }
1448 1 return ( join( "\n", @l ), 1 );
1449 }
1450  
1451 3 ▶sub _logs_of {
Subroutine _logs_of: called CC=7 SCAR=19.7
1452 3 my ( $d, $n ) = @_;
1453 3 my $c = $d->{containers}{$n};
1454 3 ▶ my $img = _image( $d, $c->{image} ) || {};
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
30
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
1455 3 my @l;
1456 3 ▶ push @l, @{ $c->{early_error} || [] };
Condition50%1/2
$$c{'early_error'} || []
l!l
03
MC/DC0%0/1
$$c{'early_error'} || []
$$c{'early_error'}
Truth table50%1/2
A
A= $$c{'early_error'}
Aresult
11
00
1457 3 ▶ if ( $c->{status} eq 'running' ) { push @l, map { _expand( $_, _env_of( $c, $img ) ) } @{ $img->{logs} || [] } }
Branch: 2 branches
BranchTrueFalseTotal
if ($$c{'status'} eq 'running') { } 1 2 3
elsif ($$c{'error'}) { } 2 0 2
Condition50%1/2
$$img{'logs'} || []
l!l
10
MC/DC0%0/1
$$img{'logs'} || []
$$img{'logs'}
Truth table50%1/2
A
A= $$img{'logs'}
Aresult
11
00
1458 2 ▶ elsif ( $c->{error} ) { push @l, ( @{ $c->{error} } ) x ( $c->{status} eq 'restarting' ? 3 : 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
$$c{'status'} eq 'restarting' ? : 1 1 2
1459 3 return @l;
1460 }
1461  
1462 2 ▶sub _docker_logs {
Subroutine _docker_logs: called CC=13 SCAR=28.7
1463 2 my ( $d, $a ) = @_;
1464 2 my @x = @$a;
1465 2 my ( $tail, $n );
1466 2 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 3 2 5
1467 3 my $v = shift @x;
1468 3 ▶ if ( $v eq '--tail' || $v eq '-n' ) { $tail = shift @x }
Branch: 4 branches
BranchTrueFalseTotal
if ($v eq '--tail' or $v eq '-n') { } 1 2 3
elsif ($v =~ /\A--tail=(\d+)\z/) { } 0 2 2
elsif ($v eq '-f' or $v eq '--follow') { } 0 2 2
elsif ($v =~ /\A-/) { } 0 2 2
Condition66%2/3
$v eq "--tail" or $v eq "-n"
l!l&&r!l&&!r
102
MC/DC50%1/2
$v eq "--tail" or $v eq "-n"
$v eq "--tail" $v eq "-n"
Truth table66%2/3
A or B
A= $v eq "--tail"B= $v eq "-n"
ABresult
1X1
011
000
1469 0 elsif ( $v =~ /\A--tail=(\d+)\z/ ) { $tail = $1 }
1470 0 ▶ elsif ( $v eq '-f' || $v eq '--follow' ) { _gap('docker logs -f'); return ( '', 0 ) }
Condition33%1/3
$v eq "-f" or $v eq "--follow"
l!l&&r!l&&!r
002
MC/DC0%0/2
$v eq "-f" or $v eq "--follow"
$v eq "-f" $v eq "--follow"
Truth table33%1/3
A or B
A= $v eq "-f"B= $v eq "--follow"
ABresult
1X1
011
000
1471 elsif ( $v =~ /\A-/ ) { }
1472 2 else { $n = $v }
1473 }
1474 2 ▶ return ( '"docker logs" requires exactly 1 argument.', 0 ) unless defined $n;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n 0 2 2
1475 2 ▶ return ( "Error response from daemon: No such container: $n", 0 ) unless $d->{containers}{$n};
Branch: 1 branch
BranchTrueFalseTotal
unless $$d{"containers"}{$n} 0 2 2
1476 2 my @l = _logs_of( $d, $n );
1477 2 ▶ @l = @l[ ( @l > $tail ? @l - $tail : 0 ) .. $#l ] if defined $tail && $tail =~ /\A\d+\z/;
Branch: 2 branches
BranchTrueFalseTotal
if defined $tail and $tail =~ /\A\d+\z/ 1 1 2
@l > $tail ? : 1 0 1
Condition66%2/3
defined $tail and $tail =~ /\A\d+\z/
!ll&&!rl&&r
101
MC/DC50%1/2
defined $tail and $tail =~ /\A\d+\z/
defined $tail $tail =~ /\A\d+\z/
Truth table66%2/3
A and B
A= defined $tailB= $tail =~ /\A\d+\z/
ABresult
0X0
100
111
1478 2 return ( join( "\n", @l ), 1 );
1479 }
1480  
1481 8 ▶sub _inspect_data {
Subroutine _inspect_data: called CC=21 SCAR=33.0
1482 8 my ( $d, $n ) = @_;
1483 8 my $c = $d->{containers}{$n};
1484 8 ▶ my $img = _image( $d, $c->{image} ) || {};
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
80
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
1485 8 my $env = _env_of( $c, $img );
1486 return {
1487 Id => _id( $n, $c->{seq} ) . ( '0' x 52 ), Name => "/$n",
1488 State => { Status => $c->{status}, Running => $c->{status} eq 'running' ? _true() : _false(), Restarting => $c->{status} eq 'restarting' ? _true() : _false(),
1489 ExitCode => $c->{exit_code} // 0, Paused => _false(), OOMKilled => $c->{oom} ? _true() : _false(), Dead => _false(),
1490 Error => $c->{status} eq 'created' && $c->{start_error} ? $c->{start_error} : '',
1491 ( defined $c->{health} ? ( Health => { Status => $c->{health}, FailingStreak => $c->{health} eq 'healthy' ? 0 : 3,
1492 Log => [ { ExitCode => $c->{health} eq 'healthy' ? 0 : 1, Output => $c->{health_log} // '' } ] } ) : () ) },
1493 RestartCount => $c->{restart_count} // 0,
1494 6 ▶ Config => { Image => $c->{image}, Env => [ map {"$_=$env->{$_}"} sort keys %$env ], User => $c->{config}{user} // $img->{user} // '',
Branch: 1 branch
BranchTrueFalseTotal
$$c{'config'}{'healthcheck'} ? : 4 4 8
Condition80%4/5
($$c{"config"}{"user"} // $$img{"user"}) // ""
l!l
53
$$c{"config"}{"user"} // $$img{"user"}
l!l&&r!l&&!r
053
MC/DC50%1/2
($$c{"config"}{"user"} // $$img{"user"}) // ""
$$c{"config"}{"user"} $$img{"user"}
Truth table66%2/3
A // B
A= $$c{"config"}{"user"}B= $$img{"user"}
ABresult
1X1
011
000
1495 Labels => { 'com.docker.compose.project' => $c->{project}, 'com.docker.compose.service' => $c->{service} },
1496 ( $c->{config}{healthcheck} ? ( Healthcheck => { Test => $c->{config}{healthcheck}{test} } ) : () ) },
1497 1 ▶ HostConfig => { RestartPolicy => { Name => $c->{config}{restart} }, PortBindings => { map { ( "$_->{target}/tcp" => [ { HostIp => $_->{host_ip} eq '0.0.0.0' ? '' : $_->{host_ip}, HostPort => $_->{published} } ] ) } grep { length $_->{published} } @{ $c->{config}{ports} } } },
Branch: 1 branch
BranchTrueFalseTotal
$$_{'host_ip'} eq '0.0.0.0' ? : 0 1 1
1498 Mounts => [ map { { Type => $_->{type}, Source => $_->{type} eq 'bind' ? $_->{source} : "/var/lib/docker/volumes/$_->{source}/_data", Destination => $_->{target},
1499 7 ▶ ( $_->{type} eq 'volume' ? ( Name => $_->{source} ) : () ), RW => $_->{read_only} ? _false() : _true() } } @{ $c->{config}{volumes} } ],
Branch: 3 branches
BranchTrueFalseTotal
$$_{'type'} eq 'bind' ? : 0 7 7
$$_{'type'} eq 'volume' ? : 7 0 7
$$_{'read_only'} ? : 0 7 7
1500 8 ▶ NetworkSettings => { Networks => { map { $_ => { Aliases => [ $n, $c->{service} ] } } @{ $c->{config}{networks} } },
Branch: 1 branch
BranchTrueFalseTotal
$$c{'status'} eq 'running' ? : 7 1 8
1501 Ports => $c->{status} eq 'running'
1502 0 ▶ ? { map { ( "$_->{target}/tcp" => [ { HostIp => $_->{host_ip}, HostPort => $_->{published} } ] ) } grep { length $_->{published} } @{ $c->{config}{ports} } }
Branch: 7 branches
BranchTrueFalseTotal
$$c{'status'} eq 'running' ? : 7 1 8
$$c{'status'} eq 'restarting' ? : 1 7 8
$$c{'oom'} ? : 1 7 8
$$c{'status'} eq 'created' && $$c{'start_error'} ? : 0 8 8
defined $$c{'health'} ? : 4 4 8
$$c{'health'} eq 'healthy' ? : 4 0 4
$$c{'health'} eq 'healthy' ? : 4 0 4
Condition66%6/9
$$c{"exit_code"} // 0
l!l
17
$$c{"status"} eq "created" and $$c{"start_error"}
!ll&&!rl&&r
800
$$c{"health_log"} // ""
l!l
04
$$c{"restart_count"} // 0
l!l
17
MC/DC100%1/1
$$c{"exit_code"} // 0
$$c{"exit_code"}
MC/DC0%0/2
$$c{"status"} eq "created" and $$c{"start_error"}
$$c{"status"} eq "created" $$c{"start_error"}
MC/DC0%0/1
$$c{"health_log"} // ""
$$c{"health_log"}
MC/DC100%1/1
$$c{"restart_count"} // 0
$$c{"restart_count"}
Truth table100%2/2
A
A= $$c{"exit_code"}
Aresult
11
00
Truth table33%1/3
A and B
A= $$c{"status"} eq "created"B= $$c{"start_error"}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$c{"health_log"}
Aresult
11
00
Truth table100%2/2
A
A= $$c{"restart_count"}
Aresult
11
00
1503 : {} },
1504 };
1505 }
1506  
1507 8 ▶sub _inspect {
Subroutine _inspect: called CC=11 SCAR=26.8
1508 8 my ( $d, $a ) = @_;
1509 8 my @x = @$a;
1510 8 my ( $fmt, @names );
1511 8 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 14 8 22
1512 14 my $v = shift @x;
1513 14 ▶ if ( $v eq '-f' || $v eq '--format' ) { $fmt = shift @x }
Branch: 3 branches
BranchTrueFalseTotal
if ($v eq '-f' or $v eq '--format') { } 6 8 14
elsif ($v =~ /\A--format=(.*)\z/s) { } 0 8 8
elsif ($v =~ /\A-/) { } 0 8 8
Condition66%2/3
$v eq "-f" or $v eq "--format"
l!l&&r!l&&!r
608
MC/DC50%1/2
$v eq "-f" or $v eq "--format"
$v eq "-f" $v eq "--format"
Truth table66%2/3
A or B
A= $v eq "-f"B= $v eq "--format"
ABresult
1X1
011
000
1514 0 elsif ( $v =~ /\A--format=(.*)\z/s ) { $fmt = $1 }
1515 elsif ( $v =~ /\A-/ ) { }
1516 8 else { push @names, $v }
1517 }
1518 8 ▶ return ( '"docker inspect" requires at least 1 argument.', 0 ) unless @names;
Branch: 1 branch
BranchTrueFalseTotal
unless @names 0 8 8
1519 8 my @data;
1520 8 for my $n (@names) {
1521 8 ▶ if ( !$d->{containers}{$n} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$d{"containers"}{$n}) 0 8 8
1522 0 ▶ if ( $d->{volumes}{$n} ) { push @data, { Name => $n, Driver => 'local', Mountpoint => "/var/lib/docker/volumes/$n/_data" }; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($$d{"volumes"}{$n}) 0 0 0
1523 0 return ( "Error: No such object: $n", 0 );
1524 }
1525 8 push @data, _inspect_data( $d, $n );
1526 }
1527 8 ▶ return ( $OUT_JSON->encode( \@data ) =~ s/\n\z//r, 1 ) unless defined $fmt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fmt 2 6 8
1528 6 return ( gofmt( $fmt, \@data ), 1 );
1529 }
1530  
1531 1 ▶sub _docker_lifecycle {
Subroutine _docker_lifecycle: called CC=9 SCAR=29.0
1532 1 my ( $dev, $d, $verb, $a, $ctx ) = @_;
1533 1 my @n = grep { !/\A-/ } @$a;
1534 1 ▶ my $force = grep { /\A-\w*f/ || $_ eq '--force' } @$a;
Condition33%1/3
/\A-\w*f/ || $_ eq '--force'
l!l&&r!l&&!r
001
MC/DC0%0/2
/\A-\w*f/ || $_ eq '--force'
/\A-\w*f/ $_ eq '--force'
Truth table33%1/3
A || B
A= /\A-\w*f/B= $_ eq '--force'
ABresult
1X1
011
000
1535 1 ▶ return ( "\"docker $verb\" requires at least 1 argument.", 0 ) unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 1 1
1536 1 my @out;
1537 1 for my $n (@n) {
1538 1 ▶ my $c = $d->{containers}{$n} or return ( "Error response from daemon: No such container: $n", 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $c = $$d{"containers"}{$n} or return "Error response from daemon: No such container: $n", 0 1 0 1
1539 1 ▶ if ( $verb eq 'rm' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($verb eq 'rm') { } 0 1 1
elsif (defined(my $e = _lifecycle($dev, $d, $n, $c, $verb, $ctx))) { } 1 0 1
1540 return ( "Error response from daemon: cannot remove container \"/$n\": container is running: stop the container before removing or force remove", 0 )
1541 0 ▶ if $c->{status} eq 'running' && !$force;
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"status"} eq "running" and not $force 0 0 0
Condition0%0/3
$$c{"status"} eq "running" and not $force
!ll&&!rl&&r
000
MC/DC0%0/2
$$c{"status"} eq "running" and not $force
$$c{"status"} eq "running" not $force
Truth table0%0/3
A and not(B)
A= $$c{"status"} eq "running"B= not $force
ABresult
0X0
100
111
1542 0 delete $d->{containers}{$n};
1543 }
1544 elsif ( defined( my $e = _lifecycle( $dev, $d, $n, $c, $verb, $ctx ) ) ) {
1545 1 _settle($dev);
1546 1 return ( join( "\n", @out, $e, "Error: failed to start containers: $n" ), 0 );
1547 }
1548 0 push @out, $n;
1549 }
1550 0 _settle($dev);
1551 0 return ( join( "\n", @out ), 1 );
1552 }
1553  
1554 4 ▶sub _lifecycle {
Subroutine _lifecycle: called CC=11 SCAR=29.5
1555 4 my ( $dev, $d, $n, $c, $verb, $ctx ) = @_;
1556 4 ▶ my $running = $c->{status} eq 'running' || $c->{status} eq 'restarting';
Condition66%2/3
$$c{'status'} eq 'running' || $$c{'status'} eq 'restarting'
l!l&&r!l&&!r
202
MC/DC50%1/2
$$c{'status'} eq 'running' || $$c{'status'} eq 'restarting'
$$c{'status'} eq 'running' $$c{'status'} eq 'restarting'
Truth table66%2/3
A || B
A= $$c{'status'} eq 'running'B= $$c{'status'} eq 'restarting'
ABresult
1X1
011
000
1557 4 ▶ if ( $verb eq 'stop' || $verb eq 'kill' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "stop" or $verb eq "kill") 0 4 4
Condition33%1/3
$verb eq "stop" or $verb eq "kill"
l!l&&r!l&&!r
004
MC/DC0%0/2
$verb eq "stop" or $verb eq "kill"
$verb eq "stop" $verb eq "kill"
Truth table33%1/3
A or B
A= $verb eq "stop"B= $verb eq "kill"
ABresult
1X1
011
000
1558 0 ▶ $c->{restarts}++ if $running;
Branch: 1 branch
BranchTrueFalseTotal
if $running 0 0 0
1559 0 $c->{status} = 'exited';
1560 0 ▶ $c->{exit_code} = $verb eq 'kill' ? 137 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$verb eq 'kill' ? : 0 0 0
1561 0 delete $c->{health};
1562 0 return;
1563 }
1564 4 ▶ return undef if $verb eq 'start' && $running;
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "start" and $running 0 4 4
Condition66%2/3
$verb eq "start" and $running
!ll&&!rl&&r
220
MC/DC0%0/2
$verb eq "start" and $running
$verb eq "start" $running
Truth table66%2/3
A and B
A= $verb eq "start"B= $running
ABresult
0X0
100
111
1565 4 ▶ $c->{restarts}++ if $running;
Branch: 1 branch
BranchTrueFalseTotal
if $running 2 2 4
1566 4 my $e = _start( $dev, $d, $n, $c, {}, $ctx->{state}, $ctx->{host} );
1567 4 ▶ $c->{start_error} = $e if defined $e;
Branch: 1 branch
BranchTrueFalseTotal
if defined $e 2 2 4
1568 4 ▶ delete $c->{start_error} unless defined $e;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e 2 2 4
1569 4 return $e;
1570 }
1571  
1572 # --- docker compose ---------------------------------------------------------------------
1573  
1574 33 ▶sub _compose {
Subroutine _compose: called CC=146 SCAR=76.5
1575 33 my ( $dev, $av, $ctx ) = @_;
1576 33 my $d = $dev->{docker};
1577 33 my @a = @$av;
1578 33 my ( @files, $proj, $pdir, $envf, @profiles );
1579 33 ▶ while ( @a && $a[0] =~ /\A-/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a and $a[0] =~ /\A-/) 9 33 42
Condition66%2/3
@a and $a[0] =~ /\A-/
!ll&&!rl&&r
0339
MC/DC50%1/2
@a and $a[0] =~ /\A-/
@a $a[0] =~ /\A-/
Truth table66%2/3
A and B
A= @aB= $a[0] =~ /\A-/
ABresult
0X0
100
111
1580 9 my $x = shift @a;
1581 9 ▶ if ( $x eq '-f' || $x eq '--file' ) { push @files, shift @a }
Branch: 8 branches
BranchTrueFalseTotal
if ($x eq '-f' or $x eq '--file') { } 7 2 9
elsif ($x =~ /\A--file=(.+)\z/) { } 0 2 2
elsif ($x eq '-p' or $x eq '--project-name') { } 2 0 2
elsif ($x eq '--project-directory') { } 0 0 0
elsif ($x eq '--env-file') { } 0 0 0
elsif ($x eq '--profile') { } 0 0 0
elsif ($x eq '--ansi' or $x eq '--progress') { } 0 0 0
elsif ($x eq '-v' or $x eq '--version') { } 0 0 0
Condition66%2/3
$x eq "-f" or $x eq "--file"
l!l&&r!l&&!r
702
MC/DC50%1/2
$x eq "-f" or $x eq "--file"
$x eq "-f" $x eq "--file"
Truth table66%2/3
A or B
A= $x eq "-f"B= $x eq "--file"
ABresult
1X1
011
000
1582 0 elsif ( $x =~ /\A--file=(.+)\z/ ) { push @files, $1 }
1583 2 ▶ elsif ( $x eq '-p' || $x eq '--project-name' ) { $proj = shift @a }
Condition33%1/3
$x eq "-p" or $x eq "--project-name"
l!l&&r!l&&!r
200
MC/DC0%0/2
$x eq "-p" or $x eq "--project-name"
$x eq "-p" $x eq "--project-name"
Truth table33%1/3
A or B
A= $x eq "-p"B= $x eq "--project-name"
ABresult
1X1
011
000
1584 0 elsif ( $x eq '--project-directory' ) { $pdir = shift @a }
1585 0 elsif ( $x eq '--env-file' ) { $envf = shift @a }
1586 0 elsif ( $x eq '--profile' ) { push @profiles, shift @a }
1587 0 ▶ elsif ( $x eq '--ansi' || $x eq '--progress' ) { shift @a }
Condition0%0/3
$x eq "--ansi" or $x eq "--progress"
l!l&&r!l&&!r
000
MC/DC0%0/2
$x eq "--ansi" or $x eq "--progress"
$x eq "--ansi" $x eq "--progress"
Truth table0%0/3
A or B
A= $x eq "--ansi"B= $x eq "--progress"
ABresult
1X1
011
000
1588 0 ▶ elsif ( $x eq '-v' || $x eq '--version' ) { return ( 'Docker Compose version v2.29.7', 1 ) }
Condition0%0/3
$x eq "-v" or $x eq "--version"
l!l&&r!l&&!r
000
MC/DC0%0/2
$x eq "-v" or $x eq "--version"
$x eq "-v" $x eq "--version"
Truth table0%0/3
A or B
A= $x eq "-v"B= $x eq "--version"
ABresult
1X1
011
000
1589 0 else { return ( "unknown shorthand flag: '" . ( $x =~ s/\A-+//r ) . "' in $x", 0 ) }
1590 }
1591 33 ▶ my $verb = shift @a // return ( "Usage: docker compose [OPTIONS] COMMAND", 0 );
Condition50%1/2
shift @a // (return "Usage: docker compose [OPTIONS] COMMAND", 0)
l!l
330
MC/DC0%0/1
shift @a // (return "Usage: docker compose [OPTIONS] COMMAND", 0)
shift @a
Truth table50%1/2
A
A= shift @a
Aresult
11
00
1592 33 ▶ return ( 'Docker Compose version v2.29.7', 1 ) if $verb eq 'version';
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "version" 0 33 33
1593 33 ▶ if ( $verb eq 'ls' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "ls") 0 33 33
1594 0 my %p;
1595 0 ▶ $p{ $_->{project} }{ $_->{status} eq 'running' ? 'running' : 'exited' }++ for values %{ $d->{containers} };
Branch: 1 branch
BranchTrueFalseTotal
$$_{'status'} eq 'running' ? : 0 0 0
1596 return ( join( "\n", sprintf( '%-16s %-20s %s', 'NAME', 'STATUS', 'CONFIG FILES' ),
1597 0 ▶ map { my $pn = $_; my $pr = $d->{projects}{$pn} || {};
Condition0%0/2
$$d{'projects'}{$pn} || {}
l!l
00
MC/DC0%0/1
$$d{'projects'}{$pn} || {}
$$d{'projects'}{$pn}
Truth table0%0/2
A
A= $$d{'projects'}{$pn}
Aresult
11
00
1598 0 ▶ sprintf( '%-16s %-20s %s', $pn, join( ', ', map {"$_($p{$pn}{$_})"} sort keys %{ $p{$pn} } ), ( $pr->{dir} // '' ) . '/compose.yaml' ) } sort keys %p ), 1 );
Condition0%0/2
$$pr{"dir"} // ""
l!l
00
MC/DC0%0/1
$$pr{"dir"} // ""
$$pr{"dir"}
Truth table0%0/2
A
A= $$pr{"dir"}
Aresult
11
00
1599 }
1600 33 my $L = _L();
1601 33 @files = map { $L->can('cwd_path')->($_) } @files;
1602 33 ▶ $pdir = $L->can('cwd_path')->($pdir) if defined $pdir;
Branch: 1 branch
BranchTrueFalseTotal
if defined $pdir 0 33 33
1603 33 ▶ $envf = $L->can('cwd_path')->($envf) if defined $envf;
Branch: 1 branch
BranchTrueFalseTotal
if defined $envf 0 33 33
1604 3 ▶ my $cwd = do { no warnings "once"; $Langertha::Holmgang::Sim::Linux::CWD_DIR } // "/root";
Subroutine BEGIN: called CC=1 SCAR=0.0
Condition100%2/2
do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $Langertha::Holmgang::Sim::Linux::CWD_DIR } // "/root"
l!l
2310
MC/DC100%1/1
do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $Langertha::Holmgang::Sim::Linux::CWD_DIR } // "/root"
do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $Langertha::Holmgang::Sim::Linux::CWD_DIR }
Truth table100%2/2
A
A= do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $Langertha::Holmgang::Sim::Linux::CWD_DIR }
Aresult
11
00
1605 33 ▶ my $dir = $pdir // ( @files ? ( $files[0] =~ m{\A(.*)/[^/]+\z} )[0] : $cwd );
Branch: 1 branch
BranchTrueFalseTotal
@files ? : 7 26 33
Condition33%1/3
$pdir // (@files ? ($files[0] =~ m[\A(.*)/[^/]+\z])[0] : $cwd)
l!l&&r!l&&!r
0330
MC/DC0%0/2
$pdir // (@files ? ($files[0] =~ m[\A(.*)/[^/]+\z])[0] : $cwd)
$pdir (@files ? ($files[0] =~ m[\A(.*)/[^/]+\z])[0] : $cwd)
Truth table33%1/3
A // B
A= $pdirB= (@files ? ($files[0] =~ m[\A(.*)/[^/]+\z])[0] : $cwd)
ABresult
1X1
011
000
1606 33 my $m = model( $dev, dir => $dir, files => \@files, project => $proj, env_file => $envf, profiles => \@profiles );
1607 # ohne Datei: Befehle, die mit dem Projektnamen auskommen (Labels)
1608 33 ▶ if ( $m->{error} && $m->{error} =~ /no configuration file/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$m{"error"} and $$m{"error"} =~ /no configuration file/) 3 30 33
Condition100%3/3
$$m{"error"} and $$m{"error"} =~ /no configuration file/
!ll&&!rl&&r
2823
MC/DC100%2/2
$$m{"error"} and $$m{"error"} =~ /no configuration file/
$$m{"error"} $$m{"error"} =~ /no configuration file/
Truth table100%3/3
A and B
A= $$m{"error"}B= $$m{"error"} =~ /no configuration file/
ABresult
0X0
100
111
1609 3 ▶ my $pn = $proj // ( $dir =~ m{([^/]+)\z} )[0] // '';
Condition60%3/5
($proj // ($dir =~ m[([^/]+)\z])[0]) // ""
l!l
30
$proj // ($dir =~ m[([^/]+)\z])[0]
l!l&&r!l&&!r
210
MC/DC0%0/2
($proj // ($dir =~ m[([^/]+)\z])[0]) // ""
$proj ($dir =~ m[([^/]+)\z])[0]
Truth table66%2/3
A // B
A= $projB= ($dir =~ m[([^/]+)\z])[0]
ABresult
1X1
011
000
1610 3 ▶ if ( $verb =~ /\A(?:ps|logs|down|stop|start|restart|exec|top)\z/ && grep { $_->{project} eq $pn } values %{ $d->{containers} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb =~ /\A(?:ps|logs|down|stop|start|restart|exec|top)\z/ and grep {$$_{"project"} eq $pn;} values %{$$d{"containers"};}) 2 1 3
Condition66%2/3
$verb =~ /\A(?:ps|logs|down|stop|start|restart|exec|top)\z/ and grep {$$_{"project"} eq $pn;} values %{$$d{"containers"};}
!ll&&!rl&&r
012
MC/DC50%1/2
$verb =~ /\A(?:ps|logs|down|stop|start|restart|exec|top)\z/ and grep {$$_{"project"} eq $pn;} values %{$$d{"containers"};}
$verb =~ /\A(?:ps|logs|down|stop|start|restart|exec|top)\z/ grep {$$_{"project"} eq $pn;} values %{$$d{"containers"};}
Truth table66%2/3
A and B
A= $verb =~ /\A(?:ps|logs|down|stop|start|restart|exec|top)\z/B= grep {$$_{"project"} eq $pn;} values %{$$d{"containers"};}
ABresult
0X0
100
111
1611 2 $m = { name => $pn, services => { map { $_->{service} => $_->{config} } grep { $_->{project} eq $pn } values %{ $d->{containers} } },
1612 warnings => [], nofile => 1 };
1613 }
1614 }
1615 0 ▶ my @warn = map {"WARN[0000] $_"} @{ $m->{warnings} || [] };
Condition100%2/2
$$m{'warnings'} || []
l!l
321
MC/DC100%1/1
$$m{'warnings'} || []
$$m{'warnings'}
Truth table100%2/2
A
A= $$m{'warnings'}
Aresult
11
00
1616 33 ▶ return ( join( "\n", @warn, $m->{error} ), 0 ) if $m->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $$m{"error"} 3 30 33
1617 30 ▶ my $out = sub { my ( $lines, $ok ) = @_; return ( join( "\n", @warn, @$lines ), $ok ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
1618 30 my ( %f, @svc );
1619 30 for my $x (@a) {
1620 43 ▶ if ( $x =~ /\A--?([\w-]+)(?:=(.*))?\z/ ) { $f{$1} = $2 // 1 }
Branch: 1 branch
BranchTrueFalseTotal
if ($x =~ /\A--?([\w-]+)(?:=(.*))?\z/) { } 26 17 43
Condition50%1/2
$2 // 1
l!l
026
MC/DC0%0/1
$2 // 1
$2
Truth table50%1/2
A
A= $2
Aresult
11
00
1621 17 else { push @svc, $x }
1622 }
1623 30 ▶ for ( my $i = 0; $i < @a; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @a) 43 30 73
1624 43 ▶ if ( $a[$i] =~ /\A(?:--tail|-n|--timeout|-t|--format|--scale|--pull|-e|--env|-u|--user|-w|--workdir|--index|--status|--filter)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a[$i] =~ /\A(?:--tail|-n|--timeout|-t|--format|--scale|--pull|-e|--env|-u|--user|-w|--workdir|--index|--status|--filter)\z/) 1 42 43
1625 1 ( my $k = $a[$i] ) =~ s/\A-+//;
1626 1 $f{$k} = $a[ $i + 1 ];
1627 1 ▶ @svc = grep { $_ ne ( $a[ $i + 1 ] // '' ) } @svc;
Condition50%1/2
$a[$i + 1] // ""
l!l
10
MC/DC0%0/1
$a[$i + 1] // ""
$a[$i + 1]
Truth table50%1/2
A
A= $a[$i + 1]
Aresult
11
00
1628 }
1629 }
1630 30 ▶ if ( $verb eq 'config' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "config") 2 28 30
1631 2 ▶ return $out->( [], 1 ) if $f{q} || $f{quiet};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"q"} or $f{"quiet"} 0 2 2
Condition33%1/3
$f{"q"} or $f{"quiet"}
l!l&&r!l&&!r
002
MC/DC0%0/2
$f{"q"} or $f{"quiet"}
$f{"q"} $f{"quiet"}
Truth table33%1/3
A or B
A= $f{"q"}B= $f{"quiet"}
ABresult
1X1
011
000
1632 0 ▶ return $out->( [ sort keys %{ $m->{services} } ], 1 ) if $f{services};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"services"} 0 2 2
1633 0 ▶ return $out->( [ sort keys %{ $m->{volumes} || {} } ], 1 ) if $f{volumes};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"volumes"} 0 2 2
Condition0%0/2
$$m{'volumes'} || {}
l!l
00
MC/DC0%0/1
$$m{'volumes'} || {}
$$m{'volumes'}
Truth table0%0/2
A
A= $$m{'volumes'}
Aresult
11
00
1634 2 return $out->( [ _config_yaml($m) ], 1 );
1635 }
1636 28 ▶ if ( $verb eq 'up' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "up") 16 12 28
1637 0 ▶ if ( !( $f{d} || $f{detach} || $f{'wait'} ) ) { _gap('docker compose up (ohne -d, haengt im Vordergrund)'); return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($f{"d"} or $f{"detach"} or $f{"wait"}) 0 16 16
Condition33%2/6
$f{"d"} or $f{"detach"} or $f{"wait"}
l!l&&r!l&&!r
1600
$f{"d"} or $f{"detach"}
l!l&&r!l&&!r
1600
MC/DC0%0/3
$f{"d"} or $f{"detach"} or $f{"wait"}
$f{"d"} $f{"detach"} $f{"wait"}
Truth table25%1/4
A or B or C
A= $f{"d"}B= $f{"detach"}C= $f{"wait"}
ABCresult
1XX1
01X1
0011
0000
1638 0 ▶ return $out->( [ 'no such service: ' . ( grep { !$m->{services}{$_} } @svc )[0] ], 0 ) if grep { !$m->{services}{$_} } @svc;
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $$m{"services"}{$_};} @svc 0 16 16
1639 16 ▶ if ( ( $f{pull} // '' ) eq 'always' ) { # --pull always: erst ziehen, was die Registry neuer hat
Branch: 1 branch
BranchTrueFalseTotal
if (($f{"pull"} // "") eq "always") 0 16 16
Condition50%1/2
$f{"pull"} // ""
l!l
016
MC/DC0%0/1
$f{"pull"} // ""
$f{"pull"}
Truth table50%1/2
A
A= $f{"pull"}
Aresult
11
00
1640 0 ▶ for my $s ( @svc ? @svc : sort keys %{ $m->{services} } ) {
Branch: 1 branch
BranchTrueFalseTotal
@svc ? : 0 0 0
1641 0 ▶ my $ref = $m->{services}{$s}{image} // next;
Condition0%0/2
$$m{"services"}{$s}{"image"} // (next)
l!l
00
MC/DC0%0/1
$$m{"services"}{$s}{"image"} // (next)
$$m{"services"}{$s}{"image"}
Truth table0%0/2
A
A= $$m{"services"}{$s}{"image"}
Aresult
11
00
1642 0 ▶ _pull( $d, $ref ) if ( $d->{registry} || {} )->{$ref};
Branch: 1 branch
BranchTrueFalseTotal
if ($$d{"registry"} || {})->{$ref} 0 0 0
Condition0%0/2
$$d{'registry'} || {}
l!l
00
MC/DC0%0/1
$$d{'registry'} || {}
$$d{'registry'}
Truth table0%0/2
A
A= $$d{'registry'}
Aresult
11
00
1643 }
1644 }
1645 my ( $l, $ok, $err ) = up( $dev, $m, { services => \@svc, force_recreate => $f{'force-recreate'}, no_deps => $f{'no-deps'},
1646 recreate_deps => $f{'always-recreate-deps'},
1647 16 remove_orphans => $f{'remove-orphans'} }, $ctx->{state}, $ctx->{host} );
1648 16 ▶ push @$l, $err if defined $err;
Branch: 1 branch
BranchTrueFalseTotal
if defined $err 4 12 16
1649 16 ▶ $d->{projects}{ $m->{name} } //= { dir => $m->{dir} } unless $m->{nofile};
Branch: 1 branch
BranchTrueFalseTotal
unless $$m{"nofile"} 16 0 16
Condition50%1/2
$$d{"projects"}{$$m{"name"}} //= {"dir", $$m{"dir"}}
l!l
160
MC/DC0%0/1
$$d{"projects"}{$$m{"name"}} //= {"dir", $$m{"dir"}}
$$d{"projects"}{$$m{"name"}}
Truth table50%1/2
A
A= $$d{"projects"}{$$m{"name"}}
Aresult
11
00
1650 16 return $out->( $l, $ok );
1651 }
1652 12 ▶ if ( $verb eq 'pull' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "pull") 0 12 12
1653 0 my @l;
1654 0 ▶ for my $s ( @svc ? @svc : sort keys %{ $m->{services} } ) {
Branch: 1 branch
BranchTrueFalseTotal
@svc ? : 0 0 0
1655 0 ▶ my $ref = $m->{services}{$s}{image} // next;
Condition0%0/2
$$m{"services"}{$s}{"image"} // (next)
l!l
00
MC/DC0%0/1
$$m{"services"}{$s}{"image"} // (next)
$$m{"services"}{$s}{"image"}
Truth table0%0/2
A
A= $$m{"services"}{$s}{"image"}
Aresult
11
00
1656 0 push @l, " $s Pulling";
1657 0 ▶ if ( _image( $d, $ref ) && !( $d->{registry} || {} )->{$ref} ) { push @l, " $s Pulled"; next }
Branch: 1 branch
BranchTrueFalseTotal
if (_image($d, $ref) and not +($$d{"registry"} || {})->{$ref}) 0 0 0
Condition0%0/5
_image($d, $ref) and not +($$d{"registry"} || {})->{$ref}
!ll&&!rl&&r
000
$$d{'registry'} || {}
l!l
00
MC/DC0%0/2
_image($d, $ref) and not +($$d{"registry"} || {})->{$ref}
_image($d, $ref) $$d{'registry'}
Truth table0%0/3
A and not(B)
A= _image($d, $ref)B= $$d{'registry'}
ABresult
0X0
110
101
1658 0 my ( $ok, $e ) = _pull( $d, $ref );
1659 0 ▶ if ( !$ok ) { push @l, " $s Error " . ( $e =~ s/\AError response from daemon: //r ), $e; return $out->( \@l, 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 0 0
1660 0 push @l, " $s Pulled";
1661 }
1662 0 return $out->( \@l, 1 );
1663 }
1664 12 my @mine = _project_containers( $d, $m->{name} );
1665 12 my %by_svc = map { $d->{containers}{$_}{service} => $_ } @mine;
1666 12 ▶ for (@svc) { return $out->( ["no such service: $_"], 0 ) if $verb ne 'exec' && $verb ne 'logs' && !$by_svc{$_} && !$m->{services}{$_} }
Branch: 1 branch
BranchTrueFalseTotal
if $verb ne "exec" and $verb ne "logs" and not $by_svc{$_} and not $$m{"services"}{$_} 0 13 13
Condition66%6/9
$verb ne "exec" and $verb ne "logs" and not $by_svc{$_} and not $$m{"services"}{$_}
!ll&&!rl&&r
1300
$verb ne "exec" and $verb ne "logs" and not $by_svc{$_}
!ll&&!rl&&r
1030
$verb ne "exec" and $verb ne "logs"
!ll&&!rl&&r
913
MC/DC0%0/4
$verb ne "exec" and $verb ne "logs" and not $by_svc{$_} and not $$m{"services"}{$_}
$verb ne "exec" $verb ne "logs" not $by_svc{$_} not $$m{"services"}{$_}
Truth table60%3/5
A and B and not(C) and not(D)
A= $verb ne "exec"B= $verb ne "logs"C= not $by_svc{$_}D= not $$m{"services"}{$_}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1667 12 ▶ if ( $verb eq 'ps' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "ps") 3 9 12
1668 0 ▶ return $out->( [ sort map { $d->{containers}{$_}{service} } grep { $f{a} || $f{all} || $d->{containers}{$_}{status} ne 'exited' } @mine ], 1 ) if $f{services};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"services"} 0 3 3
Condition0%0/6
$f{'a'} || $f{'all'} || $$d{'containers'}{$_}{'status'} ne 'exited'
l!l&&r!l&&!r
000
$f{"a"} or $f{"all"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$f{'a'} || $f{'all'} || $$d{'containers'}{$_}{'status'} ne 'exited'
$f{"a"} $f{"all"} $$d{'containers'}{$_}{'status'} ne 'exited'
Truth table0%0/4
A or B || C
A= $f{"a"}B= $f{"all"}C= $$d{'containers'}{$_}{'status'} ne 'exited'
ABCresult
1XX1
01X1
0011
0000
1669 my @rows = grep {
1670 3 my $c = $d->{containers}{$_};
1671 ( $f{a} || $f{all} || defined $f{status} || $c->{status} ne 'exited' && $c->{status} ne 'created' )
1672 0 ▶ && ( !@svc || grep { $_ eq $c->{service} } @svc ) && ( !defined $f{status} || $c->{status} eq $f{status} )
Condition33%1/3
not defined $f{"status"} or $$c{"status"} eq $f{"status"}
l!l&&r!l&&!r
600
MC/DC0%0/2
not defined $f{"status"} or $$c{"status"} eq $f{"status"}
not defined $f{"status"} $$c{"status"} eq $f{"status"}
Truth table33%1/3
not(A) or B
A= not defined $f{"status"}B= $$c{"status"} eq $f{"status"}
ABresult
1X1
011
000
1673 6 ▶ } @mine;
Condition47%10/21
($f{'a'} || $f{'all'} || defined $f{'status'} || $$c{'status'} ne 'exited' && $$c{'status'} ne 'created') && (!@svc || grep({$_ eq $$c{'service'};} @svc)) && (!defined($f{'status'}) || $$c{'status'} eq $f{'status'})
!ll&&!rl&&r
006
$f{"a"} || $f{"all"} || defined $f{"status"} || $$c{"status"} ne "exited" && $$c{"status"} ne "created" and !@svc || grep({$_ eq $$c{"service"};} @svc)
!ll&&!rl&&r
006
$f{"a"} or $f{"all"} or defined $f{"status"} or $$c{"status"} ne "exited" and $$c{"status"} ne "created"
l!l&&r!l&&!r
240
$f{"a"} or $f{"all"} or defined $f{"status"}
l!l&&r!l&&!r
204
$f{"a"} or $f{"all"}
l!l&&r!l&&!r
204
$$c{"status"} ne "exited" and $$c{"status"} ne "created"
!ll&&!rl&&r
004
not @svc or grep {$_ eq $$c{"service"};} @svc
l!l&&r!l&&!r
600
MC/DC0%0/8
($f{'a'} || $f{'all'} || defined $f{'status'} || $$c{'status'} ne 'exited' && $$c{'status'} ne 'created') && (!@svc || grep({$_ eq $$c{'service'};} @svc)) && (!defined($f{'status'}) || $$c{'status'} eq $f{'status'})
$f{"a"} $f{"all"} defined $f{"status"} $$c{"status"} ne "exited" $$c{"status"} ne "created" not @svc grep {$_ eq $$c{"service"};} @svc (!defined($f{'status'}) || $$c{'status'} eq $f{'status'})
Truth table9%2/22
A or B or C or D and E and not(F) or G && H
A= $f{"a"}B= $f{"all"}C= defined $f{"status"}D= $$c{"status"} ne "exited"E= $$c{"status"} ne "created"F= not @svcG= grep {$_ eq $$c{"service"};} @svcH= (!defined($f{'status'}) || $$c{'status'} eq $f{'status'})
ABCDEFGHresult
0000XXXX0
00010XXX0
1XXXX00X0
01XXX00X0
001XX00X0
0001100X0
1XXXX1X00
1XXXX0100
01XXX1X00
01XXX0100
001XX1X00
001XX0100
000111X00
000110100
1XXXX1X11
1XXXX0111
01XXX1X11
01XXX0111
001XX1X11
001XX0111
000111X11
000110111
1674 0 ▶ return $out->( [ map { _id( $_, $d->{containers}{$_}{seq} ) } @rows ], 1 ) if $f{q} || $f{quiet};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"q"} or $f{"quiet"} 0 3 3
Condition33%1/3
$f{"q"} or $f{"quiet"}
l!l&&r!l&&!r
003
MC/DC0%0/2
$f{"q"} or $f{"quiet"}
$f{"q"} $f{"quiet"}
Truth table33%1/3
A or B
A= $f{"q"}B= $f{"quiet"}
ABresult
1X1
011
000
1675 3 ▶ if ( defined $f{format} && $f{format} ne 'table' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $f{"format"} and $f{"format"} ne "table") 1 2 3
Condition66%2/3
defined $f{"format"} and $f{"format"} ne "table"
!ll&&!rl&&r
201
MC/DC50%1/2
defined $f{"format"} and $f{"format"} ne "table"
defined $f{"format"} $f{"format"} ne "table"
Truth table66%2/3
A and B
A= defined $f{"format"}B= $f{"format"} ne "table"
ABresult
0X0
100
111
1676 1 ▶ my $fm = $f{format} eq 'json' ? '{{json .}}' : $f{format};
Branch: 1 branch
BranchTrueFalseTotal
$f{'format'} eq 'json' ? : 0 1 1
1677 1 return $out->( [ gofmt( $fm, [ map { _ps_row( $d, $_ ) } @rows ] ) ], 1 );
1678 }
1679 2 my @l = ( sprintf( '%-22s %-44s %-24s %-10s %-18s %-28s %s', qw( NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS ) ) );
1680 2 for my $n (@rows) {
1681 4 my $c = $d->{containers}{$n};
1682 push @l, sprintf( '%-22s %-44s %-24s %-10s %-18s %-28s %s', $n, $c->{image}, '"docker-entrypoint.s…"', $c->{service},
1683 4 ▶ 'About an hour ago', _status_text($c), _ports_text( $c, _image( $d, $c->{image} ) || {} ) );
Condition50%1/2
_image($d, $$c{'image'}) || {}
l!l
40
MC/DC0%0/1
_image($d, $$c{'image'}) || {}
_image($d, $$c{'image'})
Truth table50%1/2
A
A= _image($d, $$c{'image'})
Aresult
11
00
1684 }
1685 2 return $out->( \@l, 1 );
1686 }
1687 9 ▶ if ( $verb eq 'logs' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "logs") 1 8 9
1688 1 ▶ return ( '', _gap('docker compose logs -f') ) if $f{f} || $f{follow};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"f"} or $f{"follow"} 0 1 1
Condition33%1/3
$f{"f"} or $f{"follow"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$f{"f"} or $f{"follow"}
$f{"f"} $f{"follow"}
Truth table33%1/3
A or B
A= $f{"f"}B= $f{"follow"}
ABresult
1X1
011
000
1689 1 my @l;
1690 1 for my $n (@mine) {
1691 2 my $c = $d->{containers}{$n};
1692 2 ▶ next if @svc && !grep { $_ eq $c->{service} } @svc;
Branch: 1 branch
BranchTrueFalseTotal
if @svc and not grep({$_ eq $$c{"service"};} @svc) 1 1 2
Condition66%2/3
@svc and not grep({$_ eq $$c{"service"};} @svc)
!ll&&!rl&&r
011
MC/DC50%1/2
@svc and not grep({$_ eq $$c{"service"};} @svc)
@svc not grep({$_ eq $$c{"service"};} @svc)
Truth table66%2/3
A and not(B)
A= @svcB= not grep({$_ eq $$c{"service"};} @svc)
ABresult
0X0
100
111
1693 1 my @x = _logs_of( $d, $n );
1694 1 ▶ @x = @x[ ( @x > $f{tail} ? @x - $f{tail} : 0 ) .. $#x ] if defined $f{tail} && $f{tail} =~ /\A\d+\z/;
Branch: 2 branches
BranchTrueFalseTotal
if defined $f{"tail"} and $f{"tail"} =~ /\A\d+\z/ 0 1 1
@x > $f{'tail'} ? : 0 0 0
Condition33%1/3
defined $f{"tail"} and $f{"tail"} =~ /\A\d+\z/
!ll&&!rl&&r
100
MC/DC0%0/2
defined $f{"tail"} and $f{"tail"} =~ /\A\d+\z/
defined $f{"tail"} $f{"tail"} =~ /\A\d+\z/
Truth table33%1/3
A and B
A= defined $f{"tail"}B= $f{"tail"} =~ /\A\d+\z/
ABresult
0X0
100
111
1695 1 push @l, map { sprintf( '%-12s| %s', $n, $_ ) } @x;
1696 }
1697 1 return $out->( \@l, 1 );
1698 }
1699 8 ▶ if ( $verb =~ /\A(?:restart|stop|start|kill)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb =~ /\A(?:restart|stop|start|kill)\z/) 3 5 8
1700 3 my @l;
1701 3 for my $n (@mine) {
1702 5 my $c = $d->{containers}{$n};
1703 5 ▶ next if @svc && !grep { $_ eq $c->{service} } @svc;
Branch: 1 branch
BranchTrueFalseTotal
if @svc and not grep({$_ eq $$c{"service"};} @svc) 2 3 5
Condition66%2/3
@svc and not grep({$_ eq $$c{"service"};} @svc)
!ll&&!rl&&r
032
MC/DC50%1/2
@svc and not grep({$_ eq $$c{"service"};} @svc)
@svc not grep({$_ eq $$c{"service"};} @svc)
Truth table66%2/3
A and not(B)
A= @svcB= not grep({$_ eq $$c{"service"};} @svc)
ABresult
0X0
100
111
1704 3 push @l, " Container $n " . { restart => 'Restarting', stop => 'Stopping', start => 'Starting', kill => 'Killing' }->{$verb};
1705 3 ▶ if ( defined( my $e = _lifecycle( $dev, $d, $n, $c, $verb, $ctx ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $e = _lifecycle($dev, $d, $n, $c, $verb, $ctx))) 1 2 3
1706 1 _settle($dev);
1707 1 return $out->( [ @l, " Container $n Error", $e ], 0 );
1708 }
1709 2 push @l, " Container $n " . { restart => 'Started', stop => 'Stopped', start => 'Started', kill => 'Killed' }->{$verb};
1710 }
1711 2 _settle($dev);
1712 2 return $out->( \@l, 1 );
1713 }
1714 5 ▶ if ( $verb eq 'down' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "down") 2 3 5
1715 2 my @l;
1716 2 my %svc_c = map { _cname( $m, $_ ) => 1 } keys %{ $m->{services} };
1717 2 my @orph = grep { !$svc_c{$_} } @mine;
1718 2 for my $n ( reverse @mine ) {
1719 4 ▶ next if !$svc_c{$n} && !( $f{'remove-orphans'} || $m->{nofile} );
Branch: 1 branch
BranchTrueFalseTotal
unless $svc_c{$n} or ($f{"remove-orphans"} or $$m{"nofile"}) 0 4 4
Condition16%1/6
$svc_c{$n} or ($f{"remove-orphans"} or $$m{"nofile"})
l!l&&r!l&&!r
400
$f{"remove-orphans"} or $$m{"nofile"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$svc_c{$n} or ($f{"remove-orphans"} or $$m{"nofile"})
$svc_c{$n} $f{"remove-orphans"} $$m{"nofile"}
Truth table25%1/4
A or B or C
A= $svc_c{$n}B= $f{"remove-orphans"}C= $$m{"nofile"}
ABCresult
1XX1
01X1
0011
0000
1720 4 my $c = $d->{containers}{$n};
1721 4 push @l, " Container $n Stopping", " Container $n Stopped", " Container $n Removing", " Container $n Removed";
1722 4 delete $d->{containers}{$n};
1723 }
1724 unshift @l, "WARN[0000] Found orphan containers ([" . join( ' ', @orph ) . "]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up."
1725 2 ▶ if @orph && !$f{'remove-orphans'} && !$m->{nofile};
Branch: 1 branch
BranchTrueFalseTotal
if @orph and not $f{"remove-orphans"} and not $$m{"nofile"} 0 2 2
Condition33%2/6
@orph and not $f{"remove-orphans"} and not $$m{"nofile"}
!ll&&!rl&&r
200
@orph and not $f{"remove-orphans"}
!ll&&!rl&&r
200
MC/DC0%0/3
@orph and not $f{"remove-orphans"} and not $$m{"nofile"}
@orph not $f{"remove-orphans"} not $$m{"nofile"}
Truth table25%1/4
A and not(B) and not(C)
A= @orphB= not $f{"remove-orphans"}C= not $$m{"nofile"}
ABCresult
0XX0
10X0
1100
1111
1726 2 ▶ for my $nw ( sort grep { ( $d->{networks}{$_}{project} // '' ) eq $m->{name} } keys %{ $d->{networks} || {} } ) {
Condition50%2/4
$$d{"networks"}{$_}{"project"} // ""
l!l
20
$$d{'networks'} || {}
l!l
20
MC/DC0%0/1
$$d{"networks"}{$_}{"project"} // ""
$$d{"networks"}{$_}{"project"}
MC/DC0%0/1
$$d{'networks'} || {}
$$d{'networks'}
Truth table50%1/2
A
A= $$d{"networks"}{$_}{"project"}
Aresult
11
00
Truth table50%1/2
A
A= $$d{'networks'}
Aresult
11
00
1727 2 push @l, " Network $nw Removing", " Network $nw Removed";
1728 2 delete $d->{networks}{$nw};
1729 }
1730 2 ▶ if ( $f{v} || $f{volumes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f{"v"} or $f{"volumes"}) 1 1 2
Condition66%2/3
$f{"v"} or $f{"volumes"}
l!l&&r!l&&!r
101
MC/DC50%1/2
$f{"v"} or $f{"volumes"}
$f{"v"} $f{"volumes"}
Truth table66%2/3
A or B
A= $f{"v"}B= $f{"volumes"}
ABresult
1X1
011
000
1731 1 ▶ my %mine = map { $_ => 1 } grep { !( $m->{external_volumes} || {} )->{$_} } values %{ $m->{volumes} || {} };
Condition50%2/4
$$m{'external_volumes'} || {}
l!l
10
$$m{'volumes'} || {}
l!l
10
MC/DC0%0/1
$$m{'external_volumes'} || {}
$$m{'external_volumes'}
MC/DC0%0/1
$$m{'volumes'} || {}
$$m{'volumes'}
Truth table50%1/2
A
A= $$m{'external_volumes'}
Aresult
11
00
Truth table50%1/2
A
A= $$m{'volumes'}
Aresult
11
00
1732 1 ▶ for my $v ( sort grep { $mine{$_} || ( $d->{volumes}{$_}{project} // '' ) eq $m->{name} } keys %{ $d->{volumes} || {} } ) {
Condition28%2/7
$mine{$_} || ($$d{'volumes'}{$_}{'project'} // '') eq $$m{'name'}
l!l&&r!l&&!r
100
$$d{"volumes"}{$_}{"project"} // ""
l!l
00
$$d{'volumes'} || {}
l!l
10
MC/DC0%0/2
$mine{$_} || ($$d{'volumes'}{$_}{'project'} // '') eq $$m{'name'}
$mine{$_} $$d{"volumes"}{$_}{"project"}
MC/DC0%0/1
$$d{'volumes'} || {}
$$d{'volumes'}
Truth table33%1/3
A || B
A= $mine{$_}B= $$d{"volumes"}{$_}{"project"}
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$d{'volumes'}
Aresult
11
00
1733 1 push @l, " Volume $v Removing", " Volume $v Removed";
1734 1 delete $d->{volumes}{$v};
1735 }
1736 }
1737 2 return $out->( \@l, 1 );
1738 }
1739 3 ▶ if ( $verb eq 'exec' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "exec") 3 0 3
1740 3 my @x = @a;
1741 3 my $s;
1742 3 ▶ while (@x) {
Branch: 1 branch
BranchTrueFalseTotal
if (@x) 3 0 3
1743 3 my $v = shift @x;
1744 0 ▶ if ( $v =~ /\A-(?:e|u|w|-env|-user|-workdir|-index)\z/ ) { shift @x; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /\A-(?:e|u|w|-env|-user|-workdir|-index)\z/) 0 3 3
1745 3 ▶ next if $v =~ /\A-/;
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /\A-/ 0 3 3
1746 3 $s = $v;
1747 3 last;
1748 }
1749 3 ▶ return $out->( ['"docker compose exec" requires at least 2 arguments.'], 0 ) unless defined $s && @x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $s and @x 0 3 3
Condition33%1/3
defined $s and @x
!ll&&!rl&&r
003
MC/DC0%0/2
defined $s and @x
defined $s @x
Truth table33%1/3
A and B
A= defined $sB= @x
ABresult
0X0
100
111
1750 3 my $n = $by_svc{$s};
1751 3 ▶ return $out->( ["service \"$s\" is not running"], 0 ) unless defined $n && $d->{containers}{$n}{status} eq 'running';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n and $$d{"containers"}{$n}{"status"} eq "running" 0 3 3
Condition33%1/3
defined $n and $$d{"containers"}{$n}{"status"} eq "running"
!ll&&!rl&&r
003
MC/DC0%0/2
defined $n and $$d{"containers"}{$n}{"status"} eq "running"
defined $n $$d{"containers"}{$n}{"status"} eq "running"
Truth table33%1/3
A and B
A= defined $nB= $$d{"containers"}{$n}{"status"} eq "running"
ABresult
0X0
100
111
1752 3 my ( $o, $ok ) = _exec( $dev, $d, $n, $d->{containers}{$n}, \@x );
1753 3 return $out->( [ grep { length } $o ], $ok );
1754 }
1755 0 ▶ if ( $verb eq 'images' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "images") 0 0 0
1756 return $out->( [ sprintf( '%-22s %-44s %-12s %s', 'CONTAINER', 'REPOSITORY', 'TAG', 'IMAGE ID' ),
1757 0 map { my $c = $d->{containers}{$_}; my ( $r, $t ) = $c->{image} =~ /\A(.+):([^:]+)\z/; sprintf( '%-22s %-44s %-12s %s', $_, $r, $t, $c->{image_id} ) } @mine ], 1 );
1758 }
1759 0 ▶ if ( $verb eq 'rm' ) { # gestoppte Container entfernen (-f ohne Rueckfrage, -s stoppt vorher)
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "rm") 0 0 0
1760 0 my @l;
1761 0 for my $n (@mine) {
1762 0 my $c = $d->{containers}{$n};
1763 0 ▶ next if @svc && !grep { $_ eq $c->{service} } @svc;
Branch: 1 branch
BranchTrueFalseTotal
if @svc and not grep({$_ eq $$c{"service"};} @svc) 0 0 0
Condition0%0/3
@svc and not grep({$_ eq $$c{"service"};} @svc)
!ll&&!rl&&r
000
MC/DC0%0/2
@svc and not grep({$_ eq $$c{"service"};} @svc)
@svc not grep({$_ eq $$c{"service"};} @svc)
Truth table0%0/3
A and not(B)
A= @svcB= not grep({$_ eq $$c{"service"};} @svc)
ABresult
0X0
100
111
1764 0 ▶ if ( $c->{status} eq 'running' || $c->{status} eq 'restarting' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$c{"status"} eq "running" or $$c{"status"} eq "restarting") 0 0 0
Condition0%0/3
$$c{"status"} eq "running" or $$c{"status"} eq "restarting"
l!l&&r!l&&!r
000
MC/DC0%0/2
$$c{"status"} eq "running" or $$c{"status"} eq "restarting"
$$c{"status"} eq "running" $$c{"status"} eq "restarting"
Truth table0%0/3
A or B
A= $$c{"status"} eq "running"B= $$c{"status"} eq "restarting"
ABresult
1X1
011
000
1765 0 ▶ next unless $f{s} || $f{stop};
Branch: 1 branch
BranchTrueFalseTotal
unless $f{"s"} or $f{"stop"} 0 0 0
Condition0%0/3
$f{"s"} or $f{"stop"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$f{"s"} or $f{"stop"}
$f{"s"} $f{"stop"}
Truth table0%0/3
A or B
A= $f{"s"}B= $f{"stop"}
ABresult
1X1
011
000
1766 0 _lifecycle( $dev, $d, $n, $c, 'stop', $ctx );
1767 }
1768 0 push @l, " Container $n Removing", " Container $n Removed";
1769 0 delete $d->{containers}{$n};
1770 }
1771 0 ▶ return $out->( @l ? \@l : ['No stopped containers'], 1 );
Branch: 1 branch
BranchTrueFalseTotal
@l ? : 0 0 0
1772 }
1773 0 ▶ return _gap("docker compose $verb") if $verb =~ /\A(?:build|run|cp|top|events|port|attach|watch|create|wait|scale|pause|unpause|stats)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $verb =~ /\A(?:build|run|cp|top|events|port|attach|watch|create|wait|scale|pause|unpause|stats)\z/ 0 0 0
1774 0 return ( "unknown docker command: \"compose $verb\"", 0 );
1775 }
1776  
1777 2 ▶sub _config_yaml {
Subroutine _config_yaml: called CC=17 SCAR=28.8
1778 2 my ($m) = @_;
1779 2 my %y = ( name => $m->{name}, services => {} );
1780 2 for my $s ( sort keys %{ $m->{services} } ) {
1781 4 my $c = $m->{services}{$s};
1782 4 ▶ my %o = map { defined $c->{$_} ? ( $_ => $c->{$_} ) : () } qw( image container_name user command restart healthcheck profiles );
Branch: 1 branch
BranchTrueFalseTotal
defined $$c{$_} ? : 14 14 28
1783 4 ▶ delete $o{profiles} unless @{ $c->{profiles} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$$c{"profiles"} or [];} 4 0 4
Condition50%1/2
$$c{'profiles'} || []
l!l
40
MC/DC0%0/1
$$c{'profiles'} || []
$$c{'profiles'}
Truth table50%1/2
A
A= $$c{'profiles'}
Aresult
11
00
1784 4 ▶ $o{environment} = $c->{environment} if %{ $c->{environment} || {} };
Branch: 1 branch
BranchTrueFalseTotal
if %{$$c{"environment"} or {};} 4 0 4
Condition50%1/2
$$c{'environment'} || {}
l!l
40
MC/DC0%0/1
$$c{'environment'} || {}
$$c{'environment'}
Truth table50%1/2
A
A= $$c{'environment'}
Aresult
11
00
1785 $o{ports} = [ map { { mode => 'ingress', target => 0 + $_->{target}, ( length $_->{published} ? ( published => "$_->{published}" ) : () ),
1786 4 ▶ ( $_->{host_ip} ne '0.0.0.0' ? ( host_ip => $_->{host_ip} ) : () ), protocol => $_->{protocol} } } @{ $c->{ports} } ] if @{ $c->{ports} };
Branch: 3 branches
BranchTrueFalseTotal
if @{$$c{"ports"};} 2 2 4
length $$_{'published'} ? : 2 0 2
$$_{'host_ip'} ne '0.0.0.0' ? : 1 1 2
1787 $o{volumes} = [ map { { type => $_->{type}, ( length $_->{source} ? ( source => $_->{source} ) : () ), target => $_->{target},
1788 4 ▶ ( $_->{read_only} ? ( read_only => '__TRUE__' ) : () ) } } @{ $c->{volumes} } ] if @{ $c->{volumes} };
Branch: 3 branches
BranchTrueFalseTotal
if @{$$c{"volumes"};} 2 2 4
length $$_{'source'} ? : 2 0 2
$$_{'read_only'} ? : 0 2 2
1789 4 $o{networks} = { map { $_ => undef } @{ $c->{networks} } };
1790 4 ▶ $o{depends_on} = { map { $_ => { condition => $c->{depends_on}{$_}{condition}, required => '__TRUE__' } } keys %{ $c->{depends_on} } } if %{ $c->{depends_on} };
Branch: 1 branch
BranchTrueFalseTotal
if %{$$c{"depends_on"};} 2 2 4
1791 4 $y{services}{$s} = \%o;
1792 }
1793 2 ▶ $y{networks} = { ( map { $_ => { name => $m->{networks}{$_} } } keys %{ $m->{networks} || {} } ), default => { name => "$m->{name}_default" } };
Condition50%1/2
$$m{'networks'} || {}
l!l
20
MC/DC0%0/1
$$m{'networks'} || {}
$$m{'networks'}
Truth table50%1/2
A
A= $$m{'networks'}
Aresult
11
00
1794 2 ▶ $y{volumes} = { map { $_ => { name => $m->{volumes}{$_} } } keys %{ $m->{volumes} } } if %{ $m->{volumes} || {} };
Branch: 1 branch
BranchTrueFalseTotal
if %{$$m{"volumes"} or {};} 2 0 2
Condition50%1/2
$$m{'volumes'} || {}
l!l
20
MC/DC0%0/1
$$m{'volumes'} || {}
$$m{'volumes'}
Truth table50%1/2
A
A= $$m{'volumes'}
Aresult
11
00
1795 2 my $t = Encode::decode( 'UTF-8', YAML::XS::Dump( \%y ) );
1796 2 $t =~ s/\A---\n//;
1797 2 $t =~ s/: ~$/: null/mg;
1798 2 $t =~ s/'?__TRUE__'?/true/g;
1799 2 $t =~ s/\n\z//;
1800 2 return $t;
1801 }
1802  
1803 3 1;
1804  
1805 __END__
« blib/lib/Langertha/Holmgang/Shell.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Http.pm »