]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_keyvaluedb: clean up test dir 9051/head
authorSage Weil <sage@redhat.com>
Fri, 22 Apr 2016 20:38:14 +0000 (16:38 -0400)
committerSamuel Just <sjust@redhat.com>
Tue, 10 May 2016 18:02:14 +0000 (11:02 -0700)
Just like ceph_test_objectstore

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 2b075aa52d4475338c0f3cd3360e1ee4de8befa7)

src/test/objectstore/test_kv.cc

index 32eccb8389b81a5d0cdbc62771957bdf05eaefe8..06c45e0cb7e18e7d491eb9c46a15a2c6b8f0eeed 100644 (file)
@@ -35,29 +35,38 @@ public:
 
   KVTest() : db(0) {}
 
-  string mydirname() { return "kv_test_temp_dir_" + string(GetParam()); }
+  void rm_r(string path) {
+    string cmd = string("rm -r ") + path;
+    cout << "==> " << cmd << std::endl;
+    int r = ::system(cmd.c_str());
+    if (r) {
+      cerr << "failed with exit code " << r
+          << ", continuing anyway" << std::endl;
+    }
+  }
 
   void init() {
     cout << "Creating " << string(GetParam()) << "\n";
     db.reset(KeyValueDB::create(g_ceph_context, string(GetParam()),
-                               mydirname()));
+                               "kv_test_temp_dir"));
   }
   void fini() {
     db.reset(NULL);
   }
 
   virtual void SetUp() {
-    int r = ::mkdir(mydirname().c_str(), 0777);
+    int r = ::mkdir("kv_test_temp_dir", 0777);
     if (r < 0 && errno != EEXIST) {
       r = -errno;
-      cerr << __func__ << ": unable to create " << mydirname()
-          << ": " << cpp_strerror(r) << std::endl;
+      cerr << __func__ << ": unable to create kv_test_temp_dir: "
+          << cpp_strerror(r) << std::endl;
       return;
     }
     init();
   }
   virtual void TearDown() {
     fini();
+    rm_r("kv_test_temp_dir");
   }
 };