rocksdb: print status error message when (ASSERT|EXPECT)_OK fails

Summary: Modified rocksdb status assertions ASSERT_OK and EXPECT_OK to print error message from Status::ToString() when failed.

Test Plan: Modify a test to fail status assertions ASSERT_OK and EXPECT_OK and notice an error message that came from Status::ToString()

Reviewers: meyering, sdong, yhchiang, igor

Reviewed By: igor

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D35469
main
Igor Sugak 10 years ago
parent 9405b5ef8f
commit 28bc6de989
  1. 9
      util/testharness.cc
  2. 10
      util/testharness.h

@ -13,6 +13,15 @@
namespace rocksdb {
namespace test {
::testing::AssertionResult AssertStatus(const char* s_expr, const Status& s) {
if (s.ok()) {
return ::testing::AssertionSuccess();
} else {
return ::testing::AssertionFailure() << s_expr << std::endl
<< s.ToString();
}
}
std::string TmpDir(Env* env) {
std::string dir;
Status s = env->GetTestDirectory(&dir);

@ -25,10 +25,12 @@ std::string TmpDir(Env* env = Env::Default());
// runs may be able to vary the seed.
int RandomSeed();
#define ASSERT_OK(s) ASSERT_TRUE(((s).ok()))
#define ASSERT_NOK(s) ASSERT_FALSE(((s).ok()))
#define EXPECT_OK(s) EXPECT_TRUE(((s).ok()))
#define EXPECT_NOK(s) EXPECT_FALSE(((s).ok()))
::testing::AssertionResult AssertStatus(const char* s_expr, const Status& s);
#define ASSERT_OK(s) ASSERT_PRED_FORMAT1(rocksdb::test::AssertStatus, s)
#define ASSERT_NOK(s) ASSERT_FALSE((s).ok())
#define EXPECT_OK(s) EXPECT_PRED_FORMAT1(rocksdb::test::AssertStatus, s)
#define EXPECT_NOK(s) EXPECT_FALSE((s).ok())
} // namespace test
} // namespace rocksdb

Loading…
Cancel
Save