f5e44a9b182b8de8d8b257fd70383077ebccc274
2 Startup, and shutdown the memcached servers.
5 #define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT+10
12 #include <libmemcached/memcached.h>
16 void server_startup(server_startup_st
*construct
)
20 if ((construct
->server_list
= getenv("MEMCACHED_SERVERS")))
22 printf("servers %s\n", construct
->server_list
);
23 construct
->servers
= memcached_servers_parse(construct
->server_list
);
24 construct
->server_list
= NULL
;
30 char server_string_buffer
[8096];
32 end_ptr
= server_string_buffer
;
34 for (x
= 0; x
< construct
->count
; x
++)
36 char buffer
[1024]; /* Nothing special for number */
41 sprintf(buffer
, "memcached -d -P /tmp/%umemc.pid -t 1 -U %u", x
, x
+ TEST_PORT_BASE
);
43 sprintf(buffer
, "memcached -d -P /tmp/%umemc.pid -t 1 -p %u", x
, x
+ TEST_PORT_BASE
);
44 status
= system(buffer
);
45 WATCHPOINT_ASSERT(status
== 0);
46 count
= sprintf(end_ptr
, "localhost:%u,", x
+ TEST_PORT_BASE
);
51 construct
->server_list
= strdup(server_string_buffer
);
53 printf("servers %s\n", construct
->server_list
);
54 construct
->servers
= memcached_servers_parse(construct
->server_list
);
57 assert(construct
->servers
);
61 for (x
= 0; x
< memcached_server_list_count(construct
->servers
); x
++)
63 printf("\t%s : %u\n", construct
->servers
[x
].hostname
, construct
->servers
[x
].port
);
64 assert(construct
->servers
[x
].fd
== -1);
65 assert(construct
->servers
[x
].cursor_active
== 0);
71 void server_shutdown(server_startup_st
*construct
)
75 if (construct
->server_list
)
77 for (x
= 0; x
< construct
->count
; x
++)
79 char buffer
[1024]; /* Nothing special for number */
80 sprintf(buffer
, "cat /tmp/%umemc.pid | xargs kill", x
);
83 sprintf(buffer
, "/tmp/%umemc.pid", x
);
87 free(construct
->server_list
);