2 Startup, and shutdown the memcached servers.
5 #define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT+10
11 #include <memcached.h>
15 void server_startup(server_startup_st
*construct
)
19 if ((construct
->server_list
= getenv("MEMCACHED_SERVERS")))
21 printf("servers %s\n", construct
->server_list
);
22 construct
->servers
= memcached_servers_parse(construct
->server_list
);
23 construct
->server_list
= NULL
;
29 char server_string_buffer
[8096];
31 end_ptr
= server_string_buffer
;
33 for (x
= 0; x
< construct
->count
; x
++)
35 char buffer
[1024]; /* Nothing special for number */
40 sprintf(buffer
, "memcached -d -P /tmp/%umemc.pid -t 1 -U %u", x
, x
+ TEST_PORT_BASE
);
42 sprintf(buffer
, "memcached -d -P /tmp/%umemc.pid -t 1 -p %u", x
, x
+ TEST_PORT_BASE
);
43 status
= system(buffer
);
44 WATCHPOINT_ASSERT(status
== 0);
45 count
= sprintf(end_ptr
, "localhost:%u,", x
+ TEST_PORT_BASE
);
50 construct
->server_list
= strdup(server_string_buffer
);
52 printf("servers %s\n", construct
->server_list
);
53 construct
->servers
= memcached_servers_parse(construct
->server_list
);
56 assert(construct
->servers
);
60 for (x
= 0; x
< memcached_server_list_count(construct
->servers
); x
++)
62 printf("\t%s : %u\n", construct
->servers
[x
].hostname
, construct
->servers
[x
].port
);
63 assert(construct
->servers
[x
].fd
== -1);
64 assert(construct
->servers
[x
].cursor_active
== 0);
70 void server_shutdown(server_startup_st
*construct
)
74 if (construct
->server_list
)
76 for (x
= 0; x
< construct
->count
; x
++)
78 char buffer
[1024]; /* Nothing special for number */
79 sprintf(buffer
, "cat /tmp/%umemc.pid | xargs kill", x
);
82 sprintf(buffer
, "/tmp/%umemc.pid", x
);
86 free(construct
->server_list
);