chainlint.pl: make CPU count computation more robust
commit037348e99ada4d819460326c21d6cebe6338bfe6
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 20 May 2024 19:01:29 +0000 (20 15:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 May 2024 19:36:41 +0000 (20 12:36 -0700)
treea1927018a20ec336730d633a5ab6394cb69a9ade
parentb9b439e0e3a543ddb920e4cf8d3c9d53f730111f
chainlint.pl: make CPU count computation more robust

There have been reports[1,2] of chainlint.pl failing to produce output
when output is expected. In fact, the underlying problem is more severe:
in these cases, it isn't doing any work at all, thus not checking Git
tests for semantic problems. In the reported cases, the problem was
tracked down to ncores() returning 0 for the CPU count, which resulted
in chainlint.pl not performing any work (since it thought it had no
cores on which to process).

In the reported cases, the reason for the failure was that the regular
expression counting the number of processors reported by /proc/cpuinfo
failed to find any matches, hence it counted 0 processors. Although
fixing each case as it is reported allows chaining.pl to work correctly
on that architecture, it does nothing to improve the overall robustness
of the core count computation which may still return 0 on some yet
untested architecture.

Address this shortcoming by ensuring that ncores() returns a sensible
fallback value in all cases.

[1]: https://lore.kernel.org/git/pull.1385.git.git.1669148861635.gitgitgadget@gmail.com/
[2]: https://lore.kernel.org/git/8baa12f8d044265f1ddeabd64209e7ac0d3700ae.camel@physik.fu-berlin.de/

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/chainlint.pl