Commit 66fd3ec2 by Mislav Marohnić

Merge branch 'freebsd-cpu'

Closes #610
parents bff583b2 f4c2fe67
...@@ -115,13 +115,16 @@ file_is_not_empty() { ...@@ -115,13 +115,16 @@ file_is_not_empty() {
} }
num_cpu_cores() { num_cpu_cores() {
local num="" local num
if [ "Darwin" = "$(uname -s)" ]; then case "$(uname -s)" in
Darwin | *BSD )
num="$(sysctl -n hw.ncpu 2>/dev/null || true)" num="$(sysctl -n hw.ncpu 2>/dev/null || true)"
elif [ -r /proc/cpuinfo ]; then ;;
num="$(grep ^processor /proc/cpuinfo | wc -l)" * )
[ "$num" -gt 0 ] || num="" num="$(grep ^processor /proc/cpuinfo 2>/dev/null | wc -l | xargs)"
fi num="${num#0}"
;;
esac
echo "${num:-2}" echo "${num:-2}"
} }
......
...@@ -245,6 +245,30 @@ make install ...@@ -245,6 +245,30 @@ make install
OUT OUT
} }
@test "number of CPU cores is detected on FreeBSD" {
cached_tarball "ruby-2.0.0"
stub uname '-s : echo FreeBSD'
stub sysctl '-n hw.ncpu : echo 1'
stub_make_install
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
DEF
assert_success
unstub uname
unstub sysctl
unstub make
assert_build_log <<OUT
ruby-2.0.0: --prefix=$INSTALL_ROOT
make -j 1
make install
OUT
}
@test "setting RUBY_MAKE_INSTALL_OPTS to a multi-word string" { @test "setting RUBY_MAKE_INSTALL_OPTS to a multi-word string" {
cached_tarball "ruby-2.0.0" cached_tarball "ruby-2.0.0"
......
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