Fixes to test memcp
[awesomized/libmemcached] / tests / memcp.cc
index 8aba60883cc5d66f39b38b46a3739491aa2a58a5..7fca2d3621ad22662606da303051a0155a2603d5 100644 (file)
   Test that we are cycling the servers we are creating during testing.
 */
 
-#include <config.h>
+#include <mem_config.h>
 
 #include <libtest/test.hpp>
-#include <libmemcached/memcached.h>
+#include <libmemcached-1.0/memcached.h>
+
+#include <sys/stat.h>
 
 using namespace libtest;
 
@@ -63,11 +65,20 @@ static test_return_t help_test(void *)
 
 static test_return_t server_test(void *)
 {
+  int fd;
+  std::string tmp_file= create_tmpfile("memcp", fd);
+  ASSERT_TRUE(tmp_file.c_str());
+  struct stat buf;
+  ASSERT_EQ(fstat(fd, &buf), 0);
+  ASSERT_EQ(buf.st_size, 0);
+
   char buffer[1024];
   snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
-  const char *args[]= { buffer, 0 };
+  const char *args[]= { buffer, tmp_file.c_str(), 0 };
 
   test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
+  close(fd);
+  unlink(tmp_file.c_str());
 
   return TEST_SUCCESS;
 }
@@ -85,13 +96,13 @@ collection_st collection[] ={
 
 static void *world_create(server_startup_st& servers, test_return_t& error)
 {
-  if (HAVE_MEMCACHED_BINARY == 0)
+  if (libtest::has_memcached() == false)
   {
     error= TEST_SKIPPED;
     return NULL;
   }
 
-  if (server_startup(servers, "memcached", libtest::default_port(), 0, NULL) == false)
+  if (server_startup(servers, "memcached", libtest::default_port(), NULL) == false)
   {
     error= TEST_FAILURE;
   }
@@ -100,7 +111,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error)
 }
 
 
-void get_world(Framework *world)
+void get_world(libtest::Framework* world)
 {
   world->collections(collection);
   world->create(world_create);