The kernel falls back to -1 in
/sys/devices/system/cpu/cpuN/topology/physical_package_id when the
architecture does not expose physical package information:
https://www.kernel.org/doc/html/latest/admin-guide/cputopology.html
Issue #495 reports exactly this on ppc64, where parsing the value as
usize made lscpu panic. Parse it as i64 instead, so unknown ids
collapse into a single socket bucket, matching the Socket(s): 1 that
util-linux lscpu is observed to report there.
Fixes#495
Co-authored-by: mmc <codeberg.wilder850@simplelogin.com>
* chcpu: report each error only once
Every failure was printed twice: `CpuList::run` reported it itself with a raw
`eprintln!`, then also returned it, so `uucore` printed it again with the
`chcpu: ` prefix. The unprefixed copy came first, which is the one users saw.
Reporting each per-CPU failure with `uucore::show!` keeps the diagnostic for
every element of a CPU list, gives all of them the program-name prefix that
was previously only on the duplicate, and sets the exit code rather than
returning an error - the pattern uucore documents for non-fatal errors when
applying an operation to many items. Exit codes are untouched: 1 when nothing
succeeded, 64 for partial success.
Adds the first tests for this utility, covering the error paths. They need no
privileges and change no CPU state: an absent CPU index is rejected before
anything is written, and enabling an already-enabled CPU only prints.
* chcpu: cover argument parsing in tests
These reach only clap, never sysfs, so they also guard the option surface on
the platforms where the utility itself is unimplemented.
---------
Co-authored-by: mmc <codeberg.wilder850@simplelogin.com>