Skip to content

Fixes for util unit tests #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e54b23e
Add tests for util/datetime into listfile (#155)
tsayukov Aug 6, 2024
d069898
Wrap other tests with 'add_ydb_util_tests'
tsayukov Aug 7, 2024
3e9713a
Add tests for util/generic into listfile (#158)
tsayukov Aug 7, 2024
d742035
Add tests for util/memory into listfile (#159)
tsayukov Aug 7, 2024
1137eba
Add tests for util/random into listfile (#161)
tsayukov Aug 7, 2024
8e32c0f
Add tests for util/stream into listfile (#162)
tsayukov Aug 7, 2024
b910b57
Add tests for util/string into listfile (#163)
tsayukov Aug 7, 2024
fcc2203
Add tests for util/system into listfile (#164)
tsayukov Aug 7, 2024
57cfadc
Add tests for util/thread into listfile (#165)
tsayukov Aug 7, 2024
e3f91c8
Fix progname_ut test (#164)
tsayukov Aug 7, 2024
461ed2b
Fix src_location_ut and src_root_ut (#164)
tsayukov Aug 7, 2024
bbdc622
Fix thread_ut (#164)
tsayukov Aug 7, 2024
0dd83b6
Temporary comment broken tests
tsayukov Aug 7, 2024
fa026cc
Rename wrapper function to 'add_ydb_multiple_tests' and move to testi…
tsayukov Aug 8, 2024
de02d8b
Improve 'add_ydb_multiple_tests'
tsayukov Aug 8, 2024
8b41926
Simplify 'add_ydb_multiple_tests' command
tsayukov Aug 12, 2024
71f2646
Fix __FILE__ expansion bug (#164)
tsayukov Aug 13, 2024
13a8df7
Simplify 'add_ydb_multiple_tests' command again
tsayukov Aug 13, 2024
a16fe02
Remove unnecessary CCACHE_PATH check
tsayukov Aug 13, 2024
0dba8f4
Fix cached variable's type
tsayukov Aug 14, 2024
1eee66e
Remove 'add_ydb_multiple_tests' command
tsayukov Aug 14, 2024
d8ffc2f
Add info about filtering of legacy tests
tsayukov Aug 14, 2024
9ac7ed9
Fix util/system/direct_io_ut (#164)
tsayukov Aug 7, 2024
af4fca4
Fix fstat_ut (#164)
tsayukov Aug 7, 2024
1d96b56
Fix type_name_ut (#164)
tsayukov Aug 7, 2024
b749b9a
Fix fstat_ut (#164)
tsayukov Aug 7, 2024
eebe4b0
Fix string_transparent_hash_ut (#158)
tsayukov Aug 7, 2024
043286f
Fix common_ops_ut (#161)
tsayukov Aug 8, 2024
24e3e28
Revert "Fix util/system/direct_io_ut (#164)"
tsayukov Aug 22, 2024
298518e
Add WORKING_DIRECTORY parameter to testing commands
tsayukov Aug 22, 2024
b3ea0c8
Revert "Fix fstat_ut (#164)"
tsayukov Aug 22, 2024
4821446
Revert "Fix fstat_ut (#164)"
tsayukov Aug 22, 2024
01697eb
Add OUTPUT_DIRECTORY parameter to testing command
tsayukov Aug 22, 2024
640a783
Revert "Fix type_name_ut (#164)"
tsayukov Aug 22, 2024
a71c29e
Revert "Fix string_transparent_hash_ut (#158)"
tsayukov Aug 22, 2024
fe8b6ef
Revert "Fix common_ops_ut (#161)"
tsayukov Aug 22, 2024
798dc88
Disable type_name_ut test (#164)
tsayukov Aug 22, 2024
4b26d73
Temporary comment string_transparent_hash_ut test (#158)
tsayukov Aug 22, 2024
79af1e2
Add TEST_ARG parameter to testing command
tsayukov Aug 22, 2024
0bed8c3
Exclude broken test (#161)
tsayukov Aug 22, 2024
c73e65f
Add config presets for testing
tsayukov Aug 22, 2024
da93098
Fix ARCADIA_BUILD_ROOT (#164)
tsayukov Aug 25, 2024
6372cf9
Convert ARCADIA_[BUILD_]ROOT to native path (#164)
tsayukov Aug 25, 2024
45bd7a2
Revert "Fix ARCADIA_BUILD_ROOT (#164)"
tsayukov Aug 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
run: |
mkdir -p ../build
rm -rf ../build/*
cmake -DYDB_SDK_TESTS=On -DYDB_SDK_EXAMPLES=On --preset release
cmake -DYDB_SDK_TESTS=On -DYDB_SDK_EXAMPLES=On -DARCADIA_ROOT="../ydb-cpp-sdk" -DARCADIA_BUILD_ROOT="." --preset release
- name: Build
shell: bash
run: |
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ set(YDB-CPP-SDK_AVAILABLE_COMPONENTS "" CACHE INTERNAL "")
set(YDB-CPP-SDK_COMPONENT_TARGETS "" CACHE INTERNAL "")
file(READ "src/client/resources/ydb_sdk_version.txt" YDB_SDK_VERSION)

#[=============================================================================[
NOTE: if `ccache` is used with the environment variable `CCACHE_BASEDIR`,
these cached variable should be set manually by passing them to `cmake` as
`-DARCADIA_ROOT=source/path/relative/to/build/dir` and
`-DARCADIA_BUILD_ROOT=.`, because in that case the macro `__FILE__` will be
expanded to a relative path, even if the source code file was specified as
an absolute path, and we have to know the proper prefix of that path.
See details: https://ccache.dev/manual/3.1.html#_compiling_in_different_directories
#]=============================================================================]
set(ARCADIA_ROOT ${YDB_SDK_SOURCE_DIR} CACHE INTERNAL "The source root directory")
set(ARCADIA_BUILD_ROOT ${YDB_SDK_BINARY_DIR} CACHE INTERNAL "The build root directory")

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,14 @@ Running integration tests only:

```bash
ctest -j$(nproc) --preset release-integration
```
```

Note that some tests use a legacy test library instead of GoogleTest, see `./<test_target> --help` for details. If you need to run only certain test cases, here is an alternative for `--gtest_filter` option:

```bash
cat <<EOF | ./<test_target> --filter-file /dev/fd/0
-ExcludedTestCase
+IncludedTestCase
+IncludedTestCase::TestName
EOF
```
4 changes: 1 addition & 3 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if (NOT CCACHE_PATH)
find_program(CCACHE_PATH ccache)
endif()
find_program(CCACHE_PATH ccache)
if (NOT CCACHE_PATH)
message(AUTHOR_WARNING
"Ccache is not found, that will increase the re-compilation time; "
Expand Down
278 changes: 275 additions & 3 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ add_subdirectory(charset)
add_subdirectory(draft)

if (YDB_SDK_TESTS)
add_ydb_test(NAME util-datetime-ut
SOURCES
datetime/base_ut.cpp
datetime/cputimer_ut.cpp
datetime/parser_deprecated_ut.cpp
datetime/parser_ut.cpp
datetime/process_uptime_ut.cpp
datetime/uptime_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)

add_ydb_test(NAME util-digest-ut
SOURCES
digest/city_ut.cpp
Expand All @@ -15,6 +30,7 @@ if (YDB_SDK_TESTS)
LABELS
unit
)

add_ydb_test(NAME util-folder-ut
SOURCES
folder/dirut_ut.cpp
Expand All @@ -30,6 +46,97 @@ if (YDB_SDK_TESTS)
LABELS
unit
)

add_ydb_test(NAME util-generic-ut
SOURCES
generic/adaptor_ut.cpp
generic/algorithm_ut.cpp
generic/array_ref_ut.cpp
generic/array_size_ut.cpp
generic/bitmap_ut.cpp
generic/bitops_ut.cpp
generic/buffer_ut.cpp
generic/cast_ut.cpp
generic/deque_ut.cpp
generic/enum_range_ut.cpp
generic/explicit_type_ut.cpp
generic/flags_ut.cpp
generic/function_ref_ut.cpp
generic/function_ut.cpp
generic/guid_ut.cpp
generic/hash_primes_ut.cpp
generic/hash_ut.cpp
generic/intrlist_ut.cpp
generic/is_in_ut.cpp
generic/iterator_range_ut.cpp
generic/iterator_ut.cpp
generic/lazy_value_ut.cpp
generic/list_ut.cpp
generic/mapfindptr_ut.cpp
generic/map_ut.cpp
generic/maybe_ut.cpp
generic/mem_copy_ut.cpp
generic/objects_counter_ut.cpp
generic/overloaded_ut.cpp
generic/ptr_ut.cpp
generic/queue_ut.cpp
generic/scope_ut.cpp
generic/serialized_enum_ut.cpp
generic/set_ut.cpp
generic/singleton_ut.cpp
generic/size_literals_ut.cpp
generic/stack_ut.cpp
generic/store_policy_ut.cpp
generic/strbuf_ut.cpp
generic/string_transparent_hash_ut.cpp
generic/string_ut.cpp
generic/typelist_ut.cpp
generic/typetraits_ut.cpp
generic/utility_ut.cpp
generic/va_args_ut.cpp
generic/vector_ut.cpp
generic/xrange_ut.cpp
generic/ylimits_ut.cpp
generic/ymath_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)

add_ydb_test(NAME util-generic-yexception_ut
SOURCES
generic/yexception_ut.c
generic/yexception_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)
if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin)$")
target_compile_definitions(util-generic-yexception_ut
PRIVATE
LIBCXX_BUILDING_LIBCXXRT
LIBCXX_BUILDING_LIBGCC
)
endif()

add_ydb_test(NAME util-memory-ut
SOURCES
memory/addstorage_ut.cpp
memory/blob_ut.cpp
memory/pool_ut.cpp
memory/smallobj_ut.cpp
memory/tempbuf_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)

add_ydb_test(NAME util-network-ut
SOURCES
network/address_ut.cpp
Expand All @@ -45,7 +152,170 @@ if (YDB_SDK_TESTS)
LABELS
unit
)
endif()

add_ydb_test(NAME util-random-ut
SOURCES
random/common_ops_ut.cpp
random/easy_ut.cpp
random/entropy_ut.cpp
random/fast_ut.cpp
random/mersenne_ut.cpp
random/normal_ut.cpp
random/random_ut.cpp
random/shuffle_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)

add_ydb_test(NAME util-stream-ut
SOURCES
stream/aligned_ut.cpp
stream/buffered_ut.cpp
stream/buffer_ut.cpp
stream/direct_io_ut.cpp
stream/file_ut.cpp
stream/format_std_ut.cpp
stream/format_ut.cpp
stream/hex_ut.cpp
stream/input_ut.cpp
stream/ios_ut.cpp
stream/labeled_ut.cpp
stream/length_ut.cpp
stream/mem_ut.cpp
stream/multi_ut.cpp
stream/printf_ut.cpp
stream/str_ut.cpp
stream/tokenizer_ut.cpp
stream/walk_ut.cpp
stream/zerocopy_output_ut.cpp
stream/zlib_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)

add_ydb_test(NAME util-string-ut
SOURCES
string/ascii_ut.cpp
string/builder_ut.cpp
string/cast_ut.cpp
string/escape_ut.cpp
string/hex_ut.cpp
string/join_ut.cpp
string/printf_ut.cpp
string/split_ut.cpp
string/strip_ut.cpp
string/strspn_ut.cpp
string/subst_ut.cpp
string/type_ut.cpp
string/util_ut.cpp
string/vector_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)

add_ydb_test(NAME util-system-ut
SOURCES
system/align_ut.cpp
system/atexit_ut.cpp
system/backtrace_ut.cpp
system/byteorder_ut.cpp
system/compat_ut.cpp
system/compiler_ut.cpp
system/condvar_ut.cpp
system/context_ut.cpp
system/cpu_id_ut.cpp
system/daemon_ut.cpp
system/datetime_ut.cpp
system/direct_io_ut.cpp
system/env_ut.cpp
system/error_ut.cpp
system/event_ut.cpp
system/execpath_ut.cpp
system/filemap_ut.cpp
system/file_ut.cpp
system/flock_ut.cpp
system/fstat_ut.cpp
system/fs_ut.cpp
system/getpid_ut.cpp
system/guard_ut.cpp
system/hi_lo_ut.cpp
system/hostname_ut.cpp
system/info_ut.cpp
system/interrupt_signals_ut.cpp
system/mem_info_ut.cpp
system/mincore_ut.cpp
system/mktemp_ut.cpp
system/mutex_ut.cpp
system/nice_ut.cpp
system/pipe_ut.cpp
system/platform_ut.cpp
# NOTE: `progname_ut` checks if the executable file's name, aka the target's
# name, is either "util-system-ut" or slightly different variations
system/progname_ut.cpp
system/rusage_ut.cpp
system/rwlock_ut.cpp
system/sanitizers_ut.cpp
system/shellcommand_ut.cpp
system/shmat_ut.cpp
system/spinlock_ut.cpp
system/src_location_ut.cpp
system/src_root_ut.cpp
system/tempfile_ut.cpp
system/tls_ut.cpp
system/type_name_ut.cpp
# NOTE: `thread_ut` compares the executable file's name and the current
# thread name, whose length can't be more than 16 bytes in Linux,
# so the test name shouldn't be longer than "util-system-ut"
system/thread_ut.cpp
system/types_ut.cpp
# TODO: add library/cpp/testing/benchmark
# depends only on NBench::Clobber, that's a memory optimization barrier
# system/unaligned_mem_ut.cpp
system/user_ut.cpp
system/yassert_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)

if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_ydb_test(NAME util-system-fs_win_ut
SOURCES
system/fs_win_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
LABELS
unit
)
endif()

add_ydb_test(NAME util-thread-ut
SOURCES
thread/factory_ut.cpp
thread/lfqueue_ut.cpp
thread/lfstack_ut.cpp
thread/pool_ut.cpp
thread/singleton_ut.cpp
LINK_LIBRARIES
yutil
cpp-testing-unittest_main
threading-future
LABELS
unit
)
endif(YDB_SDK_TESTS)

_ydb_sdk_add_library(yutil)

Expand All @@ -70,6 +340,7 @@ target_joined_source(yutil
${YDB_SDK_SOURCE_DIR}/util/datetime/base.cpp
${YDB_SDK_SOURCE_DIR}/util/datetime/constants.cpp
${YDB_SDK_SOURCE_DIR}/util/datetime/cputimer.cpp
${YDB_SDK_SOURCE_DIR}/util/datetime/process_uptime.cpp
${YDB_SDK_SOURCE_DIR}/util/datetime/systime.cpp
${YDB_SDK_SOURCE_DIR}/util/datetime/uptime.cpp
)
Expand Down Expand Up @@ -405,9 +676,10 @@ elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
)
endif()

# NOTE: these definitions are needed to `util/system/src_root.h` works properly
target_compile_definitions(yutil PUBLIC
ARCADIA_ROOT_CMAKE_HELPER=${YDB_SDK_SOURCE_DIR}
ARCADIA_BUILD_ROOT_CMAKE_HELPER=${YDB_SDK_BINARY_DIR}
ARCADIA_ROOT=${ARCADIA_ROOT}
ARCADIA_BUILD_ROOT=${ARCADIA_BUILD_ROOT}
)

_ydb_sdk_install_targets(TARGETS yutil)
Loading
Loading