]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
testlibrbdpp: test copy_with_progress
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 29 Aug 2011 23:57:05 +0000 (16:57 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 29 Aug 2011 23:57:27 +0000 (16:57 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/testlibrbdpp.cc

index 6034119285002bd35aae0811e4bbc089fa843cbc..d4dbfe151e4ffb1d7e2ac0f60a8767624a1f8d86 100644 (file)
@@ -248,6 +248,24 @@ void test_rbd_copy(librados::IoCtx& io_ctx, librbd::Image& image)
   }
 }
 
+static void print_progress_percent(uint64_t offset, uint64_t src_size,
+                                    void *data)
+{
+  float percent = ((float)offset * 100) / src_size;
+  printf("%3.2f%% done\n", percent);
+}
+
+void test_rbd_copy_with_progress(librados::IoCtx& io_ctx, librbd::Image& image)
+{
+  int ret;
+  ret = image.copy_with_progress(io_ctx, TEST_IMAGE2,
+                                print_progress_percent, NULL);
+  if (ret < 0) {
+    fprintf(stderr, "image.copy returned %d!\n", ret);
+    abort();
+  }
+}
+
 int main(int argc, const char **argv) 
 {
   librados::Rados rados;
@@ -287,6 +305,8 @@ int main(int argc, const char **argv)
   test_delete(io_ctx, TEST_IMAGE "1");
   test_ls(io_ctx, 0);
   test_rbd_copy(io_ctx, image);
+  test_delete(io_ctx, TEST_IMAGE2);
+  test_rbd_copy_with_progress(io_ctx, image);
   delete rbd;
   return 0;
 }