value was returned.
* Bug fixed in memcached_connect() which would cause servers that
did not need to be enabled to be enabled (performance issue).
- * Rewrote bounds checking code for get calls
+ * Rewrote bounds checking code for get calls.
+ * "make test" now starts its own memcached servers.
0.10 Tue Nov 20 23:22:31 PST 2007
* Added append binary test.
return 0;
}
+/* Do not copy the style of this code, I just access hosts to testthis function */
uint8_t stats_servername_test(memcached_st *memc)
{
memcached_return rc;
memcached_stat_st stat;
rc= memcached_stat_servername(&stat, NULL,
- "localhost",
- MEMCACHED_DEFAULT_PORT);
+ memc->hosts[0].hostname,
+ memc->hosts[0].port);
return 0;
}
#include "test.h"
+#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT+10
+#define TEST_SERVERS 1
+
long int timedif(struct timeval a, struct timeval b)
{
register int us, s;
return s + us;
}
+char *server_startup()
+{
+ unsigned int x;
+ char server_string_buffer[8096];
+ char *end_ptr;
+
+ end_ptr= server_string_buffer;
+
+ for (x= 0; x < TEST_SERVERS; x++)
+ {
+ char buffer[1024]; /* Nothing special for number */
+ int count;
+
+ sprintf(buffer, "memcached -d -P /tmp/%umemc.pid -p %u", x, x+ TEST_PORT_BASE);
+ system(buffer);
+ count= sprintf(end_ptr, "localhost:%u,", x + TEST_PORT_BASE);
+ end_ptr+= count;
+ }
+ *end_ptr= 0;
+
+ return strdup(server_string_buffer);
+}
+
+void server_shutdown(char *server_string)
+{
+ unsigned int x;
+
+ for (x= 0; x < TEST_SERVERS; x++)
+ {
+ char buffer[1024]; /* Nothing special for number */
+ sprintf(buffer, "cat /tmp/%umemc.pid | xargs kill", x);
+ system(buffer);
+ }
+ if (server_string)
+ free(server_string);
+}
+
int main(int argc, char *argv[])
{
unsigned int x;
if (argc == 3)
wildcard= argv[2];
- if (!(server_list= getenv("MEMCACHED_SERVERS")))
- server_list= "localhost";
+ if ((server_list= getenv("MEMCACHED_SERVERS")))
+ {
+ printf("servers %s\n", server_list);
+ servers= memcached_servers_parse(server_list);
+ server_list= NULL;
+ }
+ else
+ {
+ server_list= server_startup();
+ printf("servers %s\n", server_list);
+ servers= memcached_servers_parse(server_list);
+ }
+ assert(servers);
- printf("servers %s\n", server_list);
srandom(time(NULL));
- servers= memcached_servers_parse(server_list);
- assert(servers);
for (x= 0; x < memcached_server_list_count(servers); x++)
{
memcached_server_list_free(servers);
+ server_shutdown(server_list);
+
return 0;
}