{
return int(ret);
}
- ret= app.wait();
- return int(ret);
+ return int(app.wait());
}
const char *gearmand_binary()
enum test_return_t {
TEST_SUCCESS,
TEST_FAILURE,
- TEST_MEMORY_ALLOCATION_FAILURE,
- TEST_SKIPPED,
- TEST_FATAL // Collection should not be continued
+ TEST_SKIPPED
};
case TEST_FAILURE:
return "failed";
- case TEST_MEMORY_ALLOCATION_FAILURE:
- return "memory allocation";
-
case TEST_SKIPPED:
return "skipped";
-
- case TEST_FATAL:
- break;
}
- return "failed";
+ throw fatal_message("No port could be found");
}
} // namespace libtest
delete world;
return EXIT_SUCCESS;
- case TEST_FATAL:
case TEST_FAILURE:
- case TEST_MEMORY_ALLOCATION_FAILURE:
delete world;
return EXIT_FAILURE;
}
case TEST_SUCCESS:
break;
- case TEST_FATAL:
case TEST_FAILURE:
Out << next->name << " [ failed ]";
failed= true;
skipped= true;
goto cleanup;
- case TEST_MEMORY_ALLOCATION_FAILURE:
- test_assert(0, "Allocation failure, or unknown return");
+ default:
+ throw fatal_message("invalid return code");
}
Out << "Collection: " << next->name;
stats.success++;
break;
- case TEST_FATAL:
case TEST_FAILURE:
stats.failed++;
failed= true;
Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
break;
- case TEST_MEMORY_ALLOCATION_FAILURE:
- test_assert(0, "Memory Allocation Error");
+ default:
+ throw fatal_message("invalid return code");
}
if (test_failed(world->on_error(return_code, creators_ptr)))
{
std::cerr << e.what() << std::endl;
}
+ catch (std::bad_alloc& e)
+ {
+ std::cerr << e.what() << std::endl;
+ }
catch (...)
{
std::cerr << "Unknown exception halted execution" << std::endl;
check_PROGRAMS+= tests/memdump
noinst_PROGRAMS+= tests/memdump
-test-memerror: clients/memerror
+test-memstat: tests/memstat
+ tests/memstat
+
+test-memerror: tests/memerror
tests/memerror
valgrind-memerror: clients/memerror
@$(VALGRIND_COMMAND) tests/memerror
-
-test-memcp: clients/memcp
- @echo "Testing memcp"
- @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
- @clients/memcp --servers="localhost:12555" clients/memcp clients/memcat clients/memstat
- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
- @rm tests/Xumemc.pid
-
-valgrind-memcp: clients/memcat clients/memcp
- @echo "Testing memcp"
- @@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
- @$(VALGRIND_COMMAND) clients/memcp --servers="localhost:12555" clients/memcp clients/memcat clients/memstat
- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
- @rm tests/Xumemc.pid
-
-test-memflush: clients/memflush
- @echo "Testing memflush"
- @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
- @clients/memflush --servers="localhost:12555"
- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
- @rm tests/Xumemc.pid
-
-valgrind-memflush: clients/memflush
- @echo "Testing memflush"
- @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
- @$(VALGRIND_COMMAND) clients/memflush --servers="localhost:12555"
- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
- @rm tests/Xumemc.pid
-
-test-memdump: clients/memdump clients/memcp
- @echo "Testing memdump"
- @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
- @clients/memcp --servers="localhost:12555" clients/memcat
- @clients/memdump --servers="localhost:12555" > /dev/null
- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
- @rm tests/Xumemc.pid
-
-valgrind-memdump: clients/memcat clients/memcp
- @echo "Testing memdump"
- @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
- @clients/memcp --servers="localhost:12555" clients/memcat
- @$(VALGRIND_COMMAND) clients/memdump --servers="localhost:12555" > /dev/null
- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
- @rm tests/Xumemc.pid
-
-test-memstat: clients/memstat
- @echo "Testing memstat"
- @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
- @clients/memstat --servers="localhost:12555" > /dev/null
- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
- @rm tests/Xumemc.pid
-
-valgrind-memstat: clients/memstat
- @echo "Testing memstat"
- @$(MEMC_BINARY) -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
- @$(VALGRIND_COMMAND) clients/memstat --servers="localhost:12555" > /dev/null
- @cat tests/Xumemc.pid | xargs kill || echo "Failed to kill memcached server"
- @rm tests/Xumemc.pid
-
check-local: $(TEST_DOCS)
@echo "Tests completed"
-test-x: test-plus test-memcp test-memdump test-memflush test-memstat
- @echo "Tests completed"
-
test-mem: tests/var tests/libmemcached-1.0/testapp
@tests/libmemcached-1.0/testapp
for (uint32_t x= 0; x < servers.count(); x++)
{
- char variable_buffer[1024];
- snprintf(variable_buffer, sizeof(variable_buffer), "LIBMEMCACHED_PORT_%u", x);
-
- in_port_t port;
- char *var;
- if ((var= getenv(variable_buffer)))
- {
- port= in_port_t(atoi(var));
- }
- else
- {
- port= in_port_t(libtest::get_free_port());
- }
+ in_port_t port= libtest::get_free_port();
const char *argv[1]= { "memcached" };
if (servers.sasl())
{
- if (not server_startup(servers, "memcached-sasl", port, 1, argv))
+ if (server_startup(servers, "memcached-sasl", port, 1, argv) == false)
{
- error= TEST_FATAL;
- return NULL;
+ fatal_message("Could not start memcached-sasl");
}
}
else
{
- if (not server_startup(servers, "memcached", port, 1, argv))
+ if (server_startup(servers, "memcached", port, 1, argv) == false)
{
- error= TEST_FATAL;
- return NULL;
+ fatal_message("Could not start memcached");
}
}
}
libmemcached_test_container_st *global_container= new libmemcached_test_container_st(servers);
- if (global_container == NULL)
- {
- error= TEST_MEMORY_ALLOCATION_FAILURE;
- return NULL;
- }
-
- error= TEST_SUCCESS;
return global_container;
}
const char *argv[1]= { "memcached" };
if (not servers.start_socket_server("memcached", libtest::get_free_port(), 1, argv))
{
- error= TEST_FATAL;
- return NULL;
+ fatal_message("Could not launch memcached");
}
}
libmemcached_test_container_st *global_container= new libmemcached_test_container_st(servers);
- if (global_container == NULL)
- {
- error= TEST_MEMORY_ALLOCATION_FAILURE;
- return NULL;
- }
error= TEST_SUCCESS;
#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/memexist");
static test_return_t help_test(void *)
{
- const char *args[]= { "--quiet", "--help", 0 };
+ const char *args[]= { "--help", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "foo", 0 };
+ const char *args[]= { buffer, "foo", 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
- test_true(exec_cmdline(executable, args));
+ 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);
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "foo", 0 };
+ const char *args[]= { buffer, "foo", 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
- test_true(exec_cmdline(executable, args));
+ 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_st memexist_tests[] ={
- {"--quiet", true, quiet_test },
{"--help", true, help_test },
{"exist(FOUND)", true, exist_test },
{"exist(NOT_FOUND)", true, NOT_FOUND_test },
void get_world(Framework *world)
{
- executable= "./clients/memexist";
world->collections= collection;
world->_create= world_create;
}
#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/memstat");
static test_return_t help_test(void *)
{
- const char *args[]= { "--help", "--quiet", 0 };
+ const char *args[]= { "--help", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port()));
- const char *args[]= { "--quiet", buffer, " --binary ", 0 };
+ const char *args[]= { buffer, " --binary ", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port()));
- const char *args[]= { "--quiet", buffer, " --server-version", 0 };
+ const char *args[]= { buffer, " --server-version", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port()));
- const char *args[]= { "--quiet", buffer, " --binary --server-version", 0 };
+ const char *args[]= { buffer, " --binary --server-version", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
test_st memstat_tests[] ={
- {"--quiet", 0, quiet_test},
{"--help", 0, help_test},
{"--binary", 0, binary_TEST},
{"--server-version", 0, server_version_TEST},
void get_world(Framework *world)
{
- executable= "./clients/memstat";
world->collections= collection;
world->_create= world_create;
}
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 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;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", "--expire=30", buffer, "foo", 0 };
+ const char *args[]= { "--expire=30", buffer, "foo", 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_compare(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("foo")));
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
test_compare(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("foo")));
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", "--expire=30", buffer, "foo", 0 };
+ const char *args[]= { "--expire=30", buffer, "foo", 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo")));
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo")));
}
test_st memtouch_tests[] ={
- {"--quiet", true, quiet_test },
{"--help", true, help_test },
{"touch(FOUND)", true, touch_test },
{"touch(NOT_FOUND)", true, NOT_FOUND_test },