};
/* Prototypes for functions we will pass to test framework */
-void *world_create(void);
+void *world_create(test_return_t *error);
test_return_t world_destroy(hashkit_st *hashk);
-void *world_create(void)
+void *world_create(test_return_t *error)
{
hashkit_st *hashk_ptr;
hashk_ptr= hashkit_create(&global_hashk);
- assert(hashk_ptr == &global_hashk);
+ if (hashk_ptr != &global_hashk)
+ {
+ *error= TEST_FAILURE;
+ return NULL;
+ }
// First we test if hashk is even valid
- assert(hashkit_is_initialized(hashk_ptr) == true);
- assert(hashkit_is_allocated(hashk_ptr) == false);
- assert(hashk_ptr->continuum == NULL);
+ if (hashkit_is_initialized(hashk_ptr) == false)
+ {
+ *error= TEST_FAILURE;
+ return NULL;
+ }
+
+ if (hashkit_is_allocated(hashk_ptr) == true)
+ {
+ *error= TEST_FAILURE;
+ return NULL;
+ }
+
+ if (hashk_ptr->continuum != NULL)
+ {
+ *error= TEST_FAILURE;
+ return NULL;
+ }
+
+ *error= TEST_SUCCESS;
return hashk_ptr;
}
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
- *
+ *
* Description: This is the startup bits for any libmemcached test.
*
*/
} libmemcached_test_container_st;
/* Prototypes for functions we will pass to test framework */
-libmemcached_test_container_st *world_create(void);
+libmemcached_test_container_st *world_create(test_return_t *error);
test_return_t world_collection_startup(libmemcached_test_container_st *);
test_return_t world_flush(libmemcached_test_container_st *container);
test_return_t world_pre_run(libmemcached_test_container_st *);
static libmemcached_test_container_st global_container;
-libmemcached_test_container_st *world_create(void)
+libmemcached_test_container_st *world_create(test_return_t *error)
{
memset(&global_container, 0, sizeof(global_container));
global_container.construct.count= SERVERS_TO_CREATE;
global_container.construct.udp= 0;
server_startup(&global_container.construct);
- assert(global_container.construct.servers);
+ if (! global_container.construct.servers)
+ {
+ *error= TEST_FAILURE;
+ server_shutdown(&global_container.construct);
+ return NULL;
+ }
+
+ *error= TEST_SUCCESS;
return &global_container;
}
{
(void)test_state;
memcached_free(container->memc);
-
+
return TEST_SUCCESS;
}
collection= world.collections;
if (world.create)
- world_ptr= world.create();
+ {
+ test_return_t error;
+ world_ptr= world.create(&error);
+ if (error != TEST_SUCCESS)
+ exit(1);
+ }
else
+ {
world_ptr= NULL;
+ }
if (argc > 1)
collection_to_run= argv[1];
fprintf(stderr, "All tests completed successfully\n\n");
if (world.destroy)
- world.destroy(world_ptr);
+ {
+ test_return_t error;
+ error= world.destroy(world_ptr);
+
+ if (error != TEST_SUCCESS)
+ {
+ fprintf(stderr, "Failure during shutdown.\n");
+ stats.failed++; // We do this to make our exit code return 1
+ }
+ }
world_stats_print(&stats);
TEST_MAXIMUM_RETURN /* Always add new error code before */
} test_return_t;
-typedef void *(*test_callback_create_fn)(void);
+typedef void *(*test_callback_create_fn)(test_return_t *error);
typedef test_return_t (*test_callback_fn)(void *);
typedef test_return_t (*test_callback_runner_fn)(test_callback_fn, void *);
typedef test_return_t (*test_callback_error_fn)(test_return_t, void *);