Branch Coverage

blib/lib/cPanel/StateFile.pm
Criterion Covered Total %
branch 75 96 78.1


line true false branch
108 23 127 unless (defined $the_logger)
115 29 32 unless (defined $the_locker)
117 0 29 if $@
129 1 16 if @_ % 2
130 0 16 if $are_policies_set
131 4 12 unless @_
135 0 12 unless defined $object
136 9 3 if ('-logger' eq $policy) { }
2 1 elsif ('-filelock' eq $policy) { }
137 5 4 unless (ref $object)
139 1 4 if $@
144 1 7 unless _valid_logger($object)
149 1 1 unless (ref $object)
151 1 0 if $@
156 1 0 unless _valid_file_locker($object)
184 0 464 unless 'HASH' eq ref $args_ref
185 0 464 unless exists $$args_ref{'state'}
210 0 484 unless $$self{'lock_file'}
217 5 484 unless $$self{'lock_file'}
219 244 240 if ($$state_file{'file_handle'})
242 1 27 unless defined $$self{'lock_file'}
243 2 25 unless 'CODE' eq ref $code
256 1 19 if $ex
264 0 205 unless defined $$self{'lock_file'}
266 0 205 unless open my $fh, $mode, $$state_file{'file_name'}
274 0 205 unless (eval { do { local $SIG{'ALRM'} = sub { die "flock 2 timeout\n"; } ; my $orig_alarm = alarm $$state_file{'flock_timeout'}; flock $fh, 2; alarm $orig_alarm; 1 } })
276 0 0 if ($@ eq "flock 2 timeout\n") { }
289 1 225 unless defined $$self{'lock_file'}
291 225 0 unless ($$state_file{'file_handle'})
292 186 39 if (-e $$state_file{'file_name'}) { }
296 0 39 unless sysopen my $fh, $$state_file{'file_name'}, &Fcntl::O_CREAT | &Fcntl::O_EXCL | &Fcntl::O_RDWR
302 0 225 unless truncate $$state_file{'file_handle'}, 0
309 0 225 unless seek $$state_file{'file_handle'}, 0, 2
322 1 61 if (exists $$args_ref{'logger'} and _valid_logger($$args_ref{'logger'})) { }
327 1 60 if (exists $$args_ref{'logger'})
331 0 61 if (exists $$args_ref{'locker'} and _valid_file_locker($$args_ref{'locker'})) { }
336 1 60 if (exists $$args_ref{'locker'})
340 0 60 if exists $$args_ref{'cache_file'}
341 3 57 unless exists $$args_ref{'state_file'}
342 1 56 unless exists $$args_ref{'data_obj'}
346 2 54 unless eval { do { $data_obj->can('load_from_cache') } } and eval { do { $data_obj->can('save_to_cache') } }
353 11 43 unless (-d $dirname)
354 0 11 unless File::Path::mkpath($dirname)
378 2 32 unless eval { do { $logger->can($method) } }
391 2 0 unless eval { do { $locker->can($method) } }
403 40 424 if (not -e $$self{'file_name'} or -z _) { }
413 269 187 unless defined wantarray
423 19 425 if ($$self{'file_mtime'} < $mtime or $$self{'file_size'} != $size)