]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_rados_api_pool: make LibRadosPools.PoolList tolerate long pool names
authorSage Weil <sage@redhat.com>
Fri, 1 Sep 2017 21:12:56 +0000 (17:12 -0400)
committerSage Weil <sage@redhat.com>
Thu, 21 Sep 2017 18:29:35 +0000 (14:29 -0400)
There was a baked-in assumption that the first pool was <20 chars.
No more!

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/librados/pool.cc

index 5764fa8758807293b6aa13775425a1c35817f010..5cda7edd20978e00e428a8db48a5da4b5a513783 100644 (file)
@@ -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));
 }