diff options
| author | Ian Taylor <ian@lorf.org> | 2009-06-05 12:38:35 -0400 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-06-06 09:11:28 +1000 |
| commit | 41ce18cc8ea239d1633fc6cd9e9f599957a82e74 (patch) | |
| tree | 9d398b4e3e6d726a174b5b57094c7dd6749ccf0e /test/util | |
| parent | f3b40923605420f774dac298fb1708de180c0a81 (diff) | |
| download | puppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.tar.gz puppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.tar.xz puppet-41ce18cc8ea239d1633fc6cd9e9f599957a82e74.zip | |
Changed tabs to spaces without interfering with indentation or alignment
Diffstat (limited to 'test/util')
| -rwxr-xr-x | test/util/autoload.rb | 2 | ||||
| -rwxr-xr-x | test/util/features.rb | 22 | ||||
| -rwxr-xr-x | test/util/fileparsing.rb | 8 | ||||
| -rwxr-xr-x | test/util/inifile.rb | 2 | ||||
| -rwxr-xr-x | test/util/instance_loader.rb | 2 | ||||
| -rwxr-xr-x | test/util/pidlock.rb | 232 | ||||
| -rwxr-xr-x | test/util/settings.rb | 4 | ||||
| -rwxr-xr-x | test/util/storage.rb | 2 |
8 files changed, 137 insertions, 137 deletions
diff --git a/test/util/autoload.rb b/test/util/autoload.rb index 6aaf32995..ae7624b62 100755 --- a/test/util/autoload.rb +++ b/test/util/autoload.rb @@ -7,7 +7,7 @@ require 'puppet/util/autoload' require 'puppettest' class TestAutoload < Test::Unit::TestCase - include PuppetTest + include PuppetTest @things = [] def self.newthing(name) @things << name diff --git a/test/util/features.rb b/test/util/features.rb index e20c73c65..ef69ad72b 100755 --- a/test/util/features.rb +++ b/test/util/features.rb @@ -9,21 +9,21 @@ require 'puppettest' require 'puppet/util/feature' class TestFeatures < Test::Unit::TestCase - include PuppetTest - - def setup - super - @libdir = tempfile() + include PuppetTest + + def setup + super + @libdir = tempfile() Puppet[:libdir] = @libdir @path = File.join(@libdir, "features") - @features = Puppet::Util::Feature.new("features") + @features = Puppet::Util::Feature.new("features") end - - def test_new + + def test_new redirect - assert_nothing_raised do - @features.add(:failer) do - raise ArgumentError, "nopes" + assert_nothing_raised do + @features.add(:failer) do + raise ArgumentError, "nopes" end end diff --git a/test/util/fileparsing.rb b/test/util/fileparsing.rb index adccfab65..d7c196cdb 100755 --- a/test/util/fileparsing.rb +++ b/test/util/fileparsing.rb @@ -8,8 +8,8 @@ require 'puppet' require 'puppet/util/fileparsing' class TestUtilFileParsing < Test::Unit::TestCase - include PuppetTest - include PuppetTest::FileParsing + include PuppetTest + include PuppetTest::FileParsing class FParser include Puppet::Util::FileParsing @@ -598,8 +598,8 @@ billy three four\n" end class TestUtilFileRecord < Test::Unit::TestCase - include PuppetTest - include PuppetTest::FileParsing + include PuppetTest + include PuppetTest::FileParsing Record = Puppet::Util::FileParsing::FileRecord def test_new_filerecord diff --git a/test/util/inifile.rb b/test/util/inifile.rb index 498816b8d..50075fa92 100755 --- a/test/util/inifile.rb +++ b/test/util/inifile.rb @@ -7,7 +7,7 @@ require 'puppet/util/inifile' require 'puppettest' class TestFileType < Test::Unit::TestCase - include PuppetTest + include PuppetTest def setup super diff --git a/test/util/instance_loader.rb b/test/util/instance_loader.rb index 708d3f893..a7ea41532 100755 --- a/test/util/instance_loader.rb +++ b/test/util/instance_loader.rb @@ -7,7 +7,7 @@ require 'puppet/util/instance_loader' require 'puppettest' class TestInstanceloader < Test::Unit::TestCase - include PuppetTest + include PuppetTest def setup super diff --git a/test/util/pidlock.rb b/test/util/pidlock.rb index 671668d01..8d22ead81 100755 --- a/test/util/pidlock.rb +++ b/test/util/pidlock.rb @@ -7,120 +7,120 @@ require 'fileutils' Puppet.debug = false class TestPuppetUtilPidlock < Test::Unit::TestCase - include PuppetTest - - def setup - super - @workdir = tstdir - end - - def teardown - super - FileUtils.rm_rf(@workdir) - end - - def test_00_basic_create - l = nil - assert_nothing_raised { l = Puppet::Util::Pidlock.new(@workdir + '/nothingmuch') } - - assert_equal Puppet::Util::Pidlock, l.class - - assert_equal @workdir + '/nothingmuch', l.lockfile - end - - def test_10_uncontended_lock - l = Puppet::Util::Pidlock.new(@workdir + '/test_lock') - - assert !l.locked? - assert !l.mine? - assert l.lock - assert l.locked? - assert l.mine? - assert !l.anonymous? - # It's OK to call lock multiple times - assert l.lock - assert l.unlock - assert !l.locked? - assert !l.mine? - end - - def test_20_someone_elses_lock - childpid = nil - l = Puppet::Util::Pidlock.new(@workdir + '/someone_elses_lock') - - # First, we need a PID that's guaranteed to be (a) used, (b) someone - # else's, and (c) around for the life of this test. - childpid = fork { loop do; sleep 10; end } - - File.open(l.lockfile, 'w') { |fd| fd.write(childpid) } - - assert l.locked? - assert !l.mine? - assert !l.lock - assert l.locked? - assert !l.mine? - assert !l.unlock - assert l.locked? - assert !l.mine? - ensure - Process.kill("KILL", childpid) unless childpid.nil? - end - - def test_30_stale_lock - # This is a bit hard to guarantee, but we need a PID that is definitely - # unused, and will stay so for the the life of this test. Our best - # bet is to create a process, get it's PID, let it die, and *then* - # lock on it. - childpid = fork { exit } - - # Now we can't continue until we're sure that the PID is dead - Process.wait(childpid) - - l = Puppet::Util::Pidlock.new(@workdir + '/stale_lock') - - # locked? should clear the lockfile - File.open(l.lockfile, 'w') { |fd| fd.write(childpid) } - assert File.exists?(l.lockfile) - assert !l.locked? - assert !File.exists?(l.lockfile) - - # lock should replace the lockfile with our own - File.open(l.lockfile, 'w') { |fd| fd.write(childpid) } - assert File.exists?(l.lockfile) - assert l.lock - assert l.locked? - assert l.mine? - - # unlock should fail, and should *not* molest the existing lockfile, - # despite it being stale - File.open(l.lockfile, 'w') { |fd| fd.write(childpid) } - assert File.exists?(l.lockfile) - assert !l.unlock - assert File.exists?(l.lockfile) - end - - def test_40_not_locked_at_all - l = Puppet::Util::Pidlock.new(@workdir + '/not_locked') - - assert !l.locked? - # We can't unlock if we don't hold the lock - assert !l.unlock - end - - def test_50_anonymous_lock - l = Puppet::Util::Pidlock.new(@workdir + '/anonymous_lock') - - assert !l.locked? - assert l.lock(:anonymous => true) - assert l.locked? - assert l.anonymous? - assert !l.mine? - assert "", File.read(l.lockfile) - assert !l.unlock - assert l.locked? - assert l.anonymous? - assert l.unlock(:anonymous => true) - assert !File.exists?(l.lockfile) - end + include PuppetTest + + def setup + super + @workdir = tstdir + end + + def teardown + super + FileUtils.rm_rf(@workdir) + end + + def test_00_basic_create + l = nil + assert_nothing_raised { l = Puppet::Util::Pidlock.new(@workdir + '/nothingmuch') } + + assert_equal Puppet::Util::Pidlock, l.class + + assert_equal @workdir + '/nothingmuch', l.lockfile + end + + def test_10_uncontended_lock + l = Puppet::Util::Pidlock.new(@workdir + '/test_lock') + + assert !l.locked? + assert !l.mine? + assert l.lock + assert l.locked? + assert l.mine? + assert !l.anonymous? + # It's OK to call lock multiple times + assert l.lock + assert l.unlock + assert !l.locked? + assert !l.mine? + end + + def test_20_someone_elses_lock + childpid = nil + l = Puppet::Util::Pidlock.new(@workdir + '/someone_elses_lock') + + # First, we need a PID that's guaranteed to be (a) used, (b) someone + # else's, and (c) around for the life of this test. + childpid = fork { loop do; sleep 10; end } + + File.open(l.lockfile, 'w') { |fd| fd.write(childpid) } + + assert l.locked? + assert !l.mine? + assert !l.lock + assert l.locked? + assert !l.mine? + assert !l.unlock + assert l.locked? + assert !l.mine? + ensure + Process.kill("KILL", childpid) unless childpid.nil? + end + + def test_30_stale_lock + # This is a bit hard to guarantee, but we need a PID that is definitely + # unused, and will stay so for the the life of this test. Our best + # bet is to create a process, get it's PID, let it die, and *then* + # lock on it. + childpid = fork { exit } + + # Now we can't continue until we're sure that the PID is dead + Process.wait(childpid) + + l = Puppet::Util::Pidlock.new(@workdir + '/stale_lock') + + # locked? should clear the lockfile + File.open(l.lockfile, 'w') { |fd| fd.write(childpid) } + assert File.exists?(l.lockfile) + assert !l.locked? + assert !File.exists?(l.lockfile) + + # lock should replace the lockfile with our own + File.open(l.lockfile, 'w') { |fd| fd.write(childpid) } + assert File.exists?(l.lockfile) + assert l.lock + assert l.locked? + assert l.mine? + + # unlock should fail, and should *not* molest the existing lockfile, + # despite it being stale + File.open(l.lockfile, 'w') { |fd| fd.write(childpid) } + assert File.exists?(l.lockfile) + assert !l.unlock + assert File.exists?(l.lockfile) + end + + def test_40_not_locked_at_all + l = Puppet::Util::Pidlock.new(@workdir + '/not_locked') + + assert !l.locked? + # We can't unlock if we don't hold the lock + assert !l.unlock + end + + def test_50_anonymous_lock + l = Puppet::Util::Pidlock.new(@workdir + '/anonymous_lock') + + assert !l.locked? + assert l.lock(:anonymous => true) + assert l.locked? + assert l.anonymous? + assert !l.mine? + assert "", File.read(l.lockfile) + assert !l.unlock + assert l.locked? + assert l.anonymous? + assert l.unlock(:anonymous => true) + assert !File.exists?(l.lockfile) + end end - + diff --git a/test/util/settings.rb b/test/util/settings.rb index 2ff9e66ec..1fdd425e6 100755 --- a/test/util/settings.rb +++ b/test/util/settings.rb @@ -8,8 +8,8 @@ require 'puppet/util/settings' require 'puppettest/parsertesting' class TestSettings < Test::Unit::TestCase - include PuppetTest - include PuppetTest::ParserTesting + include PuppetTest + include PuppetTest::ParserTesting CElement = Puppet::Util::Settings::CElement CBoolean = Puppet::Util::Settings::CBoolean diff --git a/test/util/storage.rb b/test/util/storage.rb index cc378c690..89c3b13f8 100755 --- a/test/util/storage.rb +++ b/test/util/storage.rb @@ -6,7 +6,7 @@ require 'puppet' require 'puppettest' class TestStorage < Test::Unit::TestCase - include PuppetTest + include PuppetTest def mkfile path = tempfile() |
