Skip to content

Commit 47ad28f

Browse files
committed
test/librbd/fsx: also check sizes in check_clone()
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 <[email protected]>
1 parent c50a96c commit 47ad28f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/test/librbd/fsx.cc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,6 +2853,7 @@ check_clone(int clonenum, bool replay_image)
28532853
struct rbd_ctx cur_ctx = RBD_CTX_INIT;
28542854
struct stat file_info;
28552855
char *good_buf, *temp_buf;
2856+
uint64_t size;
28562857

28572858
if (replay_image) {
28582859
replay_imagename(imagename, sizeof(imagename), clonenum);
@@ -2864,20 +2865,30 @@ check_clone(int clonenum, bool replay_image)
28642865
prterrcode("check_clone: ops->open", ret);
28652866
exit(167);
28662867
}
2868+
if ((ret = ops->get_size(&cur_ctx, &size)) < 0) {
2869+
prterrcode("check_clone: ops->get_size", ret);
2870+
exit(167);
2871+
}
28672872

28682873
clone_filename(filename, sizeof(filename), clonenum + 1);
28692874
if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0) {
28702875
prterrcode("check_clone: open", -errno);
28712876
exit(168);
28722877
}
2873-
2874-
prt("checking clone #%d, image %s against file %s\n",
2875-
clonenum, imagename, filename);
28762878
if (fstat(fd, &file_info) < 0) {
28772879
prterrcode("check_clone: fstat", -errno);
28782880
exit(169);
28792881
}
28802882

2883+
prt("checking clone #%d, image %s against file %s\n",
2884+
clonenum, imagename, filename);
2885+
if (size != (uint64_t)file_info.st_size) {
2886+
prt("check_clone: image size 0x%llx != file size 0x%llx\n",
2887+
(unsigned long long)size,
2888+
(unsigned long long)file_info.st_size);
2889+
exit(175);
2890+
}
2891+
28812892
good_buf = NULL;
28822893
ret = posix_memalign((void **)&good_buf,
28832894
std::max(writebdy, (int)sizeof(void *)),

0 commit comments

Comments
 (0)