1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* Gearman server and library
* Copyright (C) 2011 Data Differential, http://datadifferential.com/
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*/
#include "gear_config.h"
#include <libtest/test.hpp>
using namespace libtest;
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <libgearman/gearman.h>
#include <tests/basic.h>
#include <tests/context.h>
#ifndef __INTEL_COMPILER
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
static test_return_t collection_init(void *object)
{
Context *test= (Context *)object;
ASSERT_TRUE(test);
ASSERT_TRUE(test->initialize(NULL));
return TEST_SUCCESS;
}
static test_return_t collection_cleanup(void *object)
{
Context *test= (Context *)object;
ASSERT_TRUE(test);
test->reset();
return TEST_SUCCESS;
}
static void *world_create(server_startup_st& servers, test_return_t&)
{
return new Context(servers);
}
static bool world_destroy(void *object)
{
Context *test= (Context *)object;
delete test;
return TEST_SUCCESS;
}
test_st tests[] ={
{"gearman_client_echo()", 0, client_echo_test },
{"gearman_client_echo() fail", 0, client_echo_fail_test },
{"gearman_worker_echo()", 0, worker_echo_test },
{"clean", 0, queue_clean },
{"add", 0, queue_add },
{"worker", 0, queue_worker },
{0, 0, 0}
};
collection_st collection[] ={
{"ephemeral queue", collection_init, collection_cleanup, tests},
{0, 0, 0, 0}
};
void get_world(libtest::Framework *world)
{
world->collections(collection);
world->create(world_create);
world->destroy(world_destroy);
}
|