summaryrefslogtreecommitdiff
path: root/util/env_test.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #1104 from reillyeon:chromium_envVictor Costan2023-03-281-0/+10
|\ | | | | | | PiperOrigin-RevId: 520172744
| * Address comments.Reilly Grant2023-03-281-16/+11
| |
| * Fix tests when run against ChromiumEnvReilly Grant2023-03-281-11/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a couple differences between ChromiumEnv and PosixEnv/WindowsEnv which cause test failures that are fixed (or at least patched over) in this change: * NewSequentialFile() and NewRandomAccessFile() return Status::IOError rather than Status::NotFound when a file is not found, due to https://crbug.com/760362. This means a few tests need to expect a different error result. * GetChildren() never returns the '.' or '..' entries. * As allowed by the documentation for Env::Schedule(), ChromiumEnv may execute functions on multiple threads and guarantees no sequencing. EnvTest.RunMany assumed that functions ran in order. The test has been updated.
* | Fix EnvTest.RunMany to allow parallel executionReilly Grant2023-03-281-11/+16
|/ | | | | | | | As allowed by the documentation for Env::Schedule(), ChromiumEnv may execute functions on multiple threads and guarantees no sequencing. EnvTest.RunMany assumed that functions ran in order, is the case for the stock PosixEnv and WindowsEnv implementations. This change updates the test to not assume sequential execution.
* Merge branch 'master' into patch-1Victor Costan2022-01-091-40/+38
|\
| * Remove main() from most tests.Victor Costan2022-01-031-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This gives some flexibility to embedders. Currently, embedders have to build a binary for each test file. After this CL, embedders can still choose to have a binary for each test file, by linking each test file with a googletest target that includes main() (usually "gtest_main"). Embedders can also choose to build a single binary for almost all test files, and link with a googletest target that includes main(). The latter is more convenient for projects that have very few test binaries, like Chromium. PiperOrigin-RevId: 419470798
| * Remove Windows workarounds in some tests.Victor Costan2020-01-141-5/+0
| | | | | | | | | | | | | | leveldb::Env::DeleteFile was replaced with leveldb::Env::RemoveFile in all tests. This allows us to remove workarounds for windows.h #defining DeleteFile. PiperOrigin-RevId: 289121105
| * Add Env::Remove{File,Dir} which obsolete Env::Delete{File,Dir}.Victor Costan2020-01-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "DeleteFile" method name causes pain for Windows developers, because <windows.h> #defines a DeleteFile macro to DeleteFileW or DeleteFileA. Current code uses workarounds, like #undefining DeleteFile everywhere an Env is declared, implemented, or used. This CL removes the need for workarounds by renaming Env::DeleteFile to Env::RemoveFile. For consistency, Env::DeleteDir is also renamed to Env::RemoveDir. A few internal methods are also renamed for consistency. Software that supports Windows is expected to migrate any Env implementations and usage to Remove{File,Dir}, and never use the name Env::Delete{File,Dir} in its code. The renaming is done in a backwards-compatible way, at the risk of making it slightly more difficult to build a new correct Env implementation. The backwards compatibility is achieved using the following hacks: 1) Env::Remove{File,Dir} methods are added, with a default implementation that calls into Env::Delete{File,Dir}. This makes old Env implementations compatible with code that calls into the updated API. 2) The Env::Delete{File,Dir} methods are no longer pure virtuals. Instead, they gain a default implementation that calls into Env::Remove{File,Dir}. This makes updated Env implementations compatible with code that calls into the old API. The cost of this approach is that it's possible to write an Env without overriding either Rename{File,Dir} or Delete{File,Dir}, without getting a compiler warning. However, attempting to run the test suite will immediately fail with an infinite call stack ending in {Remove,Delete}{File,Dir}, making developers aware of the problem. PiperOrigin-RevId: 288710907
| * Defend against inclusion of windows.h in tests that invokeleveldb Team2020-01-091-0/+5
| | | | | | | | | | | | Env::DeleteFile. PiperOrigin-RevId: 283607548
| * Internal change.leveldb Team2019-12-021-1/+1
| | | | | | | | PiperOrigin-RevId: 282373286
| * Switch testing harness to googletest.Victor Costan2019-11-211-35/+38
| | | | | | | | PiperOrigin-RevId: 281815695
* | Remove unused variable kDelayMicros in env_test.ccHenry Lee2019-10-151-2/+0
|/
* Fix tsan problem in env_test.Sanjay Ghemawat2019-09-291-37/+49
| | | | PiperOrigin-RevId: 268265314
* Correct class/structure declaration order.Chris Mumford2019-05-031-1/+2
| | | | | | | | | | | | | 1. Correct the class/struct declaration order to be IAW the Google C++ style guide[1]. 2. For non-copyable classes, switched from non-implemented private methods to explicitly deleted[2] methods. 3. Minor const and member initialization fixes. [1] https://google.github.io/styleguide/cppguide.html#Declaration_Order [2] http://eel.is/c++draft/dcl.fct.def.delete PiperOrigin-RevId: 246521844
* Format all files IAW the Google C++ Style Guide.Chris Mumford2019-05-021-10/+6
| | | | | | Use clang-format to correct formatting to be in agreement with the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). Doing this simplifies the process of accepting changes. Also fixed a few warnings flagged by clang-tidy. PiperOrigin-RevId: 246350737
* leveldb: Replace AtomicPointer with std::atomic.costan2019-03-111-26/+31
| | | | | | | | | | | | This CL removes AtomicPointer from leveldb's port interface. Its usage is replaced with std::atomic<> from the C++11 standard library. AtomicPointer was used to wrap flags, numbers, and pointers, so its instances are replaced with std::atomic<bool>, std::atomic<int>, std::atomic<size_t> and std::atomic<Node*>. This CL does not revise the memory ordering. AtomicPointer's methods are replaced mechanically with their std::atomic equivalents, even when the underlying usage is incorrect. (Example: DBImpl::has_imm_ is written using release stores, even though it is always read using relaxed ordering.) Revising the memory ordering is left for future CLs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=237865146
* Replace NULL with nullptr in C++ files.costan2018-04-101-3/+3
| | | | | | ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=192365747
* leveldb: Add more thread safety annotations.costan2018-03-231-9/+9
| | | | | | | | After this CL, all classes with Mutex members should be covered by annotations. Exceptions are atomic members, which shouldn't need locking, and DBImpl members that cause errors when annotated, which will be tackled separately. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190260865
* leveldb: Include <algorithm> in util/env_test.cc.costan2017-10-041-0/+2
| | | | | | | | | CL 170738066 introduced std::min and std::max to env_test.cc. These require the <algorithm> header. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171024062
* leveldb: Add tests for CL 170769101.costan2017-10-031-12/+59
| | | | | | | | | | This also removes std::unique_ptr introduced in CL 170738066, because it's C++11-only, and the open source version still supports older versions at the moment. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=170876919
* Fix issue 474: a race between the f*_unlocked() STDIO calls insanjay2017-10-031-0/+50
| | | | | | | | | | | | | | | env_posix.cc and concurrent application calls to fflush(NULL). The fix is to avoid using stdio in env_posix.cc but add our own buffering where we need it. Added a test to reproduce the bug. Added a test for Env reads/writes. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=170738066
* leveldb: Report missing CURRENT manifest file as database corruption.costan2017-07-101-0/+18
| | | | | | | | | | | | BTRFS reorders rename and write operations, so it is possible that a filesystem crash and recovery results in a situation where the file pointed to by CURRENT does not exist. DB::Open currently reports an I/O error in this case. Reporting database corruption is a better hint to the caller, which can attempt to recover the database or erase it and start over. This issue is not merely theoretical. It was reported as having showed up in the wild at https://github.com/google/leveldb/issues/195 and at https://crbug.com/738961. Also, asides from the BTRFS case described above, incorrect data in CURRENT seems like a possible corruption case that should be handled gracefully. The Env API changes here can be considered backwards compatible, because an implementation that returns Status::IOError instead of Status::NotFound will still get the same functionality as before. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=161432630
* Separate Env tests from PosixEnv tests.costan2017-03-011-48/+8
| | | | | | | | | | env_test.cc defines EnvPosixTest which tests the Env implementation returned by Env::Default(). The naming is a bit unfortunate, as the tests in env_test.cc are written against the Env contract, and therefore are applicable to any Env implementation. An instance of the confusion caused by the naming is [] which added a dependency from env_test.cc to EnvPosixTestHelper, which is closely coupled to EnvPosix. This change disentangles EnvPosix-specific test code into a env_posix_test.cc file. The code there uses EnvPosixTestHelper and specifically targets the EnvPosix implementation. env_test.cc now implements EnvTest, and contains tests that are also applicable to other ports, which may define their own Env implementation. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148914642
* Limit the number of read-only files the POSIX Env will have open.cmumford2017-01-041-0/+42
| | | | | | | | | | | | | | | | Background compaction can create an unbounded number of leveldb::RandomAccessFile instances. On 64-bit systems mmap is used and file descriptors are only used beyond a certain number of mmap's. 32-bit systems to not use mmap at all. leveldb::RandomAccessFile does not observe Options.max_open_files so compaction could exhaust the file descriptor limit. This change uses getrlimit to determine the maximum number of open files and limits RandomAccessFile to approximately 20% of that value. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143505556
* fixed issues 66 (leaking files on disk error) and 68 (no sync of CURRENT file)Sanjay Ghemawat2012-01-251-10/+12
|
* A number of fixes:Hans Wennborg2011-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Replace raw slice comparison with a call to user comparator. Added test for custom comparators. - Fix end of namespace comments. - Fixed bug in picking inputs for a level-0 compaction. When finding overlapping files, the covered range may expand as files are added to the input set. We now correctly expand the range when this happens instead of continuing to use the old range. For example, suppose L0 contains files with the following ranges: F1: a .. d F2: c .. g F3: f .. j and the initial compaction target is F3. We used to search for range f..j which yielded {F2,F3}. However we now expand the range as soon as another file is added. In this case, when F2 is added, we expand the range to c..j and restart the search. That picks up file F1 as well. This change fixes a bug related to deleted keys showing up incorrectly after a compaction as described in Issue 44. (Sync with upstream @25072954)
* reverting disastrous MOE commit, returning to r21dgrogan@chromium.org2011-04-191-0/+102
| | | | git-svn-id: https://leveldb.googlecode.com/svn/trunk@23 62dab493-f737-651d-591e-8d6aee1b9529
* Revision created by MOE tool push_codebase.dgrogan@chromium.org2011-04-191-102/+0
| | | | | | | MOE_MIGRATION= git-svn-id: https://leveldb.googlecode.com/svn/trunk@22 62dab493-f737-651d-591e-8d6aee1b9529
* chmod a-xdgrogan@chromium.org2011-04-181-0/+0
| | | | git-svn-id: https://leveldb.googlecode.com/svn/trunk@21 62dab493-f737-651d-591e-8d6aee1b9529
* @20602303. Default file permission is now 755.dgrogan@chromium.org2011-04-121-0/+0
| | | | git-svn-id: https://leveldb.googlecode.com/svn/trunk@20 62dab493-f737-651d-591e-8d6aee1b9529
* Move include files into a leveldb subdir.jorlow@chromium.org2011-03-301-1/+1
| | | | git-svn-id: https://leveldb.googlecode.com/svn/trunk@18 62dab493-f737-651d-591e-8d6aee1b9529
* Initial checkin.jorlow@chromium.org2011-03-181-0/+102
git-svn-id: https://leveldb.googlecode.com/svn/trunk@2 62dab493-f737-651d-591e-8d6aee1b9529