From: Sage Weil Date: Fri, 1 Sep 2017 21:12:56 +0000 (-0400) Subject: ceph_test_rados_api_pool: make LibRadosPools.PoolList tolerate long pool names X-Git-Tag: v13.0.1~840^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=76f1c14c77e2cd775f853711ae6bdf461095b3ec;p=ceph.git ceph_test_rados_api_pool: make LibRadosPools.PoolList tolerate long pool names There was a baked-in assumption that the first pool was <20 chars. No more! Signed-off-by: Sage Weil --- diff --git a/src/test/librados/pool.cc b/src/test/librados/pool.cc index 5764fa875880..5cda7edd2097 100644 --- a/src/test/librados/pool.cc +++ b/src/test/librados/pool.cc @@ -19,10 +19,13 @@ TEST(LibRadosPools, PoolList) { ASSERT_LT(rados_pool_list(cluster, NULL, POOL_LIST_BUF_SZ), POOL_LIST_BUF_SZ); bool found_pool = false; + int firstlen = 0; while (buf[0] != '\0') { if ((found_pool == false) && (strcmp(buf, pool_name.c_str()) == 0)) { found_pool = true; } + if (!firstlen) + firstlen = strlen(buf) + 1; buf += strlen(buf) + 1; } ASSERT_EQ(found_pool, true); @@ -30,9 +33,9 @@ TEST(LibRadosPools, PoolList) { // make sure we honor the buffer size limit buf = pool_list_buf; memset(buf, 0, POOL_LIST_BUF_SZ); - ASSERT_LT(rados_pool_list(cluster, buf, 20), POOL_LIST_BUF_SZ); + ASSERT_LT(rados_pool_list(cluster, buf, firstlen), POOL_LIST_BUF_SZ); ASSERT_NE(0, buf[0]); // include at least one pool name - ASSERT_EQ(0, buf[20]); // but don't touch the stopping point + ASSERT_EQ(0, buf[firstlen]); // but don't touch the stopping point ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster)); }