summaryrefslogtreecommitdiff
path: root/subversion/tests/libsvn_subr/cache-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'subversion/tests/libsvn_subr/cache-test.c')
-rw-r--r--subversion/tests/libsvn_subr/cache-test.c87
1 files changed, 72 insertions, 15 deletions
diff --git a/subversion/tests/libsvn_subr/cache-test.c b/subversion/tests/libsvn_subr/cache-test.c
index 9920296..9e7a7b3 100644
--- a/subversion/tests/libsvn_subr/cache-test.c
+++ b/subversion/tests/libsvn_subr/cache-test.c
@@ -36,7 +36,7 @@
/* Implements svn_cache__serialize_func_t */
static svn_error_t *
-serialize_revnum(char **data,
+serialize_revnum(void **data,
apr_size_t *data_len,
void *in,
apr_pool_t *pool)
@@ -51,7 +51,7 @@ serialize_revnum(char **data,
/* Implements svn_cache__deserialize_func_t */
static svn_error_t *
deserialize_revnum(void **out,
- char *data,
+ void *data,
apr_size_t data_len,
apr_pool_t *pool)
{
@@ -155,8 +155,8 @@ test_memcache_basic(const svn_test_opts_t *opts,
if (opts->config_file)
{
- SVN_ERR(svn_config_read2(&config, opts->config_file,
- TRUE, FALSE, pool));
+ SVN_ERR(svn_config_read3(&config, opts->config_file,
+ TRUE, FALSE, FALSE, pool));
SVN_ERR(svn_cache__make_memcache_from_config(&memcache, config, pool));
}
@@ -182,16 +182,9 @@ test_membuffer_cache_basic(apr_pool_t *pool)
{
svn_cache__t *cache;
svn_membuffer_t *membuffer;
- svn_boolean_t thread_safe;
-#if APR_HAS_THREADS
- thread_safe = TRUE;
-#else
- thread_safe = FALSE;
-#endif
-
- SVN_ERR(svn_cache__membuffer_cache_create(&membuffer, 10*1024, 1,
- thread_safe, pool));
+ 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,
@@ -200,11 +193,73 @@ test_membuffer_cache_basic(apr_pool_t *pool)
deserialize_revnum,
APR_HASH_KEY_STRING,
"cache:",
+ FALSE,
pool));
return basic_cache_test(cache, FALSE, pool);
}
+/* Implements svn_cache__deserialize_func_t */
+static svn_error_t *
+raise_error_deserialize_func(void **out,
+ void *data,
+ apr_size_t data_len,
+ apr_pool_t *pool)
+{
+ return svn_error_create(APR_EGENERAL, NULL, NULL);
+}
+
+/* Implements svn_cache__partial_getter_func_t */
+static svn_error_t *
+raise_error_partial_getter_func(void **out,
+ const void *data,
+ apr_size_t data_len,
+ void *baton,
+ apr_pool_t *result_pool)
+{
+ return svn_error_create(APR_EGENERAL, NULL, NULL);
+}
+
+static svn_error_t *
+test_membuffer_serializer_error_handling(apr_pool_t *pool)
+{
+ svn_cache__t *cache;
+ svn_membuffer_t *membuffer;
+ svn_revnum_t twenty = 20;
+ svn_boolean_t found;
+ void *val;
+
+ 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,
+ raise_error_deserialize_func,
+ APR_HASH_KEY_STRING,
+ "cache:",
+ FALSE,
+ pool));
+
+ SVN_ERR(svn_cache__set(cache, "twenty", &twenty, pool));
+
+ /* Test retrieving data from cache using full getter that
+ always raises an error. */
+ SVN_TEST_ASSERT_ERROR(
+ svn_cache__get(&val, &found, cache, "twenty", pool),
+ APR_EGENERAL);
+
+ /* Test retrieving data from cache using partial getter that
+ always raises an error. */
+ SVN_TEST_ASSERT_ERROR(
+ svn_cache__get_partial(&val, &found, cache, "twenty",
+ raise_error_partial_getter_func,
+ NULL, pool),
+ APR_EGENERAL);
+
+ return SVN_NO_ERROR;
+}
static svn_error_t *
test_memcache_long_key(const svn_test_opts_t *opts,
@@ -229,8 +284,8 @@ test_memcache_long_key(const svn_test_opts_t *opts,
if (opts->config_file)
{
- SVN_ERR(svn_config_read2(&config, opts->config_file,
- TRUE, FALSE, pool));
+ SVN_ERR(svn_config_read3(&config, opts->config_file,
+ TRUE, FALSE, FALSE, pool));
SVN_ERR(svn_cache__make_memcache_from_config(&memcache, config, pool));
}
@@ -275,5 +330,7 @@ struct svn_test_descriptor_t test_funcs[] =
"memcache svn_cache with very long keys"),
SVN_TEST_PASS2(test_membuffer_cache_basic,
"basic membuffer svn_cache test"),
+ SVN_TEST_PASS2(test_membuffer_serializer_error_handling,
+ "test for error handling in membuffer svn_cache"),
SVN_TEST_NULL
};