From fabf488ffa687540145ca8973ceb3fb0147a858b Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 14 Feb 2012 15:27:33 -0800 Subject: [PATCH] Add in a test to do memcached_set() after a kill has been issued. --- tests/libmemcached-1.0/all_tests.h | 6 ++++++ tests/libmemcached-1.0/mem_functions.cc | 28 +++++++++++++++++++++++++ tests/libmemcached-1.0/mem_functions.h | 1 + 3 files changed, 35 insertions(+) diff --git a/tests/libmemcached-1.0/all_tests.h b/tests/libmemcached-1.0/all_tests.h index a0103968..c9134a51 100644 --- a/tests/libmemcached-1.0/all_tests.h +++ b/tests/libmemcached-1.0/all_tests.h @@ -122,6 +122,11 @@ test_st touch_tests[] ={ {0, 0, 0} }; +test_st kill_TESTS[] ={ + {"kill(HUP)", 0, (test_callback_fn*)kill_HUP_TEST}, + {0, 0, 0} +}; + test_st memcached_stat_tests[] ={ {"memcached_stat() INVALID ARG", 0, (test_callback_fn*)memcached_stat_TEST}, {"memcached_stat()", 0, (test_callback_fn*)memcached_stat_TEST2}, @@ -467,5 +472,6 @@ collection_st collection[] ={ {"touch", 0, 0, touch_tests}, {"touch", (test_callback_fn*)pre_binary, 0, touch_tests}, {"memcached_stat()", 0, 0, memcached_stat_tests}, + {"kill()", 0, 0, kill_TESTS}, {0, 0, 0, 0} }; diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index aae725bf..b3f6fbe0 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -4955,3 +4955,31 @@ test_return_t regression_bug_(memcached_st *memc) return TEST_SUCCESS; } + +test_return_t kill_HUP_TEST(memcached_st *original_memc) +{ + memcached_st *memc= create_single_instance_memcached(original_memc, 0); + test_true(memc); + + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); + + pid_t pid; + test_true((pid= libmemcached_util_getpid(memcached_server_name(instance), + memcached_server_port(instance), NULL)) > -1); + + + test_compare(MEMCACHED_SUCCESS, + memcached_set(memc, + test_literal_param(__func__), // Keys + test_literal_param(__func__), // Values + 0, 0)); + test_true_got(kill(pid, SIGHUP) == 0, strerror(errno)); + + test_compare(MEMCACHED_SUCCESS, + memcached_set(memc, + test_literal_param(__func__), // Keys + test_literal_param(__func__), // Values + 0, 0)); + + return TEST_SUCCESS; +} diff --git a/tests/libmemcached-1.0/mem_functions.h b/tests/libmemcached-1.0/mem_functions.h index a8433743..7126f7fc 100644 --- a/tests/libmemcached-1.0/mem_functions.h +++ b/tests/libmemcached-1.0/mem_functions.h @@ -178,3 +178,4 @@ test_return_t util_version_test(memcached_st *memc); test_return_t version_string_test(memcached_st *); test_return_t wrong_failure_counter_test(memcached_st *memc); test_return_t wrong_failure_counter_two_test(memcached_st *memc); +test_return_t kill_HUP_TEST(memcached_st *memc); -- 2.30.2