From b14ca1fe867d10ed07d387533c409bb0e65a429d Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 5 Feb 2015 22:01:43 -0800 Subject: [PATCH] test_libcephfs: test we can't set layouts on existing files Signed-off-by: Greg Farnum --- src/test/libcephfs/test.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index ccedaa1230580..71b4aafc7b610 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); -- 2.39.5