]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librbd/fsx: also check sizes in check_clone()
authorIlya Dryomov <idryomov@gmail.com>
Sat, 11 May 2024 07:57:18 +0000 (09:57 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 12 May 2024 12:03:59 +0000 (14:03 +0200)
Currently only data is checked, based on the size of the file.
Check that the size of the image matches that.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/test/librbd/fsx.cc

index 1de97242da0f8ee0e8f41f0236ea07d50320bb4c..3cf971a23ac37532c47d74577b1c3e9197b75c7c 100644 (file)
@@ -2853,6 +2853,7 @@ check_clone(int clonenum, bool replay_image)
        struct rbd_ctx cur_ctx = RBD_CTX_INIT;
        struct stat file_info;
        char *good_buf, *temp_buf;
+       uint64_t size;
 
         if (replay_image) {
                 replay_imagename(imagename, sizeof(imagename), clonenum);
@@ -2864,20 +2865,30 @@ check_clone(int clonenum, bool replay_image)
                prterrcode("check_clone: ops->open", ret);
                exit(167);
        }
+       if ((ret = ops->get_size(&cur_ctx, &size)) < 0) {
+               prterrcode("check_clone: ops->get_size", ret);
+               exit(167);
+       }
 
        clone_filename(filename, sizeof(filename), clonenum + 1);
        if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0) {
                prterrcode("check_clone: open", -errno);
                exit(168);
        }
-
-       prt("checking clone #%d, image %s against file %s\n",
-           clonenum, imagename, filename);
        if (fstat(fd, &file_info) < 0) {
                prterrcode("check_clone: fstat", -errno);
                exit(169);
        }
 
+       prt("checking clone #%d, image %s against file %s\n",
+           clonenum, imagename, filename);
+       if (size != (uint64_t)file_info.st_size) {
+               prt("check_clone: image size 0x%llx != file size 0x%llx\n",
+                   (unsigned long long)size,
+                   (unsigned long long)file_info.st_size);
+               exit(175);
+       }
+
        good_buf = NULL;
        ret = posix_memalign((void **)&good_buf,
                             std::max(writebdy, (int)sizeof(void *)),