Modified: subversion/branches/reuse-ra-session/subversion/tests/libsvn_client/mtcc-test.c URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/libsvn_client/mtcc-test.c?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/libsvn_client/mtcc-test.c (original) +++ subversion/branches/reuse-ra-session/subversion/tests/libsvn_client/mtcc-test.c Wed Feb 4 11:23:29 2015 @@ -87,6 +87,8 @@ make_greek_tree(const char *repos_url, subpool = svn_pool_create(scratch_pool); SVN_ERR(svn_client_create_context2(&ctx, NULL, subpool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, subpool)); + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 0, ctx, subpool, subpool)); for (i = 0; svn_test__greek_tree_nodes[i].path; i++) @@ -121,16 +123,14 @@ test_mkdir(const svn_test_opts_t *opts, { svn_client__mtcc_t *mtcc; svn_client_ctx_t *ctx; - const char *repos_abspath; const char *repos_url; - svn_repos_t* repos; - repos_abspath = svn_test_data_path("mtcc-mkdir", pool); - SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-mkdir", + opts, pool, pool)); SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 0, ctx, pool, pool)); SVN_ERR(svn_client__mtcc_add_mkdir("branches", mtcc, pool)); @@ -151,18 +151,16 @@ test_mkgreek(const svn_test_opts_t *opts { svn_client__mtcc_t *mtcc; svn_client_ctx_t *ctx; - const char *repos_abspath; const char *repos_url; - svn_repos_t* repos; - repos_abspath = svn_test_data_path("mtcc-mkgreek", pool); - SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-mkgreek", + opts, pool, pool)); SVN_ERR(make_greek_tree(repos_url, pool)); SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 1, ctx, pool, pool)); SVN_ERR(svn_client__mtcc_add_copy("A", 1, "greek_A", mtcc, pool)); @@ -178,18 +176,16 @@ test_swap(const svn_test_opts_t *opts, { svn_client__mtcc_t *mtcc; svn_client_ctx_t *ctx; - const char *repos_abspath; const char *repos_url; - svn_repos_t* repos; - repos_abspath = svn_test_data_path("mtcc-swap", pool); - SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-swap", + opts, pool, pool)); SVN_ERR(make_greek_tree(repos_url, pool)); SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 1, ctx, pool, pool)); SVN_ERR(svn_client__mtcc_add_move("A/B", "B", mtcc, pool)); @@ -207,18 +203,16 @@ test_propset(const svn_test_opts_t *opts { svn_client__mtcc_t *mtcc; svn_client_ctx_t *ctx; - const char *repos_abspath; const char *repos_url; - svn_repos_t* repos; - repos_abspath = svn_test_data_path("mtcc-propset", pool); - SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-propset", + opts, pool, pool)); SVN_ERR(make_greek_tree(repos_url, pool)); SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 1, ctx, pool, pool)); SVN_ERR(svn_client__mtcc_add_propset("iota", "key", @@ -281,18 +275,15 @@ test_update_files(const svn_test_opts_t { svn_client__mtcc_t *mtcc; svn_client_ctx_t *ctx; - const char *repos_abspath; const char *repos_url; - svn_repos_t* repos; - - repos_abspath = svn_test_data_path("mtcc-update-files", pool); - SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-update-files", + opts, pool, pool)); SVN_ERR(make_greek_tree(repos_url, pool)); SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 1, ctx, pool, pool)); /* Update iota with knowledge of the old data */ @@ -331,18 +322,16 @@ test_overwrite(const svn_test_opts_t *op { svn_client__mtcc_t *mtcc; svn_client_ctx_t *ctx; - const char *repos_abspath; const char *repos_url; - svn_repos_t* repos; - repos_abspath = svn_test_data_path("mtcc-overwrite", pool); - SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-overwrite", + opts, pool, pool)); SVN_ERR(make_greek_tree(repos_url, pool)); SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 1, ctx, pool, pool)); SVN_ERR(svn_client__mtcc_add_copy("A", 1, "AA", mtcc, pool)); @@ -365,18 +354,15 @@ test_anchoring(const svn_test_opts_t *op { svn_client__mtcc_t *mtcc; svn_client_ctx_t *ctx; - const char *repos_abspath; const char *repos_url; - svn_repos_t* repos; - repos_abspath = svn_test_data_path("mtcc-anchoring", pool); - SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-anchoring", + opts, pool, pool)); SVN_ERR(make_greek_tree(repos_url, pool)); SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); /* Update a file as root operation */ SVN_ERR(svn_client__mtcc_create(&mtcc, @@ -454,20 +440,16 @@ test_replace_tree(const svn_test_opts_t { svn_client__mtcc_t *mtcc; svn_client_ctx_t *ctx; - const char *repos_abspath; const char *repos_url; - svn_repos_t* repos; - repos_abspath = svn_test_data_path("mtcc-replace_tree", pool); - SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, pool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(&repos_url, repos_abspath, pool)); - SVN_ERR(svn_test__create_repos(&repos, repos_abspath, opts, pool)); + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-replace_tree", + opts, pool, pool)); SVN_ERR(make_greek_tree(repos_url, pool)); SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); - /* Update a file as root operation */ SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 1, ctx, pool, pool)); SVN_ERR(svn_client__mtcc_add_delete("A", mtcc, pool)); @@ -484,6 +466,158 @@ test_replace_tree(const svn_test_opts_t return SVN_NO_ERROR; } +/* Baton for handle_rev */ +struct handle_rev_baton +{ + svn_revnum_t last; + svn_boolean_t up; + svn_boolean_t first; +}; + +/* Helper for test_file_revs_both_ways */ +static svn_error_t * +handle_rev(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) +{ + struct handle_rev_baton *hrb = baton; + svn_revnum_t expected_rev = hrb->up ? (hrb->last + 1) : (hrb->last - 1); + + SVN_TEST_ASSERT(rev == expected_rev); + SVN_TEST_ASSERT(apr_hash_count(rev_props) >= 3); + SVN_TEST_STRING_ASSERT(path, (rev < 5) ? "/iota" : "/mu"); + + if (!hrb->first && rev == (hrb->up ? 5 : 4)) + SVN_TEST_ASSERT(delta_handler == NULL); + else + SVN_TEST_ASSERT(delta_handler != NULL); + + if (delta_handler) + { + *delta_handler = svn_delta_noop_window_handler; + *delta_baton = NULL; + } + + hrb->last = rev; + hrb->first = FALSE; + + return SVN_NO_ERROR; +} + +static svn_error_t * +test_file_revs_both_ways(const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + svn_client__mtcc_t *mtcc; + svn_client_ctx_t *ctx; + apr_pool_t *subpool = svn_pool_create(pool); + const char *repos_url; + svn_ra_session_t *ra; + struct handle_rev_baton hrb; + + SVN_ERR(svn_test__create_repos2(NULL, &repos_url, NULL, "mtcc-file-revs", + opts, pool, subpool)); + + SVN_ERR(svn_client_create_context2(&ctx, NULL, pool)); + SVN_ERR(svn_test__init_auth_baton(&ctx->auth_baton, pool)); + + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 0, ctx, subpool, subpool)); + SVN_ERR(svn_client__mtcc_add_add_file("iota", + cstr_stream("revision-1", subpool), + NULL /* src_checksum */, + mtcc, subpool)); + SVN_ERR(verify_mtcc_commit(mtcc, 1, subpool)); + svn_pool_clear(subpool); + + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 1, ctx, subpool, subpool)); + SVN_ERR(svn_client__mtcc_add_update_file("iota", + cstr_stream("revision-2", subpool), + NULL /* src_checksum */, NULL, NULL, + mtcc, subpool)); + SVN_ERR(verify_mtcc_commit(mtcc, 2, subpool)); + svn_pool_clear(subpool); + + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 2, ctx, subpool, subpool)); + SVN_ERR(svn_client__mtcc_add_update_file("iota", + cstr_stream("revision-3", subpool), + NULL /* src_checksum */, NULL, NULL, + mtcc, subpool)); + SVN_ERR(verify_mtcc_commit(mtcc, 3, subpool)); + svn_pool_clear(subpool); + + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 3, ctx, subpool, subpool)); + SVN_ERR(svn_client__mtcc_add_update_file("iota", + cstr_stream("revision-4", subpool), + NULL /* src_checksum */, NULL, NULL, + mtcc, subpool)); + SVN_ERR(verify_mtcc_commit(mtcc, 4, subpool)); + svn_pool_clear(subpool); + + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 4, ctx, subpool, subpool)); + SVN_ERR(svn_client__mtcc_add_move("iota", "mu", mtcc, subpool)); + SVN_ERR(verify_mtcc_commit(mtcc, 5, subpool)); + svn_pool_clear(subpool); + + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 5, ctx, subpool, subpool)); + SVN_ERR(svn_client__mtcc_add_update_file("mu", + cstr_stream("revision-6", subpool), + NULL /* src_checksum */, NULL, NULL, + mtcc, subpool)); + SVN_ERR(verify_mtcc_commit(mtcc, 6, subpool)); + svn_pool_clear(subpool); + + SVN_ERR(svn_client__mtcc_create(&mtcc, repos_url, 6, ctx, subpool, subpool)); + SVN_ERR(svn_client__mtcc_add_delete("mu", mtcc, subpool)); + SVN_ERR(verify_mtcc_commit(mtcc, 7, subpool)); + svn_pool_clear(subpool); + + SVN_ERR(svn_client_open_ra_session2(&ra, repos_url, NULL, ctx, pool, subpool)); + + svn_pool_clear(subpool); + hrb.up = FALSE; + hrb.last = 5; + hrb.first = TRUE; + SVN_ERR(svn_ra_get_file_revs2(ra, "iota", 4, 1, FALSE, + handle_rev, &hrb, + subpool)); + SVN_TEST_ASSERT(hrb.last == 1); + + svn_pool_clear(subpool); + hrb.up = TRUE; + hrb.last = 0; + hrb.first = TRUE; + SVN_ERR(svn_ra_get_file_revs2(ra, "iota", 1, 4, FALSE, + handle_rev, &hrb, + subpool)); + SVN_TEST_ASSERT(hrb.last == 4); + + svn_pool_clear(subpool); + hrb.up = FALSE; + hrb.last = 7; + hrb.first = TRUE; + SVN_ERR(svn_ra_get_file_revs2(ra, "mu", 6, 1, FALSE, + handle_rev, &hrb, + subpool)); + SVN_TEST_ASSERT(hrb.last == 1); + + svn_pool_clear(subpool); + hrb.up = TRUE; + hrb.last = 0; + hrb.first = TRUE; + SVN_ERR(svn_ra_get_file_revs2(ra, "mu", 1, 6, FALSE, + handle_rev, &hrb, + subpool)); + SVN_TEST_ASSERT(hrb.last == 6); + + return SVN_NO_ERROR; +} + /* ========================================================================== */ @@ -508,6 +642,8 @@ static struct svn_test_descriptor_t test "test mtcc anchoring for root operations"), SVN_TEST_OPTS_PASS(test_replace_tree, "test mtcc replace tree"), + SVN_TEST_OPTS_PASS(test_file_revs_both_ways, + "test ra_get_file_revs2 both ways"), SVN_TEST_NULL };
Modified: subversion/branches/reuse-ra-session/subversion/tests/libsvn_ra/ra-test.c URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/libsvn_ra/ra-test.c?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/libsvn_ra/ra-test.c (original) +++ subversion/branches/reuse-ra-session/subversion/tests/libsvn_ra/ra-test.c Wed Feb 4 11:23:29 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 }; Propchange: subversion/branches/reuse-ra-session/subversion/tests/libsvn_subr/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Feb 4 11:23:29 2015 @@ -52,3 +52,4 @@ read_length_tmp bit-array-test io-test-* sqlite-test-* +x509-test Modified: subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/op-depth-test.c URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/op-depth-test.c?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/op-depth-test.c (original) +++ subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/op-depth-test.c Wed Feb 4 11:23:29 2015 @@ -718,7 +718,7 @@ repo_wc_copies(svn_test__sandbox_t *b) } /* Perform each copy. */ - SVN_ERR(svn_client_create_context(&ctx, b->pool)); + SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool)); for (subtest = subtests; subtest->from_path; subtest++) { svn_opt_revision_t rev = { svn_opt_revision_number, { 1 } }; @@ -9690,7 +9690,6 @@ static svn_error_t * repo_wc_copy(const svn_test_opts_t *opts, apr_pool_t *pool) { svn_test__sandbox_t b; - const char *repos_dir; const char *new_repos_dir; const char *new_repos_url; @@ -9718,15 +9717,13 @@ repo_wc_copy(const svn_test_opts_t *opts SVN_ERR(check_db_rows(&b, "AA", nodes)); } - SVN_ERR(svn_uri_get_dirent_from_file_url(&repos_dir, b.repos_url, - pool)); - new_repos_dir = apr_pstrcat(pool, repos_dir, "-2", SVN_VA_NULL); + new_repos_dir = apr_pstrcat(pool, b.repos_dir, "-2", SVN_VA_NULL); new_repos_url = apr_pstrcat(pool, b.repos_url, "-2", SVN_VA_NULL); svn_test_add_dir_cleanup(new_repos_dir); SVN_ERR(svn_io_remove_dir2(new_repos_dir, TRUE, NULL, NULL, pool)); - SVN_ERR(svn_io_copy_dir_recursively(repos_dir, + SVN_ERR(svn_io_copy_dir_recursively(b.repos_dir, svn_dirent_dirname(new_repos_dir, pool), svn_dirent_basename(new_repos_dir, pool), FALSE, NULL, NULL, pool)); Modified: subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/utils.c URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/utils.c?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/utils.c (original) +++ subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/utils.c Wed Feb 4 11:23:29 2015 @@ -22,6 +22,7 @@ #include "svn_error.h" #include "svn_client.h" +#include "svn_cmdline.h" #include "svn_pools.h" #include "utils.h" @@ -33,9 +34,25 @@ #define SVN_WC__I_AM_WC_DB #include "../../libsvn_wc/wc_db_private.h" +svn_error_t * +svn_test__create_client_ctx(svn_client_ctx_t **ctx, + svn_test__sandbox_t *sbox, + apr_pool_t *result_pool) +{ + SVN_ERR(svn_client_create_context2(ctx, NULL, result_pool)); + + SVN_ERR(svn_test__init_auth_baton(&(*ctx)->auth_baton, + result_pool)); + + if (sbox) + (*ctx)->wc_ctx = sbox->wc_ctx; + + return SVN_NO_ERROR; +} /* Create an empty repository and WC for the test TEST_NAME. Set *REPOS_URL - * to the URL of the new repository and *WC_ABSPATH to the root path of the + * to the URL of the new repository, *REPOS_DIR to its local path and + * *WC_ABSPATH to the root path of the * new WC. * * Create the repository and WC in subdirectories called @@ -45,6 +62,7 @@ * Register the repo and WC to be cleaned up when the test suite exits. */ static svn_error_t * create_repos_and_wc(const char **repos_url, + const char **repos_dir, const char **wc_abspath, const char *test_name, const svn_test_opts_t *opts, @@ -65,8 +83,6 @@ create_repos_and_wc(const char **repos_u /* Create a repos. Register it for clean-up. Set *REPOS_URL to its path. */ { - svn_repos_t *repos; - /* Use a subpool to create the repository and then destroy the subpool so the repository's underlying filesystem is closed. If opts->fs_type is BDB this prevents any attempt to open a second environment handle @@ -74,8 +90,8 @@ create_repos_and_wc(const char **repos_u only a single environment handle to be open per process. */ apr_pool_t *subpool = svn_pool_create(pool); - SVN_ERR(svn_test__create_repos(&repos, repos_path, opts, subpool)); - SVN_ERR(svn_uri_get_file_url_from_dirent(repos_url, repos_path, pool)); + SVN_ERR(svn_test__create_repos2(NULL, repos_url, repos_dir, repos_path, + opts, pool, subpool)); svn_pool_destroy(subpool); } @@ -85,7 +101,7 @@ create_repos_and_wc(const char **repos_u svn_client_ctx_t *ctx; svn_opt_revision_t head_rev = { svn_opt_revision_head, {0} }; - SVN_ERR(svn_client_create_context2(&ctx, NULL, subpool)); + SVN_ERR(svn_test__create_client_ctx(&ctx, NULL, subpool)); SVN_ERR(svn_dirent_get_absolute(wc_abspath, wc_path, pool)); SVN_ERR(svn_client_checkout3(NULL, *repos_url, *wc_abspath, &head_rev, &head_rev, svn_depth_infinity, @@ -101,7 +117,6 @@ create_repos_and_wc(const char **repos_u return SVN_NO_ERROR; } - WC_QUERIES_SQL_DECLARE_STATEMENTS(statements); svn_error_t * @@ -149,7 +164,8 @@ svn_test__sandbox_create(svn_test__sandb apr_pool_t *pool) { sandbox->pool = pool; - SVN_ERR(create_repos_and_wc(&sandbox->repos_url, &sandbox->wc_abspath, + SVN_ERR(create_repos_and_wc(&sandbox->repos_url, &sandbox->repos_dir, + &sandbox->wc_abspath, test_name, opts, pool)); SVN_ERR(svn_wc_context_create(&sandbox->wc_ctx, NULL, pool, pool)); return SVN_NO_ERROR; @@ -240,8 +256,7 @@ sbox_wc_copy_url(svn_test__sandbox_t *b, scratch_pool, 1, sizeof(svn_client_copy_source_t *)); - SVN_ERR(svn_client_create_context2(&ctx, NULL, scratch_pool)); - ctx->wc_ctx = b->wc_ctx; + SVN_ERR(svn_test__create_client_ctx(&ctx, b, scratch_pool)); if (SVN_IS_VALID_REVNUM(revision)) { @@ -282,7 +297,11 @@ sbox_wc_revert(svn_test__sandbox_t *b, c SVN_ERR(svn_wc__acquire_write_lock(&lock_root_abspath, b->wc_ctx, dir_abspath, FALSE /* lock_anchor */, b->pool, b->pool)); - SVN_ERR(svn_wc_revert5(b->wc_ctx, abspath, depth, FALSE, NULL, FALSE, + SVN_ERR(svn_wc_revert5(b->wc_ctx, abspath, depth, + FALSE /* use_commit_times */, + NULL /* changelist_filter */, + FALSE /* clear_changelists */, + FALSE /* metadata_only */, NULL, NULL, /* cancel baton + func */ NULL, NULL, /* notify baton + func */ b->pool)); @@ -334,8 +353,7 @@ sbox_wc_commit_ex(svn_test__sandbox_t *b apr_pool_t *scratch_pool = svn_pool_create(b->pool); svn_error_t *err; - SVN_ERR(svn_client_create_context2(&ctx, NULL, scratch_pool)); - ctx->wc_ctx = b->wc_ctx; + SVN_ERR(svn_test__create_client_ctx(&ctx, b, scratch_pool)); /* A successfull commit doesn't close the ra session, but leaves that to the caller. This leaves the BDB handle open, which might cause @@ -387,8 +405,8 @@ sbox_wc_update_depth(svn_test__sandbox_t } APR_ARRAY_PUSH(paths, const char *) = sbox_wc_path(b, path); - SVN_ERR(svn_client_create_context2(&ctx, NULL, b->pool)); - ctx->wc_ctx = b->wc_ctx; + SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool)); + return svn_client_update4(&result_revs, paths, &revision, depth, sticky, FALSE, FALSE, FALSE, FALSE, ctx, b->pool); @@ -412,8 +430,8 @@ sbox_wc_switch(svn_test__sandbox_t *b, svn_opt_revision_t head_rev = { svn_opt_revision_head, {0} }; url = apr_pstrcat(b->pool, b->repos_url, url, SVN_VA_NULL); - SVN_ERR(svn_client_create_context2(&ctx, NULL, b->pool)); - ctx->wc_ctx = b->wc_ctx; + SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool)); + return svn_client_switch3(&result_rev, sbox_wc_path(b, path), url, &head_rev, &head_rev, depth, FALSE /* depth_is_sticky */, @@ -464,8 +482,8 @@ sbox_wc_move(svn_test__sandbox_t *b, con apr_array_header_t *paths = apr_array_make(b->pool, 1, sizeof(const char *)); - SVN_ERR(svn_client_create_context2(&ctx, NULL, b->pool)); - ctx->wc_ctx = b->wc_ctx; + SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool)); + APR_ARRAY_PUSH(paths, const char *) = sbox_wc_path(b, src); return svn_client_move7(paths, sbox_wc_path(b, dst), FALSE /* move_as_child */, @@ -488,8 +506,8 @@ sbox_wc_propset(svn_test__sandbox_t *b, sizeof(const char *)); svn_string_t *pval = value ? svn_string_create(value, b->pool) : NULL; - SVN_ERR(svn_client_create_context2(&ctx, NULL, b->pool)); - ctx->wc_ctx = b->wc_ctx; + SVN_ERR(svn_test__create_client_ctx(&ctx, b, b->pool)); + APR_ARRAY_PUSH(paths, const char *) = sbox_wc_path(b, path); return svn_client_propset_local(name, pval, paths, svn_depth_empty, TRUE /* skip_checks */, @@ -503,8 +521,7 @@ sbox_wc_relocate(svn_test__sandbox_t *b, apr_pool_t *scratch_pool = b->pool; svn_client_ctx_t *ctx; - SVN_ERR(svn_client_create_context2(&ctx, NULL, scratch_pool)); - ctx->wc_ctx = b->wc_ctx; + SVN_ERR(svn_test__create_client_ctx(&ctx, b, scratch_pool)); SVN_ERR(svn_client_relocate2(b->wc_abspath, b->repos_url, new_repos_url, FALSE, ctx,scratch_pool)); Modified: subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/utils.h URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/utils.h?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/utils.h (original) +++ subversion/branches/reuse-ra-session/subversion/tests/libsvn_wc/utils.h Wed Feb 4 11:23:29 2015 @@ -25,6 +25,8 @@ #include <apr_pools.h> #include "svn_error.h" +#include "svn_client.h" + #include "../svn_test.h" #ifdef __cplusplus @@ -53,6 +55,8 @@ typedef struct svn_test__sandbox_t svn_wc_context_t *wc_ctx; /* The repository URL. */ const char *repos_url; + /* Local path to the repository */ + const char *repos_dir; /* The absolute local path of the WC root. */ const char *wc_abspath; /* A pool that can be used for all allocations. */ @@ -185,6 +189,13 @@ svn_test__create_fake_wc(const char *wc_ apr_pool_t *scratch_pool); +/* Create a client context for the specified sandbox */ +svn_error_t * +svn_test__create_client_ctx(svn_client_ctx_t **ctx, + svn_test__sandbox_t *sbox, + apr_pool_t *result_pool); + + #ifdef __cplusplus } #endif /* __cplusplus */ Modified: subversion/branches/reuse-ra-session/subversion/tests/svn_test.h URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/svn_test.h?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/svn_test.h (original) +++ subversion/branches/reuse-ra-session/subversion/tests/svn_test.h Wed Feb 4 11:23:29 2015 @@ -34,6 +34,7 @@ #include "svn_types.h" #include "svn_error.h" #include "svn_string.h" +#include "svn_auth.h" #ifdef __cplusplus extern "C" { @@ -117,12 +118,20 @@ extern "C" { */ typedef struct svn_test_opts_t { + /* The name of the application (to generate unique names) */ + const char *prog_name; /* Description of the fs backend that should be used for testing. */ const char *fs_type; /* Config file. */ const char *config_file; /* Source dir. */ const char *srcdir; + /* Repository dir: temporary directory to create repositories in as subdir */ + const char *repos_dir; + /* Repository url: The url to access REPOS_DIR as */ + const char *repos_url; + /* Repository template: pre-created repository to copy for tests */ + const char *repos_template; /* Minor version to use for servers and FS backends, or zero to use the current latest version. */ int server_minor_version; @@ -269,6 +278,11 @@ svn_test_get_srcdir(const char **srcdir, const svn_test_opts_t *opts, apr_pool_t *pool); +/* Initializes a standard auth baton for accessing the repositories */ +svn_error_t * +svn_test__init_auth_baton(svn_auth_baton_t **baton, + apr_pool_t *result_pool); + #ifdef __cplusplus } #endif /* __cplusplus */ Modified: subversion/branches/reuse-ra-session/subversion/tests/svn_test_fs.c URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/svn_test_fs.c?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/svn_test_fs.c (original) +++ subversion/branches/reuse-ra-session/subversion/tests/svn_test_fs.c Wed Feb 4 11:23:29 2015 @@ -212,42 +212,115 @@ svn_test__create_fs(svn_fs_t **fs_p, } svn_error_t * -svn_test__create_repos(svn_repos_t **repos_p, - const char *name, - const svn_test_opts_t *opts, - apr_pool_t *pool) +svn_test__create_repos2(svn_repos_t **repos_p, + const char **repos_url, + const char **repos_dirent, + const char *name, + const svn_test_opts_t *opts, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool) { svn_repos_t *repos; svn_boolean_t must_reopen; + const char *repos_abspath; + apr_pool_t *repos_pool = repos_p ? result_pool : scratch_pool; + svn_boolean_t init_svnserve = FALSE; apr_hash_t *fs_config = make_fs_config(opts->fs_type, - opts->server_minor_version, pool); + opts->server_minor_version, + repos_pool); + + if (repos_url && opts->repos_dir && opts->repos_url) + { + name = apr_psprintf(scratch_pool, "%s-%s", opts->prog_name, + svn_dirent_basename(name, NULL)); + + repos_abspath = svn_dirent_join(opts->repos_dir, name, scratch_pool); + + SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath, + scratch_pool)); + + SVN_ERR(svn_io_make_dir_recursively(repos_abspath, scratch_pool)); + + *repos_url = svn_path_url_add_component2(opts->repos_url, name, + result_pool); + + if (strstr(opts->repos_url, "svn://")) + init_svnserve = TRUE; + } + else + { + SVN_ERR(svn_dirent_get_absolute(&repos_abspath, name, scratch_pool)); + + if (repos_url) + SVN_ERR(svn_uri_get_file_url_from_dirent(repos_url, repos_abspath, + result_pool)); + } /* If there's already a repository named NAME, delete it. Doing things this way means that repositories stick around after a failure for postmortem analysis, but also that tests can be re-run without cleaning out the repositories created by prior runs. */ - SVN_ERR(svn_io_remove_dir2(name, TRUE, NULL, NULL, pool)); + SVN_ERR(svn_io_remove_dir2(repos_abspath, TRUE, NULL, NULL, scratch_pool)); - SVN_ERR(svn_repos_create(&repos, name, NULL, NULL, NULL, - fs_config, pool)); + SVN_ERR(svn_repos_create(&repos, repos_abspath, NULL, NULL, NULL, + fs_config, repos_pool)); /* Register this repo for cleanup. */ - svn_test_add_dir_cleanup(name); + svn_test_add_dir_cleanup(repos_abspath); SVN_ERR(maybe_install_fs_conf(svn_repos_fs(repos), opts, &must_reopen, - pool)); + scratch_pool)); if (must_reopen) { - SVN_ERR(svn_repos_open3(&repos, name, NULL, pool, pool)); - svn_fs_set_warning_func(svn_repos_fs(repos), fs_warning_handler, NULL); + SVN_ERR(svn_repos_open3(&repos, repos_abspath, NULL, repos_pool, + scratch_pool)); } - *repos_p = repos; + svn_fs_set_warning_func(svn_repos_fs(repos), fs_warning_handler, NULL); + + if (init_svnserve) + { + const char *cfg; + const char *pwd; + + cfg = svn_dirent_join(repos_abspath, "conf/svnserve.conf", scratch_pool); + SVN_ERR(svn_io_remove_file2(cfg, FALSE, scratch_pool)); + SVN_ERR(svn_io_file_create(cfg, + "[general]\n" + "auth-access = write\n" + "password-db = passwd\n", + scratch_pool)); + + pwd = svn_dirent_join(repos_abspath, "conf/passwd", scratch_pool); + SVN_ERR(svn_io_remove_file2(pwd, FALSE, scratch_pool)); + SVN_ERR(svn_io_file_create(pwd, + "[users]\n" + "jrandom = rayjandom\n" + "jconstant = rayjandom\n", + scratch_pool)); + } + + if (repos_p) + *repos_p = repos; + if (repos_dirent) + *repos_dirent = apr_pstrdup(result_pool, repos_abspath); + return SVN_NO_ERROR; } svn_error_t * +svn_test__create_repos(svn_repos_t **repos_p, + const char *name, + const svn_test_opts_t *opts, + apr_pool_t *pool) +{ + return svn_error_trace( + svn_test__create_repos2(repos_p, NULL, NULL, name, + opts, pool, pool)); +} + +svn_error_t * svn_test__stream_to_string(svn_stringbuf_t **string, svn_stream_t *stream, apr_pool_t *pool) Modified: subversion/branches/reuse-ra-session/subversion/tests/svn_test_fs.h URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/svn_test_fs.h?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/svn_test_fs.h (original) +++ subversion/branches/reuse-ra-session/subversion/tests/svn_test_fs.h Wed Feb 4 11:23:29 2015 @@ -82,6 +82,19 @@ svn_test__create_repos(svn_repos_t **rep const svn_test_opts_t *opts, apr_pool_t *pool); +/* Create a repository with a filesystem based on OPTS in a subdir NAME + and return optionally new REPOS object, the directory it was created in + and/or the url of the repository . */ +svn_error_t * +svn_test__create_repos2(svn_repos_t **repos_p, + const char **repos_url, + const char **repos_dirent, + const char *name, + const svn_test_opts_t *opts, + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); + + /* Read all data from a generic read STREAM, and return it in STRING. Allocate the svn_stringbuf_t in POOL. (All data in STRING will be dup'ed from STREAM using POOL too.) */ Modified: subversion/branches/reuse-ra-session/subversion/tests/svn_test_main.c URL: http://svn.apache.org/viewvc/subversion/branches/reuse-ra-session/subversion/tests/svn_test_main.c?rev=1657122&r1=1657121&r2=1657122&view=diff ============================================================================== --- subversion/branches/reuse-ra-session/subversion/tests/svn_test_main.c (original) +++ subversion/branches/reuse-ra-session/subversion/tests/svn_test_main.c Wed Feb 4 11:23:29 2015 @@ -101,6 +101,9 @@ enum test_options_e { server_minor_version_opt, allow_segfault_opt, srcdir_opt, + reposdir_opt, + reposurl_opt, + repostemplate_opt, mode_filter_opt, sqlite_log_opt, parallel_opt, @@ -135,6 +138,12 @@ static const apr_getopt_option_t cl_opti N_("don't trap seg faults (useful for debugging)")}, {"srcdir", srcdir_opt, 1, N_("directory which contains test's C source files")}, + {"repos-dir", reposdir_opt, 1, + N_("directory to create repositories in")}, + {"repos-url", reposurl_opt, 1, + N_("the url to access reposdir as")}, + {"repos-template",repostemplate_opt, 1, + N_("the repository to use as template")}, {"sqlite-logging", sqlite_log_opt, 0, N_("enable SQLite logging")}, {"parallel", parallel_opt, 0, @@ -682,12 +691,26 @@ svn_test_get_srcdir(const char **srcdir, return SVN_NO_ERROR; } +svn_error_t * +svn_test__init_auth_baton(svn_auth_baton_t **ab, + apr_pool_t *result_pool) +{ + SVN_ERR(svn_cmdline_create_auth_baton(ab, + TRUE /* non_interactive */, + "jrandom", "rayjandom", + NULL, + TRUE /* no_auth_cache */, + FALSE /* trust_server_cert */, + NULL, NULL, NULL, result_pool)); + + return SVN_NO_ERROR; +} + /* Standard svn test program */ int svn_test_main(int argc, const char *argv[], int max_threads, struct svn_test_descriptor_t *test_funcs) { - const char *prog_name; int i; svn_boolean_t got_error = FALSE; apr_pool_t *pool, *test_pool; @@ -745,21 +768,19 @@ svn_test_main(int argc, const char *argv os->interleave = TRUE; /* Let options and arguments be interleaved */ /* Strip off any leading path components from the program name. */ - prog_name = strrchr(argv[0], '/'); - if (prog_name) - prog_name++; - else - { - /* Just check if this is that weird platform that uses \ instead - of / for the path separator. */ - prog_name = strrchr(argv[0], '\\'); - if (prog_name) - prog_name++; - else - prog_name = argv[0]; - } + opts.prog_name = svn_dirent_internal_style(argv[0], pool); + opts.prog_name = svn_dirent_basename(opts.prog_name, NULL); #ifdef WIN32 + /* Abuse cast in strstr() to remove .exe extension. + Value is allocated in pool by svn_dirent_internal_style() */ + { + char *exe_ext = strstr(opts.prog_name, ".exe"); + + if (exe_ext) + *exe_ext = '\0'; + } + #if _MSC_VER >= 1400 /* ### This should work for VC++ 2002 (=1300) and later */ /* Show the abort message on STDERR instead of a dialog to allow @@ -781,7 +802,7 @@ svn_test_main(int argc, const char *argv #endif if (err) - return svn_cmdline_handle_exit_error(err, pool, prog_name); + return svn_cmdline_handle_exit_error(err, pool, opts.prog_name); while (1) { const char *opt_arg; @@ -800,7 +821,7 @@ svn_test_main(int argc, const char *argv switch (opt_id) { case help_opt: - help(prog_name, pool); + help(opts.prog_name, pool); exit(0); case cleanup_opt: cleanup_mode = TRUE; @@ -815,6 +836,20 @@ svn_test_main(int argc, const char *argv SVN_INT_ERR(svn_utf_cstring_to_utf8(&opts.srcdir, opt_arg, pool)); opts.srcdir = svn_dirent_internal_style(opts.srcdir, pool); break; + case reposdir_opt: + SVN_INT_ERR(svn_utf_cstring_to_utf8(&opts.repos_dir, opt_arg, pool)); + opts.repos_dir = svn_dirent_internal_style(opts.repos_dir, pool); + break; + case reposurl_opt: + SVN_INT_ERR(svn_utf_cstring_to_utf8(&opts.repos_url, opt_arg, pool)); + opts.repos_url = svn_uri_canonicalize(opts.repos_url, pool); + break; + case repostemplate_opt: + SVN_INT_ERR(svn_utf_cstring_to_utf8(&opts.repos_template, opt_arg, + pool)); + opts.repos_template = svn_dirent_internal_style(opts.repos_template, + pool); + break; case list_opt: list_mode = TRUE; break; @@ -903,7 +938,7 @@ svn_test_main(int argc, const char *argv "------ ----- ----------------\n"; for (i = 1; i <= array_size; i++) { - if (do_test_num(prog_name, i, test_funcs, + if (do_test_num(opts.prog_name, i, test_funcs, TRUE, &opts, &header_msg, test_pool)) got_error = TRUE; @@ -924,7 +959,7 @@ svn_test_main(int argc, const char *argv continue; ran_a_test = TRUE; - if (do_test_num(prog_name, test_num, test_funcs, + if (do_test_num(opts.prog_name, test_num, test_funcs, FALSE, &opts, NULL, test_pool)) got_error = TRUE; @@ -946,7 +981,7 @@ svn_test_main(int argc, const char *argv { for (i = 1; i <= array_size; i++) { - if (do_test_num(prog_name, i, test_funcs, + if (do_test_num(opts.prog_name, i, test_funcs, FALSE, &opts, NULL, test_pool)) got_error = TRUE; @@ -958,7 +993,7 @@ svn_test_main(int argc, const char *argv #if APR_HAS_THREADS else { - got_error = do_tests_concurrently(prog_name, test_funcs, + got_error = do_tests_concurrently(opts.prog_name, test_funcs, array_size, max_threads, &opts, test_pool); Propchange: subversion/branches/reuse-ra-session/tools/dev/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Feb 4 11:23:29 2015 @@ -1,3 +1,4 @@ .libs fsfs-access-map logdata.py +x509-parser
