From 6be7286b5a5ecc708ac8778be1d4532b37c2330c Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Fri, 16 Jul 2010 12:24:58 -0700 Subject: [PATCH] Verify that servers have started up by reading their pid file. --- tests/server.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/server.c b/tests/server.c index 58a9d276..c0521e5b 100644 --- a/tests/server.c +++ b/tests/server.c @@ -26,6 +26,8 @@ #include #include #include +#include + #include "server.h" void server_startup(server_startup_st *construct) @@ -93,6 +95,39 @@ void server_startup(server_startup_st *construct) } *end_ptr= 0; + for (uint32_t x= 0; x < construct->count; x++) + { + uint32_t counter= 3; + char buffer[1024]; /* Nothing special for number */ + + snprintf(buffer, sizeof(buffer), "/tmp/%umemc.pid", x); + + while (--counter) + { + int memcached_pid; + + FILE *file; + file= fopen(buffer, "r"); + if (file == NULL) + { + struct timespec req= { .tv_sec= 0, .tv_nsec= 5000 }; + nanosleep(&req, NULL); + + continue; + } + char *found= fgets(buffer, sizeof(buffer), file); + if (!found) + { + abort(); + } + // Yes, we currently pitch this and don't make use of it. + memcached_pid= atoi(buffer); + fclose(file); + } + + + } + construct->server_list= strdup(server_string_buffer); } printf("servers %s\n", construct->server_list); -- 2.30.2