]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test_libcephfs: test we can't set layouts on existing files 3617/head
authorGreg Farnum <gfarnum@redhat.com>
Fri, 6 Feb 2015 06:01:43 +0000 (22:01 -0800)
committerGreg Farnum <gfarnum@redhat.com>
Tue, 10 Feb 2015 06:18:31 +0000 (22:18 -0800)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/test/libcephfs/test.cc

index ccedaa1230580424b2c4a942e95448c29d8b2f64..71b4aafc7b610b74218a66fba1c6b967e21f1388 100644 (file)
@@ -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);