Add a little more to the svn_rangelist_intersect test to test the
[svn.git] / subversion / tests / svn_test_fs.h
blobc50a4827208190dae4b662f468ab63437f8d165b
1 /* fs-helpers.c --- tests for the filesystem
3 * ====================================================================
4 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
18 #ifndef SVN_TEST__FS_HELPERS_H
19 #define SVN_TEST__FS_HELPERS_H
21 #include <apr_pools.h>
22 #include "svn_error.h"
23 #include "svn_fs.h"
24 #include "svn_repos.h"
25 #include "svn_delta.h"
26 #include "svn_test.h"
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
33 /*-------------------------------------------------------------------*/
35 /** Helper routines for filesystem functionality. **/
38 /* Set *FS_P to a fresh, unopened FS object, with the right warning
39 handling function set. */
40 svn_error_t *
41 svn_test__fs_new(svn_fs_t **fs_p, apr_pool_t *pool);
44 /* Create a filesystem of FS_TYPE in a subdir NAME and return a new FS
45 object which points to it. FS_TYPE should be either "bdb" or
46 "fsfs". Filesystem tests that are backend-specific should use
47 svn_test__create_fs instead of this. */
48 svn_error_t *
49 svn_test__create_fs(svn_fs_t **fs_p,
50 const char *name,
51 const char *fs_type,
52 apr_pool_t *pool);
55 /* Create a repository with a filesystem of FS_TYPE in a subdir NAME
56 and return a new REPOS object which points to it. */
57 svn_error_t *
58 svn_test__create_repos(svn_repos_t **repos_p,
59 const char *name,
60 const char *fs_type,
61 apr_pool_t *pool);
64 /* Read all data from a generic read STREAM, and return it in STRING.
65 Allocate the svn_stringbuf_t in APRPOOL. (All data in STRING will be
66 dup'ed from STREAM using APRPOOL too.) */
67 svn_error_t *
68 svn_test__stream_to_string(svn_stringbuf_t **string,
69 svn_stream_t *stream,
70 apr_pool_t *pool);
73 /* Set the contents of file in PATH under ROOT to CONTENTS. */
74 svn_error_t *
75 svn_test__set_file_contents(svn_fs_root_t *root,
76 const char *path,
77 const char *contents,
78 apr_pool_t *pool);
81 /* Get the contents of file in PATH under ROOT, and copy them into
82 STR. */
83 svn_error_t *
84 svn_test__get_file_contents(svn_fs_root_t *root,
85 const char *path,
86 svn_stringbuf_t **str,
87 apr_pool_t *pool);
91 /* The Helper Functions to End All Helper Functions */
93 /* Structure used for testing integrity of the filesystem's revision
94 using validate_tree(). */
95 typedef struct svn_test__tree_entry_t
97 const char *path; /* full path of this node */
98 const char *contents; /* text contents (NULL for directories) */
100 svn_test__tree_entry_t;
103 /* Wrapper for an array of the above svn_test__tree_entry_t's. */
104 typedef struct svn_test__tree_t
106 svn_test__tree_entry_t *entries;
107 int num_entries;
109 svn_test__tree_t;
112 /* Given a transaction or revision root (ROOT), check to see if the
113 tree that grows from that root has all the path entries, and only
114 those entries, passed in the array ENTRIES (which is an array of
115 NUM_ENTRIES tree_test_entry_t's). */
116 svn_error_t *
117 svn_test__validate_tree(svn_fs_root_t *root,
118 svn_test__tree_entry_t *entries,
119 int num_entries,
120 apr_pool_t *pool);
122 /* Structure for describing script-ish commands to perform on a
123 transaction using svn_test__txn_script_exec(). */
124 typedef struct svn_test__txn_script_command_t
126 /* command:
128 'a' -- add (PARAM1 is file contents, or NULL for directories)
129 'c' -- copy (PARAM1 is target path, copy source is youngest rev)
130 'd' -- delete
131 'e' -- edit (PARAM1 is new file contents)
133 int cmd;
134 const char *path; /* path to resource in the filesystem */
135 const char *param1; /* command parameter (see above) */
137 svn_test__txn_script_command_t;
140 /* Execute a "script" SCRIPT on items under TXN_ROOT. */
141 svn_error_t *
142 svn_test__txn_script_exec(svn_fs_root_t *txn_root,
143 svn_test__txn_script_command_t *script,
144 int num_edits,
145 apr_pool_t *pool);
147 /* Verify that the tree that exists under ROOT is exactly the Greek
148 Tree. */
149 svn_error_t *
150 svn_test__check_greek_tree(svn_fs_root_t *root,
151 apr_pool_t *pool);
154 /* Create the Greek Tree under TXN_ROOT. See ./greek-tree.txt. */
155 svn_error_t *
156 svn_test__create_greek_tree(svn_fs_root_t *txn_root,
157 apr_pool_t *pool);
160 #ifdef __cplusplus
162 #endif /* __cplusplus */
164 #endif /* SVN_TEST__FS_HELPERS_H */