00001 /* 00002 * ==================================================================== 00003 * Copyright (c) 2000-2004 CollabNet. All rights reserved. 00004 * 00005 * This software is licensed as described in the file COPYING, which 00006 * you should have received as part of this distribution. The terms 00007 * are also available at http://subversion.tigris.org/license-1.html. 00008 * If newer versions of this license are posted there, you may use a 00009 * newer version instead, at your option. 00010 * 00011 * This software consists of voluntary contributions made by many 00012 * individuals. For exact contribution history, see the revision 00013 * history and logs, available at http://subversion.tigris.org/. 00014 * ==================================================================== 00015 */ 00016 00017 #ifndef SVN_TEST_H 00018 #define SVN_TEST_H 00019 00020 #include <apr_pools.h> 00021 #include "svn_delta.h" 00022 #include "svn_path.h" 00023 #include "svn_types.h" 00024 #include "svn_error.h" 00025 #include "svn_string.h" 00026 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif /* __cplusplus */ 00031 00032 00033 /* Baton for any arguments that need to be passed from main() to svn 00034 * test functions. 00035 */ 00036 typedef struct svn_test_opts_t 00037 { 00038 /* Description of the fs backend that should be used for testing. */ 00039 const char *fs_type; 00040 /* Add future "arguments" here. */ 00041 } svn_test_opts_t; 00042 00043 /* Prototype for test driver functions. */ 00044 typedef svn_error_t* (*svn_test_driver_t) (const char **msg, 00045 svn_boolean_t msg_only, 00046 svn_test_opts_t *opts, 00047 apr_pool_t *pool); 00048 00049 /* Test modes. */ 00050 enum svn_test_mode_t 00051 { 00052 svn_test_pass, 00053 svn_test_xfail, 00054 svn_test_skip 00055 }; 00056 00057 /* Each test gets a test descriptor, holding the function and other 00058 * associated data. 00059 */ 00060 struct svn_test_descriptor_t 00061 { 00062 /* A pointer to the test driver function. */ 00063 svn_test_driver_t func; 00064 00065 /* Is the test marked XFAIL? */ 00066 enum svn_test_mode_t mode; 00067 }; 00068 00069 /* All Subversion test programs include an array of svn_test_descriptor_t's 00070 * (all of our sub-tests) that begins and ends with a SVN_TEST_NULL entry. 00071 */ 00072 extern struct svn_test_descriptor_t test_funcs[]; 00073 00074 /* A null initializer for the test descriptor. */ 00075 #define SVN_TEST_NULL {NULL, 0} 00076 00077 /* Initializer for PASS tests */ 00078 #define SVN_TEST_PASS(func) {func, svn_test_pass} 00079 00080 /* Initializer for XFAIL tests */ 00081 #define SVN_TEST_XFAIL(func) {func, svn_test_xfail} 00082 00083 /* Initializer for SKIP tests */ 00084 #define SVN_TEST_SKIP(func, p) {func, ((p) ? svn_test_skip : svn_test_pass)} 00085 00086 00087 /* Return a pseudo-random number based on SEED, and modify SEED. 00088 * 00089 * This is a "good" pseudo-random number generator, intended to replace 00090 * all those "bad" @c rand() implementations out there. 00091 */ 00092 apr_uint32_t svn_test_rand (apr_uint32_t *seed); 00093 00094 00095 /* Add PATH to the test cleanup list. */ 00096 void svn_test_add_dir_cleanup (const char *path); 00097 00098 00099 00100 /* Set *EDITOR and *EDIT_BATON to an editor that prints its 00101 * arguments to OUT_STREAM. The edit starts at PATH, that is, 00102 * PATH will be prepended to the appropriate paths in the output. 00103 * Allocate the editor in POOL. 00104 * 00105 * EDITOR_NAME is a name for the editor, a string that will be 00106 * prepended to the editor output as shown below. EDITOR_NAME may 00107 * be the empty string (but it may not be null). 00108 * 00109 * VERBOSE is a flag for specifying whether or not your want all the 00110 * nitty gritty details displayed. When VERBOSE is FALSE, each 00111 * editor function will print only a one-line summary. 00112 * 00113 * INDENTATION is the number of spaces to indent by at each level; use 00114 * 0 for no indentation. The indent level is always the same for a 00115 * given call (i.e, stack frame). 00116 * 00117 * SOME EXAMPLES 00118 * 00119 * With an indentation of 3, editor name of "COMMIT-TEST" and with 00120 * VERBOSE = TRUE 00121 * 00122 * [COMMIT-TEST] open_root (wc) 00123 * base_revision: 1 00124 * [COMMIT-TEST] open_directory (wc/A) 00125 * parent: wc 00126 * base_revision: 1 00127 * [COMMIT-TEST] delete_entry (wc/A/B) 00128 * [COMMIT-TEST] open_file (wc/A/mu) 00129 * parent: wc/A 00130 * base_revision: 1 00131 * [COMMIT-TEST] change_file_prop (wc/A/mu) 00132 * name: foo 00133 * value: bar 00134 * [COMMIT-TEST] close_file (wc/A/mu) 00135 * [COMMIT-TEST] close_directory (wc/A) 00136 * [COMMIT-TEST] add_file (wc/zeta) 00137 * parent: wc 00138 * copyfrom_path: 00139 * copyfrom_revision: 0 00140 * [COMMIT-TEST] open_file (wc/iota) 00141 * parent: wc 00142 * base_revision: 1 00143 * [COMMIT-TEST] close_directory (wc) 00144 * [COMMIT-TEST] apply_textdelta (wc/iota) 00145 * [COMMIT-TEST] window_handler (2 ops) 00146 * (1) new text: length 11 00147 * (2) source text: offset 0, length 0 00148 * [COMMIT-TEST] window_handler (EOT) 00149 * [COMMIT-TEST] close_file (wc/iota) 00150 * [COMMIT-TEST] apply_textdelta (wc/zeta) 00151 * [COMMIT-TEST] window_handler (1 ops) 00152 * (1) new text: length 11 00153 * [COMMIT-TEST] window_handler (EOT) 00154 * [COMMIT-TEST] close_file (wc/zeta) 00155 * [COMMIT-TEST] close_edit 00156 * 00157 * The same example as above, but with verbose = FALSE 00158 * 00159 * [COMMIT-TEST] open_root (wc) 00160 * [COMMIT-TEST] open_directory (wc/A) 00161 * [COMMIT-TEST] delete_entry (wc/A/B) 00162 * [COMMIT-TEST] open_file (wc/A/mu) 00163 * [COMMIT-TEST] change_file_prop (wc/A/mu) 00164 * [COMMIT-TEST] close_file (wc/A/mu) 00165 * [COMMIT-TEST] close_directory (wc/A) 00166 * [COMMIT-TEST] add_file (wc/zeta) 00167 * [COMMIT-TEST] open_file (wc/iota) 00168 * [COMMIT-TEST] close_directory (wc) 00169 * [COMMIT-TEST] apply_textdelta (wc/iota) 00170 * [COMMIT-TEST] close_file (wc/iota) 00171 * [COMMIT-TEST] apply_textdelta (wc/zeta) 00172 * [COMMIT-TEST] close_file (wc/zeta) 00173 * [COMMIT-TEST] close_edit 00174 * 00175 */ 00176 svn_error_t *svn_test_get_editor (const svn_delta_editor_t **editor, 00177 void **edit_baton, 00178 const char *editor_name, 00179 svn_stream_t *out_stream, 00180 int indentation, 00181 svn_boolean_t verbose, 00182 const char *path, 00183 apr_pool_t *pool); 00184 00185 #ifdef __cplusplus 00186 } 00187 #endif /* __cplusplus */ 00188 00189 #endif /* SVN_TEST_H */