Commit f3288900 authored by Sergei Trofimovich's avatar Sergei Trofimovich
Browse files

validate: add simple CPU count autodetection

Summary: Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

Test Plan: ran ./validate on linux

Reviewers: austin

Reviewed By: austin

Subscribers: phaskell, simonmar, relrod, ezyang, carter

Differential Revision: https://phabricator.haskell.org/D146
parent f9f89b78
......@@ -88,6 +88,32 @@ check_packages () {
echo "== End $1 package check"
}
detect_cpu_count () {
if [ "$CPUS" = "" ]; then
# Windows standard environment variable
CPUS="$NUMBER_OF_PROCESSORS"
fi
if [ "$CPUS" = "" ]; then
# Linux
CPUS=`getconf _NPROCESSORS_ONLN 2>/dev/null`
fi
if [ "$CPUS" = "" ]; then
# FreeBSD
CPUS=`getconf NPROCESSORS_ONLN 2>/dev/null`
fi
if [ "$CPUS" = "" ]; then
# nothing helped
CPUS="1"
fi
echo "using ${CPUS} CPUs" >&2
}
detect_cpu_count
if ! [ -d testsuite ]
then
echo 'Could not find the testsuite for validation' >&2
......@@ -95,11 +121,7 @@ then
fi
if [ "$THREADS" = "" ]; then
if [ "$CPUS" = "" ]; then
threads=2
else
threads=$(($CPUS + 1)) # `expr $CPUS + 1`
fi
threads=$(($CPUS + 1)) # `expr $CPUS + 1`
else
threads="$THREADS"
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment