1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 3 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 Framework is the structure which is passed to the test implementation to be filled.
28 This must be implemented in order for the test framework to load the tests. We call
29 get_world() in order to fill this structure.
34 collection_st
*collections
;
36 /* These methods are called outside of any collection call. */
37 test_callback_create_fn
*_create
;
38 test_callback_destroy_fn
*_destroy
;
40 /* This is called a the beginning of any collection run. */
41 test_callback_fn
*collection_startup
;
43 /* This is called a the end of any collection run. */
44 test_callback_fn
*collection_shutdown
;
46 void set_collection_shutdown(test_callback_error_fn
*arg
)
52 void* create(test_return_t
& arg
);
54 test_return_t
startup(void*);
56 test_return_t
shutdown(void* arg
)
58 if (collection_shutdown
)
60 return collection_shutdown(arg
);
67 These are run before/after the test. If implemented. Their execution is not controlled
72 /* This is called a the beginning of any run. */
73 test_callback_fn
*_startup
;
75 test_return_t
startup(void*);
78 This called on a test if the test requires a flush call (the bool is
81 test_callback_fn
*_flush
;
85 Run before and after the runnner is executed.
87 test_callback_fn
*pre_run
;
88 test_callback_fn
*post_run
;
99 void set_startup(test_callback_fn
*arg
)
104 void set_collection(test_callback_fn
*arg
)
109 void set_flush(test_callback_fn
*arg
)
114 void set_pre(test_callback_fn
*arg
)
119 void set_post(test_callback_fn
*arg
)
124 test_return_t
pre(void *arg
);
125 test_return_t
flush(void* arg
, test_st
* run
);
126 test_return_t
post(void *arg
);
131 If an error occurs during the test, this is called.
133 test_callback_error_fn
*_on_error
;
135 void set_on_error(test_callback_error_fn
*arg
)
140 test_return_t
on_error(const enum test_return_t
, void *);
144 _servers
.set_socket();
147 void set_sasl(const std::string
& username_arg
, const std::string
& password_arg
)
149 _servers
.set_sasl(username_arg
, password_arg
);
152 libtest::server_startup_st
& servers()
158 Runner represents the callers for the tests. If not implemented we will use
159 a set of default implementations.
161 libtest::Runner
*_runner
;
163 void set_runner(libtest::Runner
*arg
)
168 libtest::Runner
*runner();
173 virtual ~Framework();
175 Framework(const Framework
&);
178 Framework
& operator=(const Framework
&);
179 libtest::server_startup_st _servers
;
182 unsigned long int _servers_to_run
;