testharness.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. #pragma once
  10. #ifdef OS_AIX
  11. #include "gtest/gtest.h"
  12. #else
  13. #include <gtest/gtest.h>
  14. #endif
  15. #include <string>
  16. #include "rocksdb/env.h"
  17. namespace ROCKSDB_NAMESPACE {
  18. namespace test {
  19. // Return the directory to use for temporary storage.
  20. std::string TmpDir(Env* env = Env::Default());
  21. // A path unique within the thread
  22. std::string PerThreadDBPath(std::string name);
  23. std::string PerThreadDBPath(Env* env, std::string name);
  24. std::string PerThreadDBPath(std::string dir, std::string name);
  25. // Return a randomization seed for this run. Typically returns the
  26. // same number on repeated invocations of this binary, but automated
  27. // runs may be able to vary the seed.
  28. int RandomSeed();
  29. ::testing::AssertionResult AssertStatus(const char* s_expr, const Status& s);
  30. #define ASSERT_OK(s) \
  31. ASSERT_PRED_FORMAT1(ROCKSDB_NAMESPACE::test::AssertStatus, s)
  32. #define ASSERT_NOK(s) ASSERT_FALSE((s).ok())
  33. #define EXPECT_OK(s) \
  34. EXPECT_PRED_FORMAT1(ROCKSDB_NAMESPACE::test::AssertStatus, s)
  35. #define EXPECT_NOK(s) EXPECT_FALSE((s).ok())
  36. } // namespace test
  37. } // namespace ROCKSDB_NAMESPACE