In preparation for installing temp triggers for DB validation, I'm
trying to do a simple factoring-out of a WC DB creation func, but it's
failing. I'm out of time now so if anybody wants to debug for me please
feel free!
Error on running db-test 1 (and others) is:
subversion/libsvn_wc/wc_db_wcroot.c:247: (apr_err=235000)
svn: E235000: In file 'subversion/libsvn_wc/wc_db_wcroot.c' line 247:
assertion failed (format >= 1)
which happens on the first read_info() call after the fake-WC is
created.
- Julian
Factor out a test function for creating a fake WC DB.
### Not working: db-test fails with:
subversion/libsvn_wc/wc_db_wcroot.c:247: (apr_err=235000)
svn: E235000: In file 'subversion/libsvn_wc/wc_db_wcroot.c' line 247: assertion failed (format >= 1)
* subversion/tests/libsvn_wc/utils.h,
subversion/tests/libsvn_wc/utils.c
(svn_test__create_fake_wc): New function, factored out from two places.
* subversion/tests/libsvn_wc/db-test.c
(create_fake_wc): Remove.
(create_open): Use svn_test__create_fake_wc() instead of create_fake_wc().
* subversion/tests/libsvn_wc/entries-compat.c
(make_one_db): Remove.
(create_fake_wc): Use svn_test__create_fake_wc() instead of make_one_db().
* build.conf
(db-test, entries-compat-test): Add 'utils.c' to sources and
'libsvn_client' to libs.
--This line, and those below, will be ignored--
Index: build.conf
===================================================================
--- build.conf (revision 1128411)
+++ build.conf (working copy)
@@ -952,9 +952,9 @@ libs = libsvn_client libsvn_test libsvn_
description = Test the wc-ng database subsystem
type = exe
path = subversion/tests/libsvn_wc
-sources = db-test.c
+sources = db-test.c utils.c
install = test
-libs = libsvn_test libsvn_wc libsvn_subr apriconv apr
+libs = libsvn_client libsvn_test libsvn_wc libsvn_subr apriconv apr
[pristine-store-test]
description = Test the wc-ng pristine text storage subsystem
@@ -968,9 +968,9 @@ libs = libsvn_client libsvn_test libsvn_
description = Test backwards compat for the entry interface
type = exe
path = subversion/tests/libsvn_wc
-sources = entries-compat.c
+sources = entries-compat.c utils.c
install = test
-libs = libsvn_test libsvn_wc libsvn_subr apriconv apr
+libs = libsvn_client libsvn_test libsvn_wc libsvn_subr apriconv apr
[op-depth-test]
description = Test the main WC API functions
Index: subversion/tests/libsvn_wc/db-test.c
===================================================================
--- subversion/tests/libsvn_wc/db-test.c (revision 1128411)
+++ subversion/tests/libsvn_wc/db-test.c (working copy)
@@ -37,17 +37,13 @@
#include "svn_dirent_uri.h"
#include "svn_pools.h"
-#include "private/svn_sqlite.h"
-
#include "../../libsvn_wc/wc.h"
#include "../../libsvn_wc/wc_db.h"
-#include "../../libsvn_wc/wc-queries.h"
-#define SVN_WC__I_AM_WC_DB
-#include "../../libsvn_wc/wc_db_private.h"
#include "private/svn_wc_private.h"
#include "../svn_test.h"
+#include "utils.h"
#define ROOT_ONE "http://example.com/one"
@@ -309,39 +305,6 @@ static const char * const TESTING_DATA =
" '" G_TC_DATA "', null, null, null, null);"
);
-WC_QUERIES_SQL_DECLARE_STATEMENTS(statements);
-
-
-static svn_error_t *
-create_fake_wc(const char *subdir_abspath, apr_pool_t *scratch_pool)
-{
- const char *dotsvn_abspath = svn_dirent_join(subdir_abspath, ".svn",
- scratch_pool);
- const char *db_abspath = svn_dirent_join(dotsvn_abspath, "wc.db",
- scratch_pool);
- svn_sqlite__db_t *sdb;
- const char * const my_statements[] = {
- statements[STMT_CREATE_SCHEMA],
- statements[STMT_CREATE_NODES],
- statements[STMT_CREATE_NODES_TRIGGERS],
- statements[STMT_CREATE_EXTERNALS],
- TESTING_DATA,
- NULL
- };
- int i;
-
- SVN_ERR(svn_io_make_dir_recursively(dotsvn_abspath, scratch_pool));
- svn_error_clear(svn_io_remove_file(db_abspath, scratch_pool));
- SVN_ERR(svn_wc__db_util_open_db(&sdb, subdir_abspath, "wc.db",
- svn_sqlite__mode_rwcreate, my_statements,
- scratch_pool, scratch_pool));
-
- for (i = 0; my_statements[i] != NULL; i++)
- SVN_ERR(svn_sqlite__exec_statements(sdb, /* my_statements[] */ i));
-
- return SVN_NO_ERROR;
-}
-
static svn_error_t *
create_open(svn_wc__db_t **db,
@@ -353,7 +316,7 @@ create_open(svn_wc__db_t **db,
svn_dirent_join("fake-wc", subdir, pool),
pool));
SVN_ERR(svn_wc__db_open(db, NULL, TRUE, TRUE, pool, pool));
- SVN_ERR(create_fake_wc(*local_abspath, pool));
+ SVN_ERR(svn_test__create_fake_wc(*local_abspath, TESTING_DATA, pool, pool));
return SVN_NO_ERROR;
}
Index: subversion/tests/libsvn_wc/entries-compat.c
===================================================================
--- subversion/tests/libsvn_wc/entries-compat.c (revision 1128411)
+++ subversion/tests/libsvn_wc/entries-compat.c (working copy)
@@ -38,15 +38,11 @@
#include "svn_pools.h"
#include "svn_wc.h"
-#include "private/svn_sqlite.h"
-
#include "../../libsvn_wc/wc.h"
-#include "../../libsvn_wc/wc-queries.h"
#include "../../libsvn_wc/wc_db.h"
-#define SVN_WC__I_AM_WC_DB
-#include "../../libsvn_wc/wc_db_private.h"
#include "../svn_test.h"
+#include "utils.h"
/* NOTE: these must be canonical! */
@@ -302,65 +298,22 @@ static const char * const M_TESTING_DATA
" null, null, null, null);"
);
-WC_QUERIES_SQL_DECLARE_STATEMENTS(statements);
-
static svn_error_t *
-make_one_db(const char *wc_abspath,
- const char * const my_statements[],
- apr_pool_t *scratch_pool)
-{
- const char *dotsvn_abspath = svn_dirent_join(wc_abspath, ".svn",
- scratch_pool);
- const char *db_abspath = svn_dirent_join(dotsvn_abspath, "wc.db",
- scratch_pool);
- svn_sqlite__db_t *sdb;
- int i;
-
- /* Create fake-wc/SUBDIR/.svn/ for placing the metadata. */
- SVN_ERR(svn_io_make_dir_recursively(dotsvn_abspath, scratch_pool));
-
- svn_error_clear(svn_io_remove_file(db_abspath, scratch_pool));
- SVN_ERR(svn_wc__db_util_open_db(&sdb, wc_abspath, "wc.db",
- svn_sqlite__mode_rwcreate, my_statements,
- scratch_pool, scratch_pool));
-
- for (i = 0; my_statements[i] != NULL; i++)
- SVN_ERR(svn_sqlite__exec_statements(sdb, /* my_statements[] */ i));
-
- return SVN_NO_ERROR;
-}
-
-
-static svn_error_t *
-create_fake_wc(const char *subdir, int format, apr_pool_t *scratch_pool)
+create_fake_wc(const char *subdir, apr_pool_t *pool)
{
const char *root;
const char *wc_abspath;
- const char * const my_statements[] = {
- statements[STMT_CREATE_SCHEMA],
- statements[STMT_CREATE_NODES],
- statements[STMT_CREATE_NODES_TRIGGERS],
- TESTING_DATA,
- NULL
- };
- const char * const M_statements[] = {
- statements[STMT_CREATE_SCHEMA],
- statements[STMT_CREATE_NODES],
- statements[STMT_CREATE_NODES_TRIGGERS],
- M_TESTING_DATA,
- NULL
- };
-
- root = svn_dirent_join("fake-wc", subdir, scratch_pool);
- SVN_ERR(svn_io_remove_dir2(root, TRUE, NULL, NULL, scratch_pool));
+ root = svn_dirent_join("fake-wc", subdir, pool);
+
+ SVN_ERR(svn_io_remove_dir2(root, TRUE, NULL, NULL, pool));
- SVN_ERR(svn_dirent_get_absolute(&wc_abspath, root, scratch_pool));
- SVN_ERR(make_one_db(wc_abspath, my_statements, scratch_pool));
+ SVN_ERR(svn_dirent_get_absolute(&wc_abspath, root, pool));
+ SVN_ERR(svn_test__create_fake_wc(wc_abspath, TESTING_DATA, pool, pool));
- wc_abspath = svn_dirent_join(wc_abspath, "M", scratch_pool);
- SVN_ERR(make_one_db(wc_abspath, M_statements, scratch_pool));
+ wc_abspath = svn_dirent_join(wc_abspath, "M", pool);
+ SVN_ERR(svn_test__create_fake_wc(wc_abspath, M_TESTING_DATA, pool, pool));
return SVN_NO_ERROR;
}
@@ -372,7 +325,7 @@ create_open(svn_wc__db_t **db,
const char *subdir,
apr_pool_t *pool)
{
- SVN_ERR(create_fake_wc(subdir, SVN_WC__VERSION, pool));
+ SVN_ERR(create_fake_wc(subdir, pool));
SVN_ERR(svn_dirent_get_absolute(local_abspath,
svn_dirent_join("fake-wc", subdir, pool),
Index: subversion/tests/libsvn_wc/utils.c
===================================================================
--- subversion/tests/libsvn_wc/utils.c (revision 1128411)
+++ subversion/tests/libsvn_wc/utils.c (working copy)
@@ -27,6 +27,11 @@
#include "../svn_test_fs.h"
+#include "../../libsvn_wc/wc-queries.h"
+#define SVN_WC__I_AM_WC_DB
+#include "../../libsvn_wc/wc_db_private.h"
+
+
/* 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
* new WC.
@@ -84,6 +89,47 @@ create_repos_and_wc(const char **repos_u
return SVN_NO_ERROR;
}
+
+
+WC_QUERIES_SQL_DECLARE_STATEMENTS(statements);
+
+svn_error_t *
+svn_test__create_fake_wc(const char *wc_abspath,
+ const char *extra_statements,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ const char *dotsvn_abspath = svn_dirent_join(wc_abspath, ".svn",
+ scratch_pool);
+ const char *db_abspath = svn_dirent_join(dotsvn_abspath, "wc.db",
+ scratch_pool);
+ svn_sqlite__db_t *sdb;
+ const char **my_statements;
+ int i;
+
+ /* Allocate MY_STATEMENTS in RESULT_POOL because the SDB will continue to
+ * refer to it over its lifetime. */
+ my_statements = apr_palloc(result_pool, 6 * sizeof(const char *));
+ my_statements[0] = statements[STMT_CREATE_SCHEMA];
+ my_statements[1] = statements[STMT_CREATE_NODES];
+ my_statements[2] = statements[STMT_CREATE_NODES_TRIGGERS];
+ my_statements[3] = statements[STMT_CREATE_EXTERNALS];
+ my_statements[4] = extra_statements;
+ my_statements[5] = NULL;
+
+ /* Create fake-wc/SUBDIR/.svn/ for placing the metadata. */
+ SVN_ERR(svn_io_make_dir_recursively(dotsvn_abspath, scratch_pool));
+
+ svn_error_clear(svn_io_remove_file(db_abspath, scratch_pool));
+ SVN_ERR(svn_wc__db_util_open_db(&sdb, wc_abspath, "wc.db",
+ svn_sqlite__mode_rwcreate, my_statements,
+ result_pool, scratch_pool));
+
+ for (i = 0; my_statements[i] != NULL; i++)
+ SVN_ERR(svn_sqlite__exec_statements(sdb, /* my_statements[] */ i));
+
+ return SVN_NO_ERROR;
+}
svn_error_t *
Index: subversion/tests/libsvn_wc/utils.h
===================================================================
--- subversion/tests/libsvn_wc/utils.h (revision 1128411)
+++ subversion/tests/libsvn_wc/utils.h (working copy)
@@ -75,6 +75,16 @@ svn_test__sandbox_create(svn_test__sandb
apr_pool_t *pool);
+/* Create a WC directory at WC_ABSPATH containing a fake WC DB, generated by
+ * executing the SQL statements EXTRA_STATEMENTS in addition to the standard
+ * WC DB schema. */
+svn_error_t *
+svn_test__create_fake_wc(const char *wc_abspath,
+ const char *extra_statements,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool);
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */