* subversion/tests/libsvn_fs/fs-test.c (revision_props):
Remove txn. Revision property operation does not need
transaction.
* subversion/tests/libsvn_fs/fs-test.c (node_props): New
test case for node properties.
* subversion/tests/libsvn_fs/fs-test.c (check_greek_tree_under_root):
New helper function for commit_transaction.
* subversion/tests/libsvn_fs/fs-test.c (commit_transaction):
New test case for svn_fs_commit.
* subversion/tests/libsvn_fs/fs-test.c (fetch_youngest_rev):
Add a few more tests. Moved to the last since this test
depends of svn_fs_commit.
Index: subversion/tests/libsvn_fs/fs-test.c
===================================================================
RCS file: /cvs/subversion/subversion/tests/libsvn_fs/fs-test.c,v
retrieving revision 1.33
diff -u -r1.33 fs-test.c
--- subversion/tests/libsvn_fs/fs-test.c 2001/03/03 21:10:15 1.33
+++ subversion/tests/libsvn_fs/fs-test.c 2001/03/05 03:59:27
@@ -176,26 +176,6 @@
}
-/* Fetch the youngest revision from a repos. */
-static svn_error_t *
-fetch_youngest_rev (const char **msg)
-{
- svn_fs_t *fs;
- svn_revnum_t rev;
-
- *msg = "fetch the youngest revision from a filesystem";
-
- SVN_ERR (create_fs_and_repos (&fs, "test-repo-3")); /* helper */
-
- SVN_ERR (svn_fs_youngest_rev (&rev, fs, pool));
-
- SVN_ERR (svn_fs_close_fs (fs));
-
- return SVN_NO_ERROR;
-}
-
-
-
/* Begin a txn, check its name, then close it */
static svn_error_t *
trivial_transaction (const char **msg)
@@ -602,7 +582,6 @@
revision_props (const char **msg)
{
svn_fs_t *fs;
- svn_fs_txn_t *txn;
apr_hash_t *proplist;
svn_string_t *value;
int i;
@@ -624,9 +603,8 @@
*msg = "set and get some revision properties";
- /* Open the fs and transaction */
+ /* Open the fs */
SVN_ERR (create_fs_and_repos (&fs, "test-repo-rev-props"));
- SVN_ERR (svn_fs_begin_txn (&txn, fs, 0, pool));
/* Set some properties on the revision. */
for (i = 0; i < 4; i++)
@@ -715,6 +693,132 @@
}
}
+ /* Close the fs. */
+ SVN_ERR (svn_fs_close_fs (fs));
+
+ return SVN_NO_ERROR;
+}
+
+
+static svn_error_t *
+node_props (const char **msg)
+{
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+ svn_fs_root_t *txn_root;
+ apr_hash_t *proplist;
+ svn_string_t *value;
+ int i;
+
+ const char *initial_props[4][2] = {
+ { "color", "red" },
+ { "size", "XXL" },
+ { "favorite saturday morning cartoon", "looney tunes" },
+ { "auto", "Green 1997 Saturn SL1" }
+ };
+
+ const char *final_props[4][2] = {
+ { "color", "violet" },
+ { "flower", "violet" },
+ { "favorite saturday morning cartoon", "looney tunes" },
+ { "auto", "Red 2000 Chevrolet Blazer" }
+ };
+
+
+ *msg = "set and get some node properties";
+
+ /* Open the fs and transaction */
+ SVN_ERR (create_fs_and_repos (&fs, "test-repo-node-props"));
+ SVN_ERR (svn_fs_begin_txn (&txn, fs, 0, pool));
+ SVN_ERR (svn_fs_txn_root (&txn_root, txn, pool));
+
+ /* Set some properties on the node. */
+ for (i = 0; i < 4; i++)
+ {
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create (initial_props[i][0], pool),
+ svn_string_create (initial_props[i][1], pool),
+ pool));
+ }
+
+ /* Change some of the above properties. */
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create ("color", pool),
+ svn_string_create ("violet", pool),
+ pool));
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create ("auto", pool),
+ svn_string_create ("Red 2000 Chevrolet Blazer", pool),
+ pool));
+
+ /* Remove a property altogether */
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create ("size", pool),
+ NULL,
+ pool));
+
+ /* Copy a property's value into a new property. */
+ SVN_ERR (svn_fs_node_prop
+ (&value,
+ txn_root, "/",
+ svn_string_create ("color", pool),
+ pool));
+ SVN_ERR (svn_fs_change_node_prop
+ (txn_root, "/",
+ svn_string_create ("flower", pool),
+ value,
+ pool));
+
+ /* Obtain a list of all current properties, and make sure it matches
+ the expected values. */
+ SVN_ERR (svn_fs_node_proplist (&proplist, txn_root, "/", pool));
+ {
+ apr_hash_index_t *hi;
+ int num_props = 0;
+ svn_string_t *prop_name, *prop_value;
+
+ for (hi = apr_hash_first (proplist); hi; hi = apr_hash_next (hi))
+ {
+ const void *key;
+ apr_size_t klen;
+ void *val;
+
+ /* If there are more properties than expected, this is a Bad
+ Thing */
+ if (++num_props > 4)
+ return svn_error_createf
+ (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "more node properties were found than were expected");
+
+ /* Get next property */
+ apr_hash_this (hi, &key, &klen, &val);
+ prop_name = svn_string_ncreate (key, klen, pool);
+ prop_value = (svn_string_t *) val;
+
+ /* Loop through our expected final properties list, hoping to
+ find the right name with the right value. If the name is
+ missing, or the value is wrong, the whole test fails. */
+ for (i = 0; i < 4; i++)
+ {
+ if (! strcmp (prop_name->data, final_props[i][0]))
+ break;
+ }
+ if (i >= 4)
+ return svn_error_createf
+ (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "unable to find expected node property");
+
+ if (strcmp (prop_value->data, final_props[i][1]))
+ return svn_error_createf
+ (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "node property had an unexpected value");
+ }
+ }
+
/* Close the transaction and fs. */
SVN_ERR (svn_fs_close_txn (txn));
SVN_ERR (svn_fs_close_fs (fs));
@@ -732,7 +836,6 @@
svn_fs_t *fs;
svn_fs_txn_t *txn;
svn_fs_root_t *txn_root;
- svn_error_t *err;
*msg = "delete mutable nodes from directories (INCOMPLETE TEST)";
@@ -868,6 +971,176 @@
}
+/* Helper function to check contents of Greek Tree. */
+static svn_error_t *
+check_greek_tree_under_root (svn_fs_root_t *rev_root)
+{
+ svn_stream_t *rstream;
+ svn_string_t *rstring;
+ svn_string_t *content;
+
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "iota", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'iota'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/mu", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'mu'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/B/lambda", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'lambda'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/B/E/alpha", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'alpha'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/B/E/beta", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'beta'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/D/gamma", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'gamma'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/D/G/pi", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'pi'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/D/G/rho", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'rho'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/D/G/tau", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'tau'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/D/H/chi", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'chi'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/D/H/psi", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'psi'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+
+ SVN_ERR (svn_fs_file_contents (&rstream, rev_root, "A/D/H/omega", pool));
+ SVN_ERR (stream_to_string (&rstring, rstream));
+ content = svn_string_create ("This is the file 'omega'.", pool);
+ if (! svn_string_compare (rstring, content))
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "data read != data written.");
+ return SVN_NO_ERROR;
+}
+
+
+/* Create a tree and commit it. */
+static svn_error_t *
+commit_transaction (const char **msg)
+{
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+ svn_fs_root_t *txn_root;
+ svn_fs_root_t *revision_root;
+ svn_revnum_t new_rev;
+
+ *msg = "create a tree and commit it";
+
+ /* Prepare a txn to receive the greek tree. */
+ SVN_ERR (create_fs_and_repos (&fs, "test-repo-commit-txn"));
+ SVN_ERR (svn_fs_begin_txn (&txn, fs, 0, pool));
+ SVN_ERR (svn_fs_txn_root (&txn_root, txn, pool));
+
+ /* Create the greek tree. */
+ SVN_ERR (greek_tree_under_root (txn_root, pool));
+ /* Commit it. */
+ SVN_ERR (svn_fs_commit_txn (&new_rev, txn));
+
+ SVN_ERR (svn_fs_revision_root (&revision_root, fs, new_rev, pool));
+ /* Check the tree. */
+ SVN_ERR (check_greek_tree_under_root (revision_root));
+
+ /* Close the transaction and fs. */
+ SVN_ERR (svn_fs_close_txn (txn));
+ SVN_ERR (svn_fs_close_fs (fs));
+
+ return SVN_NO_ERROR;
+}
+
+
+/* Fetch the youngest revision from a repos. */
+static svn_error_t *
+fetch_youngest_rev (const char **msg)
+{
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+ svn_fs_root_t *txn_root;
+ svn_revnum_t new_rev;
+ svn_revnum_t youngest_rev, new_youngest_rev;
+
+ *msg = "fetch the youngest revision from a filesystem";
+
+ SVN_ERR (create_fs_and_repos (&fs, "test-repo-youngest-rev"));
+
+ SVN_ERR (svn_fs_youngest_rev (&youngest_rev, fs, pool));
+
+ /* Prepare a txn to receive the greek tree. */
+ SVN_ERR (create_fs_and_repos (&fs, "test-repo-commit-txn"));
+ SVN_ERR (svn_fs_begin_txn (&txn, fs, 0, pool));
+ SVN_ERR (svn_fs_txn_root (&txn_root, txn, pool));
+
+ /* Create the greek tree. */
+ SVN_ERR (greek_tree_under_root (txn_root, pool));
+ /* Commit it. */
+ SVN_ERR (svn_fs_commit_txn (&new_rev, txn));
+
+ SVN_ERR (svn_fs_youngest_rev (&new_youngest_rev, fs, pool));
+
+ if (youngest_rev == new_rev)
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "commit didn't bump up revision number");
+
+ if (new_youngest_rev != new_rev)
+ return svn_error_create (SVN_ERR_FS_GENERAL, 0, NULL, pool,
+ "couldn't fetch youngest revision");
+
+ /* Close the transaction and fs. */
+ SVN_ERR (svn_fs_close_txn (txn));
+ SVN_ERR (svn_fs_close_fs (fs));
+
+ return SVN_NO_ERROR;
+}
+
+
+
/* The test table. */
@@ -875,7 +1148,6 @@
0,
create_berkeley_filesystem,
open_berkeley_filesystem,
- fetch_youngest_rev,
trivial_transaction,
reopen_trivial_transaction,
create_file_transaction,
@@ -885,7 +1157,10 @@
create_greek_tree_transaction,
list_directory,
revision_props,
+ node_props,
delete_mutables,
+ commit_transaction,
+ fetch_youngest_rev,
0
};
--
Yoshiki Hayashi
Received on Sat Oct 21 14:36:25 2006