You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by iv...@apache.org on 2014/12/24 14:01:59 UTC

svn commit: r1647773 - /subversion/trunk/subversion/tests/libsvn_fs/fs-test.c

Author: ivan
Date: Wed Dec 24 13:01:59 2014
New Revision: 1647773

URL: http://svn.apache.org/r1647773
Log:
Add regression test for FSFS limitation (and check) that only one file can be
modified in TXN at time.

* subversion/tests/libsvn_fs/fs-test.c
  (test_modify_txn_being_written): New test.
  (test_funcs): Add test_modify_txn_being_written() test to list.

Modified:
    subversion/trunk/subversion/tests/libsvn_fs/fs-test.c

Modified: subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs/fs-test.c?rev=1647773&r1=1647772&r2=1647773&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Wed Dec 24 13:01:59 2014
@@ -6640,6 +6640,62 @@ test_txn_pool_lifetime(const svn_test_op
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+test_modify_txn_being_written(const svn_test_opts_t *opts,
+                              apr_pool_t *pool)
+{
+  /* FSFS has a limitation (and check) that only one file can be
+   * modified in TXN at time: see r861812 and svn_fs_apply_text() docstring.
+   * This is regression test for this behavior. */
+  svn_fs_t *fs;
+  svn_fs_txn_t *txn;
+  const char *txn_name;
+  svn_fs_root_t *txn_root;
+  svn_stream_t *foo_contents;
+  svn_stream_t *bar_contents;
+
+  /* Bail (with success) on known-untestable scenarios */
+  if (strcmp(opts->fs_type, SVN_FS_TYPE_FSFS) != 0)
+    return svn_error_create(SVN_ERR_TEST_SKIPPED, NULL,
+                            "this will test FSFS repositories only");
+
+  /* Create a new repo. */
+  SVN_ERR(svn_test__create_fs(&fs, "test-modify-txn-being-written",
+                              opts, pool));
+
+  /* Create a TXN_ROOT referencing FS. */
+  SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, pool));
+  SVN_ERR(svn_fs_txn_name(&txn_name, txn, pool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+
+  /* Make file /foo and open for writing.*/
+  SVN_ERR(svn_fs_make_file(txn_root, "/foo", pool));
+  SVN_ERR(svn_fs_apply_text(&foo_contents, txn_root, "/foo", NULL, pool));
+
+  /* Attempt to modify another file '/bar' -- FSFS doesn't allow this. */
+  SVN_ERR(svn_fs_make_file(txn_root, "/bar", pool));
+  SVN_TEST_ASSERT_ERROR(
+      svn_fs_apply_text(&bar_contents, txn_root, "/bar", NULL, pool),
+      SVN_ERR_FS_REP_BEING_WRITTEN);
+
+  /* *Reopen TXN. */
+  SVN_ERR(svn_fs_open_txn(&txn, fs, txn_name, pool));
+  SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+
+  /* Check that file '/bar' still cannot be modified */
+  SVN_TEST_ASSERT_ERROR(
+      svn_fs_apply_text(&bar_contents, txn_root, "/bar", NULL, pool),
+      SVN_ERR_FS_REP_BEING_WRITTEN);
+
+  /* Close file '/foo'. */
+  SVN_ERR(svn_stream_close(foo_contents));
+
+  /* Now file '/bar' can be modified. */
+  SVN_ERR(svn_fs_apply_text(&bar_contents, txn_root, "/bar", NULL, pool));
+
+  return SVN_NO_ERROR;
+}
+
 /* ------------------------------------------------------------------------ */
 
 /* The test table.  */
@@ -6767,6 +6823,8 @@ static struct svn_test_descriptor_t test
                        "test creating FSFS repository with different opts"),
     SVN_TEST_OPTS_PASS(test_txn_pool_lifetime,
                        "test pool lifetime dependencies with txn roots"),
+    SVN_TEST_OPTS_PASS(test_modify_txn_being_written,
+                       "test modify txn being written in FSFS"),
     SVN_TEST_NULL
   };