deletefile_test.cc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  7. // Use of this source code is governed by a BSD-style license that can be
  8. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  9. #ifndef ROCKSDB_LITE
  10. #include <stdlib.h>
  11. #include <map>
  12. #include <string>
  13. #include <vector>
  14. #include "db/db_impl/db_impl.h"
  15. #include "db/db_test_util.h"
  16. #include "db/version_set.h"
  17. #include "db/write_batch_internal.h"
  18. #include "file/filename.h"
  19. #include "port/stack_trace.h"
  20. #include "rocksdb/db.h"
  21. #include "rocksdb/env.h"
  22. #include "rocksdb/transaction_log.h"
  23. #include "test_util/sync_point.h"
  24. #include "test_util/testharness.h"
  25. #include "test_util/testutil.h"
  26. #include "util/string_util.h"
  27. namespace ROCKSDB_NAMESPACE {
  28. class DeleteFileTest : public DBTestBase {
  29. public:
  30. const int numlevels_;
  31. const std::string wal_dir_;
  32. DeleteFileTest()
  33. : DBTestBase("/deletefile_test"),
  34. numlevels_(7),
  35. wal_dir_(dbname_ + "/wal_files") {}
  36. void SetOptions(Options* options) {
  37. assert(options);
  38. options->delete_obsolete_files_period_micros = 0; // always do full purge
  39. options->enable_thread_tracking = true;
  40. options->write_buffer_size = 1024 * 1024 * 1000;
  41. options->target_file_size_base = 1024 * 1024 * 1000;
  42. options->max_bytes_for_level_base = 1024 * 1024 * 1000;
  43. options->WAL_ttl_seconds = 300; // Used to test log files
  44. options->WAL_size_limit_MB = 1024; // Used to test log files
  45. options->wal_dir = wal_dir_;
  46. }
  47. void AddKeys(int numkeys, int startkey = 0) {
  48. WriteOptions options;
  49. options.sync = false;
  50. ReadOptions roptions;
  51. for (int i = startkey; i < (numkeys + startkey) ; i++) {
  52. std::string temp = ToString(i);
  53. Slice key(temp);
  54. Slice value(temp);
  55. ASSERT_OK(db_->Put(options, key, value));
  56. }
  57. }
  58. int numKeysInLevels(
  59. std::vector<LiveFileMetaData> &metadata,
  60. std::vector<int> *keysperlevel = nullptr) {
  61. if (keysperlevel != nullptr) {
  62. keysperlevel->resize(numlevels_);
  63. }
  64. int numKeys = 0;
  65. for (size_t i = 0; i < metadata.size(); i++) {
  66. int startkey = atoi(metadata[i].smallestkey.c_str());
  67. int endkey = atoi(metadata[i].largestkey.c_str());
  68. int numkeysinfile = (endkey - startkey + 1);
  69. numKeys += numkeysinfile;
  70. if (keysperlevel != nullptr) {
  71. (*keysperlevel)[(int)metadata[i].level] += numkeysinfile;
  72. }
  73. fprintf(stderr, "level %d name %s smallest %s largest %s\n",
  74. metadata[i].level, metadata[i].name.c_str(),
  75. metadata[i].smallestkey.c_str(),
  76. metadata[i].largestkey.c_str());
  77. }
  78. return numKeys;
  79. }
  80. void CreateTwoLevels() {
  81. AddKeys(50000, 10000);
  82. ASSERT_OK(dbfull()->TEST_FlushMemTable());
  83. ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
  84. for (int i = 0; i < 2; ++i) {
  85. ASSERT_OK(dbfull()->TEST_CompactRange(i, nullptr, nullptr));
  86. }
  87. AddKeys(50000, 10000);
  88. ASSERT_OK(dbfull()->TEST_FlushMemTable());
  89. ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
  90. ASSERT_OK(dbfull()->TEST_CompactRange(0, nullptr, nullptr));
  91. }
  92. void CheckFileTypeCounts(const std::string& dir, int required_log,
  93. int required_sst, int required_manifest) {
  94. std::vector<std::string> filenames;
  95. env_->GetChildren(dir, &filenames);
  96. int log_cnt = 0, sst_cnt = 0, manifest_cnt = 0;
  97. for (auto file : filenames) {
  98. uint64_t number;
  99. FileType type;
  100. if (ParseFileName(file, &number, &type)) {
  101. log_cnt += (type == kLogFile);
  102. sst_cnt += (type == kTableFile);
  103. manifest_cnt += (type == kDescriptorFile);
  104. }
  105. }
  106. ASSERT_EQ(required_log, log_cnt);
  107. ASSERT_EQ(required_sst, sst_cnt);
  108. ASSERT_EQ(required_manifest, manifest_cnt);
  109. }
  110. static void DoSleep(void* arg) {
  111. auto test = reinterpret_cast<DeleteFileTest*>(arg);
  112. test->env_->SleepForMicroseconds(2 * 1000 * 1000);
  113. }
  114. // An empty job to guard all jobs are processed
  115. static void GuardFinish(void* /*arg*/) {
  116. TEST_SYNC_POINT("DeleteFileTest::GuardFinish");
  117. }
  118. };
  119. TEST_F(DeleteFileTest, AddKeysAndQueryLevels) {
  120. Options options = CurrentOptions();
  121. SetOptions(&options);
  122. Destroy(options);
  123. options.create_if_missing = true;
  124. Reopen(options);
  125. CreateTwoLevels();
  126. std::vector<LiveFileMetaData> metadata;
  127. db_->GetLiveFilesMetaData(&metadata);
  128. std::string level1file = "";
  129. int level1keycount = 0;
  130. std::string level2file = "";
  131. int level2keycount = 0;
  132. int level1index = 0;
  133. int level2index = 1;
  134. ASSERT_EQ((int)metadata.size(), 2);
  135. if (metadata[0].level == 2) {
  136. level1index = 1;
  137. level2index = 0;
  138. }
  139. level1file = metadata[level1index].name;
  140. int startkey = atoi(metadata[level1index].smallestkey.c_str());
  141. int endkey = atoi(metadata[level1index].largestkey.c_str());
  142. level1keycount = (endkey - startkey + 1);
  143. level2file = metadata[level2index].name;
  144. startkey = atoi(metadata[level2index].smallestkey.c_str());
  145. endkey = atoi(metadata[level2index].largestkey.c_str());
  146. level2keycount = (endkey - startkey + 1);
  147. // COntrolled setup. Levels 1 and 2 should both have 50K files.
  148. // This is a little fragile as it depends on the current
  149. // compaction heuristics.
  150. ASSERT_EQ(level1keycount, 50000);
  151. ASSERT_EQ(level2keycount, 50000);
  152. Status status = db_->DeleteFile("0.sst");
  153. ASSERT_TRUE(status.IsInvalidArgument());
  154. // intermediate level files cannot be deleted.
  155. status = db_->DeleteFile(level1file);
  156. ASSERT_TRUE(status.IsInvalidArgument());
  157. // Lowest level file deletion should succeed.
  158. ASSERT_OK(db_->DeleteFile(level2file));
  159. }
  160. TEST_F(DeleteFileTest, PurgeObsoleteFilesTest) {
  161. Options options = CurrentOptions();
  162. SetOptions(&options);
  163. Destroy(options);
  164. options.create_if_missing = true;
  165. Reopen(options);
  166. CreateTwoLevels();
  167. // there should be only one (empty) log file because CreateTwoLevels()
  168. // flushes the memtables to disk
  169. CheckFileTypeCounts(wal_dir_, 1, 0, 0);
  170. // 2 ssts, 1 manifest
  171. CheckFileTypeCounts(dbname_, 0, 2, 1);
  172. std::string first("0"), last("999999");
  173. CompactRangeOptions compact_options;
  174. compact_options.change_level = true;
  175. compact_options.target_level = 2;
  176. Slice first_slice(first), last_slice(last);
  177. db_->CompactRange(compact_options, &first_slice, &last_slice);
  178. // 1 sst after compaction
  179. CheckFileTypeCounts(dbname_, 0, 1, 1);
  180. // this time, we keep an iterator alive
  181. Reopen(options);
  182. Iterator *itr = nullptr;
  183. CreateTwoLevels();
  184. itr = db_->NewIterator(ReadOptions());
  185. db_->CompactRange(compact_options, &first_slice, &last_slice);
  186. // 3 sst after compaction with live iterator
  187. CheckFileTypeCounts(dbname_, 0, 3, 1);
  188. delete itr;
  189. // 1 sst after iterator deletion
  190. CheckFileTypeCounts(dbname_, 0, 1, 1);
  191. }
  192. TEST_F(DeleteFileTest, BackgroundPurgeIteratorTest) {
  193. Options options = CurrentOptions();
  194. SetOptions(&options);
  195. Destroy(options);
  196. options.create_if_missing = true;
  197. Reopen(options);
  198. std::string first("0"), last("999999");
  199. CompactRangeOptions compact_options;
  200. compact_options.change_level = true;
  201. compact_options.target_level = 2;
  202. Slice first_slice(first), last_slice(last);
  203. // We keep an iterator alive
  204. Iterator* itr = nullptr;
  205. CreateTwoLevels();
  206. ReadOptions read_options;
  207. read_options.background_purge_on_iterator_cleanup = true;
  208. itr = db_->NewIterator(read_options);
  209. db_->CompactRange(compact_options, &first_slice, &last_slice);
  210. // 3 sst after compaction with live iterator
  211. CheckFileTypeCounts(dbname_, 0, 3, 1);
  212. test::SleepingBackgroundTask sleeping_task_before;
  213. env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
  214. &sleeping_task_before, Env::Priority::HIGH);
  215. delete itr;
  216. test::SleepingBackgroundTask sleeping_task_after;
  217. env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
  218. &sleeping_task_after, Env::Priority::HIGH);
  219. // Make sure no purges are executed foreground
  220. CheckFileTypeCounts(dbname_, 0, 3, 1);
  221. sleeping_task_before.WakeUp();
  222. sleeping_task_before.WaitUntilDone();
  223. // Make sure all background purges are executed
  224. sleeping_task_after.WakeUp();
  225. sleeping_task_after.WaitUntilDone();
  226. // 1 sst after iterator deletion
  227. CheckFileTypeCounts(dbname_, 0, 1, 1);
  228. }
  229. TEST_F(DeleteFileTest, BackgroundPurgeCFDropTest) {
  230. Options options = CurrentOptions();
  231. SetOptions(&options);
  232. Destroy(options);
  233. options.create_if_missing = true;
  234. Reopen(options);
  235. auto do_test = [&](bool bg_purge) {
  236. ColumnFamilyOptions co;
  237. co.max_write_buffer_size_to_maintain =
  238. static_cast<int64_t>(co.write_buffer_size);
  239. WriteOptions wo;
  240. FlushOptions fo;
  241. ColumnFamilyHandle* cfh = nullptr;
  242. ASSERT_OK(db_->CreateColumnFamily(co, "dropme", &cfh));
  243. ASSERT_OK(db_->Put(wo, cfh, "pika", "chu"));
  244. ASSERT_OK(db_->Flush(fo, cfh));
  245. // Expect 1 sst file.
  246. CheckFileTypeCounts(dbname_, 0, 1, 1);
  247. ASSERT_OK(db_->DropColumnFamily(cfh));
  248. // Still 1 file, it won't be deleted while ColumnFamilyHandle is alive.
  249. CheckFileTypeCounts(dbname_, 0, 1, 1);
  250. delete cfh;
  251. test::SleepingBackgroundTask sleeping_task_after;
  252. env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
  253. &sleeping_task_after, Env::Priority::HIGH);
  254. // If background purge is enabled, the file should still be there.
  255. CheckFileTypeCounts(dbname_, 0, bg_purge ? 1 : 0, 1);
  256. TEST_SYNC_POINT("DeleteFileTest::BackgroundPurgeCFDropTest:1");
  257. // Execute background purges.
  258. sleeping_task_after.WakeUp();
  259. sleeping_task_after.WaitUntilDone();
  260. // The file should have been deleted.
  261. CheckFileTypeCounts(dbname_, 0, 0, 1);
  262. };
  263. {
  264. SCOPED_TRACE("avoid_unnecessary_blocking_io = false");
  265. do_test(false);
  266. }
  267. SyncPoint::GetInstance()->DisableProcessing();
  268. SyncPoint::GetInstance()->ClearAllCallBacks();
  269. SyncPoint::GetInstance()->LoadDependency(
  270. {{"DeleteFileTest::BackgroundPurgeCFDropTest:1",
  271. "DBImpl::BGWorkPurge:start"}});
  272. SyncPoint::GetInstance()->EnableProcessing();
  273. options.avoid_unnecessary_blocking_io = true;
  274. options.create_if_missing = false;
  275. Reopen(options);
  276. {
  277. SCOPED_TRACE("avoid_unnecessary_blocking_io = true");
  278. do_test(true);
  279. }
  280. }
  281. // This test is to reproduce a bug that read invalid ReadOption in iterator
  282. // cleanup function
  283. TEST_F(DeleteFileTest, BackgroundPurgeCopyOptions) {
  284. Options options = CurrentOptions();
  285. SetOptions(&options);
  286. Destroy(options);
  287. options.create_if_missing = true;
  288. Reopen(options);
  289. std::string first("0"), last("999999");
  290. CompactRangeOptions compact_options;
  291. compact_options.change_level = true;
  292. compact_options.target_level = 2;
  293. Slice first_slice(first), last_slice(last);
  294. // We keep an iterator alive
  295. Iterator* itr = nullptr;
  296. CreateTwoLevels();
  297. {
  298. ReadOptions read_options;
  299. read_options.background_purge_on_iterator_cleanup = true;
  300. itr = db_->NewIterator(read_options);
  301. // ReadOptions is deleted, but iterator cleanup function should not be
  302. // affected
  303. }
  304. db_->CompactRange(compact_options, &first_slice, &last_slice);
  305. // 3 sst after compaction with live iterator
  306. CheckFileTypeCounts(dbname_, 0, 3, 1);
  307. delete itr;
  308. test::SleepingBackgroundTask sleeping_task_after;
  309. env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
  310. &sleeping_task_after, Env::Priority::HIGH);
  311. // Make sure all background purges are executed
  312. sleeping_task_after.WakeUp();
  313. sleeping_task_after.WaitUntilDone();
  314. // 1 sst after iterator deletion
  315. CheckFileTypeCounts(dbname_, 0, 1, 1);
  316. }
  317. TEST_F(DeleteFileTest, BackgroundPurgeTestMultipleJobs) {
  318. Options options = CurrentOptions();
  319. SetOptions(&options);
  320. Destroy(options);
  321. options.create_if_missing = true;
  322. Reopen(options);
  323. std::string first("0"), last("999999");
  324. CompactRangeOptions compact_options;
  325. compact_options.change_level = true;
  326. compact_options.target_level = 2;
  327. Slice first_slice(first), last_slice(last);
  328. // We keep an iterator alive
  329. CreateTwoLevels();
  330. ReadOptions read_options;
  331. read_options.background_purge_on_iterator_cleanup = true;
  332. Iterator* itr1 = db_->NewIterator(read_options);
  333. CreateTwoLevels();
  334. Iterator* itr2 = db_->NewIterator(read_options);
  335. db_->CompactRange(compact_options, &first_slice, &last_slice);
  336. // 5 sst files after 2 compactions with 2 live iterators
  337. CheckFileTypeCounts(dbname_, 0, 5, 1);
  338. ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
  339. // ~DBImpl should wait until all BGWorkPurge are finished
  340. ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency(
  341. {{"DBImpl::~DBImpl:WaitJob", "DBImpl::BGWorkPurge"},
  342. {"DeleteFileTest::GuardFinish",
  343. "DeleteFileTest::BackgroundPurgeTestMultipleJobs:DBClose"}});
  344. ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing();
  345. delete itr1;
  346. env_->Schedule(&DeleteFileTest::DoSleep, this, Env::Priority::HIGH);
  347. delete itr2;
  348. env_->Schedule(&DeleteFileTest::GuardFinish, nullptr, Env::Priority::HIGH);
  349. Close();
  350. TEST_SYNC_POINT("DeleteFileTest::BackgroundPurgeTestMultipleJobs:DBClose");
  351. // 1 sst after iterator deletion
  352. CheckFileTypeCounts(dbname_, 0, 1, 1);
  353. }
  354. TEST_F(DeleteFileTest, DeleteFileWithIterator) {
  355. Options options = CurrentOptions();
  356. SetOptions(&options);
  357. Destroy(options);
  358. options.create_if_missing = true;
  359. Reopen(options);
  360. CreateTwoLevels();
  361. ReadOptions read_options;
  362. Iterator* it = db_->NewIterator(read_options);
  363. std::vector<LiveFileMetaData> metadata;
  364. db_->GetLiveFilesMetaData(&metadata);
  365. std::string level2file;
  366. ASSERT_EQ(metadata.size(), static_cast<size_t>(2));
  367. if (metadata[0].level == 1) {
  368. level2file = metadata[1].name;
  369. } else {
  370. level2file = metadata[0].name;
  371. }
  372. Status status = db_->DeleteFile(level2file);
  373. fprintf(stdout, "Deletion status %s: %s\n",
  374. level2file.c_str(), status.ToString().c_str());
  375. ASSERT_TRUE(status.ok());
  376. it->SeekToFirst();
  377. int numKeysIterated = 0;
  378. while(it->Valid()) {
  379. numKeysIterated++;
  380. it->Next();
  381. }
  382. ASSERT_EQ(numKeysIterated, 50000);
  383. delete it;
  384. }
  385. TEST_F(DeleteFileTest, DeleteLogFiles) {
  386. Options options = CurrentOptions();
  387. SetOptions(&options);
  388. Destroy(options);
  389. options.create_if_missing = true;
  390. Reopen(options);
  391. AddKeys(10, 0);
  392. VectorLogPtr logfiles;
  393. db_->GetSortedWalFiles(logfiles);
  394. ASSERT_GT(logfiles.size(), 0UL);
  395. // Take the last log file which is expected to be alive and try to delete it
  396. // Should not succeed because live logs are not allowed to be deleted
  397. std::unique_ptr<LogFile> alive_log = std::move(logfiles.back());
  398. ASSERT_EQ(alive_log->Type(), kAliveLogFile);
  399. ASSERT_OK(env_->FileExists(wal_dir_ + "/" + alive_log->PathName()));
  400. fprintf(stdout, "Deleting alive log file %s\n",
  401. alive_log->PathName().c_str());
  402. ASSERT_TRUE(!db_->DeleteFile(alive_log->PathName()).ok());
  403. ASSERT_OK(env_->FileExists(wal_dir_ + "/" + alive_log->PathName()));
  404. logfiles.clear();
  405. // Call Flush to bring about a new working log file and add more keys
  406. // Call Flush again to flush out memtable and move alive log to archived log
  407. // and try to delete the archived log file
  408. FlushOptions fopts;
  409. db_->Flush(fopts);
  410. AddKeys(10, 0);
  411. db_->Flush(fopts);
  412. db_->GetSortedWalFiles(logfiles);
  413. ASSERT_GT(logfiles.size(), 0UL);
  414. std::unique_ptr<LogFile> archived_log = std::move(logfiles.front());
  415. ASSERT_EQ(archived_log->Type(), kArchivedLogFile);
  416. ASSERT_OK(env_->FileExists(wal_dir_ + "/" + archived_log->PathName()));
  417. fprintf(stdout, "Deleting archived log file %s\n",
  418. archived_log->PathName().c_str());
  419. ASSERT_OK(db_->DeleteFile(archived_log->PathName()));
  420. ASSERT_EQ(Status::NotFound(),
  421. env_->FileExists(wal_dir_ + "/" + archived_log->PathName()));
  422. }
  423. TEST_F(DeleteFileTest, DeleteNonDefaultColumnFamily) {
  424. Options options = CurrentOptions();
  425. SetOptions(&options);
  426. Destroy(options);
  427. options.create_if_missing = true;
  428. Reopen(options);
  429. CreateAndReopenWithCF({"new_cf"}, options);
  430. Random rnd(5);
  431. for (int i = 0; i < 1000; ++i) {
  432. ASSERT_OK(db_->Put(WriteOptions(), handles_[1], test::RandomKey(&rnd, 10),
  433. test::RandomKey(&rnd, 10)));
  434. }
  435. ASSERT_OK(db_->Flush(FlushOptions(), handles_[1]));
  436. for (int i = 0; i < 1000; ++i) {
  437. ASSERT_OK(db_->Put(WriteOptions(), handles_[1], test::RandomKey(&rnd, 10),
  438. test::RandomKey(&rnd, 10)));
  439. }
  440. ASSERT_OK(db_->Flush(FlushOptions(), handles_[1]));
  441. std::vector<LiveFileMetaData> metadata;
  442. db_->GetLiveFilesMetaData(&metadata);
  443. ASSERT_EQ(2U, metadata.size());
  444. ASSERT_EQ("new_cf", metadata[0].column_family_name);
  445. ASSERT_EQ("new_cf", metadata[1].column_family_name);
  446. auto old_file = metadata[0].smallest_seqno < metadata[1].smallest_seqno
  447. ? metadata[0].name
  448. : metadata[1].name;
  449. auto new_file = metadata[0].smallest_seqno > metadata[1].smallest_seqno
  450. ? metadata[0].name
  451. : metadata[1].name;
  452. ASSERT_TRUE(db_->DeleteFile(new_file).IsInvalidArgument());
  453. ASSERT_OK(db_->DeleteFile(old_file));
  454. {
  455. std::unique_ptr<Iterator> itr(db_->NewIterator(ReadOptions(), handles_[1]));
  456. int count = 0;
  457. for (itr->SeekToFirst(); itr->Valid(); itr->Next()) {
  458. ASSERT_OK(itr->status());
  459. ++count;
  460. }
  461. ASSERT_EQ(count, 1000);
  462. }
  463. Close();
  464. ReopenWithColumnFamilies({kDefaultColumnFamilyName, "new_cf"}, options);
  465. {
  466. std::unique_ptr<Iterator> itr(db_->NewIterator(ReadOptions(), handles_[1]));
  467. int count = 0;
  468. for (itr->SeekToFirst(); itr->Valid(); itr->Next()) {
  469. ASSERT_OK(itr->status());
  470. ++count;
  471. }
  472. ASSERT_EQ(count, 1000);
  473. }
  474. }
  475. } // namespace ROCKSDB_NAMESPACE
  476. #ifdef ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
  477. extern "C" {
  478. void RegisterCustomObjects(int argc, char** argv);
  479. }
  480. #else
  481. void RegisterCustomObjects(int /*argc*/, char** /*argv*/) {}
  482. #endif // !ROCKSDB_UNITTESTS_WITH_CUSTOM_OBJECTS_FROM_STATIC_LIBS
  483. int main(int argc, char** argv) {
  484. ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
  485. ::testing::InitGoogleTest(&argc, argv);
  486. RegisterCustomObjects(argc, argv);
  487. return RUN_ALL_TESTS();
  488. }
  489. #else
  490. #include <stdio.h>
  491. int main(int /*argc*/, char** /*argv*/) {
  492. fprintf(stderr,
  493. "SKIPPED as DBImpl::DeleteFile is not supported in ROCKSDB_LITE\n");
  494. return 0;
  495. }
  496. #endif // !ROCKSDB_LITE