X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Flibcephfs%2Fcaps.cc;fp=src%2Fceph%2Fsrc%2Ftest%2Flibcephfs%2Fcaps.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=4af9b418d2e8345dd36aa6d6752369e1cfc9472f;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/test/libcephfs/caps.cc b/src/ceph/src/test/libcephfs/caps.cc deleted file mode 100644 index 4af9b41..0000000 --- a/src/ceph/src/test/libcephfs/caps.cc +++ /dev/null @@ -1,92 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2011 New Dream Network - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ -#include "include/int_types.h" - -#include "gtest/gtest.h" -#include "include/ceph_fs.h" -#include "include/cephfs/libcephfs.h" -#include -#include -#include -#include -#include -#include -#include -#include - -TEST(Caps, ReadZero) { - - int mypid = getpid(); - struct ceph_mount_info *cmount; - ASSERT_EQ(0, ceph_create(&cmount, NULL)); - ASSERT_EQ(0, ceph_conf_read_file(cmount, NULL)); - ASSERT_EQ(0, ceph_mount(cmount, "/")); - - int i = 0; - for(; i < 30; ++i) { - - char c_path[1024]; - sprintf(c_path, "/caps_rzfile_%d_%d", mypid, i); - int fd = ceph_open(cmount, c_path, O_CREAT|O_TRUNC|O_WRONLY, 0644); - ASSERT_LT(0, fd); - - int expect = CEPH_CAP_FILE_EXCL | CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER; - int caps = ceph_debug_get_fd_caps(cmount, fd); - - ASSERT_EQ(expect, caps & expect); - ASSERT_EQ(0, ceph_close(cmount, fd)); - - caps = ceph_debug_get_file_caps(cmount, c_path); - ASSERT_EQ(expect, caps & expect); - - char cw_path[1024]; - sprintf(cw_path, "/caps_wzfile_%d_%d", mypid, i); - int wfd = ceph_open(cmount, cw_path, O_CREAT|O_TRUNC|O_WRONLY, 0644); - ASSERT_LT(0, wfd); - - char wbuf[4096]; - ASSERT_EQ(4096, ceph_write(cmount, wfd, wbuf, 4096, 0)); - - ASSERT_EQ(0, ceph_close(cmount, wfd)); - - struct ceph_statx stx; - ASSERT_EQ(0, ceph_statx(cmount, c_path, &stx, CEPH_STATX_MTIME, 0)); - - caps = ceph_debug_get_file_caps(cmount, c_path); - ASSERT_EQ(expect, caps & expect); - } - - ASSERT_EQ(0, ceph_conf_set(cmount, "client_debug_inject_tick_delay", "20")); - - for(i = 0; i < 30; ++i) { - - char c_path[1024]; - sprintf(c_path, "/caps_rzfile_%d_%d", mypid, i); - - int fd = ceph_open(cmount, c_path, O_RDONLY, 0); - ASSERT_LT(0, fd); - char buf[256]; - - int expect = CEPH_CAP_FILE_RD | CEPH_STAT_CAP_SIZE | CEPH_CAP_FILE_CACHE; - int caps = ceph_debug_get_fd_caps(cmount, fd); - ASSERT_EQ(expect, caps & expect); - ASSERT_EQ(0, ceph_read(cmount, fd, buf, 256, 0)); - - caps = ceph_debug_get_fd_caps(cmount, fd); - ASSERT_EQ(expect, caps & expect); - ASSERT_EQ(0, ceph_close(cmount, fd)); - - } - ceph_shutdown(cmount); -}