You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2014/03/27 17:54:00 UTC
svn commit: r1582396 - /subversion/trunk/subversion/tests/svn_test_main.c
Author: rhuijben
Date: Thu Mar 27 16:54:00 2014
New Revision: 1582396
URL: http://svn.apache.org/r1582396
Log:
Make the cleanup behavior of the C tests when running parallel similar to
cleaning up in a single threaded run: after every test.
As the function for registering cleanup paths doesn't have any usable
argument for finding a per thread pool, introduce a per thread variable in
the test runner.
This reduces the amount of temporary storage used by our testsuite enough
to finally allow running the BDB tests without creating a bigger ramdrive
or switching to non-parallel builds.
* subversion/tests/svn_test_main.c
(thread_local): Define on most platforms that don't define this C11 type.
(cleanup_pool): Make thread local if possible.
(test_thread): Create and clear a per thread cleanup pool if necessary.
Modified:
subversion/trunk/subversion/tests/svn_test_main.c
Modified: subversion/trunk/subversion/tests/svn_test_main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_main.c?rev=1582396&r1=1582395&r2=1582396&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_main.c (original)
+++ subversion/trunk/subversion/tests/svn_test_main.c Thu Mar 27 16:54:00 2014
@@ -147,7 +147,23 @@ static const apr_getopt_option_t cl_opti
static svn_boolean_t skip_cleanup = FALSE;
/* All cleanup actions are registered as cleanups on this pool. */
+#if !defined(thread_local) && APR_HAS_THREADS
+
+# if __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
+# define thread_local _Thread_local
+# elif defined(WIN32) && defined(_MSC_VER)
+# define thread_local __declspec(thread)
+# elif defined(__GNUC__)
+# define thread_local __thread
+# endif
+#endif
+
+#ifdef thread_local
+#define HAVE_PER_THREAD_CLEANUP
+static thread_local apr_pool_t * cleanup_pool = NULL;
+#else
static apr_pool_t *cleanup_pool = NULL;
+#endif
/* Used by test_thread to serialize access to stdout. */
static svn_mutex__t *log_mutex = NULL;
@@ -176,6 +192,7 @@ cleanup_rmtree(void *data)
}
+
void
svn_test_add_dir_cleanup(const char *path)
{
@@ -461,15 +478,24 @@ test_thread(apr_thread_t *thread, void *
svn_boolean_t run_this_test; /* This test's mode matches DESC->MODE. */
test_params_t *params = data;
svn_atomic_t test_num;
-
- apr_pool_t *pool
+ apr_pool_t *pool;
+ apr_pool_t *thread_root
= apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
+#ifdef HAVE_PER_THREAD_CLEANUP
+ cleanup_pool = svn_pool_create(thread_root);
+#endif
+
+ pool = svn_pool_create(thread_root);
+
for (test_num = svn_atomic_inc(¶ms->test_num);
test_num <= params->test_count;
test_num = svn_atomic_inc(¶ms->test_num))
{
svn_pool_clear(pool);
+#ifdef HAVE_PER_THREAD_CLEANUP
+ svn_pool_clear(cleanup_pool); /* after clearing pool*/
+#endif
desc = ¶ms->test_funcs[test_num];
skip = desc->mode == svn_test_skip;
@@ -494,8 +520,10 @@ test_thread(apr_thread_t *thread, void *
svn_error_clear(svn_mutex__unlock(log_mutex, NULL));
}
- /* release all test memory */
- svn_pool_destroy(pool);
+ svn_pool_clear(pool); /* Make sure this is cleared before cleanup_pool*/
+
+ /* Release all test memory. Possibly includes cleanup_pool */
+ svn_pool_destroy(thread_root);
/* End thread explicitly to prevent APR_INCOMPLETE return codes in
apr_thread_join(). */