77
77
apr_hash_t *fs_config = apr_hash_make(pool);
78
apr_hash_set(fs_config, SVN_FS_CONFIG_BDB_TXN_NOSYNC,
79
APR_HASH_KEY_STRING, "1");
80
apr_hash_set(fs_config, SVN_FS_CONFIG_FS_TYPE,
79
svn_hash_sets(fs_config, SVN_FS_CONFIG_BDB_TXN_NOSYNC, "1");
80
svn_hash_sets(fs_config, SVN_FS_CONFIG_BDB_LOG_AUTOREMOVE, "1");
81
svn_hash_sets(fs_config, SVN_FS_CONFIG_FS_TYPE, fs_type);
83
82
if (server_minor_version)
84
svn_hash_sets(fs_config, SVN_FS_CONFIG_COMPATIBLE_VERSION,
85
apr_psprintf(pool, "1.%d.0", server_minor_version));
85
86
if (server_minor_version == 6 || server_minor_version == 7)
86
87
svn_hash_sets(fs_config, SVN_FS_CONFIG_PRE_1_8_COMPATIBLE, "1");
87
88
else if (server_minor_version == 5)
103
104
const char *name,
104
105
const char *fs_type,
105
106
int server_minor_version,
107
apr_hash_t *overlay_fs_config,
106
108
apr_pool_t *pool)
109
110
apr_hash_t *fs_config = make_fs_config(fs_type, server_minor_version, pool);
112
if (overlay_fs_config)
113
fs_config = apr_hash_overlay(pool, overlay_fs_config, fs_config);
111
115
/* If there's already a repository named NAME, delete it. Doing
112
116
things this way means that repositories stick around after a
113
117
failure for postmortem analysis, but also that tests can be
114
118
re-run without cleaning out the repositories created by prior
116
if (apr_stat(&finfo, name, APR_FINFO_TYPE, pool) == APR_SUCCESS)
118
if (finfo.filetype == APR_DIR)
119
SVN_ERR_W(svn_io_remove_dir2(name, TRUE, NULL, NULL, pool),
121
"cannot create fs '%s' there is already "
122
"a directory of that name", name));
124
return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
125
"cannot create fs '%s' there is already "
126
"a file of that name", name);
120
SVN_ERR(svn_io_remove_dir2(name, TRUE, NULL, NULL, pool));
129
122
SVN_ERR(svn_fs_create(fs_p, name, fs_config, pool));
144
137
* copy that file into the filesystem FS and set *MUST_REOPEN to TRUE, else
145
138
* set *MUST_REOPEN to FALSE. */
146
139
static svn_error_t *
147
maybe_install_fsfs_conf(svn_fs_t *fs,
148
const svn_test_opts_t *opts,
149
svn_boolean_t *must_reopen,
140
maybe_install_fs_conf(svn_fs_t *fs,
141
const svn_test_opts_t *opts,
142
svn_boolean_t *must_reopen,
152
145
*must_reopen = FALSE;
153
if (strcmp(opts->fs_type, "fsfs") != 0 || ! opts->config_file)
146
if (! opts->config_file)
154
147
return SVN_NO_ERROR;
157
return svn_io_copy_file(opts->config_file,
158
svn_path_join(svn_fs_path(fs, pool),
160
FALSE /* copy_perms */,
149
if (strcmp(opts->fs_type, "fsfs") == 0)
152
return svn_io_copy_file(opts->config_file,
153
svn_path_join(svn_fs_path(fs, pool),
155
FALSE /* copy_perms */,
159
if (strcmp(opts->fs_type, "fsx") == 0)
162
return svn_io_copy_file(opts->config_file,
163
svn_path_join(svn_fs_path(fs, pool),
165
FALSE /* copy_perms */,
168
176
const svn_test_opts_t *opts,
169
177
apr_pool_t *pool)
171
return create_fs(fs_p, name, "bdb", opts->server_minor_version, pool);
179
return create_fs(fs_p, name, "bdb", opts->server_minor_version, NULL, pool);
184
svn_test__create_fs2(svn_fs_t **fs_p,
186
const svn_test_opts_t *opts,
187
apr_hash_t *fs_config,
190
svn_boolean_t must_reopen;
192
SVN_ERR(create_fs(fs_p, name, opts->fs_type, opts->server_minor_version,
195
SVN_ERR(maybe_install_fs_conf(*fs_p, opts, &must_reopen, pool));
198
SVN_ERR(svn_fs_open2(fs_p, name, NULL, pool, pool));
199
svn_fs_set_warning_func(*fs_p, fs_warning_handler, NULL);
176
206
svn_test__create_fs(svn_fs_t **fs_p,
178
208
const svn_test_opts_t *opts,
179
209
apr_pool_t *pool)
211
return svn_test__create_fs2(fs_p, name, opts, NULL, pool);
215
svn_test__create_repos2(svn_repos_t **repos_p,
216
const char **repos_url,
217
const char **repos_dirent,
219
const svn_test_opts_t *opts,
220
apr_pool_t *result_pool,
221
apr_pool_t *scratch_pool)
181
224
svn_boolean_t must_reopen;
183
SVN_ERR(create_fs(fs_p, name, opts->fs_type,
184
opts->server_minor_version, pool));
186
SVN_ERR(maybe_install_fsfs_conf(*fs_p, opts, &must_reopen, pool));
225
const char *repos_abspath;
226
apr_pool_t *repos_pool = repos_p ? result_pool : scratch_pool;
227
svn_boolean_t init_svnserve = FALSE;
228
apr_hash_t *fs_config = make_fs_config(opts->fs_type,
229
opts->server_minor_version,
232
if (repos_url && opts->repos_dir && opts->repos_url)
234
name = apr_psprintf(scratch_pool, "%s-%s", opts->prog_name,
235
svn_dirent_basename(name, NULL));
237
repos_abspath = svn_dirent_join(opts->repos_dir, name, scratch_pool);
239
SVN_ERR(svn_dirent_get_absolute(&repos_abspath, repos_abspath,
242
SVN_ERR(svn_io_make_dir_recursively(repos_abspath, scratch_pool));
244
*repos_url = svn_path_url_add_component2(opts->repos_url, name,
247
if (strstr(opts->repos_url, "svn://"))
248
init_svnserve = TRUE;
252
SVN_ERR(svn_dirent_get_absolute(&repos_abspath, name, scratch_pool));
255
SVN_ERR(svn_uri_get_file_url_from_dirent(repos_url, repos_abspath,
259
/* If there's already a repository named NAME, delete it. Doing
260
things this way means that repositories stick around after a
261
failure for postmortem analysis, but also that tests can be
262
re-run without cleaning out the repositories created by prior
264
SVN_ERR(svn_io_remove_dir2(repos_abspath, TRUE, NULL, NULL, scratch_pool));
266
SVN_ERR(svn_repos_create(&repos, repos_abspath, NULL, NULL, NULL,
267
fs_config, repos_pool));
269
/* Register this repo for cleanup. */
270
svn_test_add_dir_cleanup(repos_abspath);
272
SVN_ERR(maybe_install_fs_conf(svn_repos_fs(repos), opts, &must_reopen,
189
SVN_ERR(svn_fs_open(fs_p, name, NULL, pool));
190
svn_fs_set_warning_func(*fs_p, fs_warning_handler, NULL);
276
SVN_ERR(svn_repos_open3(&repos, repos_abspath, NULL, repos_pool,
280
svn_fs_set_warning_func(svn_repos_fs(repos), fs_warning_handler, NULL);
287
cfg = svn_dirent_join(repos_abspath, "conf/svnserve.conf", scratch_pool);
288
SVN_ERR(svn_io_remove_file2(cfg, FALSE, scratch_pool));
289
SVN_ERR(svn_io_file_create(cfg,
291
"auth-access = write\n"
292
"password-db = passwd\n",
295
pwd = svn_dirent_join(repos_abspath, "conf/passwd", scratch_pool);
296
SVN_ERR(svn_io_remove_file2(pwd, FALSE, scratch_pool));
297
SVN_ERR(svn_io_file_create(pwd,
299
"jrandom = rayjandom\n"
300
"jconstant = rayjandom\n",
307
*repos_dirent = apr_pstrdup(result_pool, repos_abspath);
193
309
return SVN_NO_ERROR;
198
313
svn_test__create_repos(svn_repos_t **repos_p,
199
314
const char *name,
200
315
const svn_test_opts_t *opts,
201
316
apr_pool_t *pool)
205
svn_boolean_t must_reopen;
206
apr_hash_t *fs_config = make_fs_config(opts->fs_type,
207
opts->server_minor_version, pool);
209
/* If there's already a repository named NAME, delete it. Doing
210
things this way means that repositories stick around after a
211
failure for postmortem analysis, but also that tests can be
212
re-run without cleaning out the repositories created by prior
214
if (apr_stat(&finfo, name, APR_FINFO_TYPE, pool) == APR_SUCCESS)
216
if (finfo.filetype == APR_DIR)
217
SVN_ERR_W(svn_io_remove_dir2(name, TRUE, NULL, NULL, pool),
219
"cannot create repos '%s' there is already "
220
"a directory of that name", name));
222
return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
223
"there is already a file named '%s'", name);
226
SVN_ERR(svn_repos_create(&repos, name, NULL, NULL, NULL,
229
/* Register this repo for cleanup. */
230
svn_test_add_dir_cleanup(name);
232
SVN_ERR(maybe_install_fsfs_conf(svn_repos_fs(repos), opts, &must_reopen,
236
SVN_ERR(svn_repos_open2(&repos, name, NULL, pool));
237
svn_fs_set_warning_func(svn_repos_fs(repos), fs_warning_handler, NULL);
318
return svn_error_trace(
319
svn_test__create_repos2(repos_p, NULL, NULL, name,
532
649
for (i=0, hi = apr_hash_first(pool, expected); hi; hi = apr_hash_next(hi))
533
SVN_DBG(("expected[%d] = '%s'\n", i++, svn__apr_hash_index_key(hi)));
650
SVN_DBG(("expected[%d] = '%s'\n", i++, apr_hash_this_key(hi)));
534
651
for (i=0, hi = apr_hash_first(pool, actual); hi; hi = apr_hash_next(hi))
535
SVN_DBG(("actual[%d] = '%s'\n", i++, svn__apr_hash_index_key(hi)));
652
SVN_DBG(("actual[%d] = '%s'\n", i++, apr_hash_this_key(hi)));
539
656
for (hi = apr_hash_first(pool, expected); hi; hi = apr_hash_next(hi))
540
if (NULL == svn_hash_gets(actual, svn__apr_hash_index_key(hi)))
657
if (NULL == svn_hash_gets(actual, apr_hash_this_key(hi)))
541
658
return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
542
659
"Path '%s' missing from actual changed-paths",
543
svn__apr_hash_index_key(hi));
660
(const char *)apr_hash_this_key(hi));
545
662
for (hi = apr_hash_first(pool, actual); hi; hi = apr_hash_next(hi))
546
if (NULL == svn_hash_gets(expected, svn__apr_hash_index_key(hi)))
663
if (NULL == svn_hash_gets(expected, apr_hash_this_key(hi)))
547
664
return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
548
665
"Path '%s' missing from expected changed-paths",
549
svn__apr_hash_index_key(hi));
666
(const char *)apr_hash_this_key(hi));
551
668
return SVN_NO_ERROR;