From 4ab5d81ce131df500273f4a67b0d61262cdda7eb Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 6 Jul 2021 13:36:24 +0200 Subject: [PATCH] tests: fix determining number of processors on non-macOS --- tests/test.d/controller.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/test.d/controller.rb b/tests/test.d/controller.rb index 3933d1ba7..192121b62 100644 --- a/tests/test.d/controller.rb +++ b/tests/test.d/controller.rb @@ -18,13 +18,11 @@ class Controller end def get_num_processors - case RUBY_PLATFORM - when /darwin/ - np = `/usr/sbin/sysctl -n hw.availcpu`.to_i - else - np = IO.readlines("/proc/cpuinfo").collect { |line| /^processor\s+:\s+(\d+)/.match(line) ? $1.to_i : 0 }.max + 1 - end - return np > 0 ? np : 1 + np = case RUBY_PLATFORM + when /darwin/ then `/usr/sbin/sysctl -n hw.availcpu`.to_i + else `nproc`.to_i + end + [ np, 0 ].max + 1 end def num_threads=(num)