Branch Coverage

blib/lib/Zabbix/ServerScript.pm
Criterion Covered Total %
branch 96 106 90.5


line true false branch
26 0 19 unless eval { do { require Zabbix::ServerScript::Config; 1 } } or eval { do { require Zabbix::ServerScript::DefaultConfig; 1 } }
51 13 7 if (defined $opt) { }
52 1 12 unless ref $opt eq 'HASH'
57 81 14 unless defined $opt->{$_}
66 1 18 unless &GetOptions($opt, @opt_specs)
86 2 10 if (defined $id) { }
96 15 63 unless defined $opt
98 0 78 unless defined $Zabbix::ServerScript::Config->{'log_dir'}
99 3 75 unless defined $ENV{'BASENAME'} and $ENV{'ID'}
100 31 44 if (defined $opt->{'log_filename'}) { }
101 28 3 if ($opt->{'log_filename'} ne '') { }
110 3 69 unless defined $Zabbix::ServerScript::Config->{'log'}
114 15 51 if (defined $opt->{'logger'}) { }
115 12 3 if ($opt->{'logger'} eq '') { }
121 16 35 if (defined $opt->{'console'} and $opt->{'console'} == 1) { }
130 7 5 if (defined $opt->{'verbose'} and $opt->{'verbose'})
133 5 61 if (defined $opt->{'debug'} and $opt->{'debug'} == 1)
139 36 23 if ($^S and not defined $ENV{'ZBX_TESTING'} && $ENV{'ZBX_TESTING'} == 1)
160 1 13 unless defined $ENV{'BASENAME'} and $ENV{'ID'}
162 11 2 unless (defined $config_filename)
165 13 0 if ($config_filename ne '')
166 2 11 if (-f $config_filename) { }
168 0 1 unless $config = YAML::LoadFile($config_filename)
170 11 0 unless $config_filename eq ''
180 8 9 if (defined $api)
189 3 5 if defined $id
201 2 9 if (defined $unique and $unique)
203 1 1 if ('Proc::PID::File'->running($pid))
211 2 9 if $daemon
217 1 3 unless (defined $cache_filename)
222 3 1 if (-f $cache_filename) { }
227 1 2 unless (eval { do { $cache = retrieve($cache_filename); 1 } })
238 1 2 unless (defined $cache_filename)
246 1 2 unless (eval { do { store($cache, $cache_filename); 1 } })
269 1 2 if (defined $value) { }
281 1 2 unless defined $dbname
284 1 1 unless $dbh = 'DBI'->connect("dbi:ODBC:DSN=$dbname", $user, $password)
295 6 2 if (ref $request_data eq 'HASH') { }
1 1 elsif (ref $request_data ne 'ARRAY') { }
306 0 6 unless my $request_json = &encode_json($request_data)
312 0 1 unless my $response_data = &decode_json($response_json)
318 10 2 unless defined $sender_host
319 11 1 unless defined $sender_port
322 4 8 unless my $socket = 'IO::Socket::INET'->new('PeerAddr', $sender_host, 'PeerPort', $sender_port, 'Proto', 'tcp', 'Timeout', 10)
334 2 4 unless $socket->write($request_json, $request_length)
335 1 3 unless $socket->read($response_json, 2048)
336 1 2 unless $socket->close
346 4 0 defined $opt ? :
360 1 3 unless -d $module_dir and -w $module_dir
364 2 1 if (-f $module_filename)
365 1 1 unless $term->ask_yn('prompt', "\n$module_filename exists.\nOverwrite?", 'default', 'n')
379 0 2 unless open my $fh, '>', $module_filename
383 0 2 unless require $module_filename