projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
libmemcached: fix #53 with supplied patch
[awesomized/libmemcached]
/
tests
/
memcat.cc
diff --git
a/tests/memcat.cc
b/tests/memcat.cc
index e8ed3efcb59346a6cc7f23fefff25060db4cbaac..3b3b021fd1fa7453012b3c82da603f655d20ace5 100644
(file)
--- a/
tests/memcat.cc
+++ b/
tests/memcat.cc
@@
-39,10
+39,10
@@
Test that we are cycling the servers we are creating during testing.
*/
Test that we are cycling the servers we are creating during testing.
*/
-#include <config.h>
+#include <
mem_
config.h>
#include <libtest/test.hpp>
#include <libtest/test.hpp>
-#include <libmemcached/memcached.h>
+#include <libmemcached
-1.0
/memcached.h>
using namespace libtest;
using namespace libtest;
@@
-50,31
+50,24
@@
using namespace libtest;
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
-static std::string executable;
-
-static test_return_t quiet_test(void *)
-{
- const char *args[]= { "--quiet", 0 };
-
- test_true(exec_cmdline(executable, args));
- return TEST_SUCCESS;
-}
+static std::string executable("clients/memcat");
static test_return_t help_test(void *)
{
static test_return_t help_test(void *)
{
- const char *args[]= { "--quiet", "--help", 0 };
+ const char *args[]= { "--help", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
static test_return_t cat_test(void *)
{
char buffer[1024];
return TEST_SUCCESS;
}
static test_return_t cat_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= {
"--quiet",
buffer, "foo", 0 };
+
int length=
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ const char *args[]= { buffer, "foo", 0 };
- memcached_st *memc= memcached(buffer,
strlen(buffer)
);
+ memcached_st *memc= memcached(buffer,
length
);
test_true(memc);
test_compare(MEMCACHED_SUCCESS,
test_true(memc);
test_compare(MEMCACHED_SUCCESS,
@@
-84,7
+77,8
@@
static test_return_t cat_test(void *)
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
- test_true(exec_cmdline(executable, args));
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
@@
-97,11
+91,11
@@
static test_return_t cat_test(void *)
static test_return_t NOT_FOUND_test(void *)
{
char buffer[1024];
static test_return_t NOT_FOUND_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= {
"--quiet",
buffer, "foo", 0 };
+
int length=
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ const char *args[]= { buffer, "foo", 0 };
- memcached_st *memc= memcached(buffer,
strlen(buffer)
);
-
test_true
(memc);
+ memcached_st *memc= memcached(buffer,
length
);
+
ASSERT_TRUE
(memc);
test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0));
test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0));
@@
-109,7
+103,8
@@
static test_return_t NOT_FOUND_test(void *)
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
- test_true(exec_cmdline(executable, args));
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
@@
-120,7
+115,6
@@
static test_return_t NOT_FOUND_test(void *)
}
test_st memcat_tests[] ={
}
test_st memcat_tests[] ={
- {"--quiet", true, quiet_test },
{"--help", true, help_test },
{"cat(FOUND)", true, cat_test },
{"cat(NOT_FOUND)", true, NOT_FOUND_test },
{"--help", true, help_test },
{"cat(FOUND)", true, cat_test },
{"cat(NOT_FOUND)", true, NOT_FOUND_test },
@@
-134,14
+128,13
@@
collection_st collection[] ={
static void *world_create(server_startup_st& servers, test_return_t& error)
{
static void *world_create(server_startup_st& servers, test_return_t& error)
{
- if (
HAVE_MEMCACHED_BINARY == 0
)
+ if (
libtest::has_memcached() == false
)
{
{
- error= TEST_
FATAL
;
+ error= TEST_
SKIPPED
;
return NULL;
}
return NULL;
}
- const char *argv[1]= { "memcat" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), NULL))
{
error= TEST_FAILURE;
}
{
error= TEST_FAILURE;
}
@@
-150,10
+143,9
@@
static void *world_create(server_startup_st& servers, test_return_t& error)
}
}
-void get_world(
Framework *
world)
+void get_world(
libtest::Framework*
world)
{
{
- executable= "clients/memcat";
- world->collections= collection;
- world->_create= world_create;
+ world->collections(collection);
+ world->create(world_create);
}
}