Fix broken test; some ldb commands can run without a db_

Summary:
It would appear our unit tests make use of code from ldb_cmd,
and don't always require a valid database handle.  D6855 was not aware
db_ could sometimes be NULL for such commands, and so it broke
reduce_levels_test.

This moves the check elsewhere to (at least) fix the 'ldb dump' case of
segfaulting when it couldn't open a database.

Test Plan: make check

Reviewers: dhruba

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D6903
This commit is contained in:
Chip Turner 2012-11-21 13:26:32 -08:00
parent 879e45eb99
commit 6caf3b8e4b
2 changed files with 3 additions and 4 deletions

View File

@ -126,6 +126,9 @@ void DBDumper::Help(std::string& ret) {
}
void DBDumper::DoCommand() {
if (!db_) {
return;
}
// Parse command line args
uint64_t count = 0;
if (print_stats_) {

View File

@ -134,10 +134,6 @@ public:
OpenDB();
}
if (!db_) {
return;
}
DoCommand();
if (exec_state_.IsNotStarted()) {
exec_state_ = LDBCommandExecuteResult::SUCCEED("");