]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph_test_libcephfs: shutdown without closing file/dir
authorYan, Zheng <zyan@redhat.com>
Wed, 9 Mar 2016 04:06:52 +0000 (12:06 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 9 Mar 2016 06:40:06 +0000 (14:40 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/test/libcephfs/test.cc

index 464c5a966453f87e49c95e00cd73881d6c4f2277..06061a6f24efc0a92791cb776146e0f5c55832ec 100644 (file)
@@ -1321,3 +1321,26 @@ TEST(LibCephFS, GetOsdAddr) {
 
   ceph_shutdown(cmount);
 }
+
+TEST(LibCephFS, OpenNoClose) {
+  struct ceph_mount_info *cmount;
+  ASSERT_EQ(ceph_create(&cmount, NULL), 0);
+  ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
+  ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
+  ASSERT_EQ(ceph_mount(cmount, "/"), 0);
+
+  pid_t mypid = getpid();
+  char str_buf[256];
+  sprintf(str_buf, "open_no_close_dir%d", mypid);
+  ASSERT_EQ(0, ceph_mkdirs(cmount, str_buf, 0777));
+
+  struct ceph_dir_result *ls_dir = NULL;
+  ASSERT_EQ(ceph_opendir(cmount, str_buf, &ls_dir), 0);
+
+  sprintf(str_buf, "open_no_close_file%d", mypid);
+  int fd = ceph_open(cmount, str_buf, O_RDONLY|O_CREAT, 0666);
+  ASSERT_LT(0, fd);
+
+  // shutdown should force close opened file/dir
+  ceph_shutdown(cmount);
+}