Main Page | Modules | Data Structures | File List | Data Fields | Globals

svn_test.h

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

Generated on Wed Oct 13 23:55:34 2004 for Subversion by doxygen 1.3.4