Skip to content

Commit

Permalink
test/filestore: add check of return values in StoreTest::SetUp
Browse files Browse the repository at this point in the history
add return value check for function calls, including mkdir, mkfs
and mount

Signed-off-by: Xing Lin <[email protected]>

test/filestore: fix return value check for mkdir

allow EEXIST from mkdir()

Signed-off-by: Xing Lin <[email protected]>
  • Loading branch information
xinglin committed Dec 3, 2013
1 parent 2884c81 commit de09778
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/test/filestore/store_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -39,11 +40,17 @@ class StoreTest : public ::testing::Test {

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() {
Expand Down

0 comments on commit de09778

Please sign in to comment.