From: Sage Weil Date: Wed, 28 Sep 2011 04:19:48 +0000 (-0700) Subject: test-rados-api: test tmap rm X-Git-Tag: v0.37~117 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fc2df623009f3f510bc60cd591f7893bf3049a3c;p=ceph.git test-rados-api: test tmap rm Make sure we get ENOENT if the entry doesn't exist. Signed-off-by: Sage Weil --- diff --git a/src/test/rados-api/misc.cc b/src/test/rados-api/misc.cc index 670ec22be809..31f77af14509 100644 --- a/src/test/rados-api/misc.cc +++ b/src/test/rados-api/misc.cc @@ -70,6 +70,23 @@ static std::string add_key_to_tmap(IoCtx &ioctx, const std::string &obj, return ""; } +static int remove_key_from_tmap(IoCtx &ioctx, const std::string &obj, + const std::string &key) +{ + __u8 c = CEPH_OSD_TMAP_RM; + + bufferlist tmbl; + ::encode(c, tmbl); + ::encode(key, tmbl); + int ret = ioctx.tmap_update(obj, tmbl); + if (ret) { + ostringstream oss; + oss << "ioctx.tmap_update(obj=" << obj << ", key=" + << key << ") failed with error " << ret; + } + return ret; +} + TEST(LibRadosMisc, TmapUpdatePP) { Rados cluster; std::string pool_name = get_temp_pool_name(); @@ -98,14 +115,8 @@ TEST(LibRadosMisc, TmapUpdatePP) { ASSERT_EQ(string("val1"), read_key_from_tmap(ioctx, "foo", "key1")); // remove key1 from tmap - { - __u8 c = CEPH_OSD_TMAP_RM; - std::string key1("key1"); - bufferlist tmbl; - ::encode(c, tmbl); - ::encode(key1, tmbl); - ASSERT_EQ(0, ioctx.tmap_update("foo", tmbl)); - } + ASSERT_EQ(0, remove_key_from_tmap(ioctx, "foo", "key1")); + ASSERT_EQ(-ENOENT, remove_key_from_tmap(ioctx, "foo", "key1")); // key should be removed ASSERT_EQ(string(""), read_key_from_tmap(ioctx, "foo", "key1"));