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
This commit is contained in:
parent
9405b5ef8f
commit
28bc6de989
@ -13,6 +13,15 @@
|
|||||||
namespace rocksdb {
|
namespace rocksdb {
|
||||||
namespace test {
|
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 TmpDir(Env* env) {
|
||||||
std::string dir;
|
std::string dir;
|
||||||
Status s = env->GetTestDirectory(&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.
|
// runs may be able to vary the seed.
|
||||||
int RandomSeed();
|
int RandomSeed();
|
||||||
|
|
||||||
#define ASSERT_OK(s) ASSERT_TRUE(((s).ok()))
|
::testing::AssertionResult AssertStatus(const char* s_expr, const Status& s);
|
||||||
#define ASSERT_NOK(s) ASSERT_FALSE(((s).ok()))
|
|
||||||
#define EXPECT_OK(s) EXPECT_TRUE(((s).ok()))
|
#define ASSERT_OK(s) ASSERT_PRED_FORMAT1(rocksdb::test::AssertStatus, s)
|
||||||
#define EXPECT_NOK(s) EXPECT_FALSE(((s).ok()))
|
#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 test
|
||||||
} // namespace rocksdb
|
} // namespace rocksdb
|
||||||
|
Loading…
Reference in New Issue
Block a user