aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-03-06 14:00:15 +0300
committeralexv-smirnov <alex@ydb.tech>2023-03-06 14:00:15 +0300
commit2b52843982ad694cf840c1f8f4db4872080b1418 (patch)
treec93bc66177c8ab9d4868f9cc531b88595c55cf1a /library
parentca44d2f11d133072b5d154d206ff3840dc2383ce (diff)
downloadydb-2b52843982ad694cf840c1f8f4db4872080b1418.tar.gz
Convert ydb/core/blobstorage/base tests to gtest
Diffstat (limited to 'library')
-rw-r--r--library/cpp/testing/CMakeLists.txt2
-rw-r--r--library/cpp/testing/gtest/CMakeLists.darwin.txt25
-rw-r--r--library/cpp/testing/gtest/CMakeLists.linux-aarch64.txt26
-rw-r--r--library/cpp/testing/gtest/CMakeLists.linux.txt26
-rw-r--r--library/cpp/testing/gtest/CMakeLists.txt15
-rw-r--r--library/cpp/testing/gtest/ut/README.md1
-rw-r--r--library/cpp/testing/gtest/ut/golden/data.txt1
-rw-r--r--library/cpp/testing/gtest/ut/matchers_ut.cpp15
-rw-r--r--library/cpp/testing/gtest/ut/ut.cpp48
-rw-r--r--library/cpp/testing/gtest_main/CMakeLists.darwin.txt18
-rw-r--r--library/cpp/testing/gtest_main/CMakeLists.linux-aarch64.txt19
-rw-r--r--library/cpp/testing/gtest_main/CMakeLists.linux.txt19
-rw-r--r--library/cpp/testing/gtest_main/CMakeLists.txt15
13 files changed, 230 insertions, 0 deletions
diff --git a/library/cpp/testing/CMakeLists.txt b/library/cpp/testing/CMakeLists.txt
index 6953208ad6..23be63b053 100644
--- a/library/cpp/testing/CMakeLists.txt
+++ b/library/cpp/testing/CMakeLists.txt
@@ -9,7 +9,9 @@
add_subdirectory(benchmark)
add_subdirectory(common)
add_subdirectory(gmock_in_unittest)
+add_subdirectory(gtest)
add_subdirectory(gtest_extensions)
+add_subdirectory(gtest_main)
add_subdirectory(hook)
add_subdirectory(unittest)
add_subdirectory(unittest_main)
diff --git a/library/cpp/testing/gtest/CMakeLists.darwin.txt b/library/cpp/testing/gtest/CMakeLists.darwin.txt
new file mode 100644
index 0000000000..41bc7e20f9
--- /dev/null
+++ b/library/cpp/testing/gtest/CMakeLists.darwin.txt
@@ -0,0 +1,25 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gtest)
+target_link_libraries(cpp-testing-gtest PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ restricted-googletest-googlemock
+ restricted-googletest-googletest
+ cpp-string_utils-relaxed_escaper
+ cpp-testing-common
+ cpp-testing-gtest_extensions
+ cpp-testing-hook
+)
+target_sources(cpp-testing-gtest PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/gtest.cpp
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/main.cpp
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/matchers.cpp
+)
diff --git a/library/cpp/testing/gtest/CMakeLists.linux-aarch64.txt b/library/cpp/testing/gtest/CMakeLists.linux-aarch64.txt
new file mode 100644
index 0000000000..e172e2381a
--- /dev/null
+++ b/library/cpp/testing/gtest/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,26 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gtest)
+target_link_libraries(cpp-testing-gtest PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ restricted-googletest-googlemock
+ restricted-googletest-googletest
+ cpp-string_utils-relaxed_escaper
+ cpp-testing-common
+ cpp-testing-gtest_extensions
+ cpp-testing-hook
+)
+target_sources(cpp-testing-gtest PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/gtest.cpp
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/main.cpp
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/matchers.cpp
+)
diff --git a/library/cpp/testing/gtest/CMakeLists.linux.txt b/library/cpp/testing/gtest/CMakeLists.linux.txt
new file mode 100644
index 0000000000..e172e2381a
--- /dev/null
+++ b/library/cpp/testing/gtest/CMakeLists.linux.txt
@@ -0,0 +1,26 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gtest)
+target_link_libraries(cpp-testing-gtest PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ restricted-googletest-googlemock
+ restricted-googletest-googletest
+ cpp-string_utils-relaxed_escaper
+ cpp-testing-common
+ cpp-testing-gtest_extensions
+ cpp-testing-hook
+)
+target_sources(cpp-testing-gtest PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/gtest.cpp
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/main.cpp
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest/matchers.cpp
+)
diff --git a/library/cpp/testing/gtest/CMakeLists.txt b/library/cpp/testing/gtest/CMakeLists.txt
new file mode 100644
index 0000000000..5bb4faffb4
--- /dev/null
+++ b/library/cpp/testing/gtest/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND UNIX AND NOT APPLE AND NOT ANDROID)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin.txt)
+elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND UNIX AND NOT APPLE AND NOT ANDROID)
+ include(CMakeLists.linux.txt)
+endif()
diff --git a/library/cpp/testing/gtest/ut/README.md b/library/cpp/testing/gtest/ut/README.md
new file mode 100644
index 0000000000..ee8d212c18
--- /dev/null
+++ b/library/cpp/testing/gtest/ut/README.md
@@ -0,0 +1 @@
+Note: integration tests are located in */devtools/ya/test/tests/gtest_beta*. Launch them as well after changing this library.
diff --git a/library/cpp/testing/gtest/ut/golden/data.txt b/library/cpp/testing/gtest/ut/golden/data.txt
new file mode 100644
index 0000000000..190a18037c
--- /dev/null
+++ b/library/cpp/testing/gtest/ut/golden/data.txt
@@ -0,0 +1 @@
+123
diff --git a/library/cpp/testing/gtest/ut/matchers_ut.cpp b/library/cpp/testing/gtest/ut/matchers_ut.cpp
new file mode 100644
index 0000000000..3ba3cf3e92
--- /dev/null
+++ b/library/cpp/testing/gtest/ut/matchers_ut.cpp
@@ -0,0 +1,15 @@
+#include <library/cpp/testing/common/env.h>
+#include <library/cpp/testing/gtest/gtest.h>
+
+#include <array>
+#include <vector>
+
+constexpr std::string_view TEST_DATA_TEXT{"123\n"};
+constexpr std::array<char, 4> TEST_DATA_ARRAY{'1', '2', '3', '\n'};
+const std::vector<char> TEST_DATA_CHAR_VECTOR{'1', '2', '3', '\n'};
+
+TEST(GoldenFileEq, Example) {
+ EXPECT_THAT(TEST_DATA_TEXT, NGTest::GoldenFileEq(std::string(SRC_("golden/data.txt"))));
+ EXPECT_THAT(TEST_DATA_ARRAY, NGTest::GoldenFileEq(TString(SRC_("golden/data.txt"))));
+ EXPECT_THAT(TEST_DATA_CHAR_VECTOR, NGTest::GoldenFileEq(SRC_("golden/data.txt")));
+}
diff --git a/library/cpp/testing/gtest/ut/ut.cpp b/library/cpp/testing/gtest/ut/ut.cpp
new file mode 100644
index 0000000000..0b6d69b2cf
--- /dev/null
+++ b/library/cpp/testing/gtest/ut/ut.cpp
@@ -0,0 +1,48 @@
+#include <library/cpp/testing/gtest/gtest.h>
+#include <library/cpp/testing/hook/hook.h>
+
+static int HookOrder = 0;
+static int PreInitHook1 = 0;
+static int PreInitHook2 = 0;
+static int PreRunHook1 = 0;
+static int PreRunHook2 = 0;
+static int PostRunHook1 = 0;
+static int PostRunHook2 = 0;
+
+Y_TEST_HOOK_BEFORE_INIT(PreInit1) {
+ PreInitHook1 = ++HookOrder;
+}
+
+Y_TEST_HOOK_BEFORE_INIT(PreInit2) {
+ PreInitHook2 = ++HookOrder;
+}
+
+Y_TEST_HOOK_BEFORE_RUN(PreRun1) {
+ PreRunHook1 = ++HookOrder;
+}
+
+Y_TEST_HOOK_BEFORE_RUN(PreRun2) {
+ PreRunHook2 = ++HookOrder;
+}
+
+Y_TEST_HOOK_AFTER_RUN(PostRun1) {
+ PostRunHook1 = ++HookOrder;
+ Cerr << "PostRunHook1" << Endl;
+}
+
+Y_TEST_HOOK_AFTER_RUN(PostRun2) {
+ PostRunHook2 = ++HookOrder;
+ Cerr << "PostRunHook2" << Endl;
+}
+
+TEST(Gtest, HookOrder) {
+ EXPECT_NEAR(PreInitHook1, PreInitHook2, 1);
+ EXPECT_NEAR(PreRunHook1, PreRunHook2, 1);
+ EXPECT_LE(std::max(PreInitHook1, PreInitHook2), std::min(PreRunHook1, PreRunHook2));
+ EXPECT_EQ(PostRunHook1, 0);
+ EXPECT_EQ(PostRunHook2, 0);
+}
+
+TEST(Gtest, Metrics) {
+ RecordProperty("Metric1", 10);
+}
diff --git a/library/cpp/testing/gtest_main/CMakeLists.darwin.txt b/library/cpp/testing/gtest_main/CMakeLists.darwin.txt
new file mode 100644
index 0000000000..1075010e22
--- /dev/null
+++ b/library/cpp/testing/gtest_main/CMakeLists.darwin.txt
@@ -0,0 +1,18 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gtest_main)
+target_link_libraries(cpp-testing-gtest_main PUBLIC
+ contrib-libs-cxxsupp
+ yutil
+ cpp-testing-gtest
+)
+target_sources(cpp-testing-gtest_main PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest_main/main.cpp
+)
diff --git a/library/cpp/testing/gtest_main/CMakeLists.linux-aarch64.txt b/library/cpp/testing/gtest_main/CMakeLists.linux-aarch64.txt
new file mode 100644
index 0000000000..f3ef692fb6
--- /dev/null
+++ b/library/cpp/testing/gtest_main/CMakeLists.linux-aarch64.txt
@@ -0,0 +1,19 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gtest_main)
+target_link_libraries(cpp-testing-gtest_main PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ cpp-testing-gtest
+)
+target_sources(cpp-testing-gtest_main PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest_main/main.cpp
+)
diff --git a/library/cpp/testing/gtest_main/CMakeLists.linux.txt b/library/cpp/testing/gtest_main/CMakeLists.linux.txt
new file mode 100644
index 0000000000..f3ef692fb6
--- /dev/null
+++ b/library/cpp/testing/gtest_main/CMakeLists.linux.txt
@@ -0,0 +1,19 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+
+add_library(cpp-testing-gtest_main)
+target_link_libraries(cpp-testing-gtest_main PUBLIC
+ contrib-libs-linux-headers
+ contrib-libs-cxxsupp
+ yutil
+ cpp-testing-gtest
+)
+target_sources(cpp-testing-gtest_main PRIVATE
+ ${CMAKE_SOURCE_DIR}/library/cpp/testing/gtest_main/main.cpp
+)
diff --git a/library/cpp/testing/gtest_main/CMakeLists.txt b/library/cpp/testing/gtest_main/CMakeLists.txt
new file mode 100644
index 0000000000..5bb4faffb4
--- /dev/null
+++ b/library/cpp/testing/gtest_main/CMakeLists.txt
@@ -0,0 +1,15 @@
+
+# This file was generated by the build system used internally in the Yandex monorepo.
+# Only simple modifications are allowed (adding source-files to targets, adding simple properties
+# like target_include_directories). These modifications will be ported to original
+# ya.make files by maintainers. Any complex modifications which can't be ported back to the
+# original buildsystem will not be accepted.
+
+
+if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND UNIX AND NOT APPLE AND NOT ANDROID)
+ include(CMakeLists.linux-aarch64.txt)
+elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ include(CMakeLists.darwin.txt)
+elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND UNIX AND NOT APPLE AND NOT ANDROID)
+ include(CMakeLists.linux.txt)
+endif()