Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use nproc without --all on Linux
  • Loading branch information
am11 committed Aug 28, 2022
commit b70642633fcdc14aa0e21a7fcfee346eb7107243
20 changes: 8 additions & 12 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,19 @@ __HostOS=$os
__BuildOS=$os

# Get the number of processors available to the scheduler
# Other techniques such as `nproc` only get the number of
# processors available to a single process.
platform="$(uname)"
if [[ "$platform" == "FreeBSD" ]]; then
__NumProc=$(($(sysctl -n hw.ncpu)+1))
__NumProc="$(($(sysctl -n hw.ncpu)+1))"
elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then
__NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
__NumProc="$(($(getconf NPROCESSORS_ONLN)+1))"
elif [[ "$platform" == "Darwin" ]]; then
__NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
__NumProc="$(($(getconf _NPROCESSORS_ONLN)+1))"
elif command -v nproc > /dev/null 2>&1; then
__NumProc="$(nproc)"
elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
__NumProc="$(getconf _NPROCESSORS_ONLN)"
else
if command -v nproc > /dev/null 2>&1; then
__NumProc=$(nproc --all)
elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
__NumProc=$(getconf _NPROCESSORS_ONLN)
else
__NumProc=1
fi
__NumProc=1
fi

while :; do
Expand Down
26 changes: 14 additions & 12 deletions src/tests/Common/scripts/bringup_runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -727,20 +727,22 @@ function run_test {
return $testScriptExitCode
}

# Variables for running tests in the background
if [ `uname` = "NetBSD" ]; then
NumProc=$(getconf NPROCESSORS_ONLN)
elif [ `uname` = "Darwin" ]; then
NumProc=$(getconf _NPROCESSORS_ONLN)
# Get the number of processors available to the scheduler
platform="$(uname)"
if [[ "$platform" == "FreeBSD" ]]; then
NumProc="$(($(sysctl -n hw.ncpu)+1))"
elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then
NumProc="$(($(getconf NPROCESSORS_ONLN)+1))"
elif [[ "$platform" == "Darwin" ]]; then
NumProc="$(($(getconf _NPROCESSORS_ONLN)+1))"
elif command -v nproc > /dev/null 2>&1; then
NumProc="$(nproc)"
elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
NumProc="$(getconf _NPROCESSORS_ONLN)"
else
if [ -x "$(command -v nproc)" ]; then
NumProc=$(nproc --all)
elif [ -x "$(command -v getconf)" ]; then
NumProc=$(getconf _NPROCESSORS_ONLN)
else
NumProc=1
fi
NumProc=1
fi

((maxProcesses = $NumProc * 3 / 2)) # long tests delay process creation, use a few more processors

((processCount = 0))
Expand Down
22 changes: 12 additions & 10 deletions src/tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,19 @@ else
fi

# Get the number of processors available to the scheduler
# Other techniques such as `nproc` only get the number of
# processors available to a single process.
__Platform="$(uname)"
if [[ "$__Platform" == "FreeBSD" ]]; then
__NumProc=$(($(sysctl -n hw.ncpu)+1))
elif [[ "$__Platform" == "NetBSD" || "$__Platform" == "SunOS" ]]; then
__NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
elif [[ "$__Platform" == "Darwin" ]]; then
__NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
platform="$(uname)"
if [[ "$platform" == "FreeBSD" ]]; then
__NumProc="$(($(sysctl -n hw.ncpu)+1))"
elif [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then
__NumProc="$(($(getconf NPROCESSORS_ONLN)+1))"
elif [[ "$platform" == "Darwin" ]]; then
__NumProc="$(($(getconf _NPROCESSORS_ONLN)+1))"
elif command -v nproc > /dev/null 2>&1; then
__NumProc="$(nproc)"
elif (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
__NumProc="$(getconf _NPROCESSORS_ONLN)"
else
__NumProc=$(nproc --all)
__NumProc=1
fi

# Set dependent variables
Expand Down