Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_ra/ra-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_ra/ra-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_ra/ra-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_ra/ra-test.c Sun Jun 14 20:58:10 2015 @@ -27,11 +27,11 @@ #include <apr_pools.h> #include <apr_file_io.h> #include <assert.h> -#define SVN_DEPRECATED #include "svn_error.h" #include "svn_delta.h" #include "svn_ra.h" +#include "svn_time.h" #include "svn_pools.h" #include "svn_cmdline.h" #include "svn_dirent_uri.h" @@ -81,13 +81,15 @@ commit_changes(svn_ra_session_t *session SVN_ERR(svn_ra_get_commit_editor3(session, &editor, &edit_baton, revprop_table, NULL, NULL, NULL, TRUE, pool)); - SVN_ERR(svn_ra_get_repos_root(session, &repos_root_url, pool)); + SVN_ERR(svn_ra_get_repos_root2(session, &repos_root_url, pool)); SVN_ERR(editor->open_root(edit_baton, SVN_INVALID_REVNUM, pool, &root_baton)); /* copy root-dir@0 to A@1 */ SVN_ERR(editor->add_directory("A", root_baton, repos_root_url, 0, pool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->close_directory(root_baton, pool)); SVN_ERR(editor->close_edit(edit_baton, pool)); return SVN_NO_ERROR; } @@ -105,7 +107,7 @@ commit_tree(svn_ra_session_t *session, SVN_ERR(svn_ra_get_commit_editor3(session, &editor, &edit_baton, revprop_table, NULL, NULL, NULL, TRUE, pool)); - SVN_ERR(svn_ra_get_repos_root(session, &repos_root_url, pool)); + SVN_ERR(svn_ra_get_repos_root2(session, &repos_root_url, pool)); SVN_ERR(editor->open_root(edit_baton, SVN_INVALID_REVNUM, pool, &root_baton)); @@ -130,6 +132,7 @@ commit_tree(svn_ra_session_t *session, SVN_ERR(editor->close_file(file_baton, NULL, pool)); SVN_ERR(editor->close_directory(B_baton, pool)); SVN_ERR(editor->close_directory(A_baton, pool)); + SVN_ERR(editor->close_directory(root_baton, pool)); SVN_ERR(editor->close_edit(edit_baton, pool)); return SVN_NO_ERROR; } @@ -338,13 +341,14 @@ check_tunnel_callback_test(const svn_tes cbtable->check_tunnel_func = check_tunnel; cbtable->open_tunnel_func = open_tunnel; cbtable->tunnel_baton = &b; - 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_cmdline_create_auth_baton2(&cbtable->auth_baton, + TRUE /* non_interactive */, + "jrandom", "rayjandom", + NULL, + TRUE /* no_auth_cache */, + FALSE /* trust_server_cert */, + FALSE, FALSE, FALSE, FALSE, + NULL, NULL, NULL, pool)); b.last_check = TRUE; err = svn_ra_open4(&session, NULL, "svn+foo://localhost/no-repo", @@ -379,13 +383,14 @@ tunnel_callback_test(const svn_test_opts cbtable->check_tunnel_func = check_tunnel; cbtable->open_tunnel_func = open_tunnel; cbtable->tunnel_baton = &b; - 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_cmdline_create_auth_baton2(&cbtable->auth_baton, + TRUE /* non_interactive */, + "jrandom", "rayjandom", + NULL, + TRUE /* no_auth_cache */, + FALSE /* trust_server_cert */, + FALSE, FALSE, FALSE, FALSE, + NULL, NULL, NULL, pool)); b.last_check = FALSE; err = svn_ra_open4(&session, NULL, url, NULL, cbtable, NULL, NULL, @@ -441,7 +446,7 @@ lock_cb(void *baton, result->err = ra_err; svn_hash_sets(b->results, apr_pstrdup(b->pool, path), result); - + return SVN_NO_ERROR; } @@ -616,11 +621,906 @@ get_dir_test(const svn_test_opts_t *opts return SVN_NO_ERROR; } +/* Implements svn_commit_callback2_t for commit_callback_failure() */ +static svn_error_t * +commit_callback_with_failure(const svn_commit_info_t *info, + void *baton, + apr_pool_t *scratch_pool) +{ + apr_time_t timetemp; + + SVN_TEST_ASSERT(info != NULL); + SVN_TEST_STRING_ASSERT(info->author, "jrandom"); + SVN_TEST_STRING_ASSERT(info->post_commit_err, NULL); + + SVN_ERR(svn_time_from_cstring(&timetemp, info->date, scratch_pool)); + SVN_TEST_ASSERT(timetemp != 0); + SVN_TEST_ASSERT(info->repos_root != NULL); + SVN_TEST_ASSERT(info->revision == 1); + + return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL); +} + +static svn_error_t * +commit_callback_failure(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_ra_session_t *ra_session; + const svn_delta_editor_t *editor; + void *edit_baton; + void *root_baton; + SVN_ERR(make_and_open_repos(&ra_session, "commit_cb_failure", opts, pool)); + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), commit_callback_with_failure, + NULL, NULL, FALSE, pool)); + + SVN_ERR(editor->open_root(edit_baton, 0, pool, &root_baton)); + SVN_ERR(editor->change_dir_prop(root_baton, "A", + svn_string_create("B", pool), pool)); + SVN_ERR(editor->close_directory(root_baton, pool)); + SVN_TEST_ASSERT_ERROR(editor->close_edit(edit_baton, pool), + SVN_ERR_CANCELLED); + + /* This is what users should do if close_edit fails... Except that in this case + the commit actually succeeded*/ + SVN_ERR(editor->abort_edit(edit_baton, pool)); + return SVN_NO_ERROR; +} + +static svn_error_t * +base_revision_above_youngest(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_ra_session_t *ra_session; + const svn_delta_editor_t *editor; + void *edit_baton; + void *root_baton; + svn_error_t *err; + SVN_ERR(make_and_open_repos(&ra_session, "base_revision_above_youngest", + opts, pool)); + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), NULL, + NULL, NULL, FALSE, pool)); + + /* r1 doesn't exist, but we say we want to apply changes against this + revision to see how the ra layers behave. + + Some will see an error directly on open_root, others in a later + state. */ + + /* ra-local and http pre-v2 will see the error here */ + err = editor->open_root(edit_baton, 1, pool, &root_baton); + + if (!err) + err = editor->change_dir_prop(root_baton, "A", + svn_string_create("B", pool), pool); + + /* http v2 will notice it here (PROPPATCH) */ + if (!err) + err = editor->close_directory(root_baton, pool); + + /* ra svn only notes it at some later point. Typically here */ + if (!err) + err = editor->close_edit(edit_baton, pool); + + SVN_TEST_ASSERT_ERROR(err, + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_ERR(editor->abort_edit(edit_baton, pool)); + return SVN_NO_ERROR; +} + +static svn_error_t * +delete_revision_above_youngest(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_ra_session_t *ra_session; + const svn_delta_editor_t *editor; + svn_error_t *err; + void *edit_baton; + + SVN_ERR(make_and_open_repos(&ra_session, "delete_revision_above_youngest", + opts, pool)); + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), NULL, + NULL, NULL, FALSE, pool)); + + { + void *root_baton; + void *dir_baton; + + SVN_ERR(editor->open_root(edit_baton, 0, pool, &root_baton)); + SVN_ERR(editor->add_directory("A", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->close_directory(root_baton, pool)); + SVN_ERR(editor->close_edit(edit_baton, pool)); + } + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), NULL, + NULL, NULL, FALSE, pool)); + + { + void *root_baton; + SVN_ERR(editor->open_root(edit_baton, 1, pool, &root_baton)); + + /* Now we supply r2, while HEAD is r1 */ + err = editor->delete_entry("A", 2, root_baton, pool); + + if (!err) + err = editor->close_edit(edit_baton, pool); + + SVN_TEST_ASSERT_ERROR(err, + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_ERR(editor->abort_edit(edit_baton, pool)); + } + return SVN_NO_ERROR; +} + +/* Stub svn_log_entry_receiver_t */ +static svn_error_t * +stub_log_receiver(void *baton, + svn_log_entry_t *entry, + apr_pool_t *scratch_pool) +{ + return SVN_NO_ERROR; +} + +/* Stub svn_location_segment_receiver_t */ +static svn_error_t * +stub_segment_receiver(svn_location_segment_t *segment, + void *baton, + apr_pool_t *scratch_pool) +{ + return SVN_NO_ERROR; +} +/* Stub svn_file_rev_handler_t */ +static svn_error_t * +stub_file_rev_handler(void *baton, + const char *path, + svn_revnum_t rev, + apr_hash_t *rev_props, + svn_boolean_t result_of_merge, + svn_txdelta_window_handler_t *delta_handler, + void **delta_baton, + apr_array_header_t *prop_diffs, + apr_pool_t *pool) +{ + if (delta_handler) + *delta_handler = svn_delta_noop_window_handler; + + return SVN_NO_ERROR; +} + +struct lock_stub_baton_t +{ + apr_status_t result_code; +}; + +static svn_error_t * +store_lock_result(void *baton, + const char *path, + svn_boolean_t do_lock, + const svn_lock_t *lock, + svn_error_t *ra_err, + apr_pool_t *pool) +{ + struct lock_stub_baton_t *b = baton; + + b->result_code = ra_err ? ra_err->apr_err : APR_SUCCESS; + return SVN_NO_ERROR; +} + +static svn_error_t * +replay_range_rev_start(svn_revnum_t revision, + void *replay_baton, + const svn_delta_editor_t **editor, + void **edit_baton, + apr_hash_t *rev_props, + apr_pool_t *pool) +{ + *editor = svn_delta_default_editor(pool); + *edit_baton = NULL; + return SVN_NO_ERROR; +} + +static svn_error_t * +replay_range_rev_end(svn_revnum_t revision, + void *replay_baton, + const svn_delta_editor_t *editor, + void *edit_baton, + apr_hash_t *rev_props, + apr_pool_t *pool) +{ + return SVN_NO_ERROR; +} + +static svn_error_t * +ra_revision_errors(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_ra_session_t *ra_session; + const svn_delta_editor_t *editor; + svn_error_t *err; + void *edit_baton; + + /* This function DOESN'T use a scratch/iter pool between requests... + + That has a reason: some ra layers (e.g. Serf) are sensitive to + reusing the same pool. In that case they may produce bad results + that they wouldn't do (as often) when the pool wasn't reused. + + It the amount of memory used gets too big we should probably split + this test... as the reuse already discovered a few issues that + are now resolved in ra_serf. + */ + SVN_ERR(make_and_open_repos(&ra_session, "ra_revision_errors", + opts, pool)); + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), NULL, + NULL, NULL, FALSE, pool)); + + { + void *root_baton; + void *dir_baton; + void *file_baton; + + SVN_ERR(editor->open_root(edit_baton, 0, pool, &root_baton)); + SVN_ERR(editor->add_directory("A", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->add_file("A/iota", dir_baton, NULL, SVN_INVALID_REVNUM, + pool, &file_baton)); + SVN_ERR(editor->close_file(file_baton, NULL, pool)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->add_directory("B", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->add_directory("C", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->add_directory("D", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->close_directory(root_baton, pool)); + SVN_ERR(editor->close_edit(edit_baton, pool)); + } + + { + const svn_ra_reporter3_t *reporter; + void *report_baton; + + err = svn_ra_do_update3(ra_session, &reporter, &report_baton, + 2, "", svn_depth_infinity, FALSE, FALSE, + svn_delta_default_editor(pool), NULL, + pool, pool); + + if (!err) + err = reporter->set_path(report_baton, "", 0, svn_depth_infinity, FALSE, + NULL, pool); + + if (!err) + err = reporter->finish_report(report_baton, pool); + + SVN_TEST_ASSERT_ERROR(err, SVN_ERR_FS_NO_SUCH_REVISION); + } + + { + const svn_ra_reporter3_t *reporter; + void *report_baton; + + err = svn_ra_do_update3(ra_session, &reporter, &report_baton, + 1, "", svn_depth_infinity, FALSE, FALSE, + svn_delta_default_editor(pool), NULL, + pool, pool); + + if (!err) + err = reporter->set_path(report_baton, "", 2, svn_depth_infinity, FALSE, + NULL, pool); + + if (!err) + err = reporter->finish_report(report_baton, pool); + + SVN_TEST_ASSERT_ERROR(err, SVN_ERR_FS_NO_SUCH_REVISION); + } + + { + const svn_ra_reporter3_t *reporter; + void *report_baton; + + err = svn_ra_do_update3(ra_session, &reporter, &report_baton, + 1, "", svn_depth_infinity, FALSE, FALSE, + svn_delta_default_editor(pool), NULL, + pool, pool); + + if (!err) + err = reporter->set_path(report_baton, "", 0, svn_depth_infinity, FALSE, + NULL, pool); + + if (!err) + err = reporter->finish_report(report_baton, pool); + + SVN_ERR(err); + } + + { + svn_revnum_t revision; + + SVN_ERR(svn_ra_get_dated_revision(ra_session, &revision, + apr_time_now() - apr_time_from_sec(3600), + pool)); + + SVN_TEST_ASSERT(revision == 0); + + SVN_ERR(svn_ra_get_dated_revision(ra_session, &revision, + apr_time_now() + apr_time_from_sec(3600), + pool)); + + SVN_TEST_ASSERT(revision == 1); + } + + { + /* SVN_INVALID_REVNUM is protected by assert in ra loader */ + + SVN_TEST_ASSERT_ERROR(svn_ra_change_rev_prop2(ra_session, + 2, + "bad", NULL, + svn_string_create("value", + pool), + pool), + SVN_ERR_FS_NO_SUCH_REVISION); + } + + { + apr_hash_t *props; + svn_string_t *value; + + /* SVN_INVALID_REVNUM is protected by assert in ra loader */ + + SVN_TEST_ASSERT_ERROR(svn_ra_rev_proplist(ra_session, 2, &props, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_rev_prop(ra_session, 2, "bad", &value, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + } + + { + apr_hash_t *props; + svn_string_t *value; + + /* SVN_INVALID_REVNUM is protected by assert in ra loader */ + + SVN_TEST_ASSERT_ERROR(svn_ra_rev_proplist(ra_session, 2, &props, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_rev_prop(ra_session, 2, "bad", &value, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + } + + { + svn_revnum_t fetched; + apr_hash_t *props; + + SVN_TEST_ASSERT_ERROR(svn_ra_get_file(ra_session, "A", 1, + svn_stream_empty(pool), &fetched, + &props, pool), + SVN_ERR_FS_NOT_FILE); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_file(ra_session, "A/iota", 2, + svn_stream_empty(pool), &fetched, + &props, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_file(ra_session, "Z", 1, + svn_stream_empty(pool), &fetched, + &props, pool), + SVN_ERR_FS_NOT_FOUND); + + SVN_ERR(svn_ra_get_file(ra_session, "A/iota", SVN_INVALID_REVNUM, + svn_stream_empty(pool), &fetched, + &props, pool)); + SVN_TEST_ASSERT(fetched == 1); + } + + { + svn_revnum_t fetched; + apr_hash_t *dirents; + apr_hash_t *props; + + SVN_TEST_ASSERT_ERROR(svn_ra_get_dir2(ra_session, &dirents, &fetched, + &props, "A/iota", 1, + SVN_DIRENT_ALL, pool), + SVN_ERR_FS_NOT_DIRECTORY); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_dir2(ra_session, &dirents, &fetched, + &props, "A", 2, + SVN_DIRENT_ALL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_dir2(ra_session, &dirents, &fetched, + &props, "Z", 1, + SVN_DIRENT_ALL, pool), + SVN_ERR_FS_NOT_FOUND); + + SVN_ERR(svn_ra_get_dir2(ra_session, &dirents, &fetched, + &props, "A", SVN_INVALID_REVNUM, + SVN_DIRENT_ALL, pool)); + SVN_TEST_ASSERT(fetched == 1); + SVN_TEST_ASSERT(apr_hash_count(dirents) == 1); + } + + { + svn_mergeinfo_catalog_t catalog; + apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(const char*)); + APR_ARRAY_PUSH(paths, const char *) = "A"; + + SVN_TEST_ASSERT_ERROR(svn_ra_get_mergeinfo(ra_session, &catalog, paths, + 2, svn_mergeinfo_inherited, + FALSE, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_mergeinfo(ra_session, &catalog, paths, + 0, svn_mergeinfo_inherited, + FALSE, pool), + SVN_ERR_FS_NOT_FOUND); + + SVN_ERR(svn_ra_get_mergeinfo(ra_session, &catalog, paths, + SVN_INVALID_REVNUM, svn_mergeinfo_inherited, + FALSE, pool)); + } + + { + apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(const char*)); + APR_ARRAY_PUSH(paths, const char *) = "A"; + + SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths, 0, 2, -1, + FALSE, FALSE, FALSE, NULL, + stub_log_receiver, NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths, 2, 0, -1, + FALSE, FALSE, FALSE, NULL, + stub_log_receiver, NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths, + SVN_INVALID_REVNUM, 2, -1, + FALSE, FALSE, FALSE, NULL, + stub_log_receiver, NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths, + 2, SVN_INVALID_REVNUM, -1, + FALSE, FALSE, FALSE, NULL, + stub_log_receiver, NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + } + + { + svn_node_kind_t kind; + SVN_TEST_ASSERT_ERROR(svn_ra_check_path(ra_session, "A", 2, &kind, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_ERR(svn_ra_check_path(ra_session, "A", SVN_INVALID_REVNUM, &kind, + pool)); + + SVN_TEST_ASSERT(kind == svn_node_dir); + } + + { + svn_dirent_t *dirent; + apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(const char*)); + APR_ARRAY_PUSH(paths, const char *) = "A"; + + SVN_TEST_ASSERT_ERROR(svn_ra_stat(ra_session, "A", 2, &dirent, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_ERR(svn_ra_stat(ra_session, "A", SVN_INVALID_REVNUM, &dirent, + pool)); + + SVN_TEST_ASSERT(dirent->kind == svn_node_dir); + } + + { + apr_hash_t *locations; + apr_array_header_t *revisions = apr_array_make(pool, 2, sizeof(svn_revnum_t)); + APR_ARRAY_PUSH(revisions, svn_revnum_t) = 1; + + /* SVN_INVALID_REVNUM as passed revision doesn't work */ + + SVN_TEST_ASSERT_ERROR(svn_ra_get_locations(ra_session, &locations, "A", 2, + revisions, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + APR_ARRAY_PUSH(revisions, svn_revnum_t) = 7; + SVN_TEST_ASSERT_ERROR(svn_ra_get_locations(ra_session, &locations, "A", 1, + revisions, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + /* Putting SVN_INVALID_REVNUM in the array doesn't marshal properly in svn:// + */ + } + + { + /* peg_rev -> SVN_INVALID_REVNUM -> youngest + start_rev -> SVN_INVALID_REVNUM -> peg_rev + end_rev -> SVN_INVALID_REVNUM -> 0 */ + SVN_TEST_ASSERT_ERROR(svn_ra_get_location_segments(ra_session, "A", + 2, 1, 0, + stub_segment_receiver, + NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_location_segments(ra_session, "A", + SVN_INVALID_REVNUM, + 2, 0, + stub_segment_receiver, + NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + + SVN_TEST_ASSERT_ERROR(svn_ra_get_location_segments(ra_session, "A", + SVN_INVALID_REVNUM, + SVN_INVALID_REVNUM, + 2, + stub_segment_receiver, + NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_ERR(svn_ra_get_location_segments(ra_session, "A", + SVN_INVALID_REVNUM, + SVN_INVALID_REVNUM, + SVN_INVALID_REVNUM, + stub_segment_receiver, + NULL, pool)); + } + + { + SVN_TEST_ASSERT_ERROR(svn_ra_get_file_revs2(ra_session, "A/iota", 2, 0, + FALSE, stub_file_rev_handler, + NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_file_revs2(ra_session, "A/iota", 0, 2, + FALSE, stub_file_rev_handler, + NULL, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_file_revs2(ra_session, "A", 1, 1, + FALSE, stub_file_rev_handler, + NULL, pool), + SVN_ERR_FS_NOT_FILE); + } + + { + apr_hash_t *locks = apr_hash_make(pool); + svn_revnum_t rev = 2; + struct lock_stub_baton_t lr = {0}; + + svn_hash_sets(locks, "A/iota", &rev); + + SVN_ERR(svn_ra_lock(ra_session, locks, "comment", FALSE, + store_lock_result, &lr, pool)); + SVN_TEST_ASSERT(lr.result_code == SVN_ERR_FS_NO_SUCH_REVISION); + + rev = 0; + SVN_ERR(svn_ra_lock(ra_session, locks, "comment", FALSE, + store_lock_result, &lr, pool)); + SVN_TEST_ASSERT(lr.result_code == SVN_ERR_FS_OUT_OF_DATE); + + svn_hash_sets(locks, "A/iota", NULL); + svn_hash_sets(locks, "A", &rev); + rev = SVN_INVALID_REVNUM; + SVN_ERR(svn_ra_lock(ra_session, locks, "comment", FALSE, + store_lock_result, &lr, pool)); + SVN_TEST_ASSERT(lr.result_code == SVN_ERR_FS_NOT_FILE); + } + + { + apr_hash_t *locks = apr_hash_make(pool); + struct lock_stub_baton_t lr = {0}; + + svn_hash_sets(locks, "A/iota", "no-token"); + + SVN_ERR(svn_ra_unlock(ra_session, locks, FALSE, + store_lock_result, &lr, pool)); + SVN_TEST_ASSERT(lr.result_code == SVN_ERR_FS_NO_SUCH_LOCK); + + + svn_hash_sets(locks, "A/iota", NULL); + svn_hash_sets(locks, "A", "no-token"); + SVN_ERR(svn_ra_unlock(ra_session, locks, FALSE, + store_lock_result, &lr, pool)); + SVN_TEST_ASSERT(lr.result_code == SVN_ERR_FS_NO_SUCH_LOCK); + } + + { + svn_lock_t *lock; + SVN_ERR(svn_ra_get_lock(ra_session, &lock, "A", pool)); + SVN_TEST_ASSERT(lock == NULL); + } + + { + SVN_TEST_ASSERT_ERROR(svn_ra_replay(ra_session, 2, 0, TRUE, + svn_delta_default_editor(pool), NULL, + pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + /* Simply assumes everything is there*/ + SVN_ERR(svn_ra_replay(ra_session, 1, 2, TRUE, + svn_delta_default_editor(pool), NULL, + pool)); + } + + { + SVN_TEST_ASSERT_ERROR(svn_ra_replay_range(ra_session, 1, 2, 0, + TRUE, + replay_range_rev_start, + replay_range_rev_end, NULL, + pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + /* Simply assumes everything is there*/ + SVN_TEST_ASSERT_ERROR(svn_ra_replay_range(ra_session, 2, 2, 0, + TRUE, + replay_range_rev_start, + replay_range_rev_end, NULL, + pool), + SVN_ERR_FS_NO_SUCH_REVISION); + } + + { + svn_revnum_t del_rev; + + /* ### Explicitly documented to not return an FS or RA error???? */ + + SVN_TEST_ASSERT_ERROR(svn_ra_get_deleted_rev(ra_session, "Z", 2, 1, + &del_rev, pool), + SVN_ERR_CLIENT_BAD_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_deleted_rev(ra_session, "Z", + SVN_INVALID_REVNUM, 2, + &del_rev, pool), + SVN_ERR_CLIENT_BAD_REVISION); + + } + + { + apr_array_header_t *iprops; + + SVN_TEST_ASSERT_ERROR(svn_ra_get_inherited_props(ra_session, &iprops, + "A", 2, pool, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + SVN_TEST_ASSERT_ERROR(svn_ra_get_inherited_props(ra_session, &iprops, + "A", SVN_INVALID_REVNUM, + pool, pool), + SVN_ERR_FS_NO_SUCH_REVISION); + + SVN_TEST_ASSERT_ERROR(svn_ra_get_inherited_props(ra_session, &iprops, + "Z", 1, + pool, pool), + SVN_ERR_FS_NOT_FOUND); + } + + return SVN_NO_ERROR; +} +/* svn_log_entry_receiver_t returning cease invocation */ +static svn_error_t * +error_log_receiver(void *baton, + svn_log_entry_t *entry, + apr_pool_t *scratch_pool) +{ + return svn_error_create(SVN_ERR_CEASE_INVOCATION, NULL, NULL); +} + +/* Stub svn_location_segment_receiver_t */ +static svn_error_t * +error_segment_receiver(svn_location_segment_t *segment, + void *baton, + apr_pool_t *scratch_pool) +{ + return svn_error_create(SVN_ERR_CEASE_INVOCATION, NULL, NULL); +} + + +static svn_error_t * +errors_from_callbacks(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_ra_session_t *ra_session; + const svn_delta_editor_t *editor; + void *edit_baton; + + /* This function DOESN'T use a scratch/iter pool between requests... + + That has a reason: some ra layers (e.g. Serf) are sensitive to + reusing the same pool. In that case they may produce bad results + that they wouldn't do (as often) when the pool wasn't reused. + + It the amount of memory used gets too big we should probably split + this test... as the reuse already discovered a few issues that + are now resolved in ra_serf. + */ + SVN_ERR(make_and_open_repos(&ra_session, "errors_from_callbacks", + opts, pool)); + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), NULL, + NULL, NULL, FALSE, pool)); + + { + void *root_baton; + void *dir_baton; + void *file_baton; + + SVN_ERR(editor->open_root(edit_baton, 0, pool, &root_baton)); + SVN_ERR(editor->add_directory("A", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->add_file("A/iota", dir_baton, NULL, SVN_INVALID_REVNUM, + pool, &file_baton)); + SVN_ERR(editor->close_file(file_baton, NULL, pool)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->add_directory("B", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->add_directory("C", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->add_directory("D", root_baton, NULL, SVN_INVALID_REVNUM, + pool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->close_directory(root_baton, pool)); + SVN_ERR(editor->close_edit(edit_baton, pool)); + } + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), NULL, + NULL, NULL, FALSE, pool)); + + { + void *root_baton; + void *dir_baton; + void *file_baton; + + SVN_ERR(editor->open_root(edit_baton, 1, pool, &root_baton)); + SVN_ERR(editor->open_directory("A", root_baton, 1, pool, &dir_baton)); + SVN_ERR(editor->open_file("A/iota", dir_baton, 1, pool, &file_baton)); + + SVN_ERR(editor->change_file_prop(file_baton, "A", svn_string_create("B", + pool), + pool)); + + SVN_ERR(editor->close_file(file_baton, NULL, pool)); + + SVN_ERR(editor->change_dir_prop(dir_baton, "A", svn_string_create("B", + pool), + pool)); + SVN_ERR(editor->close_directory(dir_baton, pool)); + SVN_ERR(editor->close_directory(root_baton, pool)); + SVN_ERR(editor->close_edit(edit_baton, pool)); + } + + { + apr_array_header_t *paths = apr_array_make(pool, 1, sizeof(const char*)); + APR_ARRAY_PUSH(paths, const char *) = "A/iota"; + + /* Note that ra_svn performs OK for SVN_ERR_CEASE_INVOCATION, but any + other error will make it break the ra session for further operations */ + + SVN_TEST_ASSERT_ERROR(svn_ra_get_log2(ra_session, paths, 2, 0, -1, + FALSE, FALSE, FALSE, NULL, + error_log_receiver, NULL, pool), + SVN_ERR_CEASE_INVOCATION); + } + + { + /* Note that ra_svn performs OK for SVN_ERR_CEASE_INVOCATION, but any + other error will make it break the ra session for further operations */ + + SVN_TEST_ASSERT_ERROR(svn_ra_get_location_segments(ra_session, "A/iota", + 2, 2, 0, + error_segment_receiver, + NULL, pool), + SVN_ERR_CEASE_INVOCATION); + } + + /* And a final check to see if the ra session is still ok */ + { + svn_node_kind_t kind; + + SVN_ERR(svn_ra_check_path(ra_session, "A", 2, &kind, pool)); + + SVN_TEST_ASSERT(kind == svn_node_dir); + } + return SVN_NO_ERROR; +} + +static svn_error_t * +ra_list_has_props(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_ra_session_t *ra_session; + const svn_delta_editor_t *editor; + apr_pool_t *iterpool = svn_pool_create(pool); + int i; + void *edit_baton; + const char *trunk_url; + + SVN_ERR(make_and_open_repos(&ra_session, "ra_list_has_props", + opts, pool)); + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), NULL, + NULL, NULL, FALSE, iterpool)); + + /* Create initial layout*/ + { + void *root_baton; + void *dir_baton; + + SVN_ERR(editor->open_root(edit_baton, 0, pool, &root_baton)); + SVN_ERR(editor->add_directory("trunk", root_baton, NULL, SVN_INVALID_REVNUM, + iterpool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, iterpool)); + SVN_ERR(editor->add_directory("tags", root_baton, NULL, SVN_INVALID_REVNUM, + iterpool, &dir_baton)); + SVN_ERR(editor->close_directory(dir_baton, iterpool)); + SVN_ERR(editor->close_directory(root_baton, iterpool)); + SVN_ERR(editor->close_edit(edit_baton, iterpool)); + } + + SVN_ERR(svn_ra_get_repos_root2(ra_session, &trunk_url, pool)); + trunk_url = svn_path_url_add_component2(trunk_url, "trunk", pool); + + /* Create a few tags. Using a value like 8000 will take too long for a normal + testrun, but produces more realistic problems */ + for (i = 0; i < 50; i++) + { + void *root_baton; + void *tags_baton; + void *dir_baton; + + svn_pool_clear(iterpool); + + SVN_ERR(svn_ra_get_commit_editor3(ra_session, &editor, &edit_baton, + apr_hash_make(pool), NULL, + NULL, NULL, FALSE, iterpool)); + + SVN_ERR(editor->open_root(edit_baton, i+1, pool, &root_baton)); + SVN_ERR(editor->open_directory("tags", root_baton, i+1, iterpool, + &tags_baton)); + SVN_ERR(editor->add_directory(apr_psprintf(iterpool, "tags/T%05d", i+1), + tags_baton, trunk_url, 1, iterpool, + &dir_baton)); + + SVN_ERR(editor->close_directory(dir_baton, iterpool)); + SVN_ERR(editor->close_directory(tags_baton, iterpool)); + SVN_ERR(editor->close_directory(root_baton, iterpool)); + SVN_ERR(editor->close_edit(edit_baton, iterpool)); + } + + { + apr_hash_t *dirents; + svn_revnum_t fetched_rev; + apr_hash_t *props; + + SVN_ERR(svn_ra_get_dir2(ra_session, &dirents, &fetched_rev, &props, + "tags", SVN_INVALID_REVNUM, + SVN_DIRENT_ALL, pool)); + } + + return SVN_NO_ERROR; +} /* The test table. */ -static int max_threads = 2; +static int max_threads = 4; static struct svn_test_descriptor_t test_funcs[] = { @@ -635,6 +1535,18 @@ static struct svn_test_descriptor_t test "lock multiple paths"), SVN_TEST_OPTS_PASS(get_dir_test, "test ra_get_dir2"), + SVN_TEST_OPTS_PASS(commit_callback_failure, + "commit callback failure"), + SVN_TEST_OPTS_PASS(base_revision_above_youngest, + "base revision newer than youngest"), + SVN_TEST_OPTS_PASS(delete_revision_above_youngest, + "delete revision newer than youngest"), + SVN_TEST_OPTS_PASS(ra_revision_errors, + "check how ra functions handle bad revisions"), + SVN_TEST_OPTS_PASS(errors_from_callbacks, + "check how ra layers handle errors from callbacks"), + SVN_TEST_OPTS_PASS(ra_list_has_props, + "check list has_props performance"), SVN_TEST_NULL };
Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/auth-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/auth-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/auth-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/auth-test.c Sun Jun 14 20:58:10 2015 @@ -312,6 +312,153 @@ test_auth_clear(apr_pool_t *pool) return SVN_NO_ERROR; } +struct plaintext_baton_t +{ + int nr_calls; + svn_boolean_t may_save; +}; +static svn_error_t * +plaintext_prompt_cb(svn_boolean_t *may_save_plaintext, + const char *realmstring, + void *baton, + apr_pool_t *pool) +{ + struct plaintext_baton_t *b = baton; + b->nr_calls++; + *may_save_plaintext = b->may_save; + return SVN_NO_ERROR; +} + +static svn_error_t * +test_save_cleartext(apr_pool_t *pool) +{ +#ifndef SVN_DISABLE_PLAINTEXT_PASSWORD_STORAGE +# define EXPECT_NO_CALLS 0 +# define EXPECT_ONE_CALL 1 +# define EXPECT_TWO_CALLS 2 +#else +# define EXPECT_NO_CALLS 0 +# define EXPECT_ONE_CALL 0 +# define EXPECT_TWO_CALLS 0 +#endif + + const char *auth_dir; + svn_auth_baton_t *baton, *slave; + svn_auth_provider_object_t *provider; + apr_array_header_t *providers; + void *credentials; + svn_auth_iterstate_t *state; + struct plaintext_baton_t pb = {0, FALSE}; + + SVN_ERR(svn_dirent_get_absolute(&auth_dir, "save-cleartext", pool)); + + SVN_ERR(svn_io_remove_dir2(auth_dir, TRUE, NULL, NULL, pool)); + SVN_ERR(svn_io_dir_make(auth_dir, APR_OS_DEFAULT, pool)); + svn_test_add_dir_cleanup(auth_dir); + + svn_auth_get_simple_provider2(&provider, plaintext_prompt_cb, &pb, pool); + + providers = apr_array_make(pool, 1, sizeof(svn_auth_provider_object_t *)); + APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; + + svn_auth_open(&baton, providers, pool); + + svn_auth_set_parameter(baton, SVN_AUTH_PARAM_DEFAULT_USERNAME, "jrandom"); + svn_auth_set_parameter(baton, SVN_AUTH_PARAM_DEFAULT_PASSWORD, "rayjandom"); + svn_auth_set_parameter(baton, SVN_AUTH_PARAM_CONFIG_DIR, auth_dir); + + /* Create the auth subdirs. Without these we can't store passwords */ + SVN_ERR(svn_config_ensure(auth_dir, pool)); + pb.nr_calls = 0; + + /* Legacy behavior: Don't ask: Save */ + SVN_ERR(svn_auth_first_credentials(&credentials, &state, + SVN_AUTH_CRED_SIMPLE, + "realm-1", baton, pool)); + SVN_TEST_ASSERT(credentials != NULL); + SVN_ERR(svn_auth_save_credentials(state, pool)); + SVN_TEST_ASSERT(pb.nr_calls == EXPECT_NO_CALLS); + + /* Set to ask */ + svn_auth_set_parameter(baton, SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, + SVN_CONFIG_ASK); + SVN_ERR(svn_auth_first_credentials(&credentials, &state, + SVN_AUTH_CRED_SIMPLE, + "realm-2", baton, pool)); + SVN_TEST_ASSERT(credentials != NULL); + SVN_ERR(svn_auth_save_credentials(state, pool)); + SVN_TEST_ASSERT(pb.nr_calls == EXPECT_ONE_CALL); + + /* Set to true */ + svn_auth_set_parameter(baton, SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, + SVN_CONFIG_TRUE); + SVN_ERR(svn_auth_first_credentials(&credentials, &state, + SVN_AUTH_CRED_SIMPLE, + "realm-3", baton, pool)); + SVN_TEST_ASSERT(credentials != NULL); + SVN_ERR(svn_auth_save_credentials(state, pool)); + SVN_TEST_ASSERT(pb.nr_calls == EXPECT_ONE_CALL); + + /* Set to false */ + svn_auth_set_parameter(baton, SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, + SVN_CONFIG_FALSE); + SVN_ERR(svn_auth_first_credentials(&credentials, &state, + SVN_AUTH_CRED_SIMPLE, + "realm-4", baton, pool)); + SVN_TEST_ASSERT(credentials != NULL); + SVN_ERR(svn_auth_save_credentials(state, pool)); + SVN_TEST_ASSERT(pb.nr_calls == EXPECT_ONE_CALL); + + /* Reset baton...*/ + svn_auth_set_parameter(baton, SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, + NULL); + pb.nr_calls = 0; + + SVN_ERR(svn_auth__make_session_auth(&slave, baton, NULL, "dummy", + pool, pool)); + + + /* Standard behavior after make session auth: */ + SVN_ERR(svn_auth_first_credentials(&credentials, &state, + SVN_AUTH_CRED_SIMPLE, + "realm-1a", slave, pool)); + SVN_TEST_ASSERT(credentials != NULL); + SVN_ERR(svn_auth_save_credentials(state, pool)); + SVN_TEST_ASSERT(pb.nr_calls == EXPECT_ONE_CALL); + + /* Set to ask */ + svn_auth_set_parameter(slave, SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, + SVN_CONFIG_ASK); + SVN_ERR(svn_auth_first_credentials(&credentials, &state, + SVN_AUTH_CRED_SIMPLE, + "realm-2a", slave, pool)); + SVN_TEST_ASSERT(credentials != NULL); + SVN_ERR(svn_auth_save_credentials(state, pool)); + SVN_TEST_ASSERT(pb.nr_calls == EXPECT_TWO_CALLS); + + /* Set to true */ + svn_auth_set_parameter(slave, SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, + SVN_CONFIG_TRUE); + SVN_ERR(svn_auth_first_credentials(&credentials, &state, + SVN_AUTH_CRED_SIMPLE, + "realm-3a", slave, pool)); + SVN_TEST_ASSERT(credentials != NULL); + SVN_ERR(svn_auth_save_credentials(state, pool)); + SVN_TEST_ASSERT(pb.nr_calls == EXPECT_TWO_CALLS); + + /* Set to false */ + svn_auth_set_parameter(slave, SVN_AUTH_PARAM_STORE_PLAINTEXT_PASSWORDS, + SVN_CONFIG_FALSE); + SVN_ERR(svn_auth_first_credentials(&credentials, &state, + SVN_AUTH_CRED_SIMPLE, + "realm-4a", slave, pool)); + SVN_TEST_ASSERT(credentials != NULL); + SVN_ERR(svn_auth_save_credentials(state, pool)); + SVN_TEST_ASSERT(pb.nr_calls == EXPECT_TWO_CALLS); + + + return SVN_NO_ERROR; +} /* The test table. */ @@ -324,6 +471,8 @@ static struct svn_test_descriptor_t test "test retrieving platform-specific auth providers"), SVN_TEST_PASS2(test_auth_clear, "test svn_auth_clear()"), + SVN_TEST_PASS2(test_save_cleartext, + "test save cleartext info"), SVN_TEST_NULL }; Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/cache-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/cache-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/cache-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/cache-test.c Sun Jun 14 20:58:10 2015 @@ -34,6 +34,39 @@ #include "../svn_test.h" +/* Create memcached cache if configured */ +static svn_error_t * +create_memcache(svn_memcache_t **memcache, + const svn_test_opts_t *opts, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) +{ + svn_config_t *config = NULL; + if (opts->config_file) + { + SVN_ERR(svn_config_read3(&config, opts->config_file, + TRUE, FALSE, FALSE, scratch_pool)); + } + else if (opts->memcached_server) + { + SVN_ERR(svn_config_create2(&config, FALSE, FALSE, scratch_pool)); + + svn_config_set(config, SVN_CACHE_CONFIG_CATEGORY_MEMCACHED_SERVERS, + "key" /* some value; ignored*/, + opts->memcached_server); + } + + if (config) + { + SVN_ERR(svn_cache__make_memcache_from_config(memcache, config, + result_pool, scratch_pool)); + } + else + *memcache = NULL; + + return SVN_NO_ERROR; +} + /* Implements svn_cache__serialize_func_t */ static svn_error_t * serialize_revnum(void **data, @@ -147,20 +180,12 @@ test_memcache_basic(const svn_test_opts_ apr_pool_t *pool) { svn_cache__t *cache; - svn_config_t *config; svn_memcache_t *memcache = NULL; const char *prefix = apr_psprintf(pool, "test_memcache_basic-%" APR_TIME_T_FMT, apr_time_now()); - if (opts->config_file) - { - SVN_ERR(svn_config_read3(&config, opts->config_file, - TRUE, FALSE, FALSE, pool)); - SVN_ERR(svn_cache__make_memcache_from_config(&memcache, config, - pool, pool)); - } - + SVN_ERR(create_memcache(&memcache, opts, pool, pool)); if (! memcache) return svn_error_create(SVN_ERR_TEST_SKIPPED, NULL, "not configured to use memcached"); @@ -290,7 +315,7 @@ test_membuffer_serializer_error_handling /* Test setting data in cache using partial setter that always raises an error. */ SVN_TEST_ASSERT_ERROR( - svn_cache__set_partial(cache, "twenty", + svn_cache__set_partial(cache, "twenty", raise_error_partial_setter_func, NULL, pool), APR_EGENERAL); @@ -303,7 +328,6 @@ test_memcache_long_key(const svn_test_op apr_pool_t *pool) { svn_cache__t *cache; - svn_config_t *config; svn_memcache_t *memcache = NULL; svn_revnum_t fifty = 50, *answer; svn_boolean_t found = FALSE; @@ -319,13 +343,7 @@ test_memcache_long_key(const svn_test_op "0123456789" "0123456789" "0123456789" "0123456789" "0123456789" /* 300 */ ; - if (opts->config_file) - { - SVN_ERR(svn_config_read3(&config, opts->config_file, - TRUE, FALSE, FALSE, pool)); - SVN_ERR(svn_cache__make_memcache_from_config(&memcache, config, - pool, pool)); - } + SVN_ERR(create_memcache(&memcache, opts, pool, pool)); if (! memcache) return svn_error_create(SVN_ERR_TEST_SKIPPED, NULL, @@ -354,7 +372,175 @@ test_memcache_long_key(const svn_test_op return SVN_NO_ERROR; } - +static svn_error_t * +test_membuffer_cache_clearing(apr_pool_t *pool) +{ + svn_cache__t *cache; + svn_membuffer_t *membuffer; + svn_boolean_t found; + svn_revnum_t *value; + svn_revnum_t valueA = 12345; + svn_revnum_t valueB = 67890; + + /* Create a simple cache for strings, keyed by strings. */ + 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)); + + /* Initially, the cache is empty. */ + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key A", pool)); + SVN_TEST_ASSERT(!found); + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key B", pool)); + SVN_TEST_ASSERT(!found); + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key C", pool)); + SVN_TEST_ASSERT(!found); + + /* Add entries. */ + SVN_ERR(svn_cache__set(cache, "key A", &valueA, pool)); + SVN_ERR(svn_cache__set(cache, "key B", &valueB, pool)); + + /* Added entries should be cached (too small to get evicted already). */ + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key A", pool)); + SVN_TEST_ASSERT(found); + SVN_TEST_ASSERT(*value == valueA); + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key B", pool)); + SVN_TEST_ASSERT(found); + SVN_TEST_ASSERT(*value == valueB); + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key C", pool)); + SVN_TEST_ASSERT(!found); + + /* Clear the cache. */ + SVN_ERR(svn_cache__membuffer_clear(membuffer)); + + /* The cache is empty again. */ + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key A", pool)); + SVN_TEST_ASSERT(!found); + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key B", pool)); + SVN_TEST_ASSERT(!found); + SVN_ERR(svn_cache__get((void **) &value, &found, cache, "key C", pool)); + SVN_TEST_ASSERT(!found); + + /* But still functional: */ + SVN_ERR(svn_cache__set(cache, "key B", &valueB, pool)); + SVN_ERR(svn_cache__has_key(&found, cache, "key A", pool)); + SVN_TEST_ASSERT(!found); + SVN_ERR(svn_cache__has_key(&found, cache, "key B", pool)); + SVN_TEST_ASSERT(found); + SVN_ERR(svn_cache__has_key(&found, cache, "key C", pool)); + SVN_TEST_ASSERT(!found); + + 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 *aligned_key = apr_pstrdup(pool, "fifty"); + 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); + + /* Make sure that we get proper result when providing aligned key*/ + SVN_ERR(svn_cache__get((void **) &answer, &found, cache, aligned_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; +} + +static svn_error_t * +test_membuffer_unaligned_fixed_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 key.*/ + const char *aligned_key = apr_pstrdup(pool, "12345678"); + const char *unaligned_key = apr_pstrdup(pool, "_12345678") + 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, + 8 /* klen*/, + 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 '12345678' (unaligned)"); + if (*answer != 50) + return svn_error_createf(SVN_ERR_TEST_FAILED, NULL, + "expected 50 but found '%ld'", *answer); + + /* Make sure that we get proper result when providing aligned key*/ + SVN_ERR(svn_cache__get((void **) &answer, &found, cache, aligned_key, + pool)); + + if (! found) + return svn_error_create(SVN_ERR_TEST_FAILED, NULL, + "cache failed to find entry for '12345678' (aligned)"); + 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; @@ -372,6 +558,12 @@ static struct svn_test_descriptor_t test "basic membuffer svn_cache test"), SVN_TEST_PASS2(test_membuffer_serializer_error_handling, "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_PASS2(test_membuffer_unaligned_fixed_keys, + "test membuffer cache with unaligned fixed keys"), SVN_TEST_NULL }; Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/checksum-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/checksum-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/checksum-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/checksum-test.c Sun Jun 14 20:58:10 2015 @@ -27,7 +27,6 @@ #include "svn_error.h" #include "svn_io.h" -#include "private/svn_pseudo_md5.h" #include "../svn_test.h" @@ -92,38 +91,6 @@ test_checksum_empty(apr_pool_t *pool) return SVN_NO_ERROR; } -static svn_error_t * -test_pseudo_md5(apr_pool_t *pool) -{ - apr_uint32_t input[16] = { 0 }; - apr_uint32_t digest_15[4] = { 0 }; - apr_uint32_t digest_31[4] = { 0 }; - apr_uint32_t digest_63[4] = { 0 }; - svn_checksum_t *checksum; - - /* input is all 0s but the hash shall be different - (due to different input sizes)*/ - svn__pseudo_md5_15(digest_15, input); - svn__pseudo_md5_31(digest_31, input); - svn__pseudo_md5_63(digest_63, input); - - SVN_TEST_ASSERT(memcmp(digest_15, digest_31, sizeof(digest_15))); - SVN_TEST_ASSERT(memcmp(digest_15, digest_63, sizeof(digest_15))); - SVN_TEST_ASSERT(memcmp(digest_31, digest_63, sizeof(digest_15))); - - /* the checksums shall also be different from "proper" MD5 */ - SVN_ERR(svn_checksum(&checksum, svn_checksum_md5, input, 15, pool)); - SVN_TEST_ASSERT(memcmp(digest_15, checksum->digest, sizeof(digest_15))); - - SVN_ERR(svn_checksum(&checksum, svn_checksum_md5, input, 31, pool)); - SVN_TEST_ASSERT(memcmp(digest_31, checksum->digest, sizeof(digest_15))); - - SVN_ERR(svn_checksum(&checksum, svn_checksum_md5, input, 63, pool)); - SVN_TEST_ASSERT(memcmp(digest_63, checksum->digest, sizeof(digest_15))); - - return SVN_NO_ERROR; -} - /* Verify that "zero" checksums work properly for the given checksum KIND. */ static svn_error_t * @@ -170,7 +137,7 @@ zero_cross_match(apr_pool_t *pool) { svn_checksum_t *i_zero; svn_checksum_t *i_A; - + i_zero = svn_checksum_create(i_kind, pool); SVN_ERR(svn_checksum_clear(i_zero)); SVN_ERR(svn_checksum(&i_A, i_kind, "A", 1, pool)); @@ -287,6 +254,26 @@ zlib_expansion_test(const svn_test_opts_ return SVN_NO_ERROR; } +static svn_error_t * +test_serialization(apr_pool_t *pool) +{ + svn_checksum_kind_t kind; + for (kind = svn_checksum_md5; kind <= svn_checksum_fnv1a_32x4; ++kind) + { + const svn_checksum_t *parsed_checksum; + svn_checksum_t *checksum = svn_checksum_empty_checksum(kind, pool); + const char *serialized = svn_checksum_serialize(checksum, pool, pool); + + SVN_ERR(svn_checksum_deserialize(&parsed_checksum, serialized, pool, + pool)); + + SVN_TEST_ASSERT(parsed_checksum->kind == kind); + SVN_TEST_ASSERT(svn_checksum_match(checksum, parsed_checksum)); + } + + return SVN_NO_ERROR; +} + /* An array of all test functions */ static int max_threads = 1; @@ -298,14 +285,14 @@ static struct svn_test_descriptor_t test "checksum parse"), SVN_TEST_PASS2(test_checksum_empty, "checksum emptiness"), - SVN_TEST_PASS2(test_pseudo_md5, - "pseudo-md5 compatibility"), SVN_TEST_PASS2(zero_match, "zero checksum matching"), SVN_TEST_OPTS_PASS(zlib_expansion_test, "zlib expansion test (zlib regression)"), SVN_TEST_PASS2(zero_cross_match, "zero checksum cross-type matching"), + SVN_TEST_PASS2(test_serialization, + "checksum (de-)serialization"), SVN_TEST_NULL }; Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/config-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/config-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/config-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/config-test.c Sun Jun 14 20:58:10 2015 @@ -363,7 +363,7 @@ test_expand(const svn_test_opts_t *opts, /* Get expanded "c". */ svn_config_get(cfg, &val, "section1", "c", NULL); - /* With pool debugging enabled this ensures that the expanded value + /* 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"); Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/io-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/io-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/io-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/io-test.c Sun Jun 14 20:58:10 2015 @@ -30,8 +30,10 @@ #include "svn_pools.h" #include "svn_string.h" +#include "svn_io.h" #include "private/svn_skel.h" #include "private/svn_dep_compat.h" +#include "private/svn_io_private.h" #include "../svn_test.h" #include "../svn_test_fs.h" @@ -703,7 +705,7 @@ ignore_enoent(apr_pool_t *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)); @@ -737,7 +739,90 @@ ignore_enoent(apr_pool_t *pool) return SVN_NO_ERROR; } - +static svn_error_t * +test_install_stream_to_longpath(apr_pool_t *pool) +{ + const char *tmp_dir; + const char *final_abspath; + const char *deep_dir; + svn_stream_t *stream; + svn_stringbuf_t *actual_content; + int i; + + /* Create an empty directory. */ + SVN_ERR(svn_dirent_get_absolute(&tmp_dir, "test_install_stream_to_longpath", + 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); + + deep_dir = tmp_dir; + + /* Generate very long path (> 260 symbols) */ + for (i = 0; i < 26; i++) + { + deep_dir = svn_dirent_join(deep_dir, "1234567890", pool); + SVN_ERR(svn_io_make_dir_recursively(deep_dir, pool)); + } + + final_abspath = svn_dirent_join(deep_dir, "stream1", pool); + SVN_ERR(svn_stream__create_for_install(&stream, deep_dir, pool, pool)); + SVN_ERR(svn_stream_puts(stream, "stream1 content")); + SVN_ERR(svn_stream_close(stream)); + SVN_ERR(svn_stream__install_stream(stream, + final_abspath, + TRUE, + pool)); + + SVN_ERR(svn_stringbuf_from_file2(&actual_content, + final_abspath, + pool)); + + SVN_TEST_STRING_ASSERT(actual_content->data, "stream1 content"); + + return SVN_NO_ERROR; +} + +static svn_error_t * +test_file_size_get(apr_pool_t *pool) +{ + const char *tmp_dir, *path; + apr_file_t *file; + svn_filesize_t filesize; + + /* Create an empty directory. */ + SVN_ERR(svn_dirent_get_absolute(&tmp_dir, "test_file_size_get", 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, "file", pool); + + /* Create a file.*/ + SVN_ERR(svn_io_file_open(&file, path, + APR_WRITE | APR_CREATE | APR_BUFFERED, + APR_OS_DEFAULT, pool)); + SVN_ERR(svn_io_file_size_get(&filesize, file, pool)); + SVN_TEST_ASSERT(filesize == 0); + + /* Write 8 bytes and check new size. */ + SVN_ERR(svn_io_file_write_full(file, "12345678", 8, NULL, pool)); + + SVN_ERR(svn_io_file_size_get(&filesize, file, pool)); + SVN_TEST_ASSERT(filesize == 8); + + /* Truncate to 2 bytes. */ + SVN_ERR(svn_io_file_trunc(file, 2, pool)); + + SVN_ERR(svn_io_file_size_get(&filesize, file, pool)); + SVN_TEST_ASSERT(filesize == 2); + + /* Close the file. */ + SVN_ERR(svn_io_file_close(file, pool)); + return SVN_NO_ERROR; +} + /* The test table. */ static int max_threads = 3; @@ -759,6 +844,10 @@ static struct svn_test_descriptor_t test "test aligned seek"), SVN_TEST_PASS2(ignore_enoent, "test ignore-enoent"), + SVN_TEST_PASS2(test_install_stream_to_longpath, + "test svn_stream__install_stream to long path"), + SVN_TEST_PASS2(test_file_size_get, + "test svn_io_file_size_get"), SVN_TEST_NULL }; Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/packed-data-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/packed-data-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/packed-data-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/packed-data-test.c Sun Jun 14 20:58:10 2015 @@ -99,7 +99,7 @@ verify_uint_stream(const apr_uint64_t *v SVN_TEST_ASSERT(stream); SVN_TEST_ASSERT(!svn_packed__next_int_stream(stream)); SVN_TEST_ASSERT(!svn_packed__first_byte_stream(root)); - + /* the stream shall contain exactly the items we put into it */ SVN_TEST_ASSERT(svn_packed__int_count(stream) == count); for (i = 0; i < count; ++i) @@ -356,7 +356,7 @@ pack(const base_record_t *data, svn_packed__create_int_substream(base_stream, TRUE, TRUE); /* large_signed1 */ svn_packed__create_int_substream(base_stream, FALSE, TRUE); /* large_signed2 */ svn_packed__create_int_substream(base_stream, TRUE, FALSE); /* prime */ - + for (i = 0; i < count; ++i) { svn_packed__add_int(base_stream, data[i].counter); @@ -434,7 +434,7 @@ unpack(apr_size_t *count, base_record_t *data; *count = svn_packed__int_count(sub_count_stream) / 2; data = apr_pcalloc(pool, *count * sizeof(*data)); - + for (i = 0; i < *count; ++i) { data[i].counter = (int) svn_packed__get_int(base_stream); Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/priority-queue-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/priority-queue-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/priority-queue-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/priority-queue-test.c Sun Jun 14 20:58:10 2015 @@ -70,7 +70,7 @@ verify_empty_queue(svn_priority_queue__t /* these should be no-ops */ svn_priority_queue__update(queue); svn_priority_queue__pop(queue); - + return SVN_NO_ERROR; } Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/spillbuf-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/spillbuf-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/spillbuf-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/spillbuf-test.c Sun Jun 14 20:58:10 2015 @@ -514,7 +514,7 @@ static svn_error_t * test_spillbuf__file_attrs(apr_pool_t *pool, svn_boolean_t spill_all, svn_spillbuf_t *buf) { - apr_finfo_t finfo; + svn_filesize_t filesize; SVN_ERR(svn_spillbuf__write(buf, "abcdef", 6, pool)); SVN_ERR(svn_spillbuf__write(buf, "ghijkl", 6, pool)); @@ -528,13 +528,12 @@ test_spillbuf__file_attrs(apr_pool_t *po SVN_TEST_ASSERT(svn_spillbuf__get_file(buf) != NULL); /* The size of the file must match expectations */ - SVN_ERR(svn_io_file_info_get(&finfo, APR_FINFO_SIZE, - svn_spillbuf__get_file(buf), pool)); + SVN_ERR(svn_io_file_size_get(&filesize, svn_spillbuf__get_file(buf), pool)); if (spill_all) - SVN_TEST_ASSERT(finfo.size == svn_spillbuf__get_size(buf)); + SVN_TEST_ASSERT(filesize == svn_spillbuf__get_size(buf)); else - SVN_TEST_ASSERT(finfo.size == (svn_spillbuf__get_size(buf) - - svn_spillbuf__get_memory_size(buf))); + SVN_TEST_ASSERT(filesize == (svn_spillbuf__get_size(buf) + - svn_spillbuf__get_memory_size(buf))); return SVN_NO_ERROR; } Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/sqlite-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/sqlite-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/sqlite-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/sqlite-test.c Sun Jun 14 20:58:10 2015 @@ -49,7 +49,7 @@ static svn_error_t * error_second(svn_sqlite__context_t *sctx, int argc, svn_sqlite__value_t *values[], - apr_pool_t *scratch_pool) + void *baton) { static int i = 0; @@ -57,7 +57,7 @@ error_second(svn_sqlite__context_t *sctx svn_sqlite__result_error(sctx, "fake error", 0); else svn_sqlite__result_int64(sctx, 1); - + return SVN_NO_ERROR; } @@ -102,7 +102,7 @@ test_sqlite_reset(apr_pool_t *pool) /* The svn_sqlite__step wrapper calls svn_sqlite__reset when step fails so the reset call here is a no-op. The first step can be - repeated. */ + repeated. */ SVN_ERR(svn_sqlite__reset(stmt)); SVN_ERR(svn_sqlite__step(&have_row, stmt)); SVN_TEST_ASSERT(have_row); Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/string-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/string-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/string-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/string-test.c Sun Jun 14 20:58:10 2015 @@ -686,10 +686,11 @@ test_string_similarity(apr_pool_t *pool) unsigned int score; } tests[] = { -#define SCORE(lcs, len) ((2000 * (lcs) + (len)/2) / (len)) +#define SCORE(lcs, len) \ + ((2 * SVN_STRING__SIM_RANGE_MAX * (lcs) + (len)/2) / (len)) /* Equality */ - {"", "", 0, 1000}, + {"", "", 0, SVN_STRING__SIM_RANGE_MAX}, {"quoth", "quoth", 5, SCORE(5, 5+5)}, /* Deletion at start */ @@ -743,17 +744,20 @@ test_string_similarity(apr_pool_t *pool) for (t = tests; t->stra; ++t) { apr_size_t lcs; - const unsigned int score = + const apr_size_t score = svn_cstring__similarity(t->stra, t->strb, &buffer, &lcs); /* fprintf(stderr, - "lcs %s ~ %s score %.3f (%"APR_SIZE_T_FMT - ") expected %.3f (%"APR_SIZE_T_FMT"))\n", - t->stra, t->strb, score/1000.0, lcs, t->score/1000.0, t->lcs); + "lcs %s ~ %s score %.6f (%"APR_SIZE_T_FMT + ") expected %.6f (%"APR_SIZE_T_FMT"))\n", + t->stra, t->strb, score/1.0/SVN_STRING__SIM_RANGE_MAX, + lcs, t->score/1.0/SVN_STRING__SIM_RANGE_MAX, t->lcs); */ if (score != t->score) - return fail(pool, "%s ~ %s score %.3f <> expected %.3f", - t->stra, t->strb, score/1000.0, t->score/1000.0); + return fail(pool, "%s ~ %s score %.6f <> expected %.6f", + t->stra, t->strb, + score/1.0/SVN_STRING__SIM_RANGE_MAX, + t->score/1.0/SVN_STRING__SIM_RANGE_MAX); if (lcs != t->lcs) return fail(pool, @@ -766,7 +770,8 @@ test_string_similarity(apr_pool_t *pool) { const svn_string_t foo = {"svn:foo", 4}; const svn_string_t bar = {"svn:bar", 4}; - if (1000 != svn_string__similarity(&foo, &bar, &buffer, NULL)) + if (SVN_STRING__SIM_RANGE_MAX + != svn_string__similarity(&foo, &bar, &buffer, NULL)) return fail(pool, "'%s'[:4] ~ '%s'[:4] found different", foo.data, bar.data); } @@ -849,7 +854,7 @@ test_string_matching(apr_pool_t *pool) SVN_TEST_ASSERT(match_len == test->match_len); SVN_TEST_ASSERT(rmatch_len == test->rmatch_len); } - + return SVN_NO_ERROR; } Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/subst_translate-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/subst_translate-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/subst_translate-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/subst_translate-test.c Sun Jun 14 20:58:10 2015 @@ -115,7 +115,7 @@ test_svn_subst_translate_string2_null_en svn_string_t *new_value = NULL; svn_boolean_t translated_to_utf8 = FALSE; svn_boolean_t translated_line_endings = TRUE; - /* 'Æ', which is 0xc6 in both ISO-8859-1 and Windows-1252 */ + /* The 'AE' ligature, which is 0xc6 in both ISO-8859-1 and Windows-1252 */ svn_string_t *source_string = svn_string_create("\xc6", pool); SVN_ERR(svn_subst_translate_string2(&new_value, &translated_to_utf8, @@ -397,7 +397,7 @@ test_svn_subst_long_keywords(apr_pool_t "01234567890123456789012345678901234567890123456789" "012345678901234567890123456789012345678901234567"; - /* The longest keyword that can be expanded: the value is empty. */ + /* The longest keyword that can be expanded: the value is empty. */ const char keyword_z[] = "Q" "01234567890123456789012345678901234567890123456789" Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/x509-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/x509-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/x509-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/x509-test.c Sun Jun 14 20:58:10 2015 @@ -151,7 +151,7 @@ static struct x509_test cert_tests[] = { "b3b9789d8a53868f418619565f6b56af0033bdd3" }, /* The issuer and subject (except for the country code) is * UnversalString encoded. Created with a hacked version of openssl - * using utf8=yes and string_mask=MASK:256. In order for that to + * using utf8=yes and string_mask=MASK:256. In order for that to * output UniversalString encoded data you need to change the * DIRSTRING_TYPE in crypto/asn1/asn1.h to be defined as * B_ASN1_DIRECTORYSTRING so that UnviersalString is available to be Propchange: subversion/branches/fsx-1.10/subversion/tests/libsvn_subr/x509-test.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: subversion/branches/fsx-1.10/subversion/tests/libsvn_wc/conflict-data-test.c URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/tests/libsvn_wc/conflict-data-test.c?rev=1685464&r1=1685463&r2=1685464&view=diff ============================================================================== --- subversion/branches/fsx-1.10/subversion/tests/libsvn_wc/conflict-data-test.c (original) +++ subversion/branches/fsx-1.10/subversion/tests/libsvn_wc/conflict-data-test.c Sun Jun 14 20:58:10 2015 @@ -294,6 +294,7 @@ test_read_write_tree_conflicts(const svn SVN_ERR(sbox_wc_mkdir(&sbox, "A")); SVN_ERR(sbox_wc_mkdir(&sbox, "A/bar")); SVN_ERR(sbox_file_write(&sbox, "A/foo", "")); + SVN_ERR(sbox_wc_add(&sbox, "A/foo")); conflict1 = tree_conflict_create(child1_abspath, svn_node_file, svn_wc_operation_merge, @@ -808,6 +809,147 @@ test_prop_conflicts(const svn_test_opts_ return SVN_NO_ERROR; } +static svn_error_t * +test_prop_conflict_resolving(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_test__sandbox_t b; + svn_skel_t *conflict; + const char *A_abspath; + const char *marker_abspath; + apr_hash_t *conflicted_props; + apr_hash_t *props; + const char *value; + + SVN_ERR(svn_test__sandbox_create(&b, "test_prop_resolving", opts, pool)); + SVN_ERR(sbox_wc_mkdir(&b, "A")); + + SVN_ERR(sbox_wc_propset(&b, "prop-1", "r1", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-2", "r1", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-3", "r1", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-4", "r1", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-5", "r1", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-6", "r1", "A")); + + SVN_ERR(sbox_wc_commit(&b, "")); + SVN_ERR(sbox_wc_propset(&b, "prop-1", "r2", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-2", "r2", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-3", "r2", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-4", NULL, "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-5", NULL, "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-7", "r2", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-8", "r2", "A")); + SVN_ERR(sbox_wc_commit(&b, "")); + + SVN_ERR(sbox_wc_propset(&b, "prop-1", "mod", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-2", "mod", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-3", "mod", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-4", "mod", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-5", "mod", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-6", "mod", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-7", "mod", "A")); + SVN_ERR(sbox_wc_propset(&b, "prop-8", "mod", "A")); + + SVN_ERR(sbox_wc_update(&b, "", 1)); + + A_abspath = sbox_wc_path(&b, "A"); + SVN_ERR(svn_wc__db_read_conflict(&conflict, NULL, NULL, + b.wc_ctx->db, A_abspath, + pool, pool)); + + /* We have tree conflicts... */ + SVN_TEST_ASSERT(conflict != NULL); + + SVN_ERR(svn_wc__conflict_read_prop_conflict(&marker_abspath, + NULL, NULL, NULL, + &conflicted_props, + b.wc_ctx->db, A_abspath, + conflict, + pool, pool)); + + SVN_TEST_ASSERT(conflicted_props != NULL); + /* All properties but r6 are conflicted */ + SVN_TEST_ASSERT(apr_hash_count(conflicted_props) == 7); + SVN_TEST_ASSERT(! svn_hash_gets(conflicted_props, "prop-6")); + + /* Let's resolve a few conflicts */ + SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-1", + svn_wc_conflict_choose_mine_conflict)); + SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-2", + svn_wc_conflict_choose_theirs_conflict)); + SVN_ERR(sbox_wc_resolve_prop(&b, "A", "prop-3", + svn_wc_conflict_choose_merged)); + + SVN_ERR(svn_wc__db_read_conflict(&conflict, NULL, NULL, + b.wc_ctx->db, A_abspath, + pool, pool)); + + /* We have tree conflicts... */ + SVN_TEST_ASSERT(conflict != NULL); + + SVN_ERR(svn_wc__conflict_read_prop_conflict(&marker_abspath, + NULL, NULL, NULL, + &conflicted_props, + b.wc_ctx->db, A_abspath, + conflict, + pool, pool)); + + SVN_TEST_ASSERT(conflicted_props != NULL); + SVN_TEST_ASSERT(apr_hash_count(conflicted_props) == 4); + + SVN_ERR(svn_wc__db_read_props(&props, b.wc_ctx->db, A_abspath, + pool, pool)); + + value = svn_prop_get_value(props, "prop-1"); + SVN_TEST_STRING_ASSERT(value, "mod"); + value = svn_prop_get_value(props, "prop-2"); + SVN_TEST_STRING_ASSERT(value, "r1"); + value = svn_prop_get_value(props, "prop-3"); + SVN_TEST_STRING_ASSERT(value, "mod"); + + return SVN_NO_ERROR; +} + +static svn_error_t * +test_binary_file_conflict(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_test__sandbox_t sbox; + const apr_array_header_t *conflicts; + svn_wc_conflict_description2_t *desc; + + SVN_ERR(svn_test__sandbox_create(&sbox, "test_binary_file_conflict", opts, pool)); + + /* Create and add a binary file. */ + SVN_ERR(sbox_file_write(&sbox, "binary-file", "\xff\xff")); + SVN_ERR(sbox_wc_add(&sbox, "binary-file")); + SVN_ERR(sbox_wc_propset(&sbox, SVN_PROP_MIME_TYPE, + "application/octet-stream", "binary-file")); + SVN_ERR(sbox_wc_commit(&sbox, "binary-file")); /* r1 */ + + /* Make a change to the binary file. */ + SVN_ERR(sbox_file_write(&sbox, "binary-file", "\xfc\xfc\xfc\xfc\xfc\xfc")); + SVN_ERR(sbox_wc_commit(&sbox, "binary-file")); /* r2 */ + + /* Update back to r1, make a conflicting change to binary file. */ + SVN_ERR(sbox_wc_update(&sbox, "binary-file", 1)); + SVN_ERR(sbox_file_write(&sbox, "binary-file", "\xfd\xfd\xfd\xfd")); + + /* Update to HEAD and ensure the conflict is marked as binary. */ + SVN_ERR(sbox_wc_update(&sbox, "binary-file", 2)); + SVN_ERR(svn_wc__read_conflicts(&conflicts, NULL, sbox.wc_ctx->db, + sbox_wc_path(&sbox, "binary-file"), + FALSE /* create_tempfiles */, + FALSE /* only_tree_conflict */, + pool, pool)); + SVN_TEST_ASSERT(conflicts->nelts == 1); + desc = APR_ARRAY_IDX(conflicts, 0, svn_wc_conflict_description2_t *); + SVN_TEST_ASSERT(desc->is_binary); + + return SVN_NO_ERROR; +} + + /* The test table. */ static int max_threads = 1; @@ -829,6 +971,10 @@ static struct svn_test_descriptor_t test "read and write a tree conflict"), SVN_TEST_OPTS_PASS(test_prop_conflicts, "test prop conflicts"), + SVN_TEST_OPTS_PASS(test_prop_conflict_resolving, + "test property conflict resolving"), + SVN_TEST_OPTS_PASS(test_binary_file_conflict, + "test binary file conflict"), SVN_TEST_NULL };
