From: Jérémie Galarneau Date: Fri, 12 Feb 2016 16:17:18 +0000 (-0500) Subject: Tests: Introduce conf_proc_count() X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=9e136324e6ac723dd66fcec57d90843ab16eaedf;p=lttng-tools.git Tests: Introduce conf_proc_count() Tests are using the nproc utility which return the number of _available_ CPUs. The distinction between online, available and configured CPUs is subtle, but important. The number of "online" CPUs can change at runtime as CPUs are hot-plugged. This could happen during a test and result in unexpected results. The number of "configured" CPUs includes any CPU which may be offline at the time. The number of "available" CPUs, which is what is returned by the nproc utility, may differ from both "online" and "configured" counts. This is the case in containers which are assigned to a subset of configured CPUs. Signed-off-by: Jérémie Galarneau --- diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 42b344138..da23f7abe 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -86,6 +86,16 @@ function randstring() echo } +# Return the number of _configured_ CPUs. +function conf_proc_count() +{ + getconf _NPROCESSORS_CONF + if [ $? -ne 0 ]; then + diag "Failed to get the number of configured CPUs" + fi + echo +} + function enable_kernel_lttng_event { local expected_to_fail="$1"