Branch Coverage

blib/lib/Sys/CpuAffinity.pm
Criterion Covered Total %
branch 120 518 23.1


line true false branch
76 6 43 if $mask == 0
77 0 43 wantarray ? :
83 0 19 if ($DEBUG)
87 0 19 unless $pid
88 0 19 if (ref $mask eq 'ARRAY')
90 0 0 if ($DEBUG)
96 4 15 if ($mask == -1 and $np > 0)
98 0 4 if ($DEBUG)
103 2 17 if ($mask <= 0)
109 2 15 if ($maxmask > 1 and $mask >= $maxmask)
111 2 0 if ($newmask == 0) { }
128 4 15 unless _sanitize_set_affinity_args($pid, $mask)
149 18 4 if ($_NUM_CPUS_CACHED)
184 0 1 if ($^O eq 'MSWin32' or $^O eq 'cygwin')
185 0 0 if (defined $ENV{'NUMBER_OF_PROCESSORS'})
203 0 0 if $^O ne 'MSWin32' and $^O ne 'cygwin'
204 0 0 unless _configModule('Win32::API')
205 0 0 if $Sys::CpuAffinity::IS_WOW64_INITIALIZED++
209 0 0 if $hmodule == 0
212 0 0 if $proc == 0
215 0 0 if $current == 0
219 0 0 if ($result != 0)
227 1 0 if $^O ne 'MSWin32' and $^O ne 'cygwin'
228 0 0 unless _configModule('Win32::API')
230 0 0 if (0 == scalar keys %WIN32_SYSTEM_INFO)
231 0 0 unless (defined $WIN32API{'GetSystemInfo'})
236 0 0 $is_wow64 ? :
0 0 $lpsysinfo_type_avail ? :
262 0 5 if ($XS_LOADED and defined &Sys::CpuAffinity::xs_cpusetGetCPUCount) { }
270 0 5 if (defined &Sys::CpuAffinity::xs_get_numcpus_from_windows_system_info) { }
0 5 elsif (defined &Sys::CpuAffinity::xs_get_numcpus_from_windows_system_info_alt) { }
284 0 5 unless -r '/proc/cpuinfo'
288 5 0 if (open $cpuinfo_fh, '<', '/proc/cpuinfo')
290 80 2080 if (/^processor\s/)
302 0 1 unless -r '/proc/stat'
306 1 0 if (open $stat_fh, '<', '/proc/stat')
308 16 8 if (/^cpu\d/i)
321 0 0 unless ($bindprocessor)
324 0 0 unless $bindprocessor
327 0 0 unless ($vp_output =~ s/The available process\S+ are:\s*//)
335 0 0 unless ($proc_output =~ s/The available process\S+ are:\s*//)
345 0 0 if (@procs == @vp) { }
354 0 0 if ($bound_output =~ s/The available process\S+ are:\s*//)
366 0 0 unless $^O =~ /solaris/i
367 0 0 unless ($SOLARIS_HINTS and $Sys::CpuAffinity::SOLARIS_HINTS->{'multicpu'})
370 0 0 if ($? == 0 and $maj > 11 || $maj == 11 && $min >= 2) { }
0 0 elsif (defined &Sys::CpuAffinity::xs_setaffinity_processor_affinity) { }
382 1 0 unless $^O =~ /aix/i
383 0 0 unless _configExternalProgram('bindprocessor')
386 0 0 unless $AIX_HINTS
391 0 0 unless $bindprocessor_output
400 1 0 unless $^O =~ /aix/i
401 0 0 unless _configExternalProgram('lsdev')
408 1 0 unless $^O =~ /bsd/i
411 0 0 if (-r '/var/run/dmesg.boot' and open my $fh, '<', '/var/run/dmesg.boot') { }
0 0 elsif (not _configExternalProgram('dmesg')) { }
434 0 0 if (@d > 0)
440 0 0 unless ($ncpus)
445 0 0 if ($dmesg =~ /^cpu(\d+) at /)
452 0 0 if (@dmesg < 50)
459 1 0 unless $^O =~ /solaris/i
460 0 0 unless defined &Sys::CpuAffinity::xs_solaris_numCpus
466 1 0 unless defined &Sys::CpuAffinity::xs_num_cpus_freebsd
471 1 0 unless $^O =~ /solaris/i
472 0 0 unless _configExternalProgram('dmesg')
481 0 0 if ($dmesg =~ /is bound to cpu (\d+)/)
483 0 0 if ($ncpus <= $n)
487 0 0 if ($dmesg =~ /^cpu(\d+):/)
489 0 0 if ($ncpus <= $n)
498 0 0 if ($ncpus == 0)
507 0 1 unless _configExternalProgram('sysctl')
512 1 0 if @results == 0
515 0 0 if ($ncpus == 0)
520 0 0 if ($ncpus == 0)
525 0 0 if ($ncpus == 0)
538 1 0 unless _configExternalProgram('psrinfo')
546 0 1 if $^O =~ /irix/i
547 1 0 unless _configExternalProgram('hinv')
551 0 0 if ($Sys::CpuAffinity::IS_TEST and not $Sys::CpuAffinity::HINV_CALLED++)
566 0 0 if ($ncpu == 0)
576 1 0 unless $^O =~ /darwin/i or $^O =~ /MacOS/i
577 0 0 unless _configExternalProgram('hwprefs')
586 1 0 unless $^O =~ /darwin/ or $^O =~ /MacOS/i
587 0 0 unless _configExternalProgram('system_profiler')
599 0 0 unless (defined $ncpus)
607 1 0 unless $^O =~ /aix/i
608 0 0 unless _configExternalProgram('prtconf')
613 0 0 unless (defined $AIX_prtconf_cache)
616 0 0 unless $result
624 1 0 unless _configModule('Test::Smoke::SysInfo')
626 0 0 if (defined $sysinfo and defined $sysinfo->{'_ncpu'})
636 0 1 unless $^O =~ /linux/i
638 0 1 unless $taskset
648 1 0 if ($mask)
660 0 0 if ($n > 1)
667 0 0 if $n >= 256
678 7 0 if $^O ne 'MSWin32' and $^O ne 'cygwin'
679 0 0 unless _configModule('Win32::API')
682 0 0 if ($^O eq 'cygwin')
686 0 0 unless $pid
688 0 0 if ($pid > 0) { }
703 0 0 unless $processHandle
704 0 0 unless _win32api('GetProcessAffinityMask', $processHandle, $processMask, $systemMask)
724 0 0 unless ($threadHandle)
751 0 0 if ($result == 0)
758 0 0 if ($processMask == 0)
767 0 0 if ($previous_affinity == 0)
773 0 0 if ($previous_affinity != $processMask)
778 0 0 if ($new_affinity == 0)
818 7 0 if $^O ne 'MSWin32' and $^O ne 'cygwin'
819 0 0 unless _configModule('Win32::Process')
820 0 0 if $pid < 0
822 0 0 if ($^O eq 'cygwin')
824 0 0 unless defined $pid
828 0 0 if (not Win32::Process::Open($processHandle, $pid, 0) or ref $processHandle ne 'Win32::Process')
832 0 0 unless ($processHandle->GetProcessAffinityMask($processMask, $systemMask))
841 0 7 if $^O ne 'linux'
842 0 7 unless _configExternalProgram('taskset')
847 6 1 unless $taskset_output
856 0 2 if (length $mask > 8) { }
867 0 50 unless defined &Sys::CpuAffinity::xs_sched_getaffinity_get_affinity
870 44 6 if ($r)
880 0 0 unless defined &Sys::CpuAffinity::xs_sched_getaffinity_get_affinity
883 0 0 if ($r)
891 7 0 unless $^O =~ /solaris/i
892 0 0 unless _configExternalProgram('pbind')
896 0 0 if ($pbind_output eq '' and $? == 0)
899 0 0 if (kill 'ZERO', $pid) { }
912 0 0 if ($pbind_output =~ /not bound/) { }
0 0 elsif ($pbind_output =~ /: (\d+)/) { }
0 0 elsif ($pbind_output =~ / bound to proces\S+\s+(.+)\.$/) { }
914 0 0 if ($np > 0) { }
926 0 0 unless (defined $cpus)
937 7 0 unless $^O =~ /aix/i
939 0 0 unless $pscmd
941 0 0 unless $AIX_HINTS
944 0 0 unless $data
950 0 0 if ($ipid ne '' and $ibnd)
953 0 0 if ($pidd == $pid)
956 0 0 if ($bndd eq '-')
959 0 0 if ($AIX_HINTS)
971 7 0 unless defined &Sys::CpuAffinity::xs_getaffinity_processor_affinity
974 0 0 if ($ret == 0)
983 7 0 unless defined &Sys::CpuAffinity::xs_getaffinity_processor_bind
984 0 0 unless $^O =~ /solaris/i
985 0 0 if _is_solarisMultiCpuBinding()
988 0 0 if ($ret == 0)
997 7 0 unless $^O =~ /bsd/i
998 0 0 unless _configModule('BSD::Process::Affinity', '0.04')
1001 0 0 unless (eval { do { my $affinity = BSD::Process::Affinity::get_process_mask($pid); $mask = $affinity->get; 1 } })
1014 7 0 unless $^O =~ /bsd/i
1015 0 0 unless _configExternalProgram('cpuset')
1025 0 0 if (@cpus > 0)
1033 7 0 unless defined &Sys::CpuAffinity::xs_getaffinity_freebsd
1036 0 0 if ($ret == 0)
1044 0 0 unless (defined &Sys::CpuAffinity::xs_getaffinity_freebsd)
1045 0 0 if ($^O =~ /bsd/)
1053 0 0 if ($ret == 0)
1062 0 7 if ($^O =~ /cygwin/)
1064 0 0 unless defined $pid
1067 2 5 if ($pid < 0) { }
1 4 elsif ($opid == $$) { }
0 4 elsif (defined &Sys::CpuAffinity::xs_win32_getAffinity_proc) { }
1068 2 0 unless defined &Sys::CpuAffinity::xs_win32_getAffinity_thread
1071 0 1 if (defined &Sys::CpuAffinity::xs_win32_getAffinity_proc) { }
0 1 elsif (defined &Sys::CpuAffinity::xs_win32_getAffinity_thread) { }
1089 7 0 unless $^O =~ /bsd/
1092 0 0 if $pid != $$
1093 0 0 unless defined &Sys::CpuAffinity::xs_pthread_self_getaffinity
1095 0 0 if ($z == 0)
1109 0 0 if ($y) { }
1123 7 0 unless $^O =~ /irix/i
1124 0 0 unless defined &Sys::CpuAffinity::xs_irix_sysmp_getaffinity
1126 0 0 if ($result < -1) { }
0 0 elsif ($result == -1) { }
1142 16 0 if $^O ne 'MSWin32' and $^O ne 'cygwin'
1143 0 0 unless _configModule('Win32::API')
1148 0 0 if ($^O eq 'cygwin')
1150 0 0 if ($DEBUG)
1153 0 0 unless defined $pid
1156 0 0 if ($pid > 0) { }
1160 0 0 if ($DEBUG)
1163 0 0 unless $processHandle
1182 0 0 unless $threadHandle
1185 0 0 if ($previous_affinity == 0)
1195 16 0 if $^O ne 'MSWin32'
1196 0 0 unless _configModule('Win32::Process')
1198 0 0 if ($^O eq 'cygwin')
1201 0 0 if ($DEBUG)
1204 0 0 unless defined $pid
1208 0 0 if (not Win32::Process::Open($processHandle, $pid, 0) or ref $processHandle ne 'Win32::Process')
1219 0 0 if ($^O eq 'MSWin32' and $v < 3.51 || $v >= 6)
1220 0 0 if ($DEBUG)
1228 0 0 if (_configModule('Win32'))
1229 0 0 unless (Win32::IsWinNT())
1230 0 0 if ($DEBUG)
1245 0 5 if $^O ne 'linux' or not _configExternalProgram('taskset')
1252 4 1 if ($taskset_status)
1261 0 16 unless defined &Sys::CpuAffinity::xs_sched_setaffinity_set_affinity
1268 5 0 unless $^O =~ /bsd/i
1269 0 0 unless _configModule('BSD::Process::Affinity', '0.04')
1271 0 0 if (not eval { do { my $affinity = BSD::Process::Affinity::get_process_mask($pid); $affinity->set($mask)->update; 1 } })
1281 1 0 unless $^O =~ /bsd/i
1282 0 0 unless _configModule('BSD::Process::Affinity', '0.04')
1290 5 0 unless $^O =~ /aix/i
1291 0 0 if $pid < 0
1292 0 0 unless _configExternalProgram('bindprocessor')
1295 0 0 unless $AIX_HINTS
1299 0 0 if (@cores == $Sys::CpuAffinity::AIX_HINTS->{'NUM_CORES'}) { }
0 0 elsif (@cores > 1) { }
1309 5 0 unless $^O =~ /solaris/i
1310 0 0 unless _configExternalProgram('pbind')
1317 0 0 if (@mask == $np) { }
1328 5 0 unless $^O =~ /solaris/i
1329 0 0 unless defined &Sys::CpuAffinity::xs_setaffinity_processor_affinity
1332 0 0 if ($ret == 0)
1340 5 0 unless $^O =~ /solaris/i
1341 0 0 unless defined &Sys::CpuAffinity::xs_setaffinity_processor_bind
1342 0 0 if _is_solarisMultiCpuBinding()
1345 0 0 if ($ret == 0)
1353 5 0 unless $^O =~ /bsd/i
1354 0 0 unless _configExternalProgram('cpuset')
1364 5 0 unless defined &Sys::CpuAffinity::xs_setaffinity_freebsd
1373 0 16 if ($^O =~ /cygwin/)
1375 0 0 unless defined $pid
1378 2 14 if ($pid < 0) { }
12 2 elsif ($opid == $$) { }
0 2 elsif (defined &Sys::CpuAffinity::xs_win32_setAffinity_proc) { }
1379 0 2 if (defined &Sys::CpuAffinity::xs_win32_setAffinity_thread)
1382 0 0 if $r
1386 0 12 if (defined &Sys::CpuAffinity::xs_win32_setAffinity_proc)
1390 0 12 if ($^O eq 'cygwin' and defined &Sys::CpuAffinity::xs_win32_setAffinity_thread)
1392 0 0 if $r
1408 5 0 unless $^O =~ /bsd/i
1411 0 0 if $$ != $pid
1412 0 0 unless defined &Sys::CpuAffinity::xs_pthread_self_setaffinity
1422 5 0 unless $^O =~ /irix/i
1423 0 0 unless defined &Sys::CpuAffinity::xs_irix_sysmp_setaffinity
1433 0 0 if ($np > 0 and $mask + 1 == &TWO() ** $np) { }
1448 148 67 if ($mask & 1)
1470 0 0 if ($] >= 5.008 and defined &Cygwin::pid_to_winpid) { }
1483 0 0 unless $pid
1484 0 0 if ($pid == $cygwinpid)
1498 31 0 unless $DEBUG
1510 0 5 if defined $MODULE{$module}
1512 1 4 if (eval "require $module") { }
1514 1 0 if (not $@ and !$version || $version <= $v) { }
1531 23 18 if defined $PROGRAM{$program}
1532 0 18 if (-x $program)
1537 18 0 if ($^O ne 'MSWin32')
1541 11 7 if ($which =~ / not in / or $which =~ /no \Q$program\E in / or $which =~ /Command not found/ or not -x $which)
1549 7 11 if ($which)
1556 2 9 if (@PATH == 0)
1563 0 143 if (-x "$dir/$program")
1617 0 0 unless _configModule('Win32::API')
1618 0 0 unless (defined $WIN32API{$function})
1621 0 0 if not defined $WIN32API{$function} or $WIN32API{$function} == 0
1629 0 0 unless (defined $spec)
1638 0 0 if ($!)