Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_ra/ra-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_ra/ra-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_ra/ra-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_ra/ra-test.c Mon Feb 9 11:23:39 2015 @@ -49,29 +49,21 @@ static const char tunnel_repos_name[] = static svn_error_t * -make_and_open_local_repos(svn_ra_session_t **session, - const char *repos_name, - const svn_test_opts_t *opts, - apr_pool_t *pool) +make_and_open_repos(svn_ra_session_t **session, + const char *repos_name, + const svn_test_opts_t *opts, + apr_pool_t *pool) { - svn_repos_t *repos; const char *url; svn_ra_callbacks2_t *cbtable; SVN_ERR(svn_ra_create_callbacks(&cbtable, pool)); - SVN_ERR(svn_cmdline_create_auth_baton(&cbtable->auth_baton, - TRUE /* non_interactive */, - "jrandom", "rayjandom", - NULL, - TRUE /* no_auth_cache */, - FALSE /* trust_server_cert */, - NULL, NULL, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&cbtable->auth_baton, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_name, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &url, NULL, repos_name, opts, + pool, pool)); SVN_ERR(svn_ra_initialize(pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&url, repos_name, pool)); - SVN_ERR(svn_ra_open4(session, NULL, url, NULL, cbtable, NULL, NULL, pool)); return SVN_NO_ERROR; @@ -272,9 +264,9 @@ location_segments_test(const svn_test_op b.segments = segments; b.pool = pool; - SVN_ERR(make_and_open_local_repos(&session, - "test-repo-locsegs", opts, - pool)); + SVN_ERR(make_and_open_repos(&session, + "test-repo-locsegs", opts, + pool)); /* ### This currently tests only a small subset of what's possible. */ SVN_ERR(commit_changes(session, pool)); @@ -439,8 +431,11 @@ expect_error(const char *path, svn_lock_t *lock; struct lock_result_t *result = svn_hash_gets(results, path); - SVN_TEST_ASSERT(result && !result->lock && result->err); + SVN_TEST_ASSERT(result && result->err); + SVN_TEST_ASSERT(!result->lock); + /* RA layers shouldn't report SVN_ERR_FS_NOT_FOUND */ SVN_ERR(svn_ra_get_lock(session, &lock, path, scratch_pool)); + SVN_TEST_ASSERT(!lock); return SVN_NO_ERROR; } @@ -488,8 +483,7 @@ lock_test(const svn_test_opts_t *opts, struct lock_baton_t baton; apr_hash_index_t *hi; - SVN_ERR(make_and_open_local_repos(&session, "test-repo-lock", opts, - pool)); + SVN_ERR(make_and_open_repos(&session, "test-repo-lock", opts, pool)); SVN_ERR(commit_tree(session, pool)); baton.results = apr_hash_make(pool); @@ -564,11 +558,31 @@ lock_test(const svn_test_opts_t *opts, return SVN_NO_ERROR; } +/* Test svn_ra_get_dir2(). */ +static svn_error_t * +get_dir_test(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_ra_session_t *session; + apr_hash_t *dirents; + + SVN_ERR(make_and_open_repos(&session, "test-get-dir", opts, pool)); + SVN_ERR(commit_tree(session, pool)); + + /* This call used to block on ra-svn for 1.8.0...r1656713 */ + SVN_TEST_ASSERT_ERROR(svn_ra_get_dir2(session, &dirents, NULL, NULL, + "non/existing/relpath", 1, + SVN_DIRENT_KIND, pool), + SVN_ERR_FS_NOT_FOUND); + + return SVN_NO_ERROR; +} + /* The test table. */ -static int max_threads = 1; +static int max_threads = 2; static struct svn_test_descriptor_t test_funcs[] = { @@ -581,6 +595,8 @@ static struct svn_test_descriptor_t test "test ra_svn tunnel creation callbacks"), SVN_TEST_OPTS_PASS(lock_test, "lock multiple paths"), + SVN_TEST_OPTS_PASS(get_dir_test, + "test ra_get_dir2"), SVN_TEST_NULL };
Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_repos/dump-load-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_repos/dump-load-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_repos/dump-load-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_repos/dump-load-test.c Mon Feb 9 11:23:39 2015 @@ -35,7 +35,114 @@ -/* Notification receiver for test_dump_bad_mergeinfo(). This does not +/* Test dumping in the presence of the property PROP_NAME:PROP_VAL. + * Return the dumped data in *DUMP_DATA_P (if DUMP_DATA_P is not null). + * REPOS is an empty repository. + * See svn_repos_dump_fs3() for START_REV, END_REV, NOTIFY_FUNC, NOTIFY_BATON. + */ +static svn_error_t * +test_dump_bad_props(svn_stringbuf_t **dump_data_p, + svn_repos_t *repos, + const char *prop_name, + const svn_string_t *prop_val, + svn_revnum_t start_rev, + svn_revnum_t end_rev, + svn_repos_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool) +{ + const char *test_path = "/bar"; + svn_fs_t *fs = svn_repos_fs(repos); + svn_fs_txn_t *txn; + svn_fs_root_t *txn_root; + svn_revnum_t youngest_rev = 0; + svn_stringbuf_t *dump_data = svn_stringbuf_create_empty(pool); + svn_stream_t *stream = svn_stream_from_stringbuf(dump_data, pool); + const char *expected_str; + + /* Revision 1: Any commit will do, here */ + SVN_ERR(svn_fs_begin_txn2(&txn, fs, youngest_rev, 0, pool)); + SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); + SVN_ERR(svn_fs_make_dir(txn_root, test_path , pool)); + SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool)); + SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev)); + + /* Revision 2: Add the bad property */ + SVN_ERR(svn_fs_begin_txn2(&txn, fs, youngest_rev, 0, pool)); + SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); + SVN_ERR(svn_fs_change_node_prop(txn_root, test_path , prop_name, prop_val, + pool)); + SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool)); + SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev)); + + /* Test that a dump completes without error. */ + SVN_ERR(svn_repos_dump_fs3(repos, stream, start_rev, end_rev, + FALSE, FALSE, + notify_func, notify_baton, + NULL, NULL, + pool)); + svn_stream_close(stream); + + /* Check that the property appears in the dump data */ + expected_str = apr_psprintf(pool, "K %d\n%s\n" + "V %d\n%s\n" + "PROPS-END\n", + (int)strlen(prop_name), prop_name, + (int)prop_val->len, prop_val->data); + SVN_TEST_ASSERT(strstr(dump_data->data, expected_str)); + + if (dump_data_p) + *dump_data_p = dump_data; + return SVN_NO_ERROR; +} + +/* Test loading in the presence of the property PROP_NAME:PROP_VAL. + * Load data from DUMP_DATA. + * REPOS is an empty repository. + */ +static svn_error_t * +test_load_bad_props(svn_stringbuf_t *dump_data, + svn_repos_t *repos, + const char *prop_name, + const svn_string_t *prop_val, + const char *parent_fspath, + svn_boolean_t validate_props, + svn_repos_notify_func_t notify_func, + void *notify_baton, + apr_pool_t *pool) +{ + const char *test_path = apr_psprintf(pool, "%s%s", + parent_fspath ? parent_fspath : "", + "/bar"); + svn_stream_t *stream = svn_stream_from_stringbuf(dump_data, pool); + svn_fs_t *fs; + svn_fs_root_t *rev_root; + svn_revnum_t youngest_rev; + svn_string_t *loaded_prop_val; + + SVN_ERR(svn_repos_load_fs5(repos, stream, + SVN_INVALID_REVNUM, SVN_INVALID_REVNUM, + svn_repos_load_uuid_default, + parent_fspath, + FALSE, FALSE, /*use_*_commit_hook*/ + validate_props, + FALSE /*ignore_dates*/, + notify_func, notify_baton, + NULL, NULL, /*cancellation*/ + pool)); + svn_stream_close(stream); + + /* Check the loaded property */ + fs = svn_repos_fs(repos); + SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, pool)); + SVN_ERR(svn_fs_revision_root(&rev_root, fs, youngest_rev, pool)); + SVN_ERR(svn_fs_node_prop(&loaded_prop_val, + rev_root, test_path, prop_name, pool)); + SVN_TEST_ASSERT(svn_string_compare(loaded_prop_val, prop_val)); + return SVN_NO_ERROR; +} + +/* Notification receiver for test_dump_r0_mergeinfo(). This does not need to do anything, it just needs to exist. */ static void @@ -51,44 +158,115 @@ static svn_error_t * test_dump_r0_mergeinfo(const svn_test_opts_t *opts, apr_pool_t *pool) { - svn_repos_t *repos; - svn_fs_t *fs; - svn_fs_txn_t *txn; - svn_fs_root_t *txn_root; - svn_revnum_t youngest_rev = 0; + const char *prop_name = "svn:mergeinfo"; const svn_string_t *bad_mergeinfo = svn_string_create("/foo:0", pool); + svn_repos_t *repos; SVN_ERR(svn_test__create_repos(&repos, "test-repo-dump-r0-mergeinfo", opts, pool)); - fs = svn_repos_fs(repos); - - /* Revision 1: Any commit will do, here */ - SVN_ERR(svn_fs_begin_txn2(&txn, fs, youngest_rev, 0, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - SVN_ERR(svn_fs_make_dir(txn_root, "/bar", pool)); - SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev)); - - /* Revision 2: Add bad mergeinfo */ - SVN_ERR(svn_fs_begin_txn2(&txn, fs, youngest_rev, 0, pool)); - SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool)); - SVN_ERR(svn_fs_change_node_prop(txn_root, "/bar", "svn:mergeinfo", bad_mergeinfo, pool)); - SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool)); - SVN_TEST_ASSERT(SVN_IS_VALID_REVNUM(youngest_rev)); - - /* Test that a dump completes without error. In order to exercise the + /* In order to exercise the functionality under test -- that is, in order for the dump to try to parse the mergeinfo it is dumping -- the dump must start from a revision greater than 1 and must take a notification callback. */ + SVN_ERR(test_dump_bad_props(NULL, repos, + prop_name, bad_mergeinfo, + 2, SVN_INVALID_REVNUM, + dump_r0_mergeinfo_notifier, NULL, + pool)); + + return SVN_NO_ERROR; +} + +static void +load_r0_mergeinfo_notifier(void *baton, + const svn_repos_notify_t *notify, + apr_pool_t *scratch_pool) +{ + svn_boolean_t *had_mergeinfo_warning = baton; + + if (notify->action == svn_repos_notify_warning) + { + if (notify->warning == svn_repos_notify_warning_invalid_mergeinfo) + { + *had_mergeinfo_warning = TRUE; + } + } +} + +/* Regression test for the 'load' part of issue #4476 "Mergeinfo + * containing r0 makes svnsync and svnadmin dump fail". + * + * Bad mergeinfo should not prevent loading a backup, at least when we do not + * require mergeinfo revision numbers or paths to be adjusted during loading. + */ +static svn_error_t * +test_load_r0_mergeinfo(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + const char *prop_name = "svn:mergeinfo"; + const svn_string_t *prop_val = svn_string_create("/foo:0", pool); + svn_stringbuf_t *dump_data = svn_stringbuf_create_empty(pool); + + /* Produce a dump file containing bad mergeinfo */ { - svn_stringbuf_t *stringbuf = svn_stringbuf_create_empty(pool); - svn_stream_t *stream = svn_stream_from_stringbuf(stringbuf, pool); + svn_repos_t *repos; + + SVN_ERR(svn_test__create_repos(&repos, "test-repo-load-r0-mi-1", + opts, pool)); + SVN_ERR(test_dump_bad_props(&dump_data, repos, + prop_name, prop_val, + SVN_INVALID_REVNUM, SVN_INVALID_REVNUM, + NULL, NULL, pool)); + } + + /* Test loading without validating properties: should warn and succeed */ + { + svn_repos_t *repos; + svn_boolean_t had_mergeinfo_warning = FALSE; + + SVN_ERR(svn_test__create_repos(&repos, "test-repo-load-r0-mi-2", + opts, pool)); + + /* Without changing revision numbers or paths */ + SVN_ERR(test_load_bad_props(dump_data, repos, + prop_name, prop_val, + NULL /*parent_dir*/, FALSE /*validate_props*/, + load_r0_mergeinfo_notifier, &had_mergeinfo_warning, + pool)); + SVN_TEST_ASSERT(had_mergeinfo_warning); + + /* With changing revision numbers and/or paths (by loading the same data + again, on top of existing revisions, into subdirectory 'bar') */ + had_mergeinfo_warning = FALSE; + SVN_ERR(test_load_bad_props(dump_data, repos, + prop_name, prop_val, + "/bar", FALSE /*validate_props*/, + load_r0_mergeinfo_notifier, &had_mergeinfo_warning, + pool)); + SVN_TEST_ASSERT(had_mergeinfo_warning); + } + + /* Test loading with validating properties: should return an error */ + { + svn_repos_t *repos; + + SVN_ERR(svn_test__create_repos(&repos, "test-repo-load-r0-mi-3", + opts, pool)); - SVN_ERR(svn_repos_dump_fs3(repos, stream, 2, SVN_INVALID_REVNUM, - FALSE, FALSE, - dump_r0_mergeinfo_notifier, NULL, - NULL, NULL, - pool)); + /* Without changing revision numbers or paths */ + SVN_TEST_ASSERT_ANY_ERROR(test_load_bad_props(dump_data, repos, + prop_name, prop_val, + NULL /*parent_dir*/, TRUE /*validate_props*/, + NULL, NULL, + pool)); + + /* With changing revision numbers and/or paths (by loading the same data + again, on top of existing revisions, into subdirectory 'bar') */ + SVN_TEST_ASSERT_ANY_ERROR(test_load_bad_props(dump_data, repos, + prop_name, prop_val, + "/bar", TRUE /*validate_props*/, + NULL, NULL, + pool)); } return SVN_NO_ERROR; @@ -103,6 +281,8 @@ static struct svn_test_descriptor_t test SVN_TEST_NULL, SVN_TEST_OPTS_PASS(test_dump_r0_mergeinfo, "test dumping with r0 mergeinfo"), + SVN_TEST_OPTS_PASS(test_load_r0_mergeinfo, + "test loading with r0 mergeinfo"), SVN_TEST_NULL }; Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_repos/repos-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_repos/repos-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_repos/repos-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_repos/repos-test.c Mon Feb 9 11:23:39 2015 @@ -3562,6 +3562,56 @@ test_repos_fs_type(const svn_test_opts_t return SVN_NO_ERROR; } +static svn_error_t * +deprecated_access_context_api(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_repos_t *repos; + svn_fs_access_t *access; + svn_fs_txn_t *txn; + svn_fs_root_t *root; + const char *conflict; + svn_revnum_t new_rev; + const char *hook; + + /* Create test repository. */ + SVN_ERR(svn_test__create_repos(&repos, + "test-repo-deprecated-access-context-api", + opts, pool)); + + /* Set an empty pre-commit hook. */ +#ifdef WIN32 + hook = apr_pstrcat(pool, svn_repos_pre_commit_hook(repos, pool), ".bat", + SVN_VA_NULL); + SVN_ERR(svn_io_file_create(hook, + "exit 0" APR_EOL_STR, + pool)); +#else + hook = svn_repos_pre_commit_hook(repos, pool); + SVN_ERR(svn_io_file_create(hook, + "#!/bin/sh" APR_EOL_STR "exit 0" APR_EOL_STR, + pool)); + SVN_ERR(svn_io_set_file_executable(hook, TRUE, FALSE, pool)); +#endif + + /* Set some access context using svn_fs_access_add_lock_token(). */ + SVN_ERR(svn_fs_create_access(&access, "jrandom", pool)); + SVN_ERR(svn_fs_access_add_lock_token(access, "opaquelocktoken:abc")); + SVN_ERR(svn_fs_set_access(svn_repos_fs(repos), access)); + + /* Commit a new revision. */ + SVN_ERR(svn_repos_fs_begin_txn_for_commit2(&txn, repos, 0, + apr_hash_make(pool), pool)); + SVN_ERR(svn_fs_txn_root(&root, txn, pool)); + SVN_ERR(svn_fs_make_dir(root, "/whatever", pool)); + SVN_ERR(svn_repos_fs_commit_txn(&conflict, repos, &new_rev, txn, pool)); + + SVN_TEST_STRING_ASSERT(conflict, NULL); + SVN_TEST_ASSERT(new_rev == 1); + + return SVN_NO_ERROR; +} + /* The test table. */ static int max_threads = 4; @@ -3615,6 +3665,8 @@ static struct svn_test_descriptor_t test "test svn_repos__config_pool_*"), SVN_TEST_OPTS_PASS(test_repos_fs_type, "test test_repos_fs_type"), + SVN_TEST_OPTS_PASS(deprecated_access_context_api, + "test deprecated access context api"), SVN_TEST_NULL }; Propchange: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Mon Feb 9 11:23:39 2015 @@ -52,3 +52,4 @@ read_length_tmp bit-array-test io-test-* sqlite-test-* +x509-test Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/auth-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/auth-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/auth-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/auth-test.c Mon Feb 9 11:23:39 2015 @@ -220,8 +220,8 @@ cleanup_callback(svn_boolean_t *delete_c { svn_auth_baton_t *b = walk_baton; - SVN_TEST_ASSERT(strcmp(cred_kind, SVN_AUTH_CRED_SIMPLE) == 0); - SVN_TEST_ASSERT(strcmp(realmstring, "<http://my.host> My realm") == 0); + SVN_TEST_STRING_ASSERT(cred_kind, SVN_AUTH_CRED_SIMPLE); + SVN_TEST_STRING_ASSERT(realmstring, "<http://my.host> My realm"); SVN_ERR(svn_auth_forget_credentials(b, cred_kind, realmstring, scratch_pool)); @@ -272,7 +272,7 @@ test_auth_clear(apr_pool_t *pool) pool)); creds = credentials; - SVN_TEST_ASSERT(strcmp(creds->username, "jrandom") == 0); + SVN_TEST_STRING_ASSERT(creds->username, "jrandom"); SVN_TEST_ASSERT(creds->may_save); /* And tell that they are ok and can be saved */ @@ -292,7 +292,7 @@ test_auth_clear(apr_pool_t *pool) SVN_TEST_ASSERT(credentials); creds = credentials; - SVN_TEST_ASSERT(strcmp(creds->username, "jrandom") == 0); + SVN_TEST_STRING_ASSERT(creds->username, "jrandom"); SVN_TEST_ASSERT(creds->may_save); /* Use our walker function to delete credentials (and forget them Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/cache-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/cache-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/cache-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/cache-test.c Mon Feb 9 11:23:39 2015 @@ -201,6 +201,102 @@ test_membuffer_cache_basic(apr_pool_t *p 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); +} + +/* Implements svn_cache__partial_setter_func_t */ +static svn_error_t * +raise_error_partial_setter_func(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:", + SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY, + FALSE, + pool, 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); + + /* Create a new cache. */ + SVN_ERR(svn_cache__membuffer_cache_create(&membuffer, 10*1024, 1, 0, + TRUE, TRUE, pool)); + SVN_ERR(svn_cache__create_membuffer_cache(&cache, + membuffer, + serialize_revnum, + deserialize_revnum, + APR_HASH_KEY_STRING, + "cache:", + SVN_CACHE__MEMBUFFER_DEFAULT_PRIORITY, + FALSE, + pool, pool)); + + /* Store one entry in cache. */ + SVN_ERR(svn_cache__set(cache, "twenty", &twenty, pool)); + + /* Test setting data in cache using partial setter that + always raises an error. */ + SVN_TEST_ASSERT_ERROR( + svn_cache__set_partial(cache, "twenty", + raise_error_partial_setter_func, + NULL, pool), + APR_EGENERAL); + + return SVN_NO_ERROR; +} static svn_error_t * test_memcache_long_key(const svn_test_opts_t *opts, @@ -274,6 +370,8 @@ static struct svn_test_descriptor_t test "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 }; Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/config-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/config-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/config-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/config-test.c Mon Feb 9 11:23:39 2015 @@ -347,6 +347,29 @@ test_read_only_mode(const svn_test_opts_ return SVN_NO_ERROR; } +static svn_error_t * +test_expand(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_config_t *cfg; + const char *cfg_file, *val; + + SVN_ERR(get_config_file_path(&cfg_file, opts, pool)); + SVN_ERR(svn_config_read3(&cfg, cfg_file, TRUE, TRUE, FALSE, pool)); + + /* Get expanded "g" which requires expanding "c". */ + svn_config_get(cfg, &val, "section1", "g", NULL); + + /* Get expanded "c". */ + svn_config_get(cfg, &val, "section1", "c", NULL); + + /* With pool debugging enabled this ensures that the expanded value + of "c" was not created in a temporary pool when expanding "g". */ + SVN_TEST_STRING_ASSERT(val, "bar"); + + return SVN_NO_ERROR; +} + /* ==================================================================== If you add a new test to this file, update this array. @@ -377,6 +400,8 @@ static struct svn_test_descriptor_t test "test parsing config file with BOM"), SVN_TEST_OPTS_PASS(test_read_only_mode, "test r/o mode"), + SVN_TEST_OPTS_PASS(test_expand, + "test variable expansion"), SVN_TEST_NULL }; Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/dirent_uri-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/dirent_uri-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/dirent_uri-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/dirent_uri-test.c Mon Feb 9 11:23:39 2015 @@ -809,6 +809,9 @@ static const testcase_canonicalize_t uri { "http://hst/foo/../bar","http://hst/foo/../bar" }, { "http://hst/", "http://hst" }, { "http:///", "http://" }, + { "http:///example.com/", "http:///example.com" }, + { "http:////example.com/", "http:///example.com" }, + { "http://///////example.com/", "http:///example.com" }, { "https://", "https://" }, { "file:///", "file://" }, { "file://", "file://" }, Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/io-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/io-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/io-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/io-test.c Mon Feb 9 11:23:39 2015 @@ -680,6 +680,63 @@ aligned_seek_test(apr_pool_t *pool) return SVN_NO_ERROR; } +static svn_error_t * +ignore_enoent(apr_pool_t *pool) +{ + const char *tmp_dir, *path; + const svn_io_dirent2_t *dirent_p; + apr_file_t *file; + + /* Create an empty directory. */ + SVN_ERR(svn_dirent_get_absolute(&tmp_dir, "ignore_enoent", pool)); + SVN_ERR(svn_io_remove_dir2(tmp_dir, TRUE, NULL, NULL, pool)); + SVN_ERR(svn_io_make_dir_recursively(tmp_dir, pool)); + svn_test_add_dir_cleanup(tmp_dir); + + /* Path does not exist. */ + path = svn_dirent_join(tmp_dir, "not-present", pool); + SVN_ERR(svn_io_remove_dir2(path, TRUE, NULL, NULL, pool)); + SVN_ERR(svn_io_remove_file2(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_read_only(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_read_write(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_executable(path, TRUE, TRUE, pool)); + SVN_ERR(svn_io_set_file_executable(path, FALSE, TRUE, pool)); + SVN_ERR(svn_io_stat_dirent2(&dirent_p, path, TRUE, TRUE, pool, pool)); + SVN_ERR(svn_io_stat_dirent2(&dirent_p, path, FALSE, TRUE, pool, pool)); + + /* Neither path nor parent exists. */ + path = svn_dirent_join(path, "not-present", pool); + SVN_ERR(svn_io_remove_dir2(path, TRUE, NULL, NULL, pool)); + SVN_ERR(svn_io_remove_file2(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_read_only(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_read_write(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_executable(path, TRUE, TRUE, pool)); + SVN_ERR(svn_io_set_file_executable(path, FALSE, TRUE, pool)); + SVN_ERR(svn_io_stat_dirent2(&dirent_p, path, TRUE, TRUE, pool, pool)); + SVN_ERR(svn_io_stat_dirent2(&dirent_p, path, FALSE, TRUE, pool, pool)); + + /* File does exist. */ + path = svn_dirent_join(tmp_dir, "present", pool); + SVN_ERR(svn_io_file_open(&file, path, + APR_WRITE | APR_CREATE | APR_TRUNCATE, + APR_OS_DEFAULT, + pool)); + SVN_ERR(svn_io_file_close(file, pool)); + + /* Path does not exist as child of file. */ + path = svn_dirent_join(path, "not-present", pool); + SVN_ERR(svn_io_remove_dir2(path, TRUE, NULL, NULL, pool)); + SVN_ERR(svn_io_remove_file2(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_read_only(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_read_write(path, TRUE, pool)); + SVN_ERR(svn_io_set_file_executable(path, TRUE, TRUE, pool)); + SVN_ERR(svn_io_set_file_executable(path, FALSE, TRUE, pool)); + SVN_ERR(svn_io_stat_dirent2(&dirent_p, path, TRUE, TRUE, pool, pool)); + SVN_ERR(svn_io_stat_dirent2(&dirent_p, path, FALSE, TRUE, pool, pool)); + + return SVN_NO_ERROR; +} + /* The test table. */ @@ -700,6 +757,8 @@ static struct svn_test_descriptor_t test "svn_io_read_length_line() shouldn't loop"), SVN_TEST_PASS2(aligned_seek_test, "test aligned seek"), + SVN_TEST_PASS2(ignore_enoent, + "test ignore-enoent"), SVN_TEST_NULL }; Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/mergeinfo-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/mergeinfo-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/mergeinfo-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/mergeinfo-test.c Mon Feb 9 11:23:39 2015 @@ -104,7 +104,7 @@ verify_mergeinfo_parse(const char *input /* Were we expecting any more ranges? */ if (j < MAX_NBR_RANGES - 1 - && !expected_ranges[j].end == 0) + && expected_ranges[j].end != 0) return svn_error_createf(SVN_ERR_TEST_FAILED, NULL, "svn_mergeinfo_parse (%s) failed to " "produce the expected number of ranges", @@ -114,7 +114,7 @@ verify_mergeinfo_parse(const char *input } -#define NBR_MERGEINFO_VALS 24 +#define NBR_MERGEINFO_VALS 25 /* Valid mergeinfo values. */ static const char * const mergeinfo_vals[NBR_MERGEINFO_VALS] = @@ -148,7 +148,8 @@ static const char * const mergeinfo_vals "/A/:7-8", "/A///:7-8", "/A/.:7-8", - "/A/./B:7-8" + "/A/./B:7-8", + ":7-8", }; /* Paths corresponding to mergeinfo_vals. */ static const char * const mergeinfo_paths[NBR_MERGEINFO_VALS] = @@ -181,7 +182,8 @@ static const char * const mergeinfo_path "/A", "/A", "/A", - "/A/B" + "/A/B", + "/", }; /* First ranges from the paths identified by mergeinfo_paths. */ static svn_merge_range_t mergeinfo_ranges[NBR_MERGEINFO_VALS][MAX_NBR_RANGES] = @@ -212,6 +214,7 @@ static svn_merge_range_t mergeinfo_range { {6, 8, TRUE} }, { {6, 8, TRUE} }, { {6, 8, TRUE} }, + { {6, 8, TRUE} }, }; static svn_error_t * @@ -298,7 +301,7 @@ test_parse_combine_rangeinfo(apr_pool_t } -#define NBR_BROKEN_MERGEINFO_VALS 27 +#define NBR_BROKEN_MERGEINFO_VALS 26 /* Invalid mergeinfo values. */ static const char * const broken_mergeinfo_vals[NBR_BROKEN_MERGEINFO_VALS] = { @@ -330,8 +333,6 @@ static const char * const broken_mergein "/trunk:", "/trunk:2-9\n/branch:", "::", - /* No path */ - ":1-3", /* Invalid revisions */ "trunk:a-3", "branch:3-four", Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/string-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/string-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/string-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/string-test.c Mon Feb 9 11:23:39 2015 @@ -604,7 +604,19 @@ test_stringbuf_insert(apr_pool_t *pool) SVN_TEST_STRING_ASSERT(a->data, "test hello, world"); svn_stringbuf_insert(a, 1200, "!", 1); - return expect_stringbuf_equal(a, "test hello, world!", pool); + SVN_TEST_STRING_ASSERT(a->data, "test hello, world!"); + + svn_stringbuf_insert(a, 4, "\0-\0", 3); + SVN_TEST_ASSERT(svn_stringbuf_compare(a, + svn_stringbuf_ncreate("test\0-\0 hello, world!", + 21, pool))); + + svn_stringbuf_insert(a, 14, a->data + 4, 3); + SVN_TEST_ASSERT(svn_stringbuf_compare(a, + svn_stringbuf_ncreate("test\0-\0 hello,\0-\0 world!", + 24, pool))); + + return SVN_NO_ERROR; } static svn_error_t * @@ -643,8 +655,24 @@ test_stringbuf_replace(apr_pool_t *pool) SVN_TEST_STRING_ASSERT(a->data, "test hello, world!"); svn_stringbuf_replace(a, 1200, 199, "!!", 2); + SVN_TEST_STRING_ASSERT(a->data, "test hello, world!!!"); + + svn_stringbuf_replace(a, 10, 2, "\0-\0", 3); + SVN_TEST_ASSERT(svn_stringbuf_compare(a, + svn_stringbuf_ncreate("test hello\0-\0world!!!", + 21, pool))); + + svn_stringbuf_replace(a, 10, 3, a->data + 10, 3); + SVN_TEST_ASSERT(svn_stringbuf_compare(a, + svn_stringbuf_ncreate("test hello\0-\0world!!!", + 21, pool))); + + svn_stringbuf_replace(a, 19, 1, a->data + 10, 3); + SVN_TEST_ASSERT(svn_stringbuf_compare(a, + svn_stringbuf_ncreate("test hello\0-\0world!\0-\0!", + 23, pool))); - return expect_stringbuf_equal(a, "test hello, world!!!", pool); + return SVN_NO_ERROR; } static svn_error_t * Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/utf-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/utf-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/utf-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_subr/utf-test.c Mon Feb 9 11:23:39 2015 @@ -737,6 +737,92 @@ test_utf_is_normalized(apr_pool_t *pool) return SVN_NO_ERROR; } + +static svn_error_t * +test_utf_conversions(apr_pool_t *pool) +{ + static const struct cvt_test_t + { + svn_boolean_t sixteenbit; + svn_boolean_t bigendian; + const char *source; + const char *result; + } tests[] = { + +#define UTF_32_LE FALSE, FALSE +#define UTF_32_BE FALSE, TRUE +#define UTF_16_LE TRUE, FALSE +#define UTF_16_BE TRUE, TRUE + + /* Normal character conversion */ + { UTF_32_LE, "t\0\0\0" "e\0\0\0" "s\0\0\0" "t\0\0\0" "\0\0\0\0", "test" }, + { UTF_32_BE, "\0\0\0t" "\0\0\0e" "\0\0\0s" "\0\0\0t" "\0\0\0\0", "test" }, + { UTF_16_LE, "t\0" "e\0" "s\0" "t\0" "\0\0", "test" }, + { UTF_16_BE, "\0t" "\0e" "\0s" "\0t" "\0\0", "test" }, + + /* Valid surrogate pairs */ + { UTF_16_LE, "\x00\xD8" "\x00\xDC" "\0\0", "\xf0\x90\x80\x80" }, /* U+010000 */ + { UTF_16_LE, "\x34\xD8" "\x1E\xDD" "\0\0", "\xf0\x9d\x84\x9e" }, /* U+01D11E */ + { UTF_16_LE, "\xFF\xDB" "\xFD\xDF" "\0\0", "\xf4\x8f\xbf\xbd" }, /* U+10FFFD */ + + { UTF_16_BE, "\xD8\x00" "\xDC\x00" "\0\0", "\xf0\x90\x80\x80" }, /* U+010000 */ + { UTF_16_BE, "\xD8\x34" "\xDD\x1E" "\0\0", "\xf0\x9d\x84\x9e" }, /* U+01D11E */ + { UTF_16_BE, "\xDB\xFF" "\xDF\xFD" "\0\0", "\xf4\x8f\xbf\xbd" }, /* U+10FFFD */ + + /* Swapped, single and trailing surrogate pairs */ + { UTF_16_LE, "*\0" "\x00\xDC" "\x00\xD8" "*\0\0\0", "*\xed\xb0\x80" "\xed\xa0\x80*" }, + { UTF_16_LE, "*\0" "\x1E\xDD" "*\0\0\0", "*\xed\xb4\x9e*" }, + { UTF_16_LE, "*\0" "\xFF\xDB" "*\0\0\0", "*\xed\xaf\xbf*" }, + { UTF_16_LE, "\x1E\xDD" "\0\0", "\xed\xb4\x9e" }, + { UTF_16_LE, "\xFF\xDB" "\0\0", "\xed\xaf\xbf" }, + + { UTF_16_BE, "\0*" "\xDC\x00" "\xD8\x00" "\0*\0\0", "*\xed\xb0\x80" "\xed\xa0\x80*" }, + { UTF_16_BE, "\0*" "\xDD\x1E" "\0*\0\0", "*\xed\xb4\x9e*" }, + { UTF_16_BE, "\0*" "\xDB\xFF" "\0*\0\0", "*\xed\xaf\xbf*" }, + { UTF_16_BE, "\xDD\x1E" "\0\0", "\xed\xb4\x9e" }, + { UTF_16_BE, "\xDB\xFF" "\0\0", "\xed\xaf\xbf" }, + +#undef UTF_32_LE +#undef UTF_32_BE +#undef UTF_16_LE +#undef UTF_16_BE + + { 0 } + }; + + const struct cvt_test_t *tc; + const svn_string_t *result; + int i; + + for (i = 1, tc = tests; tc->source; ++tc, ++i) + { + if (tc->sixteenbit) + SVN_ERR(svn_utf__utf16_to_utf8(&result, (const void*)tc->source, + SVN_UTF__UNKNOWN_LENGTH, + tc->bigendian, pool, pool)); + else + SVN_ERR(svn_utf__utf32_to_utf8(&result, (const void*)tc->source, + SVN_UTF__UNKNOWN_LENGTH, + tc->bigendian, pool, pool)); + SVN_ERR_ASSERT(0 == strcmp(result->data, tc->result)); + } + + /* Test counted strings with NUL characters */ + SVN_ERR(svn_utf__utf16_to_utf8( + &result, (void*)("x\0" "\0\0" "y\0" "*\0"), 3, + FALSE, pool, pool)); + SVN_ERR_ASSERT(0 == memcmp(result->data, "x\0y", 3)); + + SVN_ERR(svn_utf__utf32_to_utf8( + &result, + (void*)("\0\0\0x" "\0\0\0\0" "\0\0\0y" "\0\0\0*"), 3, + TRUE, pool, pool)); + SVN_ERR_ASSERT(0 == memcmp(result->data, "x\0y", 3)); + + return SVN_NO_ERROR; +} + + /* The test table. */ @@ -761,6 +847,8 @@ static struct svn_test_descriptor_t test "test svn_utf__fuzzy_escape"), SVN_TEST_PASS2(test_utf_is_normalized, "test svn_utf__is_normalized"), + SVN_TEST_PASS2(test_utf_conversions, + "test svn_utf__utf{16,32}_to_utf8"), SVN_TEST_NULL }; Modified: subversion/branches/remove-log-addressing/subversion/tests/libsvn_wc/conflict-data-test.c URL: http://svn.apache.org/viewvc/subversion/branches/remove-log-addressing/subversion/tests/libsvn_wc/conflict-data-test.c?rev=1658362&r1=1658361&r2=1658362&view=diff ============================================================================== --- subversion/branches/remove-log-addressing/subversion/tests/libsvn_wc/conflict-data-test.c (original) +++ subversion/branches/remove-log-addressing/subversion/tests/libsvn_wc/conflict-data-test.c Mon Feb 9 11:23:39 2015 @@ -293,7 +293,7 @@ test_read_write_tree_conflicts(const svn child2_abspath = svn_dirent_join(parent_abspath, "bar", pool); SVN_ERR(sbox_wc_mkdir(&sbox, "A")); SVN_ERR(sbox_wc_mkdir(&sbox, "A/bar")); - sbox_file_write(&sbox, "A/foo", ""); + SVN_ERR(sbox_file_write(&sbox, "A/foo", "")); conflict1 = tree_conflict_create(child1_abspath, svn_node_file, svn_wc_operation_merge, @@ -621,8 +621,8 @@ test_serialize_tree_conflict(const svn_t SVN_TEST_ASSERT(reason == svn_wc_conflict_reason_moved_away); SVN_TEST_ASSERT(action == svn_wc_conflict_action_delete); - SVN_TEST_ASSERT(!strcmp(moved_away_op_root_abspath, - sbox_wc_path(&sbox, "A/B"))); + SVN_TEST_STRING_ASSERT(moved_away_op_root_abspath, + sbox_wc_path(&sbox, "A/B")); } return SVN_NO_ERROR;
