summaryrefslogtreecommitdiff
path: root/validate
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2014-08-19 16:54:13 +0300
committerSergei Trofimovich <slyfox@gentoo.org>2014-08-19 16:54:14 +0300
commitf328890021253c426b7450b6c5a1061d25f6219b (patch)
tree452fc2081dd70d016aee5b790e68d0b03e0a5ce2 /validate
parentf9f89b7884ccc8ee5047cf4fffdf2b36df6832df (diff)
downloadhaskell-f328890021253c426b7450b6c5a1061d25f6219b.tar.gz
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
Diffstat (limited to 'validate')
-rwxr-xr-xvalidate32
1 files changed, 27 insertions, 5 deletions
diff --git a/validate b/validate
index 7a7b1256a5..8ea9eace1c 100755
--- a/validate
+++ b/validate
@@ -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