]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librados/cmd.cc: avoid using non-librados facilities
authorKefu Chai <kchai@redhat.com>
Thu, 26 Oct 2017 09:34:23 +0000 (17:34 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 27 Oct 2017 05:58:15 +0000 (13:58 +0800)
a test for librados should be only depending on librados

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/librados/cmd.cc

index 0db73471326caa43a67b697b4e3bdde0cf94012c..043d98328f5e1d6e8cfa25b84b32f4e57ac855e4 100644 (file)
@@ -1,18 +1,14 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
-#include "mds/mdstypes.h"
-#include "include/buffer.h"
-#include "include/rbd_types.h"
 #include "include/rados/librados.h"
 #include "include/rados/librados.hpp"
 #include "include/stringify.h"
 #include "test/librados/test.h"
 
-#include "common/Cond.h"
-
 #include "gtest/gtest.h"
 #include <errno.h>
+#include <condition_variable>
 #include <map>
 #include <sstream>
 #include <string>
@@ -238,13 +234,11 @@ TEST(LibRadosCmd, PGCmdPP) {
 
 struct Log {
   list<string> log;
-  Cond cond;
-  Mutex lock;
-
-  Log() : lock("l::lock") {}
+  std::condition_variable cond;
+  std::mutex lock;
 
-  bool contains(string str) {
-    Mutex::Locker l(lock);
+  bool contains(const string& str) {
+    std::lock_guard<std::mutex> l(lock);
     for (list<string>::iterator p = log.begin(); p != log.end(); ++p) {
       if (p->find(str) != std::string::npos)
        return true;
@@ -259,9 +253,9 @@ void log_cb(void *arg,
             uint64_t seq, const char *level,
             const char *msg) {
   Log *l = static_cast<Log *>(arg);
-  Mutex::Locker locker(l->lock);
+  std::lock_guard<std::mutex> locker(l->lock);
   l->log.push_back(line);
-  l->cond.Signal();
+  l->cond.notify_all();
   cout << "got: " << line << std::endl;
 }