subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phi...@apache.org
Subject svn commit: r1574475 - in /subversion/branches/fsfs-lock-many/subversion/tests: libsvn_fs/locks-test.c libsvn_ra/ra-test.c
Date Wed, 05 Mar 2014 13:30:47 GMT
Author: philip
Date: Wed Mar  5 13:30:47 2014
New Revision: 1574475

URL: http://svn.apache.org/r1574475
Log:
On fsfs-lock-many branch: replace some macros with functions
for easier debugging.

* subversion/tests/libsvn_fs/locks-test.c
  (expect_lock, expect_error, expect_unlock, expect_unlock_error): New.
  (lock_multiple_paths): Remove macros, use functions.

* subversion/tests/libsvn_ra/ra-test.c
  (expect_lock, expect_error, expect_unlock, expect_unlock_error): New.
  (lock_test): Remove macros, use functions.

Modified:
    subversion/branches/fsfs-lock-many/subversion/tests/libsvn_fs/locks-test.c
    subversion/branches/fsfs-lock-many/subversion/tests/libsvn_ra/ra-test.c

Modified: subversion/branches/fsfs-lock-many/subversion/tests/libsvn_fs/locks-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-lock-many/subversion/tests/libsvn_fs/locks-test.c?rev=1574475&r1=1574474&r2=1574475&view=diff
==============================================================================
--- subversion/branches/fsfs-lock-many/subversion/tests/libsvn_fs/locks-test.c (original)
+++ subversion/branches/fsfs-lock-many/subversion/tests/libsvn_fs/locks-test.c Wed Mar  5
13:30:47 2014
@@ -789,6 +789,68 @@ lock_out_of_date(const svn_test_opts_t *
 
 
 static svn_error_t *
+expect_lock(const char *path,
+            apr_hash_t *results,
+            svn_fs_t *fs,
+            apr_pool_t *scratch_pool)
+{
+  svn_lock_t *lock;
+  svn_fs_lock_result_t *result = svn_hash_gets(results, path);
+
+  SVN_TEST_ASSERT(result && result->lock && !result->err);
+  SVN_ERR(svn_fs_get_lock(&lock, fs, path, scratch_pool));
+  SVN_TEST_ASSERT(lock);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+expect_error(const char *path,
+             apr_hash_t *results,
+             svn_fs_t *fs,
+             apr_pool_t *scratch_pool)
+{
+  svn_lock_t *lock;
+  svn_fs_lock_result_t *result = svn_hash_gets(results, path);
+
+  SVN_TEST_ASSERT(result && !result->lock && result->err);
+  svn_error_clear(result->err);
+  SVN_ERR(svn_fs_get_lock(&lock, fs, path, scratch_pool));
+  SVN_TEST_ASSERT(!lock);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+expect_unlock(const char *path,
+              apr_hash_t *results,
+              svn_fs_t *fs,
+              apr_pool_t *scratch_pool)
+{
+  svn_lock_t *lock;
+  svn_fs_lock_result_t *result = svn_hash_gets(results, path);
+
+  SVN_TEST_ASSERT(result && !result->err);
+  SVN_ERR(svn_fs_get_lock(&lock, fs, path, scratch_pool));
+  SVN_TEST_ASSERT(!lock);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+expect_unlock_error(const char *path,
+                    apr_hash_t *results,
+                    svn_fs_t *fs,
+                    apr_pool_t *scratch_pool)
+{
+  svn_lock_t *lock;
+  svn_fs_lock_result_t *result = svn_hash_gets(results, path);
+
+  SVN_TEST_ASSERT(result && result->err);
+  svn_error_clear(result->err);
+  SVN_ERR(svn_fs_get_lock(&lock, fs, path, scratch_pool));
+  SVN_TEST_ASSERT(lock);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
 lock_multiple_paths(const svn_test_opts_t *opts,
                     apr_pool_t *pool)
 {
@@ -801,7 +863,6 @@ lock_multiple_paths(const svn_test_opts_
   svn_fs_lock_target_t target;
   apr_hash_t *lock_paths, *unlock_paths, *results;
   svn_fs_lock_result_t *result;
-  svn_lock_t *lock;
   apr_hash_index_t *hi;
 
   SVN_ERR(create_greek_fs(&fs, &newrev, "test-lock-multiple-paths",
@@ -831,89 +892,63 @@ lock_multiple_paths(const svn_test_opts_
   svn_hash_sets(lock_paths, "/A/mu", &target);
   svn_hash_sets(lock_paths, "/X/zulu", &target);
 
-#define EXPECT_LOCK(path)                                  \
-  result = svn_hash_gets(results, (path));                 \
-  SVN_TEST_ASSERT(result && result->lock && !result->err); \
-  SVN_ERR(svn_fs_get_lock(&lock, fs, (path), pool));       \
-  SVN_TEST_ASSERT(lock)
-
-#define EXPECT_ERROR(path)                                 \
-  result = svn_hash_gets(results, (path));                 \
-  SVN_TEST_ASSERT(result && !result->lock && result->err); \
-  svn_error_clear(result->err);                            \
-  SVN_ERR(svn_fs_get_lock(&lock, fs, (path), pool));       \
-  SVN_TEST_ASSERT(!lock)
-
-#define EXPECT_UNLOCK(path)                          \
-  result = svn_hash_gets(results, (path));           \
-  SVN_TEST_ASSERT(result && !result->err);           \
-  SVN_ERR(svn_fs_get_lock(&lock, fs, (path), pool)); \
-  SVN_TEST_ASSERT(!lock)
-
-#define EXPECT_UNLOCK_ERROR(path)                    \
-  result = svn_hash_gets(results, (path));           \
-  SVN_TEST_ASSERT(result && result->err);            \
-  svn_error_clear(result->err);                      \
-  SVN_ERR(svn_fs_get_lock(&lock, fs, (path), pool)); \
-  SVN_TEST_ASSERT(lock)
-
   /* Lock some paths. */
   SVN_ERR(svn_fs_lock2(&results, fs, lock_paths, "comment", 0, 0, 0,
                        pool, pool));
 
-  EXPECT_LOCK("/A/B/E/alpha");
-  EXPECT_LOCK("/A/B/E/beta");
-  EXPECT_ERROR("/A/B/E/zulu");
-  EXPECT_LOCK("/A/BB/mu");
-  EXPECT_LOCK("/A/BBB/mu");
-  EXPECT_LOCK("/A/D/G/pi");
-  EXPECT_LOCK("/A/D/G/rho");
-  EXPECT_LOCK("/A/mu");
-  EXPECT_ERROR("/X/zulu");
+  SVN_ERR(expect_lock("/A/B/E/alpha", results, fs, pool));
+  SVN_ERR(expect_lock("/A/B/E/beta", results, fs, pool));
+  SVN_ERR(expect_error("/A/B/E/zulu", results, fs, pool));
+  SVN_ERR(expect_lock("/A/BB/mu", results, fs, pool));
+  SVN_ERR(expect_lock("/A/BBB/mu", results, fs, pool));
+  SVN_ERR(expect_lock("/A/D/G/pi", results, fs, pool));
+  SVN_ERR(expect_lock("/A/D/G/rho", results, fs, pool));
+  SVN_ERR(expect_lock("/A/mu", results, fs, pool));
+  SVN_ERR(expect_error("/X/zulu", results, fs, pool));
 
   /* Unlock without force and wrong tokens. */
   for (hi = apr_hash_first(pool, lock_paths); hi; hi = apr_hash_next(hi))
     svn_hash_sets(unlock_paths, svn__apr_hash_index_key(hi), "wrong-token");
   SVN_ERR(svn_fs_unlock2(&results, fs, unlock_paths, FALSE, pool, pool));
 
-  EXPECT_UNLOCK_ERROR("/A/B/E/alpha");
-  EXPECT_UNLOCK_ERROR("/A/B/E/beta");
-  EXPECT_ERROR("/A/B/E/zulu");
-  EXPECT_UNLOCK_ERROR("/A/BB/mu");
-  EXPECT_UNLOCK_ERROR("/A/BBB/mu");
-  EXPECT_UNLOCK_ERROR("/A/D/G/pi");
-  EXPECT_UNLOCK_ERROR("/A/D/G/rho");
-  EXPECT_UNLOCK_ERROR("/A/mu");
-  EXPECT_ERROR("/X/zulu");
+  SVN_ERR(expect_unlock_error("/A/B/E/alpha", results, fs, pool));
+  SVN_ERR(expect_unlock_error("/A/B/E/beta", results, fs, pool));
+  SVN_ERR(expect_error("/A/B/E/zulu", results, fs, pool));
+  SVN_ERR(expect_unlock_error("/A/BB/mu", results, fs, pool));
+  SVN_ERR(expect_unlock_error("/A/BBB/mu", results, fs, pool));
+  SVN_ERR(expect_unlock_error("/A/D/G/pi", results, fs, pool));
+  SVN_ERR(expect_unlock_error("/A/D/G/rho", results, fs, pool));
+  SVN_ERR(expect_unlock_error("/A/mu", results, fs, pool));
+  SVN_ERR(expect_error("/X/zulu", results, fs, pool));
 
   /* Force unlock. */
   for (hi = apr_hash_first(pool, lock_paths); hi; hi = apr_hash_next(hi))
     svn_hash_sets(unlock_paths, svn__apr_hash_index_key(hi), "");
   SVN_ERR(svn_fs_unlock2(&results, fs, unlock_paths, TRUE, pool, pool));
 
-  EXPECT_UNLOCK("/A/B/E/alpha");
-  EXPECT_UNLOCK("/A/B/E/beta");
-  EXPECT_ERROR("/A/B/E/zulu");
-  EXPECT_UNLOCK("/A/BB/mu");
-  EXPECT_UNLOCK("/A/BBB/mu");
-  EXPECT_UNLOCK("/A/D/G/pi");
-  EXPECT_UNLOCK("/A/D/G/rho");
-  EXPECT_UNLOCK("/A/mu");
-  EXPECT_ERROR("/X/zulu");
+  SVN_ERR(expect_unlock("/A/B/E/alpha", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/B/E/beta", results, fs, pool));
+  SVN_ERR(expect_error("/A/B/E/zulu", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/BB/mu", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/BBB/mu", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/D/G/pi", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/D/G/rho", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/mu", results, fs, pool));
+  SVN_ERR(expect_error("/X/zulu", results, fs, pool));
 
   /* Lock again. */
   SVN_ERR(svn_fs_lock2(&results, fs, lock_paths, "comment", 0, 0, 0,
                        pool, pool));
 
-  EXPECT_LOCK("/A/B/E/alpha");
-  EXPECT_LOCK("/A/B/E/beta");
-  EXPECT_ERROR("/A/B/E/zulu");
-  EXPECT_LOCK("/A/BB/mu");
-  EXPECT_LOCK("/A/BBB/mu");
-  EXPECT_LOCK("/A/D/G/pi");
-  EXPECT_LOCK("/A/D/G/rho");
-  EXPECT_LOCK("/A/mu");
-  EXPECT_ERROR("/X/zulu");
+  SVN_ERR(expect_lock("/A/B/E/alpha", results, fs, pool));
+  SVN_ERR(expect_lock("/A/B/E/beta", results, fs, pool));
+  SVN_ERR(expect_error("/A/B/E/zulu", results, fs, pool));
+  SVN_ERR(expect_lock("/A/BB/mu", results, fs, pool));
+  SVN_ERR(expect_lock("/A/BBB/mu", results, fs, pool));
+  SVN_ERR(expect_lock("/A/D/G/pi", results, fs, pool));
+  SVN_ERR(expect_lock("/A/D/G/rho", results, fs, pool));
+  SVN_ERR(expect_lock("/A/mu", results, fs, pool));
+  SVN_ERR(expect_error("/X/zulu", results, fs, pool));
 
   /* Unlock without force. */
   for (hi = apr_hash_first(pool, results); hi; hi = apr_hash_next(hi))
@@ -924,21 +959,17 @@ lock_multiple_paths(const svn_test_opts_
     }
   SVN_ERR(svn_fs_unlock2(&results, fs, unlock_paths, FALSE, pool, pool));
 
-  EXPECT_UNLOCK("/A/B/E/alpha");
-  EXPECT_UNLOCK("/A/B/E/beta");
-  EXPECT_ERROR("/A/B/E/zulu");
-  EXPECT_UNLOCK("/A/BB/mu");
-  EXPECT_UNLOCK("/A/BBB/mu");
-  EXPECT_UNLOCK("/A/D/G/pi");
-  EXPECT_UNLOCK("/A/D/G/rho");
-  EXPECT_UNLOCK("/A/mu");
-  EXPECT_ERROR("/X/zulu");
+  SVN_ERR(expect_unlock("/A/B/E/alpha", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/B/E/beta", results, fs, pool));
+  SVN_ERR(expect_error("/A/B/E/zulu", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/BB/mu", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/BBB/mu", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/D/G/pi", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/D/G/rho", results, fs, pool));
+  SVN_ERR(expect_unlock("/A/mu", results, fs, pool));
+  SVN_ERR(expect_error("/X/zulu", results, fs, pool));
 
   return SVN_NO_ERROR;
-
-#undef EXPECT_LOCK
-#undef EXPECT_ERROR
-#undef EXPECT_NO_ERROR
 }
 
 /* ------------------------------------------------------------------------ */

Modified: subversion/branches/fsfs-lock-many/subversion/tests/libsvn_ra/ra-test.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-lock-many/subversion/tests/libsvn_ra/ra-test.c?rev=1574475&r1=1574474&r2=1574475&view=diff
==============================================================================
--- subversion/branches/fsfs-lock-many/subversion/tests/libsvn_ra/ra-test.c (original)
+++ subversion/branches/fsfs-lock-many/subversion/tests/libsvn_ra/ra-test.c Wed Mar  5 13:30:47
2014
@@ -410,6 +410,66 @@ lock_cb(void *baton,
   return SVN_NO_ERROR;
 }
 
+static svn_error_t *
+expect_lock(const char *path,
+            apr_hash_t *results,
+            svn_ra_session_t *session,
+            apr_pool_t *scratch_pool)
+{
+  svn_lock_t *lock;
+  svn_fs_lock_result_t *result = svn_hash_gets(results, path);
+
+  SVN_TEST_ASSERT(result && result->lock && !result->err);
+  SVN_ERR(svn_ra_get_lock(session, &lock, path, scratch_pool));
+  SVN_TEST_ASSERT(lock);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+expect_error(const char *path,
+             apr_hash_t *results,
+             svn_ra_session_t *session,
+             apr_pool_t *scratch_pool)
+{
+  svn_lock_t *lock;
+  svn_fs_lock_result_t *result = svn_hash_gets(results, path);
+
+  SVN_TEST_ASSERT(result && !result->lock && result->err);
+  SVN_ERR(svn_ra_get_lock(session, &lock, path, scratch_pool));
+  SVN_TEST_ASSERT(!lock);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+expect_unlock(const char *path,
+              apr_hash_t *results,
+              svn_ra_session_t *session,
+              apr_pool_t *scratch_pool)
+{
+  svn_lock_t *lock;
+  svn_fs_lock_result_t *result = svn_hash_gets(results, path);
+
+  SVN_TEST_ASSERT(result && !result->err);
+  SVN_ERR(svn_ra_get_lock(session, &lock, path, scratch_pool));
+  SVN_TEST_ASSERT(!lock);
+  return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+expect_unlock_error(const char *path,
+                    apr_hash_t *results,
+                    svn_ra_session_t *session,
+                    apr_pool_t *scratch_pool)
+{
+  svn_lock_t *lock;
+  svn_fs_lock_result_t *result = svn_hash_gets(results, path);
+
+  SVN_TEST_ASSERT(result && result->err);
+  SVN_ERR(svn_ra_get_lock(session, &lock, path, scratch_pool));
+  SVN_TEST_ASSERT(lock);
+  return SVN_NO_ERROR;
+}
+
 /* Test svn_ra_lock(). */
 static svn_error_t *
 lock_test(const svn_test_opts_t *opts,
@@ -421,7 +481,6 @@ lock_test(const svn_test_opts_t *opts,
   svn_revnum_t rev = 1;
   svn_fs_lock_result_t *result;
   struct lock_baton_t baton;
-  svn_lock_t *lock;
   apr_hash_index_t *hi;
 
   SVN_ERR(make_and_open_local_repos(&session, "test-repo-lock", opts,
@@ -437,39 +496,15 @@ lock_test(const svn_test_opts_t *opts,
   svn_hash_sets(lock_targets, "A/BB/f", &rev);
   svn_hash_sets(lock_targets, "X/z", &rev);
 
-#define EXPECT_LOCK(path)                                  \
-  result = svn_hash_gets(baton.results, (path));           \
-  SVN_TEST_ASSERT(result && result->lock && !result->err); \
-  SVN_ERR(svn_ra_get_lock(session, &lock, (path), pool));  \
-  SVN_TEST_ASSERT(lock)
-
-#define EXPECT_ERROR(path)                                 \
-  result = svn_hash_gets(baton.results, (path));           \
-  SVN_TEST_ASSERT(result && !result->lock && result->err); \
-  SVN_ERR(svn_ra_get_lock(session, &lock, (path), pool));  \
-  SVN_TEST_ASSERT(!lock)
-
-#define EXPECT_UNLOCK(path)                                \
-  result = svn_hash_gets(baton.results, (path));           \
-  SVN_TEST_ASSERT(result && !result->err);                 \
-  SVN_ERR(svn_ra_get_lock(session, &lock, (path), pool));  \
-  SVN_TEST_ASSERT(!lock)
-
-#define EXPECT_UNLOCK_ERROR(path)                          \
-  result = svn_hash_gets(baton.results, (path));           \
-  SVN_TEST_ASSERT(result && result->err);                  \
-  SVN_ERR(svn_ra_get_lock(session, &lock, (path), pool));  \
-  SVN_TEST_ASSERT(lock)
-
   /* Lock some paths. */
   SVN_ERR(svn_ra_lock(session, lock_targets, "foo", FALSE, lock_cb, &baton,
                       pool));
 
-  EXPECT_LOCK("A/B/f");
-  EXPECT_LOCK("A/B/g");
-  EXPECT_ERROR("A/B/z");
-  EXPECT_LOCK("A/BB/f");
-  EXPECT_ERROR("X/z");
+  SVN_ERR(expect_lock("A/B/f", baton.results, session, pool));
+  SVN_ERR(expect_lock("A/B/g", baton.results, session, pool));
+  SVN_ERR(expect_error("A/B/z", baton.results, session, pool));
+  SVN_ERR(expect_lock("A/BB/f", baton.results, session, pool));
+  SVN_ERR(expect_error("X/z", baton.results, session, pool));
 
   /* Unlock without force and wrong lock tokens */
   for (hi = apr_hash_first(pool, lock_targets); hi; hi = apr_hash_next(hi))
@@ -477,11 +512,11 @@ lock_test(const svn_test_opts_t *opts,
   apr_hash_clear(baton.results);
   SVN_ERR(svn_ra_unlock(session, unlock_targets, FALSE, lock_cb, &baton, pool));
 
-  EXPECT_UNLOCK_ERROR("A/B/f");
-  EXPECT_UNLOCK_ERROR("A/B/g");
-  EXPECT_ERROR("A/B/z");
-  EXPECT_UNLOCK_ERROR("A/BB/f");
-  EXPECT_ERROR("X/z");
+  SVN_ERR(expect_unlock_error("A/B/f", baton.results, session, pool));
+  SVN_ERR(expect_unlock_error("A/B/g", baton.results, session, pool));
+  SVN_ERR(expect_error("A/B/z", baton.results, session, pool));
+  SVN_ERR(expect_unlock_error("A/BB/f", baton.results, session, pool));
+  SVN_ERR(expect_error("X/z", baton.results, session, pool));
 
   /* Force unlock */
   for (hi = apr_hash_first(pool, lock_targets); hi; hi = apr_hash_next(hi))
@@ -489,22 +524,22 @@ lock_test(const svn_test_opts_t *opts,
   apr_hash_clear(baton.results);
   SVN_ERR(svn_ra_unlock(session, unlock_targets, TRUE, lock_cb, &baton, pool));
 
-  EXPECT_UNLOCK("A/B/f");
-  EXPECT_UNLOCK("A/B/g");
-  EXPECT_ERROR("A/B/z");
-  EXPECT_UNLOCK("A/BB/f");
-  EXPECT_ERROR("X/z");
+  SVN_ERR(expect_unlock("A/B/f", baton.results, session, pool));
+  SVN_ERR(expect_unlock("A/B/g", baton.results, session, pool));
+  SVN_ERR(expect_error("A/B/z", baton.results, session, pool));
+  SVN_ERR(expect_unlock("A/BB/f", baton.results, session, pool));
+  SVN_ERR(expect_error("X/z", baton.results, session, pool));
 
   /* Lock again. */
   apr_hash_clear(baton.results);
   SVN_ERR(svn_ra_lock(session, lock_targets, "foo", FALSE, lock_cb, &baton,
                       pool));
 
-  EXPECT_LOCK("A/B/f");
-  EXPECT_LOCK("A/B/g");
-  EXPECT_ERROR("A/B/z");
-  EXPECT_LOCK("A/BB/f");
-  EXPECT_ERROR("X/z");
+  SVN_ERR(expect_lock("A/B/f", baton.results, session, pool));
+  SVN_ERR(expect_lock("A/B/g", baton.results, session, pool));
+  SVN_ERR(expect_error("A/B/z", baton.results, session, pool));
+  SVN_ERR(expect_lock("A/BB/f", baton.results, session, pool));
+  SVN_ERR(expect_error("X/z", baton.results, session, pool));
 
   for (hi = apr_hash_first(pool, baton.results); hi; hi = apr_hash_next(hi))
     {
@@ -515,11 +550,11 @@ lock_test(const svn_test_opts_t *opts,
   apr_hash_clear(baton.results);
   SVN_ERR(svn_ra_unlock(session, unlock_targets, FALSE, lock_cb, &baton, pool));
 
-  EXPECT_UNLOCK("A/B/f");
-  EXPECT_UNLOCK("A/B/g");
-  EXPECT_ERROR("A/B/z");
-  EXPECT_UNLOCK("A/BB/f");
-  EXPECT_ERROR("X/z");
+  SVN_ERR(expect_unlock("A/B/f", baton.results, session, pool));
+  SVN_ERR(expect_unlock("A/B/g", baton.results, session, pool));
+  SVN_ERR(expect_error("A/B/z", baton.results, session, pool));
+  SVN_ERR(expect_unlock("A/BB/f", baton.results, session, pool));
+  SVN_ERR(expect_error("X/z", baton.results, session, pool));
 
   return SVN_NO_ERROR;
 }



Mime
View raw message