]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/env_timed_test.cc
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / utilities / env_timed_test.cc
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).
5
6 #ifndef ROCKSDB_LITE
7
8 #include "rocksdb/env.h"
9 #include "rocksdb/perf_context.h"
10 #include "test_util/testharness.h"
11
12 namespace ROCKSDB_NAMESPACE {
13
14 class TimedEnvTest : public testing::Test {
15 };
16
17 TEST_F(TimedEnvTest, BasicTest) {
18 SetPerfLevel(PerfLevel::kEnableTime);
19 ASSERT_EQ(0, get_perf_context()->env_new_writable_file_nanos);
20
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());
25
26 ASSERT_GT(get_perf_context()->env_new_writable_file_nanos, 0);
27 }
28
29 } // namespace ROCKSDB_NAMESPACE
30
31 int main(int argc, char** argv) {
32 ::testing::InitGoogleTest(&argc, argv);
33 return RUN_ALL_TESTS();
34 }
35
36 #else // ROCKSDB_LITE
37 #include <stdio.h>
38
39 int main(int /*argc*/, char** /*argv*/) {
40 fprintf(stderr, "SKIPPED as TimedEnv is not supported in ROCKSDB_LITE\n");
41 return 0;
42 }
43
44 #endif // ROCKSDB_LITE