botan
botan copied to clipboard
os_utils: Test failure
When trying to build on Mageia Cauldron x86_64.
os_utils:
OS::get_cpu_cycle_counter ran 1 tests all ok
OS::get_cpu_total/OS::get_cpu_available ran 1 tests 1 FAILED
Failure 1: OS::get_cpu_total/OS::get_cpu_available get_cpu_available not greater than total unexpected result 24 > 1
Build log can be found here: https://pkgsubmit.mageia.org/uploads/failure/cauldron/core/release/20211026173056.kekepower.duvel.14005/log/botan2-2.18.2-1.mga9/build.x86_64.0.20211026173205.log
Thanks for reporting this.
Looking at the implementation of those functions (OS::get_cpu_total()
, OS::get_cpu_available()
): I assume that OS::get_cpu_total()
falls back to the default return value (1) while OS::get_cpu_available()
returns the correct ::sysconf(_SC_NPROCESSORS_ONLN)
result (24 in your case).
Could you check, whether your platform provides:
-
_SC_NPROCESSORS_CONF
included withunistd.h
-
_SC_NPROCESSORS_ONLN
included withunistd.h
In any case, the sysconf()
manpage notes that both of those "may not be standard".
As a side note: std::thread::hardware_concurrency()
could return 0 under certain conditions. Hence, we should double-check this in OS::get_cpu_total()
and make those implementations more resilient.
Looking at it further get_cpu_total
isn't something we even need or use, except for this test. We can simplify things down to just get_cpu_available
, which returns a best guess at the number of CPUs (which should be at least 1!).
This was resolved by #2837