~clint-fewbar/ubuntu/precise/gearmand/drop-unneeded-patches

« back to all changes in this revision

Viewing changes to tests/drizzle_test.cc

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen, Michael Fladischer, Stig Sandbeck Mathisen
  • Date: 2012-01-23 11:31:08 UTC
  • mfrom: (6.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120123113108-wl1yhiba13q9jusb
Tags: 0.27-1
[Michael Fladischer]
* Patch: fix spelling
* Patch: remove dependency on googleanalytics
* Patch: fix tests
* Use non-authenticating URL for Vcs-Git.
* Add "status" action to init script.

[Stig Sandbeck Mathisen]
* New upstream release (Closes: #621486) (LP: #682680)
* Remove build dependency on drizzle
  (until it reaches testing again)
* Build with support for tokyocabinet
* Remove backported ipv6 patch
* Patch: disable hostile build tests, they take hours...
* Patch: workaround duplicate address issue for tests
* Do not build API documentation, the sources are not shipped in
  upstream tarball
* Update debian/copyright

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Gearman server and library
 
2
 * Copyright (C) 2008 Brian Aker, Eric Day
 
3
 * All rights reserved.
 
4
 *
 
5
 * Use and distribution licensed under the BSD license.  See
 
6
 * the COPYING file in the parent directory for full text.
 
7
 */
 
8
 
 
9
#include <config.h>
 
10
#include <libtest/test.hpp>
 
11
 
 
12
using namespace libtest;
 
13
 
 
14
#include <cassert>
 
15
#include <cstdio>
 
16
#include <cstdlib>
 
17
#include <cstring>
 
18
#include <unistd.h>
 
19
 
 
20
#include <libgearman/gearman.h>
 
21
 
 
22
#include <tests/basic.h>
 
23
#include <tests/context.h>
 
24
 
 
25
#include <tests/ports.h>
 
26
 
 
27
#define WORKER_FUNCTION "drizzle_queue_test"
 
28
 
 
29
#if defined(HAVE_LIBDRIZZLE) && HAVE_LIBDRIZZLE
 
30
#include <libdrizzle-1.0/drizzle_client.h>
 
31
#endif
 
32
 
 
33
static bool ping_drizzled(void)
 
34
{
 
35
#if defined(HAVE_LIBDRIZZLE) && HAVE_LIBDRIZZLE
 
36
  if (HAVE_LIBDRIZZLE)
 
37
  {
 
38
    drizzle_st *drizzle= drizzle_create(NULL);
 
39
 
 
40
    if (drizzle == NULL)
 
41
    {
 
42
      return false;
 
43
    }
 
44
 
 
45
    drizzle_con_st *con;
 
46
 
 
47
    if ((con= drizzle_con_create(drizzle, NULL)) == NULL)
 
48
    {
 
49
      drizzle_free(drizzle);
 
50
      return false;
 
51
    }
 
52
 
 
53
    drizzle_con_set_tcp(con, NULL, 0);
 
54
    drizzle_con_set_auth(con, "root", 0);
 
55
    drizzle_return_t rc;
 
56
    drizzle_result_st *result= drizzle_ping(con, NULL, &rc);
 
57
 
 
58
    bool success= bool(result);
 
59
 
 
60
    drizzle_result_free(result);
 
61
    drizzle_con_free(con);
 
62
    drizzle_free(drizzle);
 
63
 
 
64
    return success;
 
65
  }
 
66
#endif
 
67
 
 
68
  return false;
 
69
}
 
70
 
 
71
#ifndef __INTEL_COMPILER
 
72
#pragma GCC diagnostic ignored "-Wold-style-cast"
 
73
#endif
 
74
 
 
75
static test_return_t gearmand_basic_option_test(void *)
 
76
{
 
77
  const char *args[]= { "--check-args", 
 
78
    "--libdrizzle-host=127.0.0.1",
 
79
    "--libdrizzle-port=90",
 
80
    "--libdrizzle-uds=tmp/foo.socket",
 
81
    "--libdrizzle-user=root",
 
82
    "--libdrizzle-password=test",
 
83
    "--libdrizzle-db=gearman",
 
84
    "--libdrizzle-table=gearman",
 
85
    "--libdrizzle-mysql",
 
86
    0 };
 
87
 
 
88
  test_compare(EXIT_SUCCESS, exec_cmdline(gearmand_binary(), args, true));
 
89
  return TEST_SUCCESS;
 
90
}
 
91
 
 
92
static test_return_t collection_init(void *object)
 
93
{
 
94
  Context *test= (Context *)object;
 
95
  assert(test);
 
96
 
 
97
  const char *argv[]= { "test_gearmand", "--queue-type=libdrizzle", 0 };
 
98
 
 
99
  test->initialize(2, argv);
 
100
 
 
101
  return TEST_SUCCESS;
 
102
}
 
103
 
 
104
static test_return_t collection_cleanup(void *object)
 
105
{
 
106
  Context *test= (Context *)object;
 
107
  test->reset();
 
108
 
 
109
  return TEST_SUCCESS;
 
110
}
 
111
 
 
112
 
 
113
static void *world_create(server_startup_st& servers, test_return_t& error)
 
114
{
 
115
  if (has_drizzle_support() == false)
 
116
  {
 
117
    error= TEST_SKIPPED;
 
118
    return NULL;
 
119
  }
 
120
 
 
121
  if (HAVE_LIBDRIZZLE)
 
122
  {
 
123
    if (ping_drizzled() == false)
 
124
    {
 
125
      error= TEST_SKIPPED;
 
126
      return NULL;
 
127
    }
 
128
  }
 
129
 
 
130
  Context *test= new Context(DRIZZLE_TEST_PORT, servers);
 
131
  if (not test)
 
132
  {
 
133
    error= TEST_MEMORY_ALLOCATION_FAILURE;
 
134
    return NULL;
 
135
  }
 
136
 
 
137
  error= TEST_SUCCESS;
 
138
 
 
139
  return test;
 
140
}
 
141
 
 
142
static bool world_destroy(void *object)
 
143
{
 
144
  Context *test= (Context *)object;
 
145
 
 
146
  delete test;
 
147
 
 
148
  return TEST_SUCCESS;
 
149
}
 
150
 
 
151
test_st gearmand_basic_option_tests[] ={
 
152
  {"all options", 0, gearmand_basic_option_test },
 
153
  {0, 0, 0}
 
154
};
 
155
 
 
156
test_st tests[] ={
 
157
  {"gearman_client_echo()", 0, client_echo_test },
 
158
  {"gearman_client_echo() fail", 0, client_echo_fail_test },
 
159
  {"gearman_worker_echo()", 0, worker_echo_test },
 
160
  {"clean", 0, queue_clean },
 
161
  {"add", 0, queue_add },
 
162
  {"worker", 0, queue_worker },
 
163
  {0, 0, 0}
 
164
};
 
165
 
 
166
test_st regressions[] ={
 
167
  {"lp:734663", 0, lp_734663 },
 
168
  {0, 0, 0}
 
169
};
 
170
 
 
171
collection_st collection[] ={
 
172
  {"drizzle queue", collection_init, collection_cleanup, tests},
 
173
  {"regressions", collection_init, collection_cleanup, regressions},
 
174
  {0, 0, 0, 0}
 
175
};
 
176
 
 
177
void get_world(Framework *world)
 
178
{
 
179
  world->collections= collection;
 
180
  world->_create= world_create;
 
181
  world->_destroy= world_destroy;
 
182
}