From: Brian Aker Date: Thu, 29 Jul 2010 19:56:37 +0000 (-0700) Subject: Testing the hudson port changing feature. X-Git-Tag: 0.44~8 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=03982cb00168ed0b3fc06d063c29076a9ffe1699;hp=55e0ec6389a0d13dde237552cfef6b83b4728e3f;p=awesomized%2Flibmemcached Testing the hudson port changing feature. --- diff --git a/tests/server.c b/tests/server.c index f8d06dbf..70c0ae3b 100644 --- a/tests/server.c +++ b/tests/server.c @@ -51,6 +51,23 @@ void server_startup(server_startup_st *construct) char buffer[1024]; /* Nothing special for number */ int count; int status; + in_port_t port; + + { + char *var; + char variable_buffer[1024]; + + snprintf(variable_buffer, sizeof(variable_buffer), "LIBMEMCACHED_PORT_%u", x); + + if ((var= getenv(variable_buffer))) + { + port= (in_port_t)atoi(var); + } + else + { + port= (in_port_t)(x + TEST_PORT_BASE); + } + } sprintf(buffer, "/tmp/%umemc.pid", x); if (access(buffer, F_OK) == 0) @@ -74,23 +91,23 @@ void server_startup(server_startup_st *construct) if (x == 0) { sprintf(buffer, "%s -d -u root -P /tmp/%umemc.pid -t 1 -p %u -U %u -m 128", - MEMCACHED_BINARY, x, x + TEST_PORT_BASE, x + TEST_PORT_BASE); + MEMCACHED_BINARY, x, port, port); } else { sprintf(buffer, "%s -d -u root -P /tmp/%umemc.pid -t 1 -p %u -U %u", - MEMCACHED_BINARY, x, x + TEST_PORT_BASE, x + TEST_PORT_BASE); + MEMCACHED_BINARY, x, port, port); } - if (libmemcached_util_ping("localhost", (in_port_t)(x + TEST_PORT_BASE), NULL)) + if (libmemcached_util_ping("localhost", port, NULL)) { - fprintf(stderr, "Server on port %u already exists\n", x + TEST_PORT_BASE); + fprintf(stderr, "Server on port %u already exists\n", port); } else { status= system(buffer); fprintf(stderr, "STARTING SERVER: %s status:%d\n", buffer, status); } - count= sprintf(end_ptr, "localhost:%u,", x + TEST_PORT_BASE); + count= sprintf(end_ptr, "localhost:%u,", port); end_ptr+= count; } *end_ptr= 0;