[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Test case for svn_fs_abort_txn

From: Yoshiki Hayashi <yoshiki_at_xemacs.org>
Date: 2001-02-28 11:29:38 CET

(check_node_id): New helper function for abort_transaction.
(abort_transaction): New function to test svn_fs_abort_txn().

Index: fs-test.c
===================================================================
RCS file: /cvs/subversion/subversion/tests/libsvn_fs/fs-test.c,v
retrieving revision 1.14
diff -u -r1.14 fs-test.c
--- fs-test.c 2001/02/28 02:19:55 1.14
+++ fs-test.c 2001/02/28 10:08:43
@@ -18,6 +18,7 @@
 #include "../../libsvn_fs/fs.h"
 #include "../../libsvn_fs/rev-table.h"
 #include "../../libsvn_fs/trail.c"
+#include "../../libsvn_fs/node-rev.h"
 
 /* Some utility functions. */
 
@@ -341,6 +342,78 @@
 }
 
 
+static svn_error_t *
+check_node_id (void *baton, trail_t *trail)
+{
+ svn_fs_t *fs = baton;
+ skel_t *skel;
+
+ SVN_ERR (svn_fs__get_node_revision (&skel, fs,
+ svn_fs_parse_id ("1.1", 3, trail->pool),
+ trail));
+
+ return SVN_NO_ERROR;
+}
+
+
+static int
+abort_transaction (const char **msg)
+{
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+ svn_error_t *err;
+ const char *ignored;
+ char *first_txn_id, *second_txn_id;
+ *msg = "begin a transaction, then abort transaction";
+
+ /* Make sure the FS exists. */
+ if (create_berkeley_filesystem (&ignored) != 0)
+ return fail();
+
+ /* Open the FS. */
+ fs = svn_fs_new (pool);
+ if (fs == NULL)
+ return fail();
+
+ if (SVN_NO_ERROR != svn_fs_open_berkeley (fs, repository))
+ return fail();
+
+ /* Make sure the transaction exists. */
+ if (trivial_transaction (&ignored) != 0)
+ return fail();
+ /* Open the transaction, just to make sure it's in the database. */
+ if (SVN_NO_ERROR != svn_fs_open_txn (&txn, fs, "0", pool))
+ return fail();
+
+ if (SVN_NO_ERROR != svn_fs_txn_name (&first_txn_id, txn, pool))
+ return fail();
+ if (SVN_NO_ERROR != svn_fs_abort_txn (txn))
+ return fail();
+
+ err = svn_fs_open_txn (&txn, fs, first_txn_id, pool);
+ if (!err || err->apr_err != SVN_ERR_FS_NO_SUCH_TRANSACTION)
+ return fail();
+
+ /* Previously created node revision of "beer.txt" must be gone now.
+ ### Create more complex structure. */
+ err = svn_fs__retry_txn (fs, check_node_id, fs, fs->pool);
+ if (!err || err->apr_err != SVN_ERR_FS_CORRUPT)
+ return fail();
+
+ /* Begin new transaction. */
+ if (SVN_NO_ERROR != svn_fs_begin_txn (&txn, fs, 0, pool))
+ fail();
+
+ if (SVN_NO_ERROR != svn_fs_txn_name (&second_txn_id, txn, pool))
+ return fail();
+
+ /* Transaction id must be different. */
+ if (! strcmp (first_txn_id, second_txn_id))
+ fail();
+
+ return 0;
+}
+
 
 /* The test table. */
 
@@ -352,6 +425,7 @@
   reopen_trivial_transaction,
   create_file_transaction,
   list_live_transactions,
+ abort_transaction,
   0
 };
 

-- 
Yoshiki Hayashi
Received on Sat Oct 21 14:36:23 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.