Branch Coverage

blib/lib/Sys/CpuAffinity.pm
Criterion Covered Total %
branch 120 520 23.0


line true false branch
74 6 43 if $mask == 0
75 0 43 wantarray ? :
81 0 19 if ($DEBUG)
85 0 19 unless $pid
86 0 19 if (ref $mask eq "ARRAY")
88 0 0 if ($DEBUG)
94 4 15 if ($mask == -1 and $np > 0)
96 0 4 if ($DEBUG)
101 2 17 if ($mask <= 0)
107 2 15 if ($maxmask > 1 and $mask >= $maxmask)
109 2 0 if ($newmask == 0) { }
126 4 15 unless _sanitize_set_affinity_args($pid, $mask)
147 18 4 if ($_NUM_CPUS_CACHED)
182 0 1 if ($^O eq "MSWin32" or $^O eq "cygwin")
183 0 0 if (defined $ENV{'NUMBER_OF_PROCESSORS'})
201 0 0 if $^O ne "MSWin32" and $^O ne "cygwin"
202 0 0 unless _configModule("Win32::API")
203 0 0 if $Sys::CpuAffinity::IS_WOW64_INITIALIZED++
207 0 0 if $hmodule == 0
210 0 0 if $proc == 0
213 0 0 if $current == 0
217 0 0 if ($result != 0)
225 1 0 if $^O ne "MSWin32" and $^O ne "cygwin"
226 0 0 unless _configModule("Win32::API")
228 0 0 if (0 == scalar keys %WIN32_SYSTEM_INFO)
229 0 0 unless (defined $WIN32API{'GetSystemInfo'})
234 0 0 $is_wow64 ? :
0 0 $lpsysinfo_type_avail ? :
260 0 5 if ($XS_LOADED and defined &Sys::CpuAffinity::xs_cpusetGetCPUCount) { }
268 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) { }
282 0 5 unless -r "/proc/cpuinfo"
286 5 0 if (open $cpuinfo_fh, "<", "/proc/cpuinfo")
288 80 2080 if (/^processor\s/)
300 0 1 unless -r "/proc/stat"
304 1 0 if (open $stat_fh, "<", "/proc/stat")
306 16 8 if (/^cpu\d/i)
319 0 0 unless ($bindprocessor)
322 0 0 unless $bindprocessor
325 0 0 unless ($vp_output =~ s/The available process\S+ are:\s*//)
333 0 0 unless ($proc_output =~ s/The available process\S+ are:\s*//)
343 0 0 if (@procs == @vp) { }
352 0 0 if ($bound_output =~ s/The available process\S+ are:\s*//)
364 0 0 unless $^O =~ /solaris/i
365 0 0 unless ($SOLARIS_HINTS and $Sys::CpuAffinity::SOLARIS_HINTS->{'multicpu'})
368 0 0 if ($? == 0 and $maj > 11 || $maj == 11 && $min >= 2) { }
0 0 elsif (defined &Sys::CpuAffinity::xs_setaffinity_processor_affinity) { }
380 1 0 unless $^O =~ /aix/i
381 0 0 unless _configExternalProgram("bindprocessor")
384 0 0 unless $AIX_HINTS
389 0 0 unless $bindprocessor_output
398 1 0 unless $^O =~ /aix/i
399 0 0 unless _configExternalProgram("lsdev")
406 1 0 unless $^O =~ /bsd/i
409 0 0 if (-r '/var/run/dmesg.boot' and open my $fh, '<', '/var/run/dmesg.boot') { }
0 0 elsif (not _configExternalProgram('dmesg')) { }
432 0 0 if (@d > 0)
438 0 0 unless ($ncpus)
443 0 0 if ($dmesg =~ /^cpu(\d+) at /)
450 0 0 if (@dmesg < 50)
457 1 0 unless $^O =~ /solaris/i
458 0 0 unless defined &Sys::CpuAffinity::xs_solaris_numCpus
464 1 0 unless defined &Sys::CpuAffinity::xs_num_cpus_freebsd
469 1 0 unless $^O =~ /solaris/i
470 0 0 unless _configExternalProgram("dmesg")
479 0 0 if ($dmesg =~ /is bound to cpu (\d+)/)
481 0 0 if ($ncpus <= $n)
485 0 0 if ($dmesg =~ /^cpu(\d+):/)
487 0 0 if ($ncpus <= $n)
496 0 0 if ($ncpus == 0)
505 0 1 unless _configExternalProgram("sysctl")
510 1 0 if @results == 0
513 0 0 if ($ncpus == 0)
518 0 0 if ($ncpus == 0)
523 0 0 if ($ncpus == 0)
536 1 0 unless _configExternalProgram("psrinfo")
544 0 1 if $^O =~ /irix/i
545 1 0 unless _configExternalProgram("hinv")
549 0 0 if ($Sys::CpuAffinity::IS_TEST and not $Sys::CpuAffinity::HINV_CALLED++)
564 0 0 if ($ncpu == 0)
574 1 0 unless $^O =~ /darwin/i or $^O =~ /MacOS/i
575 0 0 unless _configExternalProgram("hwprefs")
584 1 0 unless $^O =~ /darwin/ or $^O =~ /MacOS/i
585 0 0 unless _configExternalProgram("system_profiler")
597 0 0 unless (defined $ncpus)
605 1 0 unless $^O =~ /aix/i
606 0 0 unless _configExternalProgram("prtconf")
611 0 0 unless (defined $AIX_prtconf_cache)
614 0 0 unless $result
622 1 0 unless _configModule("Test::Smoke::SysInfo")
624 0 0 if (defined $sysinfo and defined $sysinfo->{'_ncpu'})
634 0 1 unless $^O =~ /linux/i
636 0 1 unless $taskset
646 1 0 if ($mask)
658 0 0 if ($n > 1)
665 0 0 if $n >= 256
676 7 0 if $^O ne "MSWin32" and $^O ne "cygwin"
677 0 0 unless _configModule("Win32::API")
680 0 0 if ($^O eq "cygwin")
684 0 0 unless $pid
686 0 0 if ($pid > 0) { }
701 0 0 unless $processHandle
702 0 0 unless _win32api("GetProcessAffinityMask", $processHandle, $processMask, $systemMask)
722 0 0 unless ($threadHandle)
749 0 0 if ($result == 0)
756 0 0 if ($processMask == 0)
765 0 0 if ($previous_affinity == 0)
771 0 0 if ($previous_affinity != $processMask)
776 0 0 if ($new_affinity == 0)
816 7 0 if $^O ne "MSWin32" and $^O ne "cygwin"
817 0 0 unless _configModule("Win32::Process")
818 0 0 if $pid < 0
820 0 0 if ($^O eq "cygwin")
822 0 0 unless defined $pid
826 0 0 if (not Win32::Process::Open($processHandle, $pid, 0) or ref $processHandle ne "Win32::Process")
830 0 0 unless ($processHandle->GetProcessAffinityMask($processMask, $systemMask))
839 0 7 if $^O ne "linux"
840 0 7 unless _configExternalProgram("taskset")
845 6 1 unless $taskset_output
854 0 2 if (length $mask > 8) { }
865 0 50 unless defined &Sys::CpuAffinity::xs_sched_getaffinity_get_affinity
868 44 6 if ($r)
878 0 0 unless defined &Sys::CpuAffinity::xs_sched_getaffinity_get_affinity
881 0 0 if ($r)
889 7 0 unless $^O =~ /solaris/i
890 0 0 unless _configExternalProgram("pbind")
894 0 0 if ($pbind_output eq "" and $? == 0)
897 0 0 if (kill 'ZERO', $pid) { }
910 0 0 if ($pbind_output =~ /not bound/) { }
0 0 elsif ($pbind_output =~ /: (\d+)/) { }
0 0 elsif ($pbind_output =~ / bound to proces\S+\s+(.+)\.$/) { }
912 0 0 if ($np > 0) { }
924 0 0 unless (defined $cpus)
935 7 0 unless $^O =~ /aix/i
937 0 0 unless $pscmd
939 0 0 unless $AIX_HINTS
942 0 0 unless $data
948 0 0 if ($ipid ne "" and $ibnd)
951 0 0 if ($pidd == $pid)
954 0 0 if ($bndd eq "-")
957 0 0 if ($AIX_HINTS)
969 7 0 unless defined &Sys::CpuAffinity::xs_getaffinity_processor_affinity
972 0 0 if ($ret == 0)
981 7 0 unless defined &Sys::CpuAffinity::xs_getaffinity_processor_bind
982 0 0 unless $^O =~ /solaris/i
983 0 0 if _is_solarisMultiCpuBinding()
986 0 0 if ($ret == 0)
995 7 0 unless $^O =~ /bsd/i
996 0 0 unless _configModule("BSD::Process::Affinity", "0.04")
999 0 0 unless (eval { do { my $affinity = BSD::Process::Affinity::get_process_mask($pid); $mask = $affinity->get; 1 } })
1012 7 0 unless $^O =~ /bsd/i
1013 0 0 unless _configExternalProgram("cpuset")
1022 0 0 if ($cpuset_output =~ /NaN/i)
1026 0 0 if (@cpus > 0)
1034 7 0 unless defined &Sys::CpuAffinity::xs_getaffinity_freebsd
1037 0 0 if ($ret == 0)
1045 0 0 unless (defined &Sys::CpuAffinity::xs_getaffinity_freebsd)
1046 0 0 if ($^O =~ /bsd/)
1054 0 0 if ($ret == 0)
1063 0 7 if ($^O =~ /cygwin/)
1065 0 0 unless defined $pid
1068 2 5 if ($pid < 0) { }
1 4 elsif ($opid == $$) { }
0 4 elsif (defined &Sys::CpuAffinity::xs_win32_getAffinity_proc) { }
1069 2 0 unless defined &Sys::CpuAffinity::xs_win32_getAffinity_thread
1072 0 1 if (defined &Sys::CpuAffinity::xs_win32_getAffinity_proc) { }
0 1 elsif (defined &Sys::CpuAffinity::xs_win32_getAffinity_thread) { }
1090 7 0 unless $^O =~ /bsd/
1093 0 0 if $pid != $$
1094 0 0 unless defined &Sys::CpuAffinity::xs_pthread_self_getaffinity
1096 0 0 if ($z == 0)
1110 0 0 if ($y) { }
1124 7 0 unless $^O =~ /irix/i
1125 0 0 unless defined &Sys::CpuAffinity::xs_irix_sysmp_getaffinity
1127 0 0 if ($result < -1) { }
0 0 elsif ($result == -1) { }
1143 16 0 if $^O ne "MSWin32" and $^O ne "cygwin"
1144 0 0 unless _configModule("Win32::API")
1149 0 0 if ($^O eq "cygwin")
1151 0 0 if ($DEBUG)
1154 0 0 unless defined $pid
1157 0 0 if ($pid > 0) { }
1161 0 0 if ($DEBUG)
1164 0 0 unless $processHandle
1183 0 0 unless $threadHandle
1186 0 0 if ($previous_affinity == 0)
1196 16 0 if $^O ne "MSWin32"
1197 0 0 unless _configModule("Win32::Process")
1199 0 0 if ($^O eq "cygwin")
1202 0 0 if ($DEBUG)
1205 0 0 unless defined $pid
1209 0 0 if (not Win32::Process::Open($processHandle, $pid, 0) or ref $processHandle ne "Win32::Process")
1220 0 0 if ($^O eq "MSWin32" and $v lt '3.51' || $v ge '6.0')
1221 0 0 if ($DEBUG)
1229 0 0 if (_configModule("Win32"))
1230 0 0 unless (Win32::IsWinNT())
1231 0 0 if ($DEBUG)
1246 0 5 if $^O ne "linux" or not _configExternalProgram("taskset")
1253 4 1 if ($taskset_status)
1262 0 16 unless defined &Sys::CpuAffinity::xs_sched_setaffinity_set_affinity
1269 5 0 unless $^O =~ /bsd/i
1270 0 0 unless _configModule("BSD::Process::Affinity", "0.04")
1272 0 0 if (not eval { do { my $affinity = BSD::Process::Affinity::get_process_mask($pid); $affinity->set($mask)->update; 1 } })
1282 1 0 unless $^O =~ /bsd/i
1283 0 0 unless _configModule("BSD::Process::Affinity", "0.04")
1291 5 0 unless $^O =~ /aix/i
1292 0 0 if $pid < 0
1293 0 0 unless _configExternalProgram("bindprocessor")
1296 0 0 unless $AIX_HINTS
1300 0 0 if (@cores == $Sys::CpuAffinity::AIX_HINTS->{'NUM_CORES'}) { }
0 0 elsif (@cores > 1) { }
1310 5 0 unless $^O =~ /solaris/i
1311 0 0 unless _configExternalProgram("pbind")
1318 0 0 if (@mask == $np) { }
1331 5 0 unless $^O =~ /solaris/i
1332 0 0 unless defined &Sys::CpuAffinity::xs_setaffinity_processor_affinity
1335 0 0 if ($ret == 0)
1343 5 0 unless $^O =~ /solaris/i
1344 0 0 unless defined &Sys::CpuAffinity::xs_setaffinity_processor_bind
1345 0 0 if _is_solarisMultiCpuBinding()
1348 0 0 if ($ret == 0)
1356 5 0 unless $^O =~ /bsd/i
1357 0 0 unless _configExternalProgram("cpuset")
1367 5 0 unless defined &Sys::CpuAffinity::xs_setaffinity_freebsd
1376 0 16 if ($^O =~ /cygwin/)
1378 0 0 unless defined $pid
1381 2 14 if ($pid < 0) { }
12 2 elsif ($opid == $$) { }
0 2 elsif (defined &Sys::CpuAffinity::xs_win32_setAffinity_proc) { }
1382 0 2 if (defined &Sys::CpuAffinity::xs_win32_setAffinity_thread)
1385 0 0 if $r
1389 0 12 if (defined &Sys::CpuAffinity::xs_win32_setAffinity_proc)
1393 0 12 if ($^O eq "cygwin" and defined &Sys::CpuAffinity::xs_win32_setAffinity_thread)
1395 0 0 if $r
1411 5 0 unless $^O =~ /bsd/i
1414 0 0 if $$ != $pid
1415 0 0 unless defined &Sys::CpuAffinity::xs_pthread_self_setaffinity
1425 5 0 unless $^O =~ /irix/i
1426 0 0 unless defined &Sys::CpuAffinity::xs_irix_sysmp_setaffinity
1436 0 0 if ($np > 0 and $mask + 1 == &TWO() ** $np) { }
1451 153 66 if ($mask & 1)
1473 0 0 if ($] >= 5.008 and defined &Cygwin::pid_to_winpid) { }
1486 0 0 unless $pid
1487 0 0 if ($pid == $cygwinpid)
1501 31 0 unless $DEBUG
1513 0 5 if defined $MODULE{$module}
1515 1 4 if (eval "require $module") { }
1517 1 0 if (not $@ and !$version || $version <= $v) { }
1534 23 18 if defined $PROGRAM{$program}
1535 0 18 if (-x $program)
1540 18 0 if ($^O ne "MSWin32")
1544 11 7 if ($which =~ / not in / or $which =~ /no \Q$program\E in / or $which =~ /Command not found/ or not -x $which)
1552 7 11 if ($which)
1559 2 9 if (@PATH == 0)
1566 0 143 if (-x "$dir/$program")
1621 0 0 unless _configModule("Win32::API")
1622 0 0 unless (defined $WIN32API{$function})
1625 0 0 if not defined $WIN32API{$function} or $WIN32API{$function} == 0
1633 0 0 unless (defined $spec)
1642 0 0 if ($!)