subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1656779 - in /subversion/trunk/subversion/tests: svn_test_fs.c svn_test_fs.h
Date Tue, 03 Feb 2015 16:25:25 GMT
Author: rhuijben
Date: Tue Feb  3 16:25:24 2015
New Revision: 1656779

URL: http://svn.apache.org/r1656779
Log:
Following up on r1656778, update repository create helper to create
repositories accessible via the current ra layer.

* subversion/tests/svn_test_fs.c
  (svn_test__create_repos): Rename to...
  (svn_test__create_repos2): ... this and handle repository creation
    for DAV and SVN.
  (svn_test__create_repos): Reimplement as wrapper around
    svn_test__create_repos2.

* subversion/tests/svn_test_fs.h
  (svn_test__create_repos2): New function.

Modified:
    subversion/trunk/subversion/tests/svn_test_fs.c
    subversion/trunk/subversion/tests/svn_test_fs.h

Modified: subversion/trunk/subversion/tests/svn_test_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_fs.c?rev=1656779&r1=1656778&r2=1656779&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_fs.c (original)
+++ subversion/trunk/subversion/tests/svn_test_fs.c Tue Feb  3 16:25:24 2015
@@ -212,42 +212,117 @@ 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));
+
+  SVN_DBG(("Created repository at %s", repos_abspath));
 
   /* 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));
+    }
+
+  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));
     }
 
-  *repos_p = repos;
+  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/trunk/subversion/tests/svn_test_fs.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_fs.h?rev=1656779&r1=1656778&r2=1656779&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_fs.h (original)
+++ subversion/trunk/subversion/tests/svn_test_fs.h Tue Feb  3 16:25:24 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.) */



Mime
View raw message