From 0ccec3ba6ce515f61e5d0b3c0a07220646c85e40 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 16 Aug 2011 17:55:24 -0700 Subject: [PATCH] Update --- libtest/error.h | 2 +- libtest/memcached.cc | 2 +- libtest/unittest.cc | 50 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/libtest/error.h b/libtest/error.h index 047d66b8..e24c1791 100644 --- a/libtest/error.h +++ b/libtest/error.h @@ -23,7 +23,7 @@ #pragma once enum test_return_t { - TEST_SUCCESS= 0, /* Backwards compatibility */ + TEST_SUCCESS, TEST_FAILURE, TEST_MEMORY_ALLOCATION_FAILURE, TEST_SKIPPED, diff --git a/libtest/memcached.cc b/libtest/memcached.cc index ceb2d878..3e8e3fcd 100644 --- a/libtest/memcached.cc +++ b/libtest/memcached.cc @@ -97,7 +97,7 @@ public: } pid_t local_pid; - memcached_return_t rc; + memcached_return_t rc= MEMCACHED_SUCCESS; if (has_socket()) { local_pid= libmemcached_util_getpid(socket().c_str(), 0, &rc); diff --git a/libtest/unittest.cc b/libtest/unittest.cc index b2d7df0d..93192a25 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -24,6 +24,14 @@ #include +#if defined(LIBTEST_WITH_LIBMEMCACHED_SUPPORT) && LIBTEST_WITH_LIBMEMCACHED_SUPPORT +#include +#endif + +#if defined(LIBTEST_WITH_LIBGEARMAN_SUPPORT) && LIBTEST_WITH_LIBGEARMAN_SUPPORT +#include +#endif + #include #include @@ -53,6 +61,13 @@ static test_return_t GDB_COMMAND_test(void *) return TEST_SUCCESS; } +static test_return_t test_success_equals_one_test(void *) +{ + test_skip(HAVE_LIBMEMCACHED, true); + test_zero(MEMCACHED_SUCCESS); + return TEST_SUCCESS; +} + static test_return_t test_success_test(void *) { return TEST_SUCCESS; @@ -181,6 +196,28 @@ static test_return_t var_log_rm_test(void *) return TEST_SUCCESS; } +static test_return_t _compare_test_return_t_test(void *) +{ + test_compare(TEST_SUCCESS, TEST_SUCCESS); + + return TEST_SUCCESS; +} + +static test_return_t _compare_memcached_return_t_test(void *) +{ + test_skip(HAVE_LIBMEMCACHED, true); + test_compare(MEMCACHED_SUCCESS, MEMCACHED_SUCCESS); + + return TEST_SUCCESS; +} + +static test_return_t _compare_gearman_return_t_test(void *) +{ + test_skip(HAVE_LIBGEARMAN, true); + + return TEST_SUCCESS; +} + static test_return_t gearmand_cycle_test(void *object) { server_startup_st *servers= (server_startup_st*)object; @@ -274,8 +311,9 @@ test_st environment_tests[] ={ }; test_st tests_log[] ={ - {"TEST_SUCCESS", 0, test_success_test }, - {"TEST_FAILURE", 0, test_failure_test }, + {"TEST_SUCCESS", false, test_success_test }, + {"TEST_FAILURE", false, test_failure_test }, + {"TEST_SUCCESS == 0", false, test_success_equals_one_test }, {0, 0, 0} }; @@ -299,11 +337,19 @@ test_st directories_tests[] ={ {0, 0, 0} }; +test_st comparison_tests[] ={ + {"_compare(test_return_t)", 0, _compare_test_return_t_test }, + {"_compare(memcached_return_t)", 0, _compare_memcached_return_t_test }, + {"_compare(gearman_return_t)", 0, _compare_gearman_return_t_test }, + {0, 0, 0} +}; + collection_st collection[] ={ {"environment", 0, 0, environment_tests}, {"return values", 0, 0, tests_log}, {"local", 0, 0, local_log}, {"directories", 0, 0, directories_tests}, + {"comparison", 0, 0, comparison_tests}, {"gearmand", 0, 0, gearmand_tests}, {"memcached", 0, 0, memcached_tests}, {0, 0, 0, 0} -- 2.30.2