*
*/
-#include <config.h>
+#include "libtest/yatlcon.h"
#include <libtest/test.hpp>
-#if defined(LIBTEST_WITH_LIBMEMCACHED_SUPPORT) && LIBTEST_WITH_LIBMEMCACHED_SUPPORT
-#include <libmemcached-1.0/memcached.h>
+#if defined(HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H) && HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H
+# include <libmemcached-1.0/types/return.h>
#endif
-#if defined(LIBTEST_WITH_LIBGEARMAN_SUPPORT) && LIBTEST_WITH_LIBGEARMAN_SUPPORT
-#include <libgearman/gearman.h>
+#if defined(HAVE_LIBGEARMAN_1_0_RETURN_H) && HAVE_LIBGEARMAN_1_0_RETURN_H
+# include <libgearman-1.0/return.h>
#endif
#include <cstdlib>
// Used to track setups where we see if failure is happening
static uint32_t fatal_calls= 0;
+static test_return_t getenv_TEST(void *)
+{
+#if 0
+ for (char **ptr= environ; *ptr; ptr++)
+ {
+ Error << *ptr;
+ }
+#endif
+
+ return TEST_SUCCESS;
+}
+
static test_return_t LIBTOOL_COMMAND_test(void *)
{
test_true(getenv("LIBTOOL_COMMAND"));
static test_return_t test_success_equals_one_test(void *)
{
test_skip(HAVE_LIBMEMCACHED, 1);
-#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
+#if defined(HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H) && HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H
test_zero(MEMCACHED_SUCCESS);
#endif
return TEST_SUCCESS;
return TEST_SUCCESS;
}
+static test_return_t test_throw_success_TEST(void *)
+{
+ try {
+ _SUCCESS;
+ }
+ catch (libtest::__success)
+ {
+ return TEST_SUCCESS;
+ }
+ catch (...)
+ {
+ return TEST_FAILURE;
+ }
+
+ return TEST_FAILURE;
+}
+
+static test_return_t test_throw_skip_TEST(void *)
+{
+ try {
+ SKIP;
+ }
+ catch (libtest::__skipped)
+ {
+ return TEST_SUCCESS;
+ }
+ catch (...)
+ {
+ return TEST_FAILURE;
+ }
+
+ return TEST_FAILURE;
+}
+
+static test_return_t test_throw_fail_TEST(void *)
+{
+ std::string error_messsage("test message!");
+ try {
+ FAIL(error_messsage);
+ }
+ catch (libtest::__failure e)
+ {
+ std::string compare_message("test message!");
+ test_zero(compare_message.compare(e.what()));
+ return TEST_SUCCESS;
+ }
+ catch (...)
+ {
+ return TEST_FAILURE;
+ }
+
+ return TEST_FAILURE;
+}
+
static test_return_t test_failure_test(void *)
{
return TEST_SKIPPED; // Only run this when debugging
static test_return_t _compare_memcached_return_t_test(void *)
{
test_skip(HAVE_LIBMEMCACHED, true);
-#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
+#if defined(HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H) && HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H
test_compare(MEMCACHED_SUCCESS, MEMCACHED_SUCCESS);
#endif
static test_return_t _compare_gearman_return_t_test(void *)
{
test_skip(HAVE_LIBGEARMAN, true);
-#if defined(HAVE_LIBGEARMAN) && HAVE_LIBGEARMAN
+#if defined(HAVE_LIBGEARMAN_1_0_RETURN_H) && HAVE_LIBGEARMAN_1_0_RETURN_H
test_compare(GEARMAN_SUCCESS, GEARMAN_SUCCESS);
#endif
return TEST_SUCCESS;
}
-#if 0
-static test_return_t memcached_light_cycle_TEST(void *object)
-{
- server_startup_st *servers= (server_startup_st*)object;
- test_true(servers);
-
- test_skip(true, bool(HAVE_MEMCACHED_LIGHT_BINARY));
-
- test_true(server_startup(*servers, "memcached-light", get_free_port(), 0, NULL, false));
-
- return TEST_SUCCESS;
-}
-#endif
-
static test_return_t skip_shim(bool a, bool b)
{
test_skip(a, b);
static test_return_t application_gdb_true_BINARY2(void *)
{
test_skip(0, access("/usr/bin/gdb", X_OK ));
+ test_skip(0, access("/usr/bin/true", X_OK ));
+
Application true_app("/usr/bin/true");
true_app.use_gdb();
static test_return_t application_gdb_true_BINARY(void *)
{
test_skip(0, access("/usr/bin/gdb", X_OK ));
+ test_skip(0, access("/usr/bin/true", X_OK ));
+
Application true_app("/usr/bin/true");
true_app.use_gdb();
const char *args[]= { "--fubar", 0 };
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
test_compare(Application::INVALID_POSIX_SPAWN, true_app.run(args));
+#elif defined(TARGET_OS_FREEBSD) && TARGET_OS_FREEBSD
+ test_compare(Application::INVALID_POSIX_SPAWN, true_app.run(args));
#else
test_compare(Application::SUCCESS, true_app.run(args));
test_compare(Application::INVALID_POSIX_SPAWN, true_app.join());
static test_return_t wait_services_appliction_TEST(void *)
{
- test_skip(0, access("/usr/bin/gdb", X_OK ));
test_skip(0, access("/etc/services", R_OK ));
+ test_skip(0, access("/usr/bin/gdb", X_OK ));
+ test_skip(0, access("libtest/wait", X_OK ));
libtest::Application wait_app("libtest/wait", true);
wait_app.use_gdb();
test_skip(0, TARGET_OS_OSX);
#endif
- test_skip(0, access("/usr/bin/gdb", X_OK ));
test_skip(0, access("/etc/services", R_OK ));
+ test_skip(0, access("/usr/bin/gdb", X_OK ));
+ test_skip(0, access("libtest/wait", X_OK ));
libtest::Application wait_app("libtest/wait", true);
wait_app.use_gdb();
static test_return_t gdb_abort_services_appliction_TEST(void *)
{
- test_skip(true, false);
test_skip(0, access("/usr/bin/gdb", X_OK ));
+ test_skip(0, access("libtest/abort", X_OK ));
+ test_skip(true, false);
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
test_skip(0, TARGET_OS_OSX);
static test_return_t create_tmpfile_TEST(void *)
{
+ test_skip(0, access("/usr/bin/touch", X_OK ));
std::string tmp= create_tmpfile(__func__);
test_compare(-1, access(tmp.c_str(), R_OK));
test_compare(-1, access(tmp.c_str(), F_OK));
{
test_skip(true, HAVE_LIBGEARMAN);
test_skip(true, has_gearmand());
+#if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
+ if (GEARMAND_BINARY)
+ {
+ test_zero(access(GEARMAND_BINARY, X_OK ));
+ }
+ else
+ {
+ return TEST_SKIPPED;
+ }
+#endif
testing_service= "gearmand";
};
test_st environment_tests[] ={
+ {"getenv()", 0, getenv_TEST },
{"LIBTOOL_COMMAND", 0, LIBTOOL_COMMAND_test },
{"VALGRIND_COMMAND", 0, VALGRIND_COMMAND_test },
{"HELGRIND_COMMAND", 0, HELGRIND_COMMAND_test },
{"TEST_SUCCESS", false, test_success_test },
{"TEST_FAILURE", false, test_failure_test },
{"TEST_SUCCESS == 0", false, test_success_equals_one_test },
+ {"SUCCESS", false, test_throw_success_TEST },
+ {"SKIP", false, test_throw_skip_TEST },
+ {"FAIL", false, test_throw_fail_TEST },
{0, 0, 0}
};