]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/filestore: add check of return values in StoreTest::SetUp
authorXing Lin <xinglin@cs.utah.edu>
Thu, 28 Nov 2013 05:20:45 +0000 (22:20 -0700)
committerXing Lin <xinglin@cs.utah.edu>
Tue, 3 Dec 2013 18:18:55 +0000 (11:18 -0700)
add return value check for function calls, including mkdir, mkfs
and mount

Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
test/filestore: fix return value check for mkdir

allow EEXIST from mkdir()

Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
src/test/filestore/store_test.cc

index 50450f467ff00ff4a54f0759780af437b6008d1c..89c0f51ff215396fbffabf4150560d5307f93534 100644 (file)
@@ -23,6 +23,7 @@
 #include "global/global_init.h"
 #include "common/Mutex.h"
 #include "common/Cond.h"
+#include "common/errno.h"
 #include <boost/scoped_ptr.hpp>
 #include <boost/random/mersenne_twister.hpp>
 #include <boost/random/uniform_int.hpp>
@@ -39,11 +40,17 @@ public:
 
   StoreTest() : store(0) {}
   virtual void SetUp() {
-    ::mkdir("store_test_temp_dir", 0777);
+    int r = ::mkdir("store_test_temp_dir", 0777);
+    if (r < 0 && errno != EEXIST) {
+      r = -errno;
+      cerr << __func__ << ": unable to create store_test_temp_dir" << ": " << cpp_strerror(r) << std::endl;
+      return;
+    }
+
     ObjectStore *store_ = new FileStore(string("store_test_temp_dir"), string("store_test_temp_journal"));
     store.reset(store_);
-    store->mkfs();
-    store->mount();
+    EXPECT_EQ(store->mkfs(), 0);
+    EXPECT_EQ(store->mount(), 0);
   }
 
   virtual void TearDown() {