From 76f1c14c77e2cd775f853711ae6bdf461095b3ec Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 1 Sep 2017 17:12:56 -0400 Subject: [PATCH] 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 --- src/test/librados/pool.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/librados/pool.cc b/src/test/librados/pool.cc index 5764fa8758807..5cda7edd20978 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)); } -- 2.39.5