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

« back to all changes in this revision

Viewing changes to tests/cycle.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
/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
2
 * 
 
3
 *  Cycle the Gearmand server
 
4
 *
 
5
 *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
 
6
 *
 
7
 *  Redistribution and use in source and binary forms, with or without
 
8
 *  modification, are permitted provided that the following conditions are
 
9
 *  met:
 
10
 *
 
11
 *      * Redistributions of source code must retain the above copyright
 
12
 *  notice, this list of conditions and the following disclaimer.
 
13
 *
 
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
 
17
 *  distribution.
 
18
 *
 
19
 *      * The names of its contributors may not be used to endorse or
 
20
 *  promote products derived from this software without specific prior
 
21
 *  written permission.
 
22
 *
 
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.
 
34
 *
 
35
 */
 
36
 
 
37
 
 
38
/*
 
39
  Test that we are cycling the servers we are creating during testing.
 
40
*/
 
41
 
 
42
#include <config.h>
 
43
#include <libtest/test.hpp>
 
44
 
 
45
using namespace libtest;
 
46
#include <libgearman/gearman.h>
 
47
 
 
48
#include "tests/ports.h"
 
49
#include "tests/start_worker.h"
 
50
 
 
51
static gearman_return_t success_fn(gearman_job_st*, void* /* context */)
 
52
{
 
53
  return GEARMAN_SUCCESS;
 
54
}
 
55
 
 
56
static test_return_t single_cycle(void *)
 
57
{
 
58
  (void)success_fn;
 
59
#if 0
 
60
  gearman_function_t success_function= gearman_function_create(success_fn);
 
61
  worker_handle_st *worker= test_worker_start(CYCLE_TEST_PORT, NULL, "success", success_function, NULL, gearman_worker_options_t());
 
62
  test_true(worker);
 
63
  test_true(worker->shutdown());
 
64
  delete worker;
 
65
#endif
 
66
 
 
67
  return TEST_SUCCESS;
 
68
}
 
69
 
 
70
static test_return_t kill_test(void *)
 
71
{
 
72
  libtest::dream(2, 0);
 
73
 
 
74
  return TEST_SUCCESS;
 
75
}
 
76
 
 
77
test_st kill_tests[] ={
 
78
  {"kill", true, (test_callback_fn*)kill_test },
 
79
  {0, 0, 0}
 
80
};
 
81
 
 
82
test_st worker_tests[] ={
 
83
  {"single startup/shutdown", true, (test_callback_fn*)single_cycle },
 
84
  {0, 0, 0}
 
85
};
 
86
 
 
87
collection_st collection[] ={
 
88
  {"kill", 0, 0, kill_tests},
 
89
  {"worker", 0, 0, worker_tests},
 
90
  {0, 0, 0, 0}
 
91
};
 
92
 
 
93
static void *world_create(server_startup_st& servers, test_return_t& error)
 
94
{
 
95
  const char *argv[1]= { "client_gearmand" };
 
96
  if (server_startup(servers, "gearmand", CYCLE_TEST_PORT, 1, argv) == false)
 
97
  {
 
98
    error= TEST_FAILURE;
 
99
  }
 
100
 
 
101
  return NULL;
 
102
}
 
103
 
 
104
void get_world(Framework *world)
 
105
{
 
106
  world->collections= collection;
 
107
  world->_create= world_create;
 
108
}
 
109