summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2013-06-20 17:27:53 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2013-06-20 17:27:53 -0700
commit523bce73dc42a524a59564deb3306de4979cc86d (patch)
tree0907df885a816ce3e12a236517fb02c50d7e6487 /spec
parentc30083f59dd2860eebd7ca269f1e36837d6a58e6 (diff)
downloadchef-523bce73dc42a524a59564deb3306de4979cc86d.tar.gz
add test, bitwise arithm, note about 1.8/1.9/2.0 differences
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/run_lock_spec.rb5
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/support/platform_helpers.rb6
3 files changed, 12 insertions, 0 deletions
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index 5e64e42a0b..7dc23d41fd 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -168,6 +168,11 @@ describe Chef::RunLock do
File.should exist(lockfile)
end
+ it "sets FD_CLOEXEC on the lockfile", :supports_cloexec => true do
+ run_lock.acquire
+ (run_lock.runlock.fcntl(Fcntl::F_GETFD, 0) & Fcntl::FD_CLOEXEC).should == Fcntl::FD_CLOEXEC
+ end
+
it "allows only one chef client run per lockfile" do
# First process, gets the lock and keeps it.
p1 = fork do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 23d10b2bba..c3619dd773 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -94,6 +94,7 @@ RSpec.configure do |config|
config.filter_run_excluding :windows32_only => true unless windows32?
config.filter_run_excluding :system_windows_service_gem_only => true unless system_windows_service_gem?
config.filter_run_excluding :unix_only => true unless unix?
+ config.filter_run_excluding :supports_cloexec => true unless supports_cloexec?
config.filter_run_excluding :selinux_only => true unless selinux_enabled?
config.filter_run_excluding :ruby_18_only => true unless ruby_18?
config.filter_run_excluding :ruby_19_only => true unless ruby_19?
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index f9d2338bf4..92f03ac996 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -1,3 +1,5 @@
+require 'fcntl'
+
def ruby_19?
!!(RUBY_VERSION =~ /^1.9/)
end
@@ -46,6 +48,10 @@ def freebsd?
!!(RUBY_PLATFORM =~ /freebsd/)
end
+def supports_cloexec?
+ Fcntl.const_defined?('F_SETFD') && Fcntl.const_defined?('FD_CLOEXEC')
+end
+
DEV_NULL = windows? ? 'NUL' : '/dev/null'
def selinux_enabled?