Branch Coverage

blib/lib/Zabbix/ServerScript.pm
Criterion Covered Total %
branch 92 102 90.2


line true false branch
26 0 19 unless eval { do { require Zabbix::ServerScript::Config; 1 } } or eval { do { require Zabbix::ServerScript::DefaultConfig; 1 } }
50 11 7 defined $opt ? :
61 1 17 unless &GetOptions($opt, @opt_specs)
81 2 10 if (defined $id) { }
91 15 63 unless defined $opt
93 0 78 unless defined $Zabbix::ServerScript::Config->{'log_dir'}
94 3 75 unless defined $ENV{'BASENAME'} and $ENV{'ID'}
95 31 44 if (defined $opt->{'log_filename'}) { }
96 28 3 if ($opt->{'log_filename'} ne '') { }
105 3 69 unless defined $Zabbix::ServerScript::Config->{'log'}
109 15 51 if (defined $opt->{'logger'}) { }
110 12 3 if ($opt->{'logger'} eq '') { }
116 16 35 if (defined $opt->{'console'} and $opt->{'console'} == 1) { }
125 7 5 if (defined $opt->{'verbose'} and $opt->{'verbose'})
128 5 61 if (defined $opt->{'debug'} and $opt->{'debug'} == 1)
134 36 23 if ($^S and not defined $ENV{'ZBX_TESTING'} && $ENV{'ZBX_TESTING'} == 1)
155 1 13 unless defined $ENV{'BASENAME'} and $ENV{'ID'}
157 11 2 unless (defined $config_filename)
160 13 0 if ($config_filename ne '')
161 2 11 if (-f $config_filename) { }
163 0 1 unless $config = YAML::LoadFile($config_filename)
165 11 0 unless $config_filename eq ''
175 8 9 if (defined $api)
184 3 5 if defined $id
196 2 9 if (defined $unique and $unique)
198 1 1 if ('Proc::PID::File'->running($pid))
206 2 9 if $daemon
212 1 3 unless (defined $cache_filename)
217 3 1 if (-f $cache_filename) { }
222 1 2 unless (eval { do { $cache = retrieve($cache_filename); 1 } })
233 1 2 unless (defined $cache_filename)
241 1 2 unless (eval { do { store($cache, $cache_filename); 1 } })
264 1 2 if (defined $value) { }
276 1 2 unless defined $dbname
279 1 1 unless $dbh = 'DBI'->connect("dbi:ODBC:DSN=$dbname", $user, $password)
290 6 2 if (ref $request_data eq 'HASH') { }
1 1 elsif (ref $request_data ne 'ARRAY') { }
301 0 6 unless my $request_json = &encode_json($request_data)
307 0 1 unless my $response_data = &decode_json($response_json)
313 10 2 unless defined $sender_host
314 11 1 unless defined $sender_port
317 4 8 unless my $socket = 'IO::Socket::INET'->new('PeerAddr', $sender_host, 'PeerPort', $sender_port, 'Proto', 'tcp', 'Timeout', 10)
329 2 4 unless $socket->write($request_json, $request_length)
330 1 3 unless $socket->read($response_json, 2048)
331 1 2 unless $socket->close
341 4 0 defined $opt ? :
355 1 3 unless -d $module_dir and -w $module_dir
359 2 1 if (-f $module_filename)
360 1 1 unless $term->ask_yn('prompt', "\n$module_filename exists.\nOverwrite?", 'default', 'n')
374 0 2 unless open my $fh, '>', $module_filename
378 0 2 unless require $module_filename