From: Greg Farnum Date: Fri, 6 Feb 2015 06:01:43 +0000 (-0800) Subject: test_libcephfs: test we can't set layouts on existing files X-Git-Tag: v0.93~46^2~5^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b14ca1fe867d10ed07d387533c409bb0e65a429d;p=ceph.git test_libcephfs: test we can't set layouts on existing files Signed-off-by: Greg Farnum --- diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index ccedaa123058..71b4aafc7b61 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -171,14 +171,23 @@ TEST(LibCephFS, OpenLayout) { /* valid layout */ char test_layout_file[256]; sprintf(test_layout_file, "test_layout_%d_b", getpid()); - int fd = ceph_open_layout(cmount, test_layout_file, O_CREAT, 0666, (1<<20), 7, (1<<20), NULL); + int fd = ceph_open_layout(cmount, test_layout_file, O_CREAT|O_WRONLY, 0666, (1<<20), 7, (1<<20), NULL); ASSERT_GT(fd, 0); char poolname[80]; ASSERT_LT(0, ceph_get_file_pool_name(cmount, fd, poolname, sizeof(poolname))); ASSERT_EQ(4, ceph_get_file_pool_name(cmount, fd, poolname, 0)); ASSERT_EQ(0, strcmp("data", poolname)); + + /* on already-written file (ENOTEMPTY) */ + ceph_write(cmount, fd, "hello world", 11, 0); ceph_close(cmount, fd); + char xattrk[128]; + char xattrv[128]; + sprintf(xattrk, "ceph.file.layout.stripe_unit"); + sprintf(xattrv, "65536"); + ASSERT_EQ(-ENOTEMPTY, ceph_setxattr(cmount, test_layout_file, xattrk, (void *)xattrv, 5, 0)); + /* invalid layout */ sprintf(test_layout_file, "test_layout_%d_c", getpid()); fd = ceph_open_layout(cmount, test_layout_file, O_CREAT, 0666, (1<<20), 1, 19, NULL);