1 // Copyright (c) 2017-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).
8 #include "rocksdb/env.h"
9 #include "rocksdb/perf_context.h"
10 #include "test_util/testharness.h"
12 namespace ROCKSDB_NAMESPACE
{
14 class TimedEnvTest
: public testing::Test
{
17 TEST_F(TimedEnvTest
, BasicTest
) {
18 SetPerfLevel(PerfLevel::kEnableTime
);
19 ASSERT_EQ(0, get_perf_context()->env_new_writable_file_nanos
);
21 std::unique_ptr
<Env
> mem_env(NewMemEnv(Env::Default()));
22 std::unique_ptr
<Env
> timed_env(NewTimedEnv(mem_env
.get()));
23 std::unique_ptr
<WritableFile
> writable_file
;
24 timed_env
->NewWritableFile("f", &writable_file
, EnvOptions());
26 ASSERT_GT(get_perf_context()->env_new_writable_file_nanos
, 0);
29 } // namespace ROCKSDB_NAMESPACE
31 int main(int argc
, char** argv
) {
32 ::testing::InitGoogleTest(&argc
, argv
);
33 return RUN_ALL_TESTS();
39 int main(int /*argc*/, char** /*argv*/) {
40 fprintf(stderr
, "SKIPPED as TimedEnv is not supported in ROCKSDB_LITE\n");
44 #endif // ROCKSDB_LITE