You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by iv...@apache.org on 2015/05/12 14:58:34 UTC
svn commit: r1678927 -
/subversion/trunk/subversion/tests/libsvn_subr/cache-test.c
Author: ivan
Date: Tue May 12 12:58:34 2015
New Revision: 1678927
URL: http://svn.apache.org/r1678927
Log:
Add test for accessing membuffer cache with unaligned string keys. The
current implementation doesn't seem have problems with this scenario.
* subversion/tests/libsvn_subr/cache-test.c
(test_membuffer_unaligned_string_keys): New test.
(test_funcs): Add test_membuffer_unaligned_string_keys to test list.
Modified:
subversion/trunk/subversion/tests/libsvn_subr/cache-test.c
Modified: subversion/trunk/subversion/tests/libsvn_subr/cache-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/cache-test.c?rev=1678927&r1=1678926&r2=1678927&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/cache-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/cache-test.c Tue May 12 12:58:34 2015
@@ -440,7 +440,44 @@ test_membuffer_cache_clearing(apr_pool_t
return SVN_NO_ERROR;
}
-
+static svn_error_t *
+test_membuffer_unaligned_string_keys(apr_pool_t *pool)
+{
+ svn_cache__t *cache;
+ svn_membuffer_t *membuffer;
+ svn_revnum_t fifty = 50;
+ svn_revnum_t *answer;
+ svn_boolean_t found = FALSE;
+
+ /* Allocate explicitly to have aligned string and this add one
+ * to have unaligned string.*/
+ const char *unaligned_key = apr_pstrdup(pool, "_fifty") + 1;
+ const char *unaligned_prefix = apr_pstrdup(pool, "_cache:") + 1;
+
+ SVN_ERR(svn_cache__membuffer_cache_create(&membuffer, 10*1024, 1, 0,
+ TRUE, TRUE, pool));
+
+ /* Create a cache with just one entry. */
+ SVN_ERR(svn_cache__create_membuffer_cache(
+ &cache, membuffer, serialize_revnum, deserialize_revnum,
+ APR_HASH_KEY_STRING, unaligned_prefix,
+ SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY, FALSE,
+ pool, pool));
+
+ SVN_ERR(svn_cache__set(cache, unaligned_key, &fifty, pool));
+ SVN_ERR(svn_cache__get((void **) &answer, &found, cache, unaligned_key,
+ pool));
+
+ if (! found)
+ return svn_error_create(SVN_ERR_TEST_FAILED, NULL,
+ "cache failed to find entry for 'fifty'");
+ if (*answer != 50)
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
+ "expected 50 but found '%ld'", *answer);
+
+ return SVN_NO_ERROR;
+}
+
/* The test table. */
static int max_threads = 1;
@@ -460,6 +497,8 @@ static struct svn_test_descriptor_t test
"test for error handling in membuffer svn_cache"),
SVN_TEST_PASS2(test_membuffer_cache_clearing,
"test clearing a membuffer svn_cache"),
+ SVN_TEST_PASS2(test_membuffer_unaligned_string_keys,
+ "test membuffer cache with unaligned string keys"),
SVN_TEST_NULL
};