Set ulimit only with many CPUs

Allow ulimit setting fail without breaking the build.
Some builders do not allow changing ulimit, that would not be a problem
on most of builders. Use it more a hint than requirement.
This commit is contained in:
Petr Menšík 2021-01-27 14:36:55 +01:00
parent a6938e85a7
commit 9bba50dd4a

View File

@ -598,15 +598,18 @@ export TSAN_OPTIONS="log_exe_name=true log_path=ThreadSanitizer exitcode=0"
%if %{with UNITTEST} %if %{with UNITTEST}
pushd build pushd build
ORIGFILES=$(ulimit -n) CPUS=$(lscpu -p=cpu,core | grep -v '^#' | wc -l)
ulimit -n 4096 # Requires on some machines with many cores if [ "$CPUS" -gt 16 ]; then
ORIGFILES=$(ulimit -n)
ulimit -n 4096 || : # Requires on some machines with many cores
fi
make unit make unit
e=$? e=$?
if [ "$e" -ne 0 ]; then if [ "$e" -ne 0 ]; then
echo "ERROR: this build of BIND failed 'make unit'. Aborting." echo "ERROR: this build of BIND failed 'make unit'. Aborting."
exit $e; exit $e;
fi; fi;
ulimit -n $ORIGFILES [ "$CPUS" -gt 16 ] && ulimit -n $ORIGFILES || :
popd popd
## End of UNITTEST ## End of UNITTEST
%endif %endif