diff options
51 files changed, 351 insertions, 416 deletions
diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 448f183..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,36 +0,0 @@ -# Build matrix / environment variables are explained on: -# https://www.appveyor.com/docs/appveyor-yml/ -# This file can be validated on: https://ci.appveyor.com/tools/validate-yaml - -version: "{build}" - -environment: - matrix: - # AppVeyor currently has no custom job name feature. - # http://help.appveyor.com/discussions/questions/1623-can-i-provide-a-friendly-name-for-jobs - - JOB: Visual Studio 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - CMAKE_GENERATOR: Visual Studio 16 2019 - -platform: - - x86 - - x64 - -configuration: - - RelWithDebInfo - - Debug - -build_script: - - git submodule update --init --recursive - - mkdir build - - cd build - - if "%platform%"=="x86" (set CMAKE_GENERATOR_PLATFORM="Win32") - else (set CMAKE_GENERATOR_PLATFORM="%platform%") - - cmake --version - - cmake .. -G "%CMAKE_GENERATOR%" -A "%CMAKE_GENERATOR_PLATFORM%" - -DCMAKE_CONFIGURATION_TYPES="%CONFIGURATION%" - - cmake --build . --config "%CONFIGURATION%" - - cd .. - -test_script: - - cd build && ctest --verbose --build-config "%CONFIGURATION%" && cd .. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..efb81ee --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,101 @@ +# Copyright 2021 The LevelDB Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. See the AUTHORS file for names of contributors. + +name: ci +on: [push, pull_request] + +permissions: + contents: read + +jobs: + build-and-test: + name: >- + CI + ${{ matrix.os }} + ${{ matrix.compiler }} + ${{ matrix.optimized && 'release' || 'debug' }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + compiler: [clang, gcc, msvc] + os: [ubuntu-latest, macos-latest, windows-latest] + optimized: [true, false] + exclude: + # MSVC only works on Windows. + - os: ubuntu-latest + compiler: msvc + - os: macos-latest + compiler: msvc + # Not testing with GCC on macOS. + - os: macos-latest + compiler: gcc + # Only testing with MSVC on Windows. + - os: windows-latest + compiler: clang + - os: windows-latest + compiler: gcc + include: + - compiler: clang + CC: clang + CXX: clang++ + - compiler: gcc + CC: gcc + CXX: g++ + - compiler: msvc + CC: + CXX: + + env: + CMAKE_BUILD_DIR: ${{ github.workspace }}/build + CMAKE_BUILD_TYPE: ${{ matrix.optimized && 'RelWithDebInfo' || 'Debug' }} + CC: ${{ matrix.CC }} + CXX: ${{ matrix.CXX }} + BINARY_SUFFIX: ${{ startsWith(matrix.os, 'windows') && '.exe' || '' }} + BINARY_PATH: >- + ${{ format( + startsWith(matrix.os, 'windows') && '{0}\build\{1}\' || '{0}/build/', + github.workspace, + matrix.optimized && 'RelWithDebInfo' || 'Debug') }} + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Install dependencies on Linux + if: ${{ runner.os == 'Linux' }} + run: | + sudo apt-get update + sudo apt-get install libgoogle-perftools-dev libkyotocabinet-dev \ + libsnappy-dev libsqlite3-dev + + - name: Generate build config + run: >- + cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" + -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} + -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/install_test/ + + - name: Build + run: >- + cmake --build "${{ env.CMAKE_BUILD_DIR }}" + --config "${{ env.CMAKE_BUILD_TYPE }}" + + - name: Run Tests + working-directory: ${{ github.workspace }}/build + run: ctest -C "${{ env.CMAKE_BUILD_TYPE }}" --verbose + + - name: Run LevelDB Benchmarks + run: ${{ env.BINARY_PATH }}db_bench${{ env.BINARY_SUFFIX }} + + - name: Run SQLite Benchmarks + if: ${{ runner.os != 'Windows' }} + run: ${{ env.BINARY_PATH }}db_bench_sqlite3${{ env.BINARY_SUFFIX }} + + - name: Run Kyoto Cabinet Benchmarks + if: ${{ runner.os == 'Linux' && matrix.compiler == 'clang' }} + run: ${{ env.BINARY_PATH }}db_bench_tree_db${{ env.BINARY_SUFFIX }} + + - name: Test CMake installation + run: cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e34a67e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,88 +0,0 @@ -# Build matrix / environment variables are explained on: -# http://about.travis-ci.org/docs/user/build-configuration/ -# This file can be validated on: http://lint.travis-ci.org/ - -language: cpp -dist: bionic -osx_image: xcode12.2 - -compiler: -- gcc -- clang -os: -- linux -- osx - -env: -- BUILD_TYPE=Debug -- BUILD_TYPE=RelWithDebInfo - -jobs: - allow_failures: - # Homebrew's GCC is currently broken on XCode 11. - - compiler: gcc - os: osx - -addons: - apt: - sources: - - sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main' - key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key' - - sourceline: 'ppa:ubuntu-toolchain-r/test' - packages: - - clang-10 - - cmake - - gcc-10 - - g++-10 - - libgoogle-perftools-dev - - libkyotocabinet-dev - - libsnappy-dev - - libsqlite3-dev - - ninja-build - homebrew: - packages: - - cmake - - crc32c - - gcc@10 - - gperftools - - kyoto-cabinet - - llvm@10 - - ninja - - snappy - - sqlite3 - update: true - -install: -# The following Homebrew packages aren't linked by default, and need to be -# prepended to the path explicitly. -- if [ "$TRAVIS_OS_NAME" = "osx" ]; then - export PATH="$(brew --prefix llvm)/bin:$PATH"; - fi -# /usr/bin/gcc points to an older compiler on both Linux and macOS. -- if [ "$CXX" = "g++" ]; then export CXX="g++-10" CC="gcc-10"; fi -# /usr/bin/clang points to an older compiler on both Linux and macOS. -# -# Homebrew's llvm package doesn't ship a versioned clang++ binary, so the values -# below don't work on macOS. Fortunately, the path change above makes the -# default values (clang and clang++) resolve to the correct compiler on macOS. -- if [ "$TRAVIS_OS_NAME" = "linux" ]; then - if [ "$CXX" = "clang++" ]; then export CXX="clang++-10" CC="clang-10"; fi; - fi -- echo ${CC} -- echo ${CXX} -- ${CXX} --version -- cmake --version - -before_script: -- mkdir -p build && cd build -- cmake .. -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE - -DCMAKE_INSTALL_PREFIX=$HOME/.local -- cmake --build . -- cd .. - -script: -- cd build && ctest --verbose && cd .. -- "if [ -f build/db_bench ] ; then build/db_bench ; fi" -- "if [ -f build/db_bench_sqlite3 ] ; then build/db_bench_sqlite3 ; fi" -- "if [ -f build/db_bench_tree_db ] ; then build/db_bench_tree_db ; fi" -- cd build && cmake --build . --target install diff --git a/CMakeLists.txt b/CMakeLists.txt index f8285b8..b829c94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -298,11 +298,6 @@ if(LEVELDB_BUILD_TESTS) # This project is tested using GoogleTest. add_subdirectory("third_party/googletest") - # This project uses Google benchmark for benchmarking. - set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE) - set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE) - add_subdirectory("third_party/benchmark") - # GoogleTest triggers a missing field initializers warning. if(LEVELDB_HAVE_NO_MISSING_FIELD_INITIALIZERS) set_property(TARGET gtest @@ -311,6 +306,60 @@ if(LEVELDB_BUILD_TESTS) APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers) endif(LEVELDB_HAVE_NO_MISSING_FIELD_INITIALIZERS) + add_executable(leveldb_tests "") + target_sources(leveldb_tests + PRIVATE + # "db/fault_injection_test.cc" + # "issues/issue178_test.cc" + # "issues/issue200_test.cc" + # "issues/issue320_test.cc" + "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h" + # "util/env_test.cc" + "util/status_test.cc" + "util/no_destructor_test.cc" + "util/testutil.cc" + "util/testutil.h" + ) + if(NOT BUILD_SHARED_LIBS) + target_sources(leveldb_tests + PRIVATE + "db/autocompact_test.cc" + "db/corruption_test.cc" + "db/db_test.cc" + "db/dbformat_test.cc" + "db/filename_test.cc" + "db/log_test.cc" + "db/recovery_test.cc" + "db/skiplist_test.cc" + "db/version_edit_test.cc" + "db/version_set_test.cc" + "db/write_batch_test.cc" + "helpers/memenv/memenv_test.cc" + "table/filter_block_test.cc" + "table/table_test.cc" + "util/arena_test.cc" + "util/bloom_test.cc" + "util/cache_test.cc" + "util/coding_test.cc" + "util/crc32c_test.cc" + "util/hash_test.cc" + "util/logging_test.cc" + ) + endif(NOT BUILD_SHARED_LIBS) + target_link_libraries(leveldb_tests leveldb gmock gtest gtest_main) + target_compile_definitions(leveldb_tests + PRIVATE + ${LEVELDB_PLATFORM_NAME}=1 + ) + if (NOT HAVE_CXX17_HAS_INCLUDE) + target_compile_definitions(leveldb_tests + PRIVATE + LEVELDB_HAS_PORT_CONFIG_H=1 + ) + endif(NOT HAVE_CXX17_HAS_INCLUDE) + + add_test(NAME "leveldb_tests" COMMAND "leveldb_tests") + function(leveldb_test test_file) get_filename_component(test_target_name "${test_file}" NAME_WE) @@ -323,7 +372,7 @@ if(LEVELDB_BUILD_TESTS) "${test_file}" ) - target_link_libraries("${test_target_name}" leveldb gmock gtest benchmark) + target_link_libraries("${test_target_name}" leveldb gmock gtest) target_compile_definitions("${test_target_name}" PRIVATE ${LEVELDB_PLATFORM_NAME}=1 @@ -339,42 +388,8 @@ if(LEVELDB_BUILD_TESTS) endfunction(leveldb_test) leveldb_test("db/c_test.c") - leveldb_test("db/fault_injection_test.cc") - - leveldb_test("issues/issue178_test.cc") - leveldb_test("issues/issue200_test.cc") - leveldb_test("issues/issue320_test.cc") - - leveldb_test("util/env_test.cc") - leveldb_test("util/status_test.cc") - leveldb_test("util/no_destructor_test.cc") if(NOT BUILD_SHARED_LIBS) - leveldb_test("db/autocompact_test.cc") - leveldb_test("db/corruption_test.cc") - leveldb_test("db/db_test.cc") - leveldb_test("db/dbformat_test.cc") - leveldb_test("db/filename_test.cc") - leveldb_test("db/log_test.cc") - leveldb_test("db/recovery_test.cc") - leveldb_test("db/skiplist_test.cc") - leveldb_test("db/version_edit_test.cc") - leveldb_test("db/version_set_test.cc") - leveldb_test("db/write_batch_test.cc") - - leveldb_test("helpers/memenv/memenv_test.cc") - - leveldb_test("table/filter_block_test.cc") - leveldb_test("table/table_test.cc") - - leveldb_test("util/arena_test.cc") - leveldb_test("util/bloom_test.cc") - leveldb_test("util/cache_test.cc") - leveldb_test("util/coding_test.cc") - leveldb_test("util/crc32c_test.cc") - leveldb_test("util/hash_test.cc") - leveldb_test("util/logging_test.cc") - # TODO(costan): This test also uses # "util/env_{posix|windows}_test_helper.h" if (WIN32) @@ -386,6 +401,11 @@ if(LEVELDB_BUILD_TESTS) endif(LEVELDB_BUILD_TESTS) if(LEVELDB_BUILD_BENCHMARKS) + # This project uses Google benchmark for benchmarking. + set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE) + set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE) + add_subdirectory("third_party/benchmark") + function(leveldb_benchmark bench_file) get_filename_component(bench_target_name "${bench_file}" NAME_WE) @@ -400,7 +420,7 @@ if(LEVELDB_BUILD_BENCHMARKS) "${bench_file}" ) - target_link_libraries("${bench_target_name}" leveldb gmock gtest) + target_link_libraries("${bench_target_name}" leveldb gmock gtest benchmark) target_compile_definitions("${bench_target_name}" PRIVATE ${LEVELDB_PLATFORM_NAME}=1 @@ -1,7 +1,6 @@ **LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.** -[![Build Status](https://travis-ci.org/google/leveldb.svg?branch=master)](https://travis-ci.org/google/leveldb) -[![Build status](https://ci.appveyor.com/api/projects/status/g2j5j4rfkda6eyw5/branch/master?svg=true)](https://ci.appveyor.com/project/pwnall/leveldb) +[![ci](https://github.com/google/leveldb/actions/workflows/build.yml/badge.svg)](https://github.com/google/leveldb/actions/workflows/build.yml) Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com) diff --git a/benchmarks/db_bench_log.cc b/benchmarks/db_bench_log.cc new file mode 100644 index 0000000..a1845bf --- /dev/null +++ b/benchmarks/db_bench_log.cc @@ -0,0 +1,92 @@ +// Copyright (c) 2019 The LevelDB Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. See the AUTHORS file for names of contributors. + +#include <cinttypes> +#include <cstdio> +#include <string> + +#include "gtest/gtest.h" +#include "benchmark/benchmark.h" +#include "db/version_set.h" +#include "leveldb/comparator.h" +#include "leveldb/db.h" +#include "leveldb/env.h" +#include "leveldb/options.h" +#include "port/port.h" +#include "util/mutexlock.h" +#include "util/testutil.h" + +namespace leveldb { + +namespace { + +std::string MakeKey(unsigned int num) { + char buf[30]; + std::snprintf(buf, sizeof(buf), "%016u", num); + return std::string(buf); +} + +void BM_LogAndApply(benchmark::State& state) { + const int num_base_files = state.range(0); + + std::string dbname = testing::TempDir() + "leveldb_test_benchmark"; + DestroyDB(dbname, Options()); + + DB* db = nullptr; + Options opts; + opts.create_if_missing = true; + Status s = DB::Open(opts, dbname, &db); + ASSERT_LEVELDB_OK(s); + ASSERT_TRUE(db != nullptr); + + delete db; + db = nullptr; + + Env* env = Env::Default(); + + port::Mutex mu; + MutexLock l(&mu); + + InternalKeyComparator cmp(BytewiseComparator()); + Options options; + VersionSet vset(dbname, &options, nullptr, &cmp); + bool save_manifest; + ASSERT_LEVELDB_OK(vset.Recover(&save_manifest)); + VersionEdit vbase; + uint64_t fnum = 1; + for (int i = 0; i < num_base_files; i++) { + InternalKey start(MakeKey(2 * fnum), 1, kTypeValue); + InternalKey limit(MakeKey(2 * fnum + 1), 1, kTypeDeletion); + vbase.AddFile(2, fnum++, 1 /* file size */, start, limit); + } + ASSERT_LEVELDB_OK(vset.LogAndApply(&vbase, &mu)); + + uint64_t start_micros = env->NowMicros(); + + for (auto st : state) { + VersionEdit vedit; + vedit.RemoveFile(2, fnum); + InternalKey start(MakeKey(2 * fnum), 1, kTypeValue); + InternalKey limit(MakeKey(2 * fnum + 1), 1, kTypeDeletion); + vedit.AddFile(2, fnum++, 1 /* file size */, start, limit); + vset.LogAndApply(&vedit, &mu); + } + + uint64_t stop_micros = env->NowMicros(); + unsigned int us = stop_micros - start_micros; + char buf[16]; + std::snprintf(buf, sizeof(buf), "%d", num_base_files); + std::fprintf(stderr, + "BM_LogAndApply/%-6s %8" PRIu64 + " iters : %9u us (%7.0f us / iter)\n", + buf, state.iterations(), us, ((float)us) / state.iterations()); +} + +BENCHMARK(BM_LogAndApply)->Arg(1)->Arg(100)->Arg(10000)->Arg(100000); + +} // namespace + +} // namespace leveldb + +BENCHMARK_MAIN(); diff --git a/db/autocompact_test.cc b/db/autocompact_test.cc index 3b7241b..69341e3 100644 --- a/db/autocompact_test.cc +++ b/db/autocompact_test.cc @@ -108,8 +108,3 @@ TEST_F(AutoCompactTest, ReadAll) { DoReads(kCount); } TEST_F(AutoCompactTest, ReadHalf) { DoReads(kCount / 2); } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/corruption_test.cc b/db/corruption_test.cc index a31f448..dc7da76 100644 --- a/db/corruption_test.cc +++ b/db/corruption_test.cc @@ -360,8 +360,3 @@ TEST_F(CorruptionTest, UnrelatedKeys) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/db_test.cc b/db/db_test.cc index 908b41d..9bd6e14 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -9,7 +9,6 @@ #include <string> #include "gtest/gtest.h" -#include "benchmark/benchmark.h" #include "db/db_impl.h" #include "db/filename.h" #include "db/version_set.h" @@ -2295,72 +2294,4 @@ TEST_F(DBTest, Randomized) { } while (ChangeOptions()); } -std::string MakeKey(unsigned int num) { - char buf[30]; - std::snprintf(buf, sizeof(buf), "%016u", num); - return std::string(buf); -} - -static void BM_LogAndApply(benchmark::State& state) { - const int num_base_files = state.range(0); - - std::string dbname = testing::TempDir() + "leveldb_test_benchmark"; - DestroyDB(dbname, Options()); - - DB* db = nullptr; - Options opts; - opts.create_if_missing = true; - Status s = DB::Open(opts, dbname, &db); - ASSERT_LEVELDB_OK(s); - ASSERT_TRUE(db != nullptr); - - delete db; - db = nullptr; - - Env* env = Env::Default(); - - port::Mutex mu; - MutexLock l(&mu); - - InternalKeyComparator cmp(BytewiseComparator()); - Options options; - VersionSet vset(dbname, &options, nullptr, &cmp); - bool save_manifest; - ASSERT_LEVELDB_OK(vset.Recover(&save_manifest)); - VersionEdit vbase; - uint64_t fnum = 1; - for (int i = 0; i < num_base_files; i++) { - InternalKey start(MakeKey(2 * fnum), 1, kTypeValue); - InternalKey limit(MakeKey(2 * fnum + 1), 1, kTypeDeletion); - vbase.AddFile(2, fnum++, 1 /* file size */, start, limit); - } - ASSERT_LEVELDB_OK(vset.LogAndApply(&vbase, &mu)); - - uint64_t start_micros = env->NowMicros(); - - for (auto st : state) { - VersionEdit vedit; - vedit.RemoveFile(2, fnum); - InternalKey start(MakeKey(2 * fnum), 1, kTypeValue); - InternalKey limit(MakeKey(2 * fnum + 1), 1, kTypeDeletion); - vedit.AddFile(2, fnum++, 1 /* file size */, start, limit); - vset.LogAndApply(&vedit, &mu); - } - uint64_t stop_micros = env->NowMicros(); - unsigned int us = stop_micros - start_micros; - char buf[16]; - std::snprintf(buf, sizeof(buf), "%d", num_base_files); - std::fprintf(stderr, - "BM_LogAndApply/%-6s %8" PRIu64 - " iters : %9u us (%7.0f us / iter)\n", - buf, state.iterations(), us, ((float)us) / state.iterations()); -} - -BENCHMARK(BM_LogAndApply)->Arg(1)->Arg(100)->Arg(10000)->Arg(100000); } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); - return RUN_ALL_TESTS(); -} diff --git a/db/dbformat_test.cc b/db/dbformat_test.cc index 4a11c4a..7f3f81a 100644 --- a/db/dbformat_test.cc +++ b/db/dbformat_test.cc @@ -126,8 +126,3 @@ TEST(FormatTest, InternalKeyDebugString) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/fault_injection_test.cc b/db/fault_injection_test.cc index 6eebafa..ef864a4 100644 --- a/db/fault_injection_test.cc +++ b/db/fault_injection_test.cc @@ -548,8 +548,3 @@ TEST_F(FaultInjectionTest, FaultTestWithLogReuse) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/filename_test.cc b/db/filename_test.cc index f291d72..9ac0111 100644 --- a/db/filename_test.cc +++ b/db/filename_test.cc @@ -125,8 +125,3 @@ TEST(FileNameTest, Construction) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/log_reader.h b/db/log_reader.h index 75d53f7..ba711f8 100644 --- a/db/log_reader.h +++ b/db/log_reader.h @@ -24,7 +24,7 @@ class Reader { public: virtual ~Reporter(); - // Some corruption was detected. "size" is the approximate number + // Some corruption was detected. "bytes" is the approximate number // of bytes dropped due to the corruption. virtual void Corruption(size_t bytes, const Status& status) = 0; }; diff --git a/db/log_test.cc b/db/log_test.cc index 346b19c..d55d4dd 100644 --- a/db/log_test.cc +++ b/db/log_test.cc @@ -556,8 +556,3 @@ TEST_F(LogTest, ReadPastEnd) { CheckOffsetPastEndReturnsNoRecords(5); } } // namespace log } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/memtable.cc b/db/memtable.cc index f42774d..4f09340 100644 --- a/db/memtable.cc +++ b/db/memtable.cc @@ -78,6 +78,7 @@ void MemTable::Add(SequenceNumber s, ValueType type, const Slice& key, // Format of an entry is concatenation of: // key_size : varint32 of internal_key.size() // key bytes : char[internal_key.size()] + // tag : uint64((sequence << 8) | type) // value_size : varint32 of value.size() // value bytes : char[value.size()] size_t key_size = key.size(); diff --git a/db/recovery_test.cc b/db/recovery_test.cc index 3db817e..1d9f621 100644 --- a/db/recovery_test.cc +++ b/db/recovery_test.cc @@ -18,7 +18,7 @@ namespace leveldb { class RecoveryTest : public testing::Test { public: RecoveryTest() : env_(Env::Default()), db_(nullptr) { - dbname_ = testing::TempDir() + "/recovery_test"; + dbname_ = testing::TempDir() + "recovery_test"; DestroyDB(dbname_, Options()); Open(); } @@ -332,8 +332,3 @@ TEST_F(RecoveryTest, ManifestMissing) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/skiplist.h b/db/skiplist.h index 00f4132..1140e59 100644 --- a/db/skiplist.h +++ b/db/skiplist.h @@ -241,7 +241,7 @@ int SkipList<Key, Comparator>::RandomHeight() { // Increase height with probability 1 in kBranching static const unsigned int kBranching = 4; int height = 1; - while (height < kMaxHeight && ((rnd_.Next() % kBranching) == 0)) { + while (height < kMaxHeight && rnd_.OneIn(kBranching)) { height++; } assert(height > 0); diff --git a/db/skiplist_test.cc b/db/skiplist_test.cc index 79a5b86..1d355cb 100644 --- a/db/skiplist_test.cc +++ b/db/skiplist_test.cc @@ -366,8 +366,3 @@ TEST(SkipTest, Concurrent4) { RunConcurrent(4); } TEST(SkipTest, Concurrent5) { RunConcurrent(5); } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/snapshot.h b/db/snapshot.h index 9f1d664..817bb7b 100644 --- a/db/snapshot.h +++ b/db/snapshot.h @@ -25,7 +25,7 @@ class SnapshotImpl : public Snapshot { friend class SnapshotList; // SnapshotImpl is kept in a doubly-linked circular list. The SnapshotList - // implementation operates on the next/previous fields direcly. + // implementation operates on the next/previous fields directly. SnapshotImpl* prev_; SnapshotImpl* next_; diff --git a/db/table_cache.h b/db/table_cache.h index aac9bfc..db8a123 100644 --- a/db/table_cache.h +++ b/db/table_cache.h @@ -22,6 +22,10 @@ class Env; class TableCache { public: TableCache(const std::string& dbname, const Options& options, int entries); + + TableCache(const TableCache&) = delete; + TableCache& operator=(const TableCache&) = delete; + ~TableCache(); // Return an iterator for the specified file number (the corresponding diff --git a/db/version_edit.cc b/db/version_edit.cc index 3e9012f..356ce88 100644 --- a/db/version_edit.cc +++ b/db/version_edit.cc @@ -34,6 +34,7 @@ void VersionEdit::Clear() { has_prev_log_number_ = false; has_next_file_number_ = false; has_last_sequence_ = false; + compact_pointers_.clear(); deleted_files_.clear(); new_files_.clear(); } diff --git a/db/version_edit_test.cc b/db/version_edit_test.cc index acafab0..a108c15 100644 --- a/db/version_edit_test.cc +++ b/db/version_edit_test.cc @@ -39,8 +39,3 @@ TEST(VersionEditTest, EncodeDecode) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/version_set.cc b/db/version_set.cc index 1963353..4e37bf9 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -626,7 +626,7 @@ class VersionSet::Builder { } // Apply all of the edits in *edit to the current state. - void Apply(VersionEdit* edit) { + void Apply(const VersionEdit* edit) { // Update compaction pointers for (size_t i = 0; i < edit->compact_pointers_.size(); i++) { const int level = edit->compact_pointers_[i].first; @@ -806,7 +806,6 @@ Status VersionSet::LogAndApply(VersionEdit* edit, port::Mutex* mu) { // first call to LogAndApply (when opening the database). assert(descriptor_file_ == nullptr); new_manifest_file = DescriptorFileName(dbname_, manifest_file_number_); - edit->SetNextFile(next_file_number_); s = env_->NewWritableFile(new_manifest_file, &descriptor_file_); if (s.ok()) { descriptor_log_ = new log::Writer(descriptor_file_); @@ -1304,7 +1303,7 @@ Compaction* VersionSet::PickCompaction() { return c; } -// Finds the largest key in a vector of files. Returns true if files it not +// Finds the largest key in a vector of files. Returns true if files is not // empty. bool FindLargestKey(const InternalKeyComparator& icmp, const std::vector<FileMetaData*>& files, @@ -1392,6 +1391,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) { current_->GetOverlappingInputs(level + 1, &smallest, &largest, &c->inputs_[1]); + AddBoundaryInputs(icmp_, current_->files_[level + 1], &c->inputs_[1]); // Get entire range covered by compaction InternalKey all_start, all_limit; @@ -1414,6 +1414,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) { std::vector<FileMetaData*> expanded1; current_->GetOverlappingInputs(level + 1, &new_start, &new_limit, &expanded1); + AddBoundaryInputs(icmp_, current_->files_[level + 1], &expanded1); if (expanded1.size() == c->inputs_[1].size()) { Log(options_->info_log, "Expanding@%d %d+%d (%ld+%ld bytes) to %d+%d (%ld+%ld bytes)\n", diff --git a/db/version_set.h b/db/version_set.h index 69f3d70..ea0c925 100644 --- a/db/version_set.h +++ b/db/version_set.h @@ -59,9 +59,6 @@ bool SomeFileOverlapsRange(const InternalKeyComparator& icmp, class Version { public: - // Lookup the value for key. If found, store it in *val and - // return OK. Else return a non-OK status. Fills *stats. - // REQUIRES: lock is not held struct GetStats { FileMetaData* seek_file; int seek_file_level; @@ -72,6 +69,9 @@ class Version { // REQUIRES: This version has been saved (see VersionSet::SaveTo) void AddIterators(const ReadOptions&, std::vector<Iterator*>* iters); + // Lookup the value for key. If found, store it in *val and + // return OK. Else return a non-OK status. Fills *stats. + // REQUIRES: lock is not held Status Get(const ReadOptions&, const LookupKey& key, std::string* val, GetStats* stats); diff --git a/db/version_set_test.cc b/db/version_set_test.cc index dee6b4c..64bb983 100644 --- a/db/version_set_test.cc +++ b/db/version_set_test.cc @@ -329,8 +329,3 @@ TEST_F(AddBoundaryInputsTest, TestDisjoinFilePointers) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/db/write_batch_test.cc b/db/write_batch_test.cc index 64df9b8..1a3ea8f 100644 --- a/db/write_batch_test.cc +++ b/db/write_batch_test.cc @@ -130,8 +130,3 @@ TEST(WriteBatchTest, ApproximateSize) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/doc/index.md b/doc/index.md index 01693ad..0f6d649 100644 --- a/doc/index.md +++ b/doc/index.md @@ -369,6 +369,7 @@ leveldb::Iterator* it = db->NewIterator(options); for (it->SeekToFirst(); it->Valid(); it->Next()) { ... } +delete it; ``` ### Key Layout @@ -424,21 +425,21 @@ spaces. For example: ```c++ class CustomFilterPolicy : public leveldb::FilterPolicy { private: - FilterPolicy* builtin_policy_; + leveldb::FilterPolicy* builtin_policy_; public: - CustomFilterPolicy() : builtin_policy_(NewBloomFilterPolicy(10)) {} + CustomFilterPolicy() : builtin_policy_(leveldb::NewBloomFilterPolicy(10)) {} ~CustomFilterPolicy() { delete builtin_policy_; } const char* Name() const { return "IgnoreTrailingSpacesFilter"; } - void CreateFilter(const Slice* keys, int n, std::string* dst) const { + void CreateFilter(const leveldb::Slice* keys, int n, std::string* dst) const { // Use builtin bloom filter code after removing trailing spaces - std::vector<Slice> trimmed(n); + std::vector<leveldb::Slice> trimmed(n); for (int i = 0; i < n; i++) { trimmed[i] = RemoveTrailingSpaces(keys[i]); } - return builtin_policy_->CreateFilter(trimmed.data(), n, dst); + builtin_policy_->CreateFilter(trimmed.data(), n, dst); } }; ``` diff --git a/helpers/memenv/memenv_test.cc b/helpers/memenv/memenv_test.cc index 3f03cb6..909a0ca 100644 --- a/helpers/memenv/memenv_test.cc +++ b/helpers/memenv/memenv_test.cc @@ -257,8 +257,3 @@ TEST_F(MemEnvTest, DBTest) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/include/leveldb/cache.h b/include/leveldb/cache.h index 98c95ac..a94c683 100644 --- a/include/leveldb/cache.h +++ b/include/leveldb/cache.h @@ -96,14 +96,6 @@ class LEVELDB_EXPORT Cache { // Return an estimate of the combined charges of all elements stored in the // cache. virtual size_t TotalCharge() const = 0; - - private: - void LRU_Remove(Handle* e); - void LRU_Append(Handle* e); - void Unref(Handle* e); - - struct Rep; - Rep* rep_; }; } // namespace leveldb diff --git a/issues/issue178_test.cc b/issues/issue178_test.cc index 8fa5bb9..5cd5862 100644 --- a/issues/issue178_test.cc +++ b/issues/issue178_test.cc @@ -83,8 +83,3 @@ TEST(Issue178, Test) { } } // anonymous namespace - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/issues/issue200_test.cc b/issues/issue200_test.cc index 4eba23a..959b371 100644 --- a/issues/issue200_test.cc +++ b/issues/issue200_test.cc @@ -52,8 +52,3 @@ TEST(Issue200, Test) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/issues/issue320_test.cc b/issues/issue320_test.cc index c08296a..9d7fa7b 100644 --- a/issues/issue320_test.cc +++ b/issues/issue320_test.cc @@ -124,8 +124,3 @@ TEST(Issue320, Test) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/port/port_example.h b/port/port_example.h index a665910..704aa24 100644 --- a/port/port_example.h +++ b/port/port_example.h @@ -55,7 +55,7 @@ class CondVar { void Signal(); // Wake up all waiting threads. - void SignallAll(); + void SignalAll(); }; // ------------------ Compression ------------------- diff --git a/table/filter_block_test.cc b/table/filter_block_test.cc index 91a6be2..3ee41cf 100644 --- a/table/filter_block_test.cc +++ b/table/filter_block_test.cc @@ -120,8 +120,3 @@ TEST_F(FilterBlockTest, MultiChunk) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/table/table_test.cc b/table/table_test.cc index 190dd0f..7f0f998 100644 --- a/table/table_test.cc +++ b/table/table_test.cc @@ -827,8 +827,3 @@ TEST(TableTest, ApproximateOffsetOfCompressed) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/third_party/benchmark b/third_party/benchmark -Subproject bf585a2789e30585b4e3ce6baf11ef2750b5467 +Subproject 7d0d9061d83b663ce05d9de5da3d5865a3845b7 diff --git a/third_party/googletest b/third_party/googletest -Subproject c27acebba3b3c7d94209e0467b0a801db4af73e +Subproject 662fe38e44900c007eccb65a5d2ea19df7bd520 diff --git a/util/arena_test.cc b/util/arena_test.cc index 90226fe..3e2011e 100644 --- a/util/arena_test.cc +++ b/util/arena_test.cc @@ -59,8 +59,3 @@ TEST(ArenaTest, Simple) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/bloom_test.cc b/util/bloom_test.cc index 520473e..9f11108 100644 --- a/util/bloom_test.cc +++ b/util/bloom_test.cc @@ -152,8 +152,3 @@ TEST_F(BloomTest, VaryingLengths) { // Different bits-per-byte } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/cache.cc b/util/cache.cc index ad1e9a2..fc3d154 100644 --- a/util/cache.cc +++ b/util/cache.cc @@ -54,7 +54,7 @@ struct LRUHandle { char key_data[1]; // Beginning of key Slice key() const { - // next_ is only equal to this if the LRU handle is the list head of an + // next is only equal to this if the LRU handle is the list head of an // empty list. List heads never have meaningful keys. assert(next != this); diff --git a/util/cache_test.cc b/util/cache_test.cc index 79cfc27..e68da34 100644 --- a/util/cache_test.cc +++ b/util/cache_test.cc @@ -222,8 +222,3 @@ TEST_F(CacheTest, ZeroSizeCache) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/coding_test.cc b/util/coding_test.cc index aa6c748..cceda14 100644 --- a/util/coding_test.cc +++ b/util/coding_test.cc @@ -191,8 +191,3 @@ TEST(Coding, Strings) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/crc32c_test.cc b/util/crc32c_test.cc index 647e561..2fe1c41 100644 --- a/util/crc32c_test.cc +++ b/util/crc32c_test.cc @@ -54,8 +54,3 @@ TEST(CRC, Mask) { } // namespace crc32c } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/env_posix.cc b/util/env_posix.cc index d84cd1e..ffd06c4 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -4,9 +4,10 @@ #include <dirent.h> #include <fcntl.h> -#include <pthread.h> #include <sys/mman.h> +#ifndef __Fuchsia__ #include <sys/resource.h> +#endif #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> @@ -72,7 +73,14 @@ Status PosixError(const std::string& context, int error_number) { class Limiter { public: // Limit maximum number of resources to |max_acquires|. - Limiter(int max_acquires) : acquires_allowed_(max_acquires) {} + Limiter(int max_acquires) + : +#if !defined(NDEBUG) + max_acquires_(max_acquires), +#endif // !defined(NDEBUG) + acquires_allowed_(max_acquires) { + assert(max_acquires >= 0); + } Limiter(const Limiter&) = delete; Limiter operator=(const Limiter&) = delete; @@ -85,15 +93,35 @@ class Limiter { if (old_acquires_allowed > 0) return true; - acquires_allowed_.fetch_add(1, std::memory_order_relaxed); + int pre_increment_acquires_allowed = + acquires_allowed_.fetch_add(1, std::memory_order_relaxed); + + // Silence compiler warnings about unused arguments when NDEBUG is defined. + (void)pre_increment_acquires_allowed; + // If the check below fails, Release() was called more times than acquire. + assert(pre_increment_acquires_allowed < max_acquires_); + return false; } // Release a resource acquired by a previous call to Acquire() that returned // true. - void Release() { acquires_allowed_.fetch_add(1, std::memory_order_relaxed); } + void Release() { + int old_acquires_allowed = + acquires_allowed_.fetch_add(1, std::memory_order_relaxed); + + // Silence compiler warnings about unused arguments when NDEBUG is defined. + (void)old_acquires_allowed; + // If the check below fails, Release() was called more times than acquire. + assert(old_acquires_allowed < max_acquires_); + } private: +#if !defined(NDEBUG) + // Catches an excessive number of Release() calls. + const int max_acquires_; +#endif // !defined(NDEBUG) + // The number of available resources. // // This is a counter and is not tied to the invariants of any other class, so @@ -108,7 +136,7 @@ class Limiter { class PosixSequentialFile final : public SequentialFile { public: PosixSequentialFile(std::string filename, int fd) - : fd_(fd), filename_(filename) {} + : fd_(fd), filename_(std::move(filename)) {} ~PosixSequentialFile() override { close(fd_); } Status Read(size_t n, Slice* result, char* scratch) override { @@ -214,7 +242,7 @@ class PosixMmapReadableFile final : public RandomAccessFile { // over the ownership of the region. // // |mmap_limiter| must outlive this instance. The caller must have already - // aquired the right to use one mmap region, which will be released when this + // acquired the right to use one mmap region, which will be released when this // instance is destroyed. PosixMmapReadableFile(std::string filename, char* mmap_base, size_t length, Limiter* mmap_limiter) @@ -728,7 +756,7 @@ class PosixEnv : public Env { // Instances are constructed on the thread calling Schedule() and used on the // background thread. // - // This structure is thread-safe beacuse it is immutable. + // This structure is thread-safe because it is immutable. struct BackgroundWorkItem { explicit BackgroundWorkItem(void (*function)(void* arg), void* arg) : function(function), arg(arg) {} @@ -757,6 +785,10 @@ int MaxOpenFiles() { if (g_open_read_only_file_limit >= 0) { return g_open_read_only_file_limit; } +#ifdef __Fuchsia__ + // Fuchsia doesn't implement getrlimit. + g_open_read_only_file_limit = 50; +#else struct ::rlimit rlim; if (::getrlimit(RLIMIT_NOFILE, &rlim)) { // getrlimit failed, fallback to hard-coded default. @@ -767,6 +799,7 @@ int MaxOpenFiles() { // Allow use of 20% of available file descriptors for read-only files. g_open_read_only_file_limit = rlim.rlim_cur / 5; } +#endif return g_open_read_only_file_limit; } @@ -837,7 +870,7 @@ class SingletonEnv { public: SingletonEnv() { #if !defined(NDEBUG) - env_initialized_.store(true, std::memory_order::memory_order_relaxed); + env_initialized_.store(true, std::memory_order_relaxed); #endif // !defined(NDEBUG) static_assert(sizeof(env_storage_) >= sizeof(EnvType), "env_storage_ will not fit the Env"); @@ -854,7 +887,7 @@ class SingletonEnv { static void AssertEnvNotInitialized() { #if !defined(NDEBUG) - assert(!env_initialized_.load(std::memory_order::memory_order_relaxed)); + assert(!env_initialized_.load(std::memory_order_relaxed)); #endif // !defined(NDEBUG) } diff --git a/util/env_posix_test.cc b/util/env_posix_test.cc index da264f0..34bda62 100644 --- a/util/env_posix_test.cc +++ b/util/env_posix_test.cc @@ -243,8 +243,8 @@ TEST_F(EnvPosixTest, TestCloseOnExecRandomAccessFile) { // Exhaust the RandomAccessFile mmap limit. This way, the test // RandomAccessFile instance below is backed by a file descriptor, not by an // mmap region. - leveldb::RandomAccessFile* mmapped_files[kReadOnlyFileLimit] = {nullptr}; - for (int i = 0; i < kReadOnlyFileLimit; i++) { + leveldb::RandomAccessFile* mmapped_files[kMMapLimit]; + for (int i = 0; i < kMMapLimit; i++) { ASSERT_LEVELDB_OK(env_->NewRandomAccessFile(file_path, &mmapped_files[i])); } @@ -253,7 +253,7 @@ TEST_F(EnvPosixTest, TestCloseOnExecRandomAccessFile) { CheckCloseOnExecDoesNotLeakFDs(open_fds); delete file; - for (int i = 0; i < kReadOnlyFileLimit; i++) { + for (int i = 0; i < kMMapLimit; i++) { delete mmapped_files[i]; } ASSERT_LEVELDB_OK(env_->RemoveFile(file_path)); diff --git a/util/env_test.cc b/util/env_test.cc index 491ef43..47174f5 100644 --- a/util/env_test.cc +++ b/util/env_test.cc @@ -14,8 +14,6 @@ namespace leveldb { -static const int kDelayMicros = 100000; - class EnvTest : public testing::Test { public: EnvTest() : env_(Env::Default()) {} @@ -233,8 +231,3 @@ TEST_F(EnvTest, ReopenAppendableFile) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/env_windows.cc b/util/env_windows.cc index 449f564..1c74b02 100644 --- a/util/env_windows.cc +++ b/util/env_windows.cc @@ -114,7 +114,14 @@ class ScopedHandle { class Limiter { public: // Limit maximum number of resources to |max_acquires|. - Limiter(int max_acquires) : acquires_allowed_(max_acquires) {} + Limiter(int max_acquires) + : +#if !defined(NDEBUG) + max_acquires_(max_acquires), +#endif // !defined(NDEBUG) + acquires_allowed_(max_acquires) { + assert(max_acquires >= 0); + } Limiter(const Limiter&) = delete; Limiter operator=(const Limiter&) = delete; @@ -133,9 +140,22 @@ class Limiter { // Release a resource acquired by a previous call to Acquire() that returned // true. - void Release() { acquires_allowed_.fetch_add(1, std::memory_order_relaxed); } + void Release() { + int old_acquires_allowed = + acquires_allowed_.fetch_add(1, std::memory_order_relaxed); + + // Silence compiler warnings about unused arguments when NDEBUG is defined. + (void)old_acquires_allowed; + // If the check below fails, Release() was called more times than acquire. + assert(old_acquires_allowed < max_acquires_); + } private: +#if !defined(NDEBUG) + // Catches an excessive number of Release() calls. + const int max_acquires_; +#endif // !defined(NDEBUG) + // The number of available resources. // // This is a counter and is not tied to the invariants of any other class, so @@ -622,7 +642,7 @@ class WindowsEnv : public Env { } Status NewLogger(const std::string& filename, Logger** result) override { - std::FILE* fp = std::fopen(filename.c_str(), "w"); + std::FILE* fp = std::fopen(filename.c_str(), "wN"); if (fp == nullptr) { *result = nullptr; return WindowsError(filename, ::GetLastError()); @@ -661,7 +681,7 @@ class WindowsEnv : public Env { // Instances are constructed on the thread calling Schedule() and used on the // background thread. // - // This structure is thread-safe beacuse it is immutable. + // This structure is thread-safe because it is immutable. struct BackgroundWorkItem { explicit BackgroundWorkItem(void (*function)(void* arg), void* arg) : function(function), arg(arg) {} @@ -745,7 +765,7 @@ class SingletonEnv { public: SingletonEnv() { #if !defined(NDEBUG) - env_initialized_.store(true, std::memory_order::memory_order_relaxed); + env_initialized_.store(true, std::memory_order_relaxed); #endif // !defined(NDEBUG) static_assert(sizeof(env_storage_) >= sizeof(EnvType), "env_storage_ will not fit the Env"); @@ -762,7 +782,7 @@ class SingletonEnv { static void AssertEnvNotInitialized() { #if !defined(NDEBUG) - assert(!env_initialized_.load(std::memory_order::memory_order_relaxed)); + assert(!env_initialized_.load(std::memory_order_relaxed)); #endif // !defined(NDEBUG) } diff --git a/util/hash_test.cc b/util/hash_test.cc index 6d6771f..0ea5977 100644 --- a/util/hash_test.cc +++ b/util/hash_test.cc @@ -39,8 +39,3 @@ TEST(HASH, SignedUnsignedIssue) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/logging_test.cc b/util/logging_test.cc index 24e1fe9..1746c57 100644 --- a/util/logging_test.cc +++ b/util/logging_test.cc @@ -138,8 +138,3 @@ TEST(Logging, ConsumeDecimalNumberNoDigits) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/no_destructor_test.cc b/util/no_destructor_test.cc index 68fdfee..e3602cc 100644 --- a/util/no_destructor_test.cc +++ b/util/no_destructor_test.cc @@ -42,8 +42,3 @@ TEST(NoDestructorTest, StaticInstance) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/util/status_test.cc b/util/status_test.cc index 914b386..dbf5faa 100644 --- a/util/status_test.cc +++ b/util/status_test.cc @@ -37,8 +37,3 @@ TEST(Status, MoveConstructor) { } } // namespace leveldb - -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} |