1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
19 * * The names of its contributors may not be used to endorse or
20 * promote products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 Framework is the structure which is passed to the test implementation to be filled.
42 This must be implemented in order for the test framework to load the tests. We call
43 get_world() in order to fill this structure.
48 collection_st
*collections
;
50 /* These methods are called outside of any collection call. */
51 test_callback_create_fn
*_create
;
52 test_callback_destroy_fn
*_destroy
;
54 /* This is called a the beginning of any collection run. */
55 test_callback_fn
*collection_startup
;
57 /* This is called a the end of any collection run. */
58 test_callback_fn
*collection_shutdown
;
60 void set_collection_shutdown(test_callback_error_fn
*arg
)
66 void* create(test_return_t
& arg
);
68 test_return_t
startup(void*);
70 test_return_t
shutdown(void* arg
)
72 if (collection_shutdown
)
74 return collection_shutdown(arg
);
81 These are run before/after the test. If implemented. Their execution is not controlled
86 /* This is called a the beginning of any run. */
87 test_callback_fn
*_startup
;
89 test_return_t
startup(void*);
92 This called on a test if the test requires a flush call (the bool is
95 test_callback_fn
*_flush
;
99 Run before and after the runnner is executed.
101 test_callback_fn
*pre_run
;
102 test_callback_fn
*post_run
;
113 void set_startup(test_callback_fn
*arg
)
118 void set_collection(test_callback_fn
*arg
)
123 void set_flush(test_callback_fn
*arg
)
128 void set_pre(test_callback_fn
*arg
)
133 void set_post(test_callback_fn
*arg
)
138 test_return_t
pre(void *arg
);
139 test_return_t
flush(void* arg
, test_st
* run
);
140 test_return_t
post(void *arg
);
145 If an error occurs during the test, this is called.
147 test_callback_error_fn
*_on_error
;
149 void set_on_error(test_callback_error_fn
*arg
)
154 test_return_t
on_error(const enum test_return_t
, void *);
157 Runner represents the callers for the tests. If not implemented we will use
158 a set of default implementations.
160 libtest::Runner
*_runner
;
162 void set_runner(libtest::Runner
*arg
)
167 libtest::Runner
*runner();
172 virtual ~Framework();
174 Framework(const Framework
&);
177 Framework
& operator=(const Framework
&);
178 libtest::server_startup_st _servers
;