diff options
Diffstat (limited to 'subversion/tests/libsvn_fs/locks-test.c')
-rw-r--r-- | subversion/tests/libsvn_fs/locks-test.c | 200 |
1 files changed, 67 insertions, 133 deletions
diff --git a/subversion/tests/libsvn_fs/locks-test.c b/subversion/tests/libsvn_fs/locks-test.c index ff6772c..ee275de 100644 --- a/subversion/tests/libsvn_fs/locks-test.c +++ b/subversion/tests/libsvn_fs/locks-test.c @@ -91,28 +91,24 @@ verify_matching_lock_paths(struct get_locks_baton_t *baton, } -/*-----------------------------------------------------------------*/ - -/** The actual lock-tests called by `make check` **/ - - - -/* Test that we can create a lock--nothing more. */ +/* Create a filesystem in a directory called NAME, and populate it with + * the standard Greek tree. Set *FS_P to the new filesystem object and + * *NEWREV_P to the head revision number. Unwanted outputs may be NULL. */ static svn_error_t * -lock_only(const svn_test_opts_t *opts, - apr_pool_t *pool) +create_greek_fs(svn_fs_t **fs_p, + svn_revnum_t *newrev_p, + const char *name, + const svn_test_opts_t *opts, + apr_pool_t *pool) { svn_fs_t *fs; svn_fs_txn_t *txn; svn_fs_root_t *txn_root; const char *conflict; svn_revnum_t newrev; - svn_fs_access_t *access; - svn_lock_t *mylock; /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-lock-only", - opts, pool)); + SVN_ERR(svn_test__create_fs(&fs, name, opts, pool)); SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); @@ -121,6 +117,32 @@ lock_only(const svn_test_opts_t *opts, SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + if (fs_p) + *fs_p = fs; + if (newrev_p) + *newrev_p = newrev; + return SVN_NO_ERROR; +} + + +/*-----------------------------------------------------------------*/ + +/** The actual lock-tests called by `make check` **/ + + + +/* Test that we can create a lock--nothing more. */ +static svn_error_t * +lock_only(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_fs_t *fs; + svn_fs_access_t *access; + svn_lock_t *mylock; + + SVN_ERR(create_greek_fs(&fs, NULL, "test-repo-lock-only", + opts, pool)); + /* We are now 'bubba'. */ SVN_ERR(svn_fs_create_access(&access, "bubba", pool)); SVN_ERR(svn_fs_set_access(fs, access)); @@ -143,23 +165,11 @@ lookup_lock_by_path(const svn_test_opts_t *opts, apr_pool_t *pool) { svn_fs_t *fs; - svn_fs_txn_t *txn; - svn_fs_root_t *txn_root; - const char *conflict; - svn_revnum_t newrev; svn_fs_access_t *access; svn_lock_t *mylock, *somelock; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-lookup-lock-by-path", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, NULL, "test-repo-lookup-lock-by-path", + opts, pool)); /* We are now 'bubba'. */ SVN_ERR(svn_fs_create_access(&access, "bubba", pool)); @@ -185,25 +195,13 @@ attach_lock(const svn_test_opts_t *opts, apr_pool_t *pool) { svn_fs_t *fs; - svn_fs_txn_t *txn; - svn_fs_root_t *txn_root; - const char *conflict; - svn_revnum_t newrev; svn_fs_access_t *access; svn_lock_t *somelock; svn_lock_t *mylock; const char *token; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-attach-lock", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, NULL, "test-repo-attach-lock", + opts, pool)); /* We are now 'bubba'. */ SVN_ERR(svn_fs_create_access(&access, "bubba", pool)); @@ -238,25 +236,13 @@ get_locks(const svn_test_opts_t *opts, apr_pool_t *pool) { svn_fs_t *fs; - svn_fs_txn_t *txn; - svn_fs_root_t *txn_root; - const char *conflict; - svn_revnum_t newrev; svn_fs_access_t *access; svn_lock_t *mylock; struct get_locks_baton_t *get_locks_baton; apr_size_t i, num_expected_paths; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-get-locks", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, NULL, "test-repo-get-locks", + opts, pool)); /* We are now 'bubba'. */ SVN_ERR(svn_fs_create_access(&access, "bubba", pool)); @@ -358,6 +344,18 @@ get_locks(const svn_test_opts_t *opts, num_expected_paths, pool)); } + /* A path that is longer and alphabetically earlier than some locked + paths, this exercises the r1205848 BDB lock code. */ + { + static const char *expected_paths[] = { 0 }; + num_expected_paths = 0; + get_locks_baton = make_get_locks_baton(pool); + SVN_ERR(svn_fs_get_locks(fs, "A/D/H/ABCDEFGHIJKLMNOPQR", get_locks_callback, + get_locks_baton, pool)); + SVN_ERR(verify_matching_lock_paths(get_locks_baton, expected_paths, + num_expected_paths, pool)); + } + return SVN_NO_ERROR; } @@ -369,23 +367,11 @@ basic_lock(const svn_test_opts_t *opts, apr_pool_t *pool) { svn_fs_t *fs; - svn_fs_txn_t *txn; - svn_fs_root_t *txn_root; - const char *conflict; - svn_revnum_t newrev; svn_fs_access_t *access; svn_lock_t *mylock, *somelock; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-basic-lock", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, NULL, "test-repo-basic-lock", + opts, pool)); /* We are now 'bubba'. */ SVN_ERR(svn_fs_create_access(&access, "bubba", pool)); @@ -428,16 +414,8 @@ lock_credentials(const svn_test_opts_t *opts, svn_lock_t *mylock; svn_error_t *err; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-lock-credentials", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, &newrev, "test-repo-lock-credentials", + opts, pool)); /* We are now 'bubba'. */ SVN_ERR(svn_fs_create_access(&access, "bubba", pool)); @@ -523,16 +501,8 @@ final_lock_check(const svn_test_opts_t *opts, svn_lock_t *mylock; svn_error_t *err; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-final-lock-check", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, &newrev, "test-repo-final-lock-check", + opts, pool)); /* Make a new transaction and delete "/A" */ SVN_ERR(svn_fs_begin_txn2(&txn, fs, newrev, SVN_FS_TXN_CHECK_LOCKS, pool)); @@ -583,16 +553,8 @@ lock_dir_propchange(const svn_test_opts_t *opts, svn_fs_access_t *access; svn_lock_t *mylock; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-lock-dir-propchange", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, &newrev, "test-repo-lock-dir-propchange", + opts, pool)); /* Become 'bubba' and lock "/A/D/G/rho". */ SVN_ERR(svn_fs_create_access(&access, "bubba", pool)); @@ -633,16 +595,8 @@ lock_expiration(const svn_test_opts_t *opts, svn_error_t *err; struct get_locks_baton_t *get_locks_baton; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-lock-expiration", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, &newrev, "test-repo-lock-expiration", + opts, pool)); /* Make a new transaction and change rho. */ SVN_ERR(svn_fs_begin_txn2(&txn, fs, newrev, SVN_FS_TXN_CHECK_LOCKS, pool)); @@ -713,23 +667,11 @@ lock_break_steal_refresh(const svn_test_opts_t *opts, apr_pool_t *pool) { svn_fs_t *fs; - svn_fs_txn_t *txn; - svn_fs_root_t *txn_root; - const char *conflict; - svn_revnum_t newrev; svn_fs_access_t *access; svn_lock_t *mylock, *somelock; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-steal-refresh", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, NULL, "test-repo-steal-refresh", + opts, pool)); /* Become 'bubba' and lock "/A/D/G/rho". */ SVN_ERR(svn_fs_create_access(&access, "bubba", pool)); @@ -801,16 +743,8 @@ lock_out_of_date(const svn_test_opts_t *opts, svn_lock_t *mylock; svn_error_t *err; - /* Prepare a filesystem and a new txn. */ - SVN_ERR(svn_test__create_fs(&fs, "test-repo-lock-out-of-date", - opts, pool)); - SVN_ERR(svn_fs_begin_txn2(&txn, fs, 0, SVN_FS_TXN_CHECK_LOCKS, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - - /* Create the greek tree and commit it. */ - SVN_ERR(svn_test__create_greek_tree(txn_root, pool)); - SVN_ERR(svn_fs_commit_txn(&conflict, &newrev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(newrev)); + SVN_ERR(create_greek_fs(&fs, &newrev, "test-repo-lock-out-of-date", + opts, pool)); /* Commit a small change to /A/D/G/rho, creating revision 2. */ SVN_ERR(svn_fs_begin_txn2(&txn, fs, newrev, SVN_FS_TXN_CHECK_LOCKS, pool)); |