1 /* svn_test_fs.h --- test helpers for the filesystem 2 * 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 */ 22 23 #ifndef SVN_TEST_FS_H 24 #define SVN_TEST_FS_H 25 26 #include <apr_pools.h> 27 #include "svn_error.h" 28 #include "svn_fs.h" 29 #include "svn_repos.h" 30 #include "svn_delta.h" 31 #include "svn_test.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif /* __cplusplus */ 36 37 38 /*-------------------------------------------------------------------*/ 39 40 /** Helper routines for filesystem functionality. **/ 41 42 43 /* Set *FS_P to a fresh, unopened FS object, with the right warning 44 handling function set. */ 45 svn_error_t * 46 svn_test__fs_new(svn_fs_t **fs_p, apr_pool_t *pool); 47 48 49 /* Creates a filesystem which is always of type "bdb" in a subdir NAME 50 and return a new FS object which points to it. (Ignores any 51 fs-type declaration in OPTS.) */ 52 svn_error_t * 53 svn_test__create_bdb_fs(svn_fs_t **fs_p, 54 const char *name, 55 const svn_test_opts_t *opts, 56 apr_pool_t *pool); 57 58 59 /* Create a filesystem based on OPTS in a subdir NAME and return a new 60 FS object which points to it. Override the default test filesystem 61 config with values from FS_CONFIG. */ 62 svn_error_t * 63 svn_test__create_fs2(svn_fs_t **fs_p, 64 const char *name, 65 const svn_test_opts_t *opts, 66 apr_hash_t *fs_config, 67 apr_pool_t *pool); 68 69 /* The same as svn_test__create_fs2() but with FS_CONFIG set to NULL. */ 70 svn_error_t * 71 svn_test__create_fs(svn_fs_t **fs_p, 72 const char *name, 73 const svn_test_opts_t *opts, 74 apr_pool_t *pool); 75 76 77 /* Create a repository with a filesystem based on OPTS in a subdir NAME 78 and return a new REPOS object which points to it. */ 79 svn_error_t * 80 svn_test__create_repos(svn_repos_t **repos_p, 81 const char *name, 82 const svn_test_opts_t *opts, 83 apr_pool_t *pool); 84 85 /* Create a repository with a filesystem based on OPTS in a subdir NAME 86 and return optionally new REPOS object, the directory it was created in 87 and/or the url of the repository . */ 88 svn_error_t * 89 svn_test__create_repos2(svn_repos_t **repos_p, 90 const char **repos_url, 91 const char **repos_dirent, 92 const char *name, 93 const svn_test_opts_t *opts, 94 apr_pool_t *result_pool, 95 apr_pool_t *scratch_pool); 96 97 98 /* Read all data from a generic read STREAM, and return it in STRING. 99 Allocate the svn_stringbuf_t in POOL. (All data in STRING will be 100 dup'ed from STREAM using POOL too.) */ 101 svn_error_t * 102 svn_test__stream_to_string(svn_stringbuf_t **string, 103 svn_stream_t *stream, 104 apr_pool_t *pool); 105 106 107 /* Set the contents of file in PATH under ROOT to CONTENTS. */ 108 svn_error_t * 109 svn_test__set_file_contents(svn_fs_root_t *root, 110 const char *path, 111 const char *contents, 112 apr_pool_t *pool); 113 114 115 /* Get the contents of file in PATH under ROOT, and copy them into 116 STR. */ 117 svn_error_t * 118 svn_test__get_file_contents(svn_fs_root_t *root, 119 const char *path, 120 svn_stringbuf_t **str, 121 apr_pool_t *pool); 122 123 124 125 /* The Helper Functions to End All Helper Functions */ 126 127 /* Given a transaction or revision root (ROOT), check to see if the 128 tree that grows from that root has all the path entries, and only 129 those entries, passed in the array ENTRIES (which is an array of 130 NUM_ENTRIES svn_test__tree_entry_t's). */ 131 svn_error_t * 132 svn_test__validate_tree(svn_fs_root_t *root, 133 svn_test__tree_entry_t *entries, 134 int num_entries, 135 apr_pool_t *pool); 136 137 /* Verify that svn_fs_paths_changed3(ROOT) returns a hash with exactly 138 the same keys as EXPECTED_KEYS. Values are not currently verified. 139 */ 140 svn_error_t * 141 svn_test__validate_changes(svn_fs_root_t *root, 142 apr_hash_t *expected_keys, 143 apr_pool_t *pool); 144 145 /* Structure for describing script-ish commands to perform on a 146 transaction using svn_test__txn_script_exec(). */ 147 typedef struct svn_test__txn_script_command_t 148 { 149 /* command: 150 151 'a' -- add (PARAM1 is file contents, or NULL for directories) 152 'c' -- copy (PARAM1 is target path, copy source is youngest rev) 153 'd' -- delete 154 'e' -- edit (PARAM1 is new file contents) 155 */ 156 int cmd; 157 const char *path; /* path to resource in the filesystem */ 158 const char *param1; /* command parameter (see above) */ 159 } 160 svn_test__txn_script_command_t; 161 162 163 /* Execute a "script" SCRIPT on items under TXN_ROOT. */ 164 svn_error_t * 165 svn_test__txn_script_exec(svn_fs_root_t *txn_root, 166 svn_test__txn_script_command_t *script, 167 int num_edits, 168 apr_pool_t *pool); 169 170 /* Verify that the tree that exists under ROOT is exactly the Greek 171 Tree. */ 172 svn_error_t * 173 svn_test__check_greek_tree(svn_fs_root_t *root, 174 apr_pool_t *pool); 175 176 177 /* Create the Greek Tree under TXN_ROOT. See ./greek-tree.txt. */ 178 svn_error_t * 179 svn_test__create_greek_tree(svn_fs_root_t *txn_root, 180 apr_pool_t *pool); 181 182 /* Create the Greek Tree under TXN_ROOT at dir ROOT_DIR. 183 * ROOT_DIR should be created by the caller. 184 * 185 * Note: this function will not commit the transaction. */ 186 svn_error_t * 187 svn_test__create_greek_tree_at(svn_fs_root_t *txn_root, 188 const char *root_dir, 189 apr_pool_t *pool); 190 191 /* Create a new repository with a greek tree, trunk, branch and some 192 merges between them. */ 193 svn_error_t * 194 svn_test__create_blame_repository(svn_repos_t **out_repos, 195 const char *test_name, 196 const svn_test_opts_t *opts, 197 apr_pool_t *pool); 198 199 #ifdef __cplusplus 200 } 201 #endif /* __cplusplus */ 202 203 #endif /* SVN_TEST_FS_H */ 204