about summary refs log tree commit homepage
diff options
context:
space:
mode:
-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')