Consider OS when query processor count in ctest_all.sh (#12490)

On macOS, we don't have `nproc`. Instead, we should use `sysctl -n
hw.logicalcpu`.

---------

Co-authored-by: Scott Todd <scotttodd@google.com>
Co-authored-by: Geoffrey Martin-Noble <gcmn@google.com>
diff --git a/build_tools/cmake/ctest_all.sh b/build_tools/cmake/ctest_all.sh
index 2837a2f..b1a2560 100755
--- a/build_tools/cmake/ctest_all.sh
+++ b/build_tools/cmake/ctest_all.sh
@@ -15,8 +15,16 @@
 
 BUILD_DIR="$1"
 
+get_default_parallel_level() {
+  if [[ "$(uname)" == "Darwin" ]]; then
+    echo "$(sysctl -n hw.logicalcpu)"
+  else
+    echo "$(nproc)"
+  fi
+}
+
 # Respect the user setting, but default to as many jobs as we have cores.
-export CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL:-$(nproc)}
+export CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL:-$(get_default_parallel_level)}
 
 # Respect the user setting, but default to turning on Vulkan.
 export IREE_VULKAN_DISABLE=${IREE_VULKAN_DISABLE:-0}