From 19016c9ae94e092e42d1a8484b1d295526945ad7 Mon Sep 17 00:00:00 2001 From: Pavel Tsayukov Date: Mon, 9 Sep 2024 14:29:10 +0300 Subject: [PATCH 1/6] Add tests for 'library/cpp/blockcodecs' into listfile (#166) --- library/cpp/blockcodecs/CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/library/cpp/blockcodecs/CMakeLists.txt b/library/cpp/blockcodecs/CMakeLists.txt index 2982c27142..f006a9f02b 100644 --- a/library/cpp/blockcodecs/CMakeLists.txt +++ b/library/cpp/blockcodecs/CMakeLists.txt @@ -1,3 +1,15 @@ +if (YDB_SDK_TESTS) + add_ydb_test(NAME blockcodecs-ut + SOURCES + codecs_ut.cpp + LINK_LIBRARIES + blockcodecs-core + cpp-testing-unittest_main + LABELS + unit + ) +endif() + _ydb_sdk_add_library(blockcodecs-core) target_link_libraries(blockcodecs-core PUBLIC @@ -29,7 +41,7 @@ _ydb_sdk_install_targets(TARGETS blockcodecs-codecs-brotli) _ydb_sdk_add_library(blockcodecs-codecs-bzip INTERFACE) add_global_library_for(blockcodecs-codecs-bzip.global blockcodecs-codecs-bzip) -target_link_libraries(blockcodecs-codecs-bzip.global +target_link_libraries(blockcodecs-codecs-bzip.global PRIVATE yutil BZip2::BZip2 @@ -144,7 +156,7 @@ _ydb_sdk_install_targets(TARGETS blockcodecs-codecs-zstd) _ydb_sdk_add_library(blockcodecs) -target_link_libraries(blockcodecs +target_link_libraries(blockcodecs PUBLIC yutil blockcodecs-core @@ -157,7 +169,7 @@ target_link_libraries(blockcodecs blockcodecs-codecs-zlib blockcodecs-codecs-zstd ) -target_sources(blockcodecs +target_sources(blockcodecs PRIVATE codecs.cpp stream.cpp From 23be804d3b536303ae936f193d5185f314617290 Mon Sep 17 00:00:00 2001 From: Pavel Tsayukov Date: Mon, 9 Sep 2024 18:48:59 +0300 Subject: [PATCH 2/6] Exclude 'TestListAllCodecs' (#166) --- library/cpp/blockcodecs/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/cpp/blockcodecs/CMakeLists.txt b/library/cpp/blockcodecs/CMakeLists.txt index f006a9f02b..2a7da5e424 100644 --- a/library/cpp/blockcodecs/CMakeLists.txt +++ b/library/cpp/blockcodecs/CMakeLists.txt @@ -3,12 +3,18 @@ if (YDB_SDK_TESTS) SOURCES codecs_ut.cpp LINK_LIBRARIES - blockcodecs-core + blockcodecs cpp-testing-unittest_main LABELS unit + TEST_ARG + --filter-file filter.txt ) -endif() + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/filter.txt + # Exclude this test case, because we don't use zstd06 + "-TBlockCodecsTest::TestListAllCodecs" + ) +endif(YDB_SDK_TESTS) _ydb_sdk_add_library(blockcodecs-core) target_link_libraries(blockcodecs-core From 6efdad88ad3baceb3d461206f11ae59ac0a856a5 Mon Sep 17 00:00:00 2001 From: Pavel Tsayukov Date: Mon, 9 Sep 2024 19:11:05 +0300 Subject: [PATCH 3/6] Exclude test case via option --- README.md | 6 +----- library/cpp/blockcodecs/CMakeLists.txt | 7 ++----- util/CMakeLists.txt | 5 +---- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9475dcfb66..3ac0872545 100644 --- a/README.md +++ b/README.md @@ -143,9 +143,5 @@ ctest -j$(nproc) --preset release-integration Note that some tests use a legacy test library instead of GoogleTest, see `./ --help` for details. If you need to run only certain test cases, here is an alternative for `--gtest_filter` option: ```bash -cat < --filter-file /dev/fd/0 --ExcludedTestCase -+IncludedTestCase -+IncludedTestCase::TestName -EOF +./ --filter-file -ExcludedTestSuite +IncludedTestSuite::TestName ``` diff --git a/library/cpp/blockcodecs/CMakeLists.txt b/library/cpp/blockcodecs/CMakeLists.txt index 2a7da5e424..6b32fa3c0c 100644 --- a/library/cpp/blockcodecs/CMakeLists.txt +++ b/library/cpp/blockcodecs/CMakeLists.txt @@ -8,11 +8,8 @@ if (YDB_SDK_TESTS) LABELS unit TEST_ARG - --filter-file filter.txt - ) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/filter.txt - # Exclude this test case, because we don't use zstd06 - "-TBlockCodecsTest::TestListAllCodecs" + # Exclude this test case, because we don't use zstd06 + -TBlockCodecsTest::TestListAllCodecs ) endif(YDB_SDK_TESTS) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 9220b75b74..350983faf7 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -185,10 +185,7 @@ if (YDB_SDK_TESTS) LABELS unit TEST_ARG - --filter-file filter.txt - ) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/random/filter.txt - "-TestCommonRNG::TestStlCompatibility" + -TestCommonRNG::TestStlCompatibility ) add_ydb_test(NAME util-stream-ut From 3fed9bb706cd585a39781cbc1daaee8873b315af Mon Sep 17 00:00:00 2001 From: Pavel Tsayukov Date: Mon, 9 Sep 2024 19:13:05 +0300 Subject: [PATCH 4/6] Specify how to configure and build tests --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ac0872545..f42bf90658 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,14 @@ cmake --build --preset release ## Test -Specify a level of parallelism by passing the `-j` option into the command below (e.g. `-j$(nproc)`) +Configure and build tests: + +```bash +cmake --preset release-test +cmake --build --preset release +``` + +Specify a level of parallelism by passing the `-j` option into the commands below (e.g. `-j$(nproc)`). Running all tests: From 14889678081c1484f55575c3e629c985d6a76b16 Mon Sep 17 00:00:00 2001 From: Pavel Tsayukov Date: Mon, 9 Sep 2024 18:51:30 +0300 Subject: [PATCH 5/6] Fix std::basic_string::assign on [nullptr, nullptr) range (#166) --- util/generic/buffer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/generic/buffer.cpp b/util/generic/buffer.cpp index b92697e1d0..ba2b602452 100644 --- a/util/generic/buffer.cpp +++ b/util/generic/buffer.cpp @@ -94,6 +94,7 @@ TBuffer::~TBuffer() { } void TBuffer::AsString(TString& s) { - s.assign(Data(), Size()); + Y_ASSERT(Data() != nullptr || Size() == 0); + s.assign(Data() == nullptr ? "" : Data(), Size()); Clear(); } From 86c8cf75d212e4aae8db7736272b5262e59d327c Mon Sep 17 00:00:00 2001 From: Pavel Tsayukov Date: Mon, 9 Sep 2024 20:27:37 +0300 Subject: [PATCH 6/6] Remove --filter-file option --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f42bf90658..707102e16e 100644 --- a/README.md +++ b/README.md @@ -150,5 +150,5 @@ ctest -j$(nproc) --preset release-integration Note that some tests use a legacy test library instead of GoogleTest, see `./ --help` for details. If you need to run only certain test cases, here is an alternative for `--gtest_filter` option: ```bash -./ --filter-file -ExcludedTestSuite +IncludedTestSuite::TestName +./ -ExcludedTestSuite +IncludedTestSuite::TestName ```