1
/* Gearman server and library
2
* Copyright (C) 2008 Brian Aker, Eric Day
5
* Use and distribution licensed under the BSD license. See
6
* the COPYING file in the parent directory for full text.
17
#include "test_worker.h"
19
pid_t test_worker_start(in_port_t port, const char *function_name,
20
gearman_worker_fn *function, const void *function_arg)
23
gearman_worker_st worker;
26
assert(worker_pid != -1);
30
assert(gearman_worker_create(&worker) != NULL);
31
assert(gearman_worker_add_server(&worker, NULL, port) == GEARMAN_SUCCESS);
32
assert(gearman_worker_add_function(&worker, function_name, 0, function,
33
function_arg) == GEARMAN_SUCCESS);
36
gearman_return_t ret= gearman_worker_work(&worker);
37
assert(ret == GEARMAN_SUCCESS);
40
/* TODO: unreachable - the only way out of the loop above is the assert
41
* gearman_worker_free(&worker);
47
/* Wait for the server to start and bind the port. */
54
void test_worker_stop(pid_t worker_pid)
56
assert(kill(worker_pid, SIGKILL) == 0);
57
assert(waitpid(worker_pid, NULL, 0) == worker_pid);