about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-08-18 09:01:59 +0000
committerEric Wong <normalperson@yhbt.net>2011-08-18 09:01:59 +0000
commitd4b13c817667479af84f4af58afe05138d53ba3a (patch)
tree0eac1cd6d2b08912c9e3da742220e065b90c7142
parent6d7697ffacf190535a2bbe4be05757bb310c45da (diff)
downloadruby-tdb-d4b13c817667479af84f4af58afe05138d53ba3a.tar.gz
Just in case...
-rw-r--r--test/test_tdb.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test_tdb.rb b/test/test_tdb.rb
index 7e77f14..7864ace 100644
--- a/test/test_tdb.rb
+++ b/test/test_tdb.rb
@@ -275,6 +275,23 @@ class TestTdb < Test::Unit::TestCase
     assert ! @tdb.include?("hello")
   end
 
+  def test_fork
+    @tmp = Tempfile.new('tdb')
+    File.unlink(@tmp.path)
+    @tdb = TDB.new(@tmp.path)
+    @tdb["hello"] = "world"
+    pid = fork do
+      assert_equal "world", @tdb["hello"]
+      @tdb["hello"] = "WORLD"
+      @tdb["#$$"] = "NO"
+      exit 0
+    end
+    _, status = Process.waitpid2(pid)
+    assert status.success?, status.inspect
+    assert_equal "WORLD", @tdb["hello"]
+    assert_equal "NO", @tdb[pid.to_s]
+  end
+
   def test_fetch_reuse_buf
     assert_nothing_raised do
       @tmp = Tempfile.new('tdb')