dbm/test_dbm.rb: specify pid for Process.wait.
gdbm/test_gdbm.rb: ditto. sdbm/test_sdbm.rb: ditto. dbm/test_dbm.rb: add tests for open when db is not exist. gdbm/test_gdbm.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
66323da355
commit
2b5bb9ad00
@ -87,7 +87,7 @@ if defined? DBM
|
|||||||
end
|
end
|
||||||
def test_s_open_lock
|
def test_s_open_lock
|
||||||
return unless have_fork? # snip this test
|
return unless have_fork? # snip this test
|
||||||
fork() {
|
pid = fork() {
|
||||||
assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644))
|
assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644))
|
||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ if defined? DBM
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
Process.wait
|
Process.wait pid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ if defined? DBM
|
|||||||
end
|
end
|
||||||
return unless have_fork? # snip this test
|
return unless have_fork? # snip this test
|
||||||
|
|
||||||
fork() {
|
pid = fork() {
|
||||||
assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644,
|
assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644,
|
||||||
DBM::NOLOCK))
|
DBM::NOLOCK))
|
||||||
sleep 2
|
sleep 2
|
||||||
@ -139,13 +139,13 @@ if defined? DBM
|
|||||||
assert_instance_of(DBM, dbm2 = DBM.open("tmptest_dbm", 0644))
|
assert_instance_of(DBM, dbm2 = DBM.open("tmptest_dbm", 0644))
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
Process.wait
|
Process.wait pid
|
||||||
dbm2.close if dbm2
|
dbm2.close if dbm2
|
||||||
end
|
end
|
||||||
|
|
||||||
p Dir.glob("tmptest_dbm*") if $DEBUG
|
p Dir.glob("tmptest_dbm*") if $DEBUG
|
||||||
|
|
||||||
fork() {
|
pid = fork() {
|
||||||
assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644))
|
assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644))
|
||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ if defined? DBM
|
|||||||
DBM::NOLOCK))
|
DBM::NOLOCK))
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
Process.wait
|
Process.wait pid
|
||||||
dbm2.close if dbm2
|
dbm2.close if dbm2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -590,8 +590,32 @@ if defined? DBM
|
|||||||
FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT)
|
FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_reader_open_notexist
|
||||||
|
assert_raise(Errno::ENOENT) {
|
||||||
|
DBM.open("#{TMPROOT}/a", 0666, DBM::READER)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_writer_open_notexist
|
||||||
|
assert_raise(Errno::ENOENT) {
|
||||||
|
DBM.open("#{TMPROOT}/a", 0666, DBM::WRITER)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_wrcreat_open_notexist
|
||||||
|
v = DBM.open("#{TMPROOT}/a", 0666, DBM::WRCREAT)
|
||||||
|
assert_instance_of(DBM, v)
|
||||||
|
v.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_newdb_open_notexist
|
||||||
|
v = DBM.open("#{TMPROOT}/a", 0666, DBM::NEWDB)
|
||||||
|
assert_instance_of(DBM, v)
|
||||||
|
v.close
|
||||||
|
end
|
||||||
|
|
||||||
def test_reader_open
|
def test_reader_open
|
||||||
DBM.open("#{TMPROOT}/a") {}
|
DBM.open("#{TMPROOT}/a") {} # create a db.
|
||||||
v = DBM.open("#{TMPROOT}/a", nil, DBM::READER) {|d|
|
v = DBM.open("#{TMPROOT}/a", nil, DBM::READER) {|d|
|
||||||
# Errno::EPERM is raised on Solaris which use ndbm.
|
# Errno::EPERM is raised on Solaris which use ndbm.
|
||||||
# DBMError is raised on Debian which use gdbm.
|
# DBMError is raised on Debian which use gdbm.
|
||||||
|
@ -118,7 +118,7 @@ if defined? GDBM
|
|||||||
end
|
end
|
||||||
def test_s_open_lock
|
def test_s_open_lock
|
||||||
return unless have_fork? # snip this test
|
return unless have_fork? # snip this test
|
||||||
fork() {
|
pid = fork() {
|
||||||
assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
|
assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
|
||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ if defined? GDBM
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
Process.wait
|
Process.wait pid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ if defined? GDBM
|
|||||||
end
|
end
|
||||||
return unless have_fork? # snip this test
|
return unless have_fork? # snip this test
|
||||||
|
|
||||||
fork() {
|
pid = fork() {
|
||||||
assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
|
assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
|
||||||
GDBM::NOLOCK))
|
GDBM::NOLOCK))
|
||||||
sleep 2
|
sleep 2
|
||||||
@ -170,13 +170,13 @@ if defined? GDBM
|
|||||||
assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644))
|
assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644))
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
Process.wait
|
Process.wait pid
|
||||||
gdbm2.close if gdbm2
|
gdbm2.close if gdbm2
|
||||||
end
|
end
|
||||||
|
|
||||||
p Dir.glob("tmptest_gdbm*") if $DEBUG
|
p Dir.glob("tmptest_gdbm*") if $DEBUG
|
||||||
|
|
||||||
fork() {
|
pid = fork() {
|
||||||
assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
|
assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
|
||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ if defined? GDBM
|
|||||||
GDBM::NOLOCK))
|
GDBM::NOLOCK))
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
Process.wait
|
Process.wait pid
|
||||||
gdbm2.close if gdbm2
|
gdbm2.close if gdbm2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -660,8 +660,32 @@ if defined? GDBM
|
|||||||
FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT)
|
FileUtils.rm_rf TMPROOT if File.directory?(TMPROOT)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_reader_open_notexist
|
||||||
|
assert_raise(Errno::ENOENT) {
|
||||||
|
GDBM.open("#{TMPROOT}/a", 0666, GDBM::READER)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_writer_open_notexist
|
||||||
|
assert_raise(Errno::ENOENT) {
|
||||||
|
GDBM.open("#{TMPROOT}/a", 0666, GDBM::WRITER)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_wrcreat_open_notexist
|
||||||
|
v = GDBM.open("#{TMPROOT}/a", 0666, GDBM::WRCREAT)
|
||||||
|
assert_instance_of(GDBM, v)
|
||||||
|
v.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_newdb_open_notexist
|
||||||
|
v = GDBM.open("#{TMPROOT}/a", 0666, GDBM::NEWDB)
|
||||||
|
assert_instance_of(GDBM, v)
|
||||||
|
v.close
|
||||||
|
end
|
||||||
|
|
||||||
def test_reader_open
|
def test_reader_open
|
||||||
GDBM.open("#{TMPROOT}/a.dbm") {}
|
GDBM.open("#{TMPROOT}/a.dbm") {} # create a db.
|
||||||
v = GDBM.open("#{TMPROOT}/a.dbm", nil, GDBM::READER) {|d|
|
v = GDBM.open("#{TMPROOT}/a.dbm", nil, GDBM::READER) {|d|
|
||||||
assert_raises(GDBMError) { d["k"] = "v" }
|
assert_raises(GDBMError) { d["k"] = "v" }
|
||||||
true
|
true
|
||||||
|
@ -81,7 +81,7 @@ class TestSDBM < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
return unless have_fork? # snip this test
|
return unless have_fork? # snip this test
|
||||||
|
|
||||||
fork() {
|
pid = fork() {
|
||||||
assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644,
|
assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644,
|
||||||
SDBM::NOLOCK))
|
SDBM::NOLOCK))
|
||||||
sleep 2
|
sleep 2
|
||||||
@ -93,13 +93,13 @@ class TestSDBM < Test::Unit::TestCase
|
|||||||
assert_instance_of(SDBM, sdbm2 = SDBM.open("tmptest_sdbm", 0644))
|
assert_instance_of(SDBM, sdbm2 = SDBM.open("tmptest_sdbm", 0644))
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
Process.wait
|
Process.wait pid
|
||||||
sdbm2.close if sdbm2
|
sdbm2.close if sdbm2
|
||||||
end
|
end
|
||||||
|
|
||||||
p Dir.glob("tmptest_sdbm*") if $DEBUG
|
p Dir.glob("tmptest_sdbm*") if $DEBUG
|
||||||
|
|
||||||
fork() {
|
pid = fork() {
|
||||||
assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644))
|
assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644))
|
||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ class TestSDBM < Test::Unit::TestCase
|
|||||||
SDBM::NOLOCK))
|
SDBM::NOLOCK))
|
||||||
}
|
}
|
||||||
ensure
|
ensure
|
||||||
Process.wait
|
Process.wait pid
|
||||||
sdbm2.close if sdbm2
|
sdbm2.close if sdbm2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user