diff options
author | Ilnur Khuziev <ilnur.khuziev@yandex.ru> | 2022-02-10 16:46:14 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:14 +0300 |
commit | 60040c91ffe701a84689b2c6310ff845e65cff42 (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/system | |
parent | 736dcd8ca259457a136f2f9f9168c44643914323 (diff) | |
download | ydb-60040c91ffe701a84689b2c6310ff845e65cff42.tar.gz |
Restoring authorship annotation for Ilnur Khuziev <ilnur.khuziev@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system')
71 files changed, 531 insertions, 531 deletions
diff --git a/util/system/align_ut.cpp b/util/system/align_ut.cpp index 0d80d42e6a..3ba3a3442b 100644 --- a/util/system/align_ut.cpp +++ b/util/system/align_ut.cpp @@ -1,6 +1,6 @@ #include "align.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> class TAlignTest: public TTestBase { UNIT_TEST_SUITE(TAlignTest); diff --git a/util/system/atexit_ut.cpp b/util/system/atexit_ut.cpp index a26f5abb35..953f432811 100644 --- a/util/system/atexit_ut.cpp +++ b/util/system/atexit_ut.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include "atexit.h" diff --git a/util/system/atomic_ut.cpp b/util/system/atomic_ut.cpp index 235d2dd060..07211ffba7 100644 --- a/util/system/atomic_ut.cpp +++ b/util/system/atomic_ut.cpp @@ -1,6 +1,6 @@ #include "atomic.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/generic/ylimits.h> diff --git a/util/system/backtrace_ut.cpp b/util/system/backtrace_ut.cpp index 7e4919a1bb..9b5ead71bc 100644 --- a/util/system/backtrace_ut.cpp +++ b/util/system/backtrace_ut.cpp @@ -1,7 +1,7 @@ #include "backtrace.h" #include <util/generic/array_ref.h> -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/stream/output.h> diff --git a/util/system/benchmark/cpu_id/main.cpp b/util/system/benchmark/cpu_id/main.cpp index a073543508..8efe539983 100644 --- a/util/system/benchmark/cpu_id/main.cpp +++ b/util/system/benchmark/cpu_id/main.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/benchmark/bench.h> +#include <library/cpp/testing/benchmark/bench.h> #include <util/system/cpu_id.h> diff --git a/util/system/benchmark/create_destroy_thread/main.cpp b/util/system/benchmark/create_destroy_thread/main.cpp index ebafa960d2..0ca2a9d96f 100644 --- a/util/system/benchmark/create_destroy_thread/main.cpp +++ b/util/system/benchmark/create_destroy_thread/main.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/benchmark/bench.h> +#include <library/cpp/testing/benchmark/bench.h> #include <util/system/thread.h> diff --git a/util/system/benchmark/rdtsc/main.cpp b/util/system/benchmark/rdtsc/main.cpp index d51ea9d172..8189d10f06 100644 --- a/util/system/benchmark/rdtsc/main.cpp +++ b/util/system/benchmark/rdtsc/main.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/benchmark/bench.h> +#include <library/cpp/testing/benchmark/bench.h> #include <util/system/datetime.h> #include <util/generic/xrange.h> diff --git a/util/system/byteorder_ut.cpp b/util/system/byteorder_ut.cpp index f53b19af48..39b8603d3f 100644 --- a/util/system/byteorder_ut.cpp +++ b/util/system/byteorder_ut.cpp @@ -1,6 +1,6 @@ #include "byteorder.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> class TByteOrderTest: public TTestBase { UNIT_TEST_SUITE(TByteOrderTest); diff --git a/util/system/compat_ut.cpp b/util/system/compat_ut.cpp index eac69c58cb..dbd9289c17 100644 --- a/util/system/compat_ut.cpp +++ b/util/system/compat_ut.cpp @@ -1,6 +1,6 @@ #include "compat.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/folder/dirut.h> #include <util/stream/output.h> diff --git a/util/system/compiler.h b/util/system/compiler.h index d534f92779..b373edcc46 100644 --- a/util/system/compiler.h +++ b/util/system/compiler.h @@ -187,15 +187,15 @@ #define Y_PUBLIC #endif -#if !defined(Y_UNUSED) && !defined(__cplusplus) +#if !defined(Y_UNUSED) && !defined(__cplusplus) #define Y_UNUSED(var) (void)(var) #endif -#if !defined(Y_UNUSED) && defined(__cplusplus) +#if !defined(Y_UNUSED) && defined(__cplusplus) template <class... Types> constexpr Y_FORCE_INLINE int Y_UNUSED(Types&&...) { return 0; }; -#endif +#endif /** * @def Y_ASSUME @@ -553,15 +553,15 @@ _YandexAbort(); // Memory sanitizer sometimes doesn't correctly set parameter shadow of constant functions. #if (defined(__clang__) || defined(__GNUC__)) && !defined(_msan_enabled_) /** - * @def Y_CONST_FUNCTION - methods and functions, marked with this method are promised to: - 1. do not have side effects - 2. this method do not read global memory - NOTE: this attribute can't be set for methods that depend on data, pointed by this - this allow compilers to do hard optimization of that functions - NOTE: in common case this attribute can't be set if method have pointer-arguments - NOTE: as result there no any reason to discard result of such method -*/ + * @def Y_CONST_FUNCTION + methods and functions, marked with this method are promised to: + 1. do not have side effects + 2. this method do not read global memory + NOTE: this attribute can't be set for methods that depend on data, pointed by this + this allow compilers to do hard optimization of that functions + NOTE: in common case this attribute can't be set if method have pointer-arguments + NOTE: as result there no any reason to discard result of such method +*/ #define Y_CONST_FUNCTION [[gnu::const]] #endif @@ -571,13 +571,13 @@ _YandexAbort(); #if defined(__clang__) || defined(__GNUC__) /** - * @def Y_PURE_FUNCTION - methods and functions, marked with this method are promised to: - 1. do not have side effects - 2. result will be the same if no global memory changed - this allow compilers to do hard optimization of that functions - NOTE: as result there no any reason to discard result of such method -*/ + * @def Y_PURE_FUNCTION + methods and functions, marked with this method are promised to: + 1. do not have side effects + 2. result will be the same if no global memory changed + this allow compilers to do hard optimization of that functions + NOTE: as result there no any reason to discard result of such method +*/ #define Y_PURE_FUNCTION [[gnu::pure]] #endif diff --git a/util/system/compiler_ut.cpp b/util/system/compiler_ut.cpp index 63cc6cdbeb..f93b1c0850 100644 --- a/util/system/compiler_ut.cpp +++ b/util/system/compiler_ut.cpp @@ -1,6 +1,6 @@ #include "compiler.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TCompilerTest) { Y_UNIT_TEST(TestPragmaNoWshadow) { diff --git a/util/system/condvar_ut.cpp b/util/system/condvar_ut.cpp index cc8ae57dd2..5130a18d32 100644 --- a/util/system/condvar_ut.cpp +++ b/util/system/condvar_ut.cpp @@ -2,7 +2,7 @@ #include "guard.h" #include "condvar.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/system/atomic.h> #include <util/system/atomic_ops.h> diff --git a/util/system/context_ut.cpp b/util/system/context_ut.cpp index 042a934bab..45cb0249f7 100644 --- a/util/system/context_ut.cpp +++ b/util/system/context_ut.cpp @@ -1,6 +1,6 @@ #include "context.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/generic/deque.h> #include <util/generic/yexception.h> diff --git a/util/system/cpu_id.cpp b/util/system/cpu_id.cpp index aa9c180c64..598c71f4d9 100644 --- a/util/system/cpu_id.cpp +++ b/util/system/cpu_id.cpp @@ -118,10 +118,10 @@ bool NX86::HaveSSE42() noexcept { return (TX86CpuInfo(0x1).ECX >> 20) & 1u; } -bool NX86::HaveF16C() noexcept { - return (TX86CpuInfo(0x1).ECX >> 29) & 1u; -} - +bool NX86::HaveF16C() noexcept { + return (TX86CpuInfo(0x1).ECX >> 29) & 1u; +} + bool NX86::HavePOPCNT() noexcept { return (TX86CpuInfo(0x1).ECX >> 23) & 1u; } diff --git a/util/system/cpu_id.h b/util/system/cpu_id.h index f6ec49a9fa..3c49e728a7 100644 --- a/util/system/cpu_id.h +++ b/util/system/cpu_id.h @@ -1,7 +1,7 @@ #pragma once #include "types.h" -#include "compiler.h" +#include "compiler.h" #include <util/generic/singleton.h> #define Y_CPU_ID_ENUMERATE(F) \ @@ -11,7 +11,7 @@ F(SSSE3) \ F(SSE41) \ F(SSE42) \ - F(F16C) \ + F(F16C) \ F(POPCNT) \ F(BMI1) \ F(BMI2) \ @@ -78,11 +78,11 @@ namespace NX86 { bool CpuId(ui32 op, ui32 res[4]) noexcept; bool CpuId(ui32 op, ui32 subOp, ui32 res[4]) noexcept; -#define Y_DEF_NAME(X) Y_CONST_FUNCTION bool Have##X() noexcept; +#define Y_DEF_NAME(X) Y_CONST_FUNCTION bool Have##X() noexcept; Y_CPU_ID_ENUMERATE(Y_DEF_NAME) #undef Y_DEF_NAME -#define Y_DEF_NAME(X) Y_CONST_FUNCTION bool CachedHave##X() noexcept; +#define Y_DEF_NAME(X) Y_CONST_FUNCTION bool CachedHave##X() noexcept; Y_CPU_ID_ENUMERATE_OUTLINED_CACHED_DEFINE(Y_DEF_NAME) #undef Y_DEF_NAME diff --git a/util/system/cpu_id_ut.cpp b/util/system/cpu_id_ut.cpp index ac41440900..68f1f8aac7 100644 --- a/util/system/cpu_id_ut.cpp +++ b/util/system/cpu_id_ut.cpp @@ -2,7 +2,7 @@ #include "platform.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> // There are no tests yet for instructions that use 512-bit wide registers because they are not // supported by some compilers yet. @@ -18,7 +18,7 @@ static void ExecuteSSE3Instruction(); static void ExecuteSSSE3Instruction(); static void ExecuteSSE41Instruction(); static void ExecuteSSE42Instruction(); -static void ExecuteF16CInstruction(); +static void ExecuteF16CInstruction(); static void ExecuteAVXInstruction(); static void ExecuteAVX2Instruction(); static void ExecutePOPCNTInstruction(); @@ -134,13 +134,13 @@ void ExecuteSSE42Instruction() { : "eax"); } -void ExecuteF16CInstruction() { - __asm__ __volatile__("vcvtph2ps %%xmm0, %%ymm0\n" - : - : - : "xmm0"); -} - +void ExecuteF16CInstruction() { + __asm__ __volatile__("vcvtph2ps %%xmm0, %%ymm0\n" + : + : + : "xmm0"); +} + void ExecuteAVXInstruction() { __asm__ __volatile__("vzeroupper\n" : @@ -276,9 +276,9 @@ void ExecuteSSE41Instruction() { void ExecuteSSE42Instruction() { } -void ExecuteF16CInstruction() { -} - +void ExecuteF16CInstruction() { +} + void ExecuteAVXInstruction() { } @@ -373,9 +373,9 @@ void ExecuteSSE41Instruction() { void ExecuteSSE42Instruction() { } -void ExecuteF16CInstruction() { -} - +void ExecuteF16CInstruction() { +} + void ExecuteAVXInstruction() { } diff --git a/util/system/daemon_ut.cpp b/util/system/daemon_ut.cpp index 5a0201185c..f93b9a9645 100644 --- a/util/system/daemon_ut.cpp +++ b/util/system/daemon_ut.cpp @@ -1,6 +1,6 @@ #include "daemon.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/network/pair.h> #include <util/network/socket.h> diff --git a/util/system/defaults.h b/util/system/defaults.h index 325480a55b..dcd7abea38 100644 --- a/util/system/defaults.h +++ b/util/system/defaults.h @@ -83,14 +83,14 @@ #ifdef NDEBUG #define Y_IF_DEBUG(X) - #ifdef __cplusplus -constexpr bool Y_IS_DEBUG_BUILD = false; - #endif + #ifdef __cplusplus +constexpr bool Y_IS_DEBUG_BUILD = false; + #endif #else #define Y_IF_DEBUG(X) X - #ifdef __cplusplus -constexpr bool Y_IS_DEBUG_BUILD = true; - #endif + #ifdef __cplusplus +constexpr bool Y_IS_DEBUG_BUILD = true; + #endif #endif /** diff --git a/util/system/direct_io_ut.cpp b/util/system/direct_io_ut.cpp index f8f7ede132..839c3de7ca 100644 --- a/util/system/direct_io_ut.cpp +++ b/util/system/direct_io_ut.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/generic/yexception.h> #include <util/system/fs.h> diff --git a/util/system/env.cpp b/util/system/env.cpp index a3d46e48d3..ead9b566a5 100644 --- a/util/system/env.cpp +++ b/util/system/env.cpp @@ -50,18 +50,18 @@ TString GetEnv(const TString& key, const TString& def) { } void SetEnv(const TString& key, const TString& value) { - bool isOk = false; - int errorCode = 0; + bool isOk = false; + int errorCode = 0; #ifdef _win_ isOk = SetEnvironmentVariable(key.data(), value.data()); - if (!isOk) { - errorCode = GetLastError(); - } + if (!isOk) { + errorCode = GetLastError(); + } #else isOk = (0 == setenv(key.data(), value.data(), true /*replace*/)); - if (!isOk) { - errorCode = errno; - } + if (!isOk) { + errorCode = errno; + } #endif - Y_ENSURE_EX(isOk, TSystemError() << "failed to SetEnv with error-code " << errorCode); + Y_ENSURE_EX(isOk, TSystemError() << "failed to SetEnv with error-code " << errorCode); } diff --git a/util/system/env_ut.cpp b/util/system/env_ut.cpp index fb8bcd2420..e03cc01658 100644 --- a/util/system/env_ut.cpp +++ b/util/system/env_ut.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/generic/string.h> #include "env.h" diff --git a/util/system/error_ut.cpp b/util/system/error_ut.cpp index 98ea0e9f7d..763b0dddb7 100644 --- a/util/system/error_ut.cpp +++ b/util/system/error_ut.cpp @@ -1,6 +1,6 @@ #include "error.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/generic/ylimits.h> diff --git a/util/system/event_ut.cpp b/util/system/event_ut.cpp index 40565a8688..2506cb7a91 100644 --- a/util/system/event_ut.cpp +++ b/util/system/event_ut.cpp @@ -1,7 +1,7 @@ #include "event.h" #include "atomic.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/thread/pool.h> diff --git a/util/system/execpath.cpp b/util/system/execpath.cpp index c2d798e1c4..33198af58b 100644 --- a/util/system/execpath.cpp +++ b/util/system/execpath.cpp @@ -84,7 +84,7 @@ static inline TString FreeBSDGetArgv0() { } static inline bool FreeBSDGuessExecPath(const TString& guessPath, TString& execPath) { - if (NFs::Exists(guessPath)) { + if (NFs::Exists(guessPath)) { // now it should work for real execPath = FreeBSDGetExecPath(); if (RealPath(execPath) == RealPath(guessPath)) { diff --git a/util/system/execpath_ut.cpp b/util/system/execpath_ut.cpp index 40838e01a7..16b01466f5 100644 --- a/util/system/execpath_ut.cpp +++ b/util/system/execpath_ut.cpp @@ -1,6 +1,6 @@ #include "execpath.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include "platform.h" #include <util/folder/dirut.h> @@ -11,7 +11,7 @@ Y_UNIT_TEST_SUITE(TExecPathTest) { TString persistentExecPath = GetPersistentExecPath(); try { - UNIT_ASSERT(NFs::Exists(execPath)); + UNIT_ASSERT(NFs::Exists(execPath)); UNIT_ASSERT(NFs::Exists(persistentExecPath)); } catch (...) { Cerr << execPath << Endl; diff --git a/util/system/file_ut.cpp b/util/system/file_ut.cpp index 8b759a8a89..941e6a50f3 100644 --- a/util/system/file_ut.cpp +++ b/util/system/file_ut.cpp @@ -2,7 +2,7 @@ #include "fs.h" #include "tempfile.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/stream/file.h> #include <util/generic/yexception.h> diff --git a/util/system/filemap.cpp b/util/system/filemap.cpp index 42b6b775d2..7454a4cb94 100644 --- a/util/system/filemap.cpp +++ b/util/system/filemap.cpp @@ -31,7 +31,7 @@ #endif #include <util/generic/utility.h> -#include <util/system/sanitizers.h> +#include <util/system/sanitizers.h> #include "filemap.h" #undef PAGE_SIZE @@ -260,7 +260,7 @@ public: } else { ythrow yexception() << "Can't map " << (unsigned long)size << " bytes at offset " << offset << " of '" << DbgName_ << "': " << LastSystemErrorText(); } - NSan::Unpoison(result.Ptr, result.Size); + NSan::Unpoison(result.Ptr, result.Size); if (Mode_ & oPrecharge) { NPrivate::Precharge(result.Ptr, result.Size, 0, result.Size); } diff --git a/util/system/filemap.h b/util/system/filemap.h index a1c1c43bc5..11be64bff4 100644 --- a/util/system/filemap.h +++ b/util/system/filemap.h @@ -255,7 +255,7 @@ public: Y_PURE_FUNCTION bool empty() const noexcept { return Empty(); } - + Y_PURE_FUNCTION bool Empty() const noexcept { return 0 == Size_; } diff --git a/util/system/filemap_ut.cpp b/util/system/filemap_ut.cpp index 415b42ca7d..73f109dc88 100644 --- a/util/system/filemap_ut.cpp +++ b/util/system/filemap_ut.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #ifdef _unix_ #include <sys/resource.h> diff --git a/util/system/flock_ut.cpp b/util/system/flock_ut.cpp index 7b4f7e1c5e..b5f6cb5328 100644 --- a/util/system/flock_ut.cpp +++ b/util/system/flock_ut.cpp @@ -3,7 +3,7 @@ #include "guard.h" #include "tempfile.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TFileLockTest) { Y_UNIT_TEST(TestFlock) { diff --git a/util/system/fs.cpp b/util/system/fs.cpp index 2ee29591a7..d2611a8ccc 100644 --- a/util/system/fs.cpp +++ b/util/system/fs.cpp @@ -12,9 +12,9 @@ #include <util/memory/tempbuf.h> #include <util/stream/file.h> #include <util/charset/wide.h> -#include <util/folder/iterator.h> -#include <util/system/fstat.h> -#include <util/folder/path.h> +#include <util/folder/iterator.h> +#include <util/system/fstat.h> +#include <util/folder/path.h> bool NFs::Remove(const TString& path) { #if defined(_win_) @@ -25,65 +25,65 @@ bool NFs::Remove(const TString& path) { } void NFs::RemoveRecursive(const TString& path) { - static const TStringBuf errStr = "error while removing "; - - if (!NFs::Exists(path)) { - return; - } - - if (!TFileStat(path).IsDir()) { + static const TStringBuf errStr = "error while removing "; + + if (!NFs::Exists(path)) { + return; + } + + if (!TFileStat(path).IsDir()) { if (!NFs::Remove(path)) { - ythrow TSystemError() << errStr << path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; + ythrow TSystemError() << errStr << path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; } - } - - TDirIterator dir(path); - + } + + TDirIterator dir(path); + for (auto it = dir.begin(); it != dir.end(); ++it) { - switch (it->fts_info) { - case FTS_DOT: - case FTS_D: + switch (it->fts_info) { + case FTS_DOT: + case FTS_D: break; - default: + default: if (!NFs::Remove(it->fts_path)) { - ythrow TSystemError() << errStr << it->fts_path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; + ythrow TSystemError() << errStr << it->fts_path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; } - break; - } - } -} - + break; + } + } +} + bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) { -#if defined(_win_) +#if defined(_win_) Y_UNUSED(mode); - return NFsPrivate::WinMakeDirectory(path); -#else + return NFsPrivate::WinMakeDirectory(path); +#else return mkdir(path.data(), mode) == 0; -#endif -} - +#endif +} + bool NFs::MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate) { - if (NFs::Exists(path) && TFileStat(path).IsDir()) { - if (alwaysCreate) { + if (NFs::Exists(path) && TFileStat(path).IsDir()) { + if (alwaysCreate) { ythrow TIoException() << "path " << path << " already exists" << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; - } - return true; - } else { - //NOTE: recursion is finite due to existence of "." and "/" + } + return true; + } else { + //NOTE: recursion is finite due to existence of "." and "/" if (!NFs::MakeDirectoryRecursive(TFsPath(path).Parent(), mode, false)) { return false; } bool isDirMade = NFs::MakeDirectory(path, mode); if (!isDirMade && alwaysCreate) { - ythrow TIoException() << "failed to create " << path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; - } + ythrow TIoException() << "failed to create " << path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; + } return TFileStat(path).IsDir(); - } -} - + } +} + bool NFs::Rename(const TString& oldPath, const TString& newPath) { #if defined(_win_) return NFsPrivate::WinRename(oldPath, newPath); @@ -145,35 +145,35 @@ void NFs::Copy(const TString& existingPath, const TString& newPath) { TransferData(&src, &dst); } - + bool NFs::Exists(const TString& path) { -#if defined(_win_) +#if defined(_win_) return NFsPrivate::WinExists(path); -#elif defined(_unix_) +#elif defined(_unix_) return access(path.data(), F_OK) == 0; -#endif -} - +#endif +} + TString NFs::CurrentWorkingDirectory() { -#if defined(_win_) - return NFsPrivate::WinCurrentWorkingDirectory(); -#elif defined(_unix_) - TTempBuf result; - char* r = getcwd(result.Data(), result.Size()); +#if defined(_win_) + return NFsPrivate::WinCurrentWorkingDirectory(); +#elif defined(_unix_) + TTempBuf result; + char* r = getcwd(result.Data(), result.Size()); if (r == nullptr) { - throw TIoSystemError() << "failed to getcwd"; + throw TIoSystemError() << "failed to getcwd"; } - return result.Data(); -#endif -} - + return result.Data(); +#endif +} + void NFs::SetCurrentWorkingDirectory(TString path) { -#ifdef _win_ - bool ok = NFsPrivate::WinSetCurrentWorkingDirectory(path); -#else +#ifdef _win_ + bool ok = NFsPrivate::WinSetCurrentWorkingDirectory(path); +#else bool ok = !chdir(path.data()); -#endif +#endif if (!ok) { - ythrow TSystemError() << "failed to change directory to " << path.Quote(); + ythrow TSystemError() << "failed to change directory to " << path.Quote(); } -} +} diff --git a/util/system/fs.h b/util/system/fs.h index 613ae9c793..237daf2d2d 100644 --- a/util/system/fs.h +++ b/util/system/fs.h @@ -1,11 +1,11 @@ #pragma once -#include <util/generic/flags.h> +#include <util/generic/flags.h> #include <util/generic/string.h> -#include <util/generic/yexception.h> +#include <util/generic/yexception.h> namespace NFs { - enum EFilePermission { + enum EFilePermission { FP_ALL_EXEC = 01, FP_ALL_WRITE = 02, FP_ALL_READ = 04, @@ -15,14 +15,14 @@ namespace NFs { FP_OWNER_READ = 0400, FP_OWNER_WRITE = 0200, FP_OWNER_EXEC = 0100, - + FP_COMMON_FILE = 0777, FP_SECRET_FILE = 0700, - FP_NONSECRET_FILE = 0744, - }; - - Y_DECLARE_FLAGS(EFilePermissions, EFilePermission); - + FP_NONSECRET_FILE = 0744, + }; + + Y_DECLARE_FLAGS(EFilePermissions, EFilePermission); + /// Remove a file or empty directory /// /// @param[in] path Path to file or directory @@ -30,53 +30,53 @@ namespace NFs { /// LastSystemError() is set in case of failure bool Remove(const TString& path); - /// Remove a file or directory with contents - /// - /// @param[in] path Path to file or directory - /// @throws + /// Remove a file or directory with contents + /// + /// @param[in] path Path to file or directory + /// @throws void RemoveRecursive(const TString& path); - - /// Creates directory - /// - /// @param[in] path Path to the directory - /// @param[in] mode Access permissions field; NOTE: ignored on win - /// @returns true on success or false otherwise + + /// Creates directory + /// + /// @param[in] path Path to the directory + /// @param[in] mode Access permissions field; NOTE: ignored on win + /// @returns true on success or false otherwise bool MakeDirectory(const TString& path, EFilePermissions mode); - - /// Creates directory - /// - /// @param[in] path Path to the directory - /// @returns true on success or false otherwise - /// NOTE: access permissions is set to 0777 + + /// Creates directory + /// + /// @param[in] path Path to the directory + /// @returns true on success or false otherwise + /// NOTE: access permissions is set to 0777 inline bool MakeDirectory(const TString& path) { - return MakeDirectory(path, FP_COMMON_FILE); - } - - /// Creates directory and all non-existings parents - /// - /// @param[in] path Path to be created - /// @param[in] mode Access permissions field; NOTE: ignored on win - /// @param[in] alwaysCreate Throw if path already exists or failed to create - /// @returns true if target path created or exists (and directory) + return MakeDirectory(path, FP_COMMON_FILE); + } + + /// Creates directory and all non-existings parents + /// + /// @param[in] path Path to be created + /// @param[in] mode Access permissions field; NOTE: ignored on win + /// @param[in] alwaysCreate Throw if path already exists or failed to create + /// @returns true if target path created or exists (and directory) bool MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate); - - /// Creates directory and all non-existings parents - /// - /// @param[in] path Path to be created - /// @param[in] mode Access permissions field; NOTE: ignored on win + + /// Creates directory and all non-existings parents + /// + /// @param[in] path Path to be created + /// @param[in] mode Access permissions field; NOTE: ignored on win /// @returns true if target path created or exists (and directory) inline bool MakeDirectoryRecursive(const TString& path, EFilePermissions mode) { - return MakeDirectoryRecursive(path, mode, false); - } - - /// Creates directory and all non-existings parents - /// - /// @param[in] path Path to be created - /// @returns true if target path created or exists (and directory) + return MakeDirectoryRecursive(path, mode, false); + } + + /// Creates directory and all non-existings parents + /// + /// @param[in] path Path to be created + /// @returns true if target path created or exists (and directory) inline bool MakeDirectoryRecursive(const TString& path) { - return MakeDirectoryRecursive(path, FP_COMMON_FILE, false); - } - + return MakeDirectoryRecursive(path, FP_COMMON_FILE, false); + } + /// Rename a file or directory. /// Removes newPath if it exists /// @@ -126,31 +126,31 @@ namespace NFs { /// @param[in] existingPath Path to an existing file /// @param[in] newPath New path of file void Copy(const TString& existingPath, const TString& newPath); - - /// Returns path to the current working directory - /// - /// Note: is not threadsafe + + /// Returns path to the current working directory + /// + /// Note: is not threadsafe TString CurrentWorkingDirectory(); - - /// Changes current working directory - /// - /// @param[in] path Path for new cwd - /// Note: is not threadsafe + + /// Changes current working directory + /// + /// @param[in] path Path for new cwd + /// Note: is not threadsafe void SetCurrentWorkingDirectory(TString path); - - /// Checks if file exists - /// - /// @param[in] path Path to check + + /// Checks if file exists + /// + /// @param[in] path Path to check bool Exists(const TString& path); - - /// Ensures that file exists - /// - /// @param[in] path Path to check - /// @returns input argument + + /// Ensures that file exists + /// + /// @param[in] path Path to check + /// @returns input argument inline const TString& EnsureExists(const TString& path) { Y_ENSURE_EX(Exists(path), TFileError{} << "Path " << path << " does not exists (checked from cwd:" << NFs::CurrentWorkingDirectory() << ")"); - return path; - } + return path; + } } - -Y_DECLARE_OPERATORS_FOR_FLAGS(NFs::EFilePermissions) + +Y_DECLARE_OPERATORS_FOR_FLAGS(NFs::EFilePermissions) diff --git a/util/system/fs_ut.cpp b/util/system/fs_ut.cpp index 21d0a9729a..de071ebf55 100644 --- a/util/system/fs_ut.cpp +++ b/util/system/fs_ut.cpp @@ -1,6 +1,6 @@ #include "fs.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include "file.h" #include "sysstat.h" @@ -8,61 +8,61 @@ #include <util/folder/dirut.h> #include <util/folder/path.h> -//WARNING: on windows the test must be run with administative rules - +//WARNING: on windows the test must be run with administative rules + class TFsTest: public TTestBase { UNIT_TEST_SUITE(TFsTest); - UNIT_TEST(TestCreateRemove); - UNIT_TEST(TestRename); + UNIT_TEST(TestCreateRemove); + UNIT_TEST(TestRename); UNIT_TEST(TestSymlink); UNIT_TEST(TestHardlink); - UNIT_TEST(TestCwdOpts); - UNIT_TEST(TestEnsureExists); + UNIT_TEST(TestCwdOpts); + UNIT_TEST(TestEnsureExists); UNIT_TEST_SUITE_END(); public: - void TestCreateRemove(); - void TestRename(); + void TestCreateRemove(); + void TestRename(); void TestSymlink(); void TestHardlink(); - void TestCwdOpts(); - void TestEnsureExists(); + void TestCwdOpts(); + void TestEnsureExists(); }; UNIT_TEST_SUITE_REGISTRATION(TFsTest); -static void Touch(const TFsPath& path) { - TFile file(path, CreateAlways | WrOnly); - file.Write("123", 3); -} - -void TFsTest::TestCreateRemove() { - TFsPath dir1 = "dir_aбвг"; - NFs::RemoveRecursive(dir1); - UNIT_ASSERT(!NFs::Exists(dir1)); - UNIT_ASSERT(NFs::MakeDirectory(dir1)); - - UNIT_ASSERT(TFileStat(dir1).IsDir()); - UNIT_ASSERT(!NFs::MakeDirectory(dir1)); - - UNIT_ASSERT(NFs::Exists(dir1)); - TFsPath subdir1 = dir1 / "a" / "b"; - //TFsPath link = dir1 / "link"; - - UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, true)); - UNIT_ASSERT(NFs::Exists(subdir1)); - UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, false)); - UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE)); - UNIT_ASSERT_EXCEPTION(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, true), TIoException); - - TFsPath file1 = dir1 / "f1.txt"; +static void Touch(const TFsPath& path) { + TFile file(path, CreateAlways | WrOnly); + file.Write("123", 3); +} + +void TFsTest::TestCreateRemove() { + TFsPath dir1 = "dir_aбвг"; + NFs::RemoveRecursive(dir1); + UNIT_ASSERT(!NFs::Exists(dir1)); + UNIT_ASSERT(NFs::MakeDirectory(dir1)); + + UNIT_ASSERT(TFileStat(dir1).IsDir()); + UNIT_ASSERT(!NFs::MakeDirectory(dir1)); + + UNIT_ASSERT(NFs::Exists(dir1)); + TFsPath subdir1 = dir1 / "a" / "b"; + //TFsPath link = dir1 / "link"; + + UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, true)); + UNIT_ASSERT(NFs::Exists(subdir1)); + UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, false)); + UNIT_ASSERT(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE)); + UNIT_ASSERT_EXCEPTION(NFs::MakeDirectoryRecursive(subdir1, NFs::FP_COMMON_FILE, true), TIoException); + + TFsPath file1 = dir1 / "f1.txt"; TFsPath file2 = subdir1 + TString("_f2.txt"); - TFsPath file3 = subdir1 / "f2.txt"; - Touch(file1); - Touch(file2); - Touch(file3); - //UNIT_ASSERT(NFs::SymLink(file3.RealPath(), link)); - + TFsPath file3 = subdir1 / "f2.txt"; + Touch(file1); + Touch(file2); + Touch(file3); + //UNIT_ASSERT(NFs::SymLink(file3.RealPath(), link)); + UNIT_ASSERT(NFs::MakeDirectoryRecursive(dir1 / "subdir1" / "subdir2" / "subdir3" / "subdir4", NFs::FP_COMMON_FILE, false)); UNIT_ASSERT(NFs::MakeDirectoryRecursive(dir1 / "subdir1" / "subdir2", NFs::FP_COMMON_FILE, false)); @@ -72,202 +72,202 @@ void TFsTest::TestCreateRemove() { TString longUtf8Name = ""; while (longUtf8Name.size() < 255) { - longUtf8Name = longUtf8Name + "fф"; - } + longUtf8Name = longUtf8Name + "fф"; + } UNIT_ASSERT_EQUAL(longUtf8Name.size(), 255); - TFsPath longfile = dir1 / longUtf8Name; - Touch(longfile); - - UNIT_ASSERT(NFs::Exists(longfile)); - UNIT_ASSERT(NFs::Exists(file1)); - UNIT_ASSERT(NFs::Exists(file2)); - UNIT_ASSERT(NFs::Exists(file3)); - //UNIT_ASSERT(NFs::Exists(link)); - - UNIT_ASSERT(!NFs::Remove(dir1)); - NFs::RemoveRecursive(dir1); - - UNIT_ASSERT(!NFs::Exists(file1)); - UNIT_ASSERT(!NFs::Exists(file2)); - UNIT_ASSERT(!NFs::Exists(file3)); - //UNIT_ASSERT(!NFs::Exists(link)); - UNIT_ASSERT(!NFs::Exists(subdir1)); - UNIT_ASSERT(!NFs::Exists(longfile)); - UNIT_ASSERT(!NFs::Exists(dir1)); -} - + TFsPath longfile = dir1 / longUtf8Name; + Touch(longfile); + + UNIT_ASSERT(NFs::Exists(longfile)); + UNIT_ASSERT(NFs::Exists(file1)); + UNIT_ASSERT(NFs::Exists(file2)); + UNIT_ASSERT(NFs::Exists(file3)); + //UNIT_ASSERT(NFs::Exists(link)); + + UNIT_ASSERT(!NFs::Remove(dir1)); + NFs::RemoveRecursive(dir1); + + UNIT_ASSERT(!NFs::Exists(file1)); + UNIT_ASSERT(!NFs::Exists(file2)); + UNIT_ASSERT(!NFs::Exists(file3)); + //UNIT_ASSERT(!NFs::Exists(link)); + UNIT_ASSERT(!NFs::Exists(subdir1)); + UNIT_ASSERT(!NFs::Exists(longfile)); + UNIT_ASSERT(!NFs::Exists(dir1)); +} + void RunRenameTest(TFsPath src, TFsPath dst) { // if previous running was failed - TFsPath dir1 = "dir"; - TFsPath dir2 = "dst_dir"; - - NFs::Remove(src); - NFs::Remove(dst); - - NFs::Remove(dir1 / src); - NFs::Remove(dir1); - NFs::Remove(dir2 / src); - NFs::Remove(dir2); - + TFsPath dir1 = "dir"; + TFsPath dir2 = "dst_dir"; + + NFs::Remove(src); + NFs::Remove(dst); + + NFs::Remove(dir1 / src); + NFs::Remove(dir1); + NFs::Remove(dir2 / src); + NFs::Remove(dir2); + { - TFile file(src, CreateNew | WrOnly); + TFile file(src, CreateNew | WrOnly); file.Write("123", 3); } UNIT_ASSERT(NFs::Rename(src, dst)); - UNIT_ASSERT(NFs::Exists(dst)); - UNIT_ASSERT(!NFs::Exists(src)); - + UNIT_ASSERT(NFs::Exists(dst)); + UNIT_ASSERT(!NFs::Exists(src)); + { - TFile file(dst, OpenExisting); + TFile file(dst, OpenExisting); UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 3); } - - NFs::MakeDirectory(dir1); + + NFs::MakeDirectory(dir1); { - TFile file(dir1 / src, CreateNew | WrOnly); - file.Write("123", 3); - } + TFile file(dir1 / src, CreateNew | WrOnly); + file.Write("123", 3); + } UNIT_ASSERT(NFs::Rename(dir1, dir2)); - UNIT_ASSERT(NFs::Exists(dir2 / src)); - UNIT_ASSERT(!NFs::Exists(dir1)); - - { - TFile file(dir2 / src, OpenExisting); - UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 3); - } - + UNIT_ASSERT(NFs::Exists(dir2 / src)); + UNIT_ASSERT(!NFs::Exists(dir1)); + + { + TFile file(dir2 / src, OpenExisting); + UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 3); + } + UNIT_ASSERT(!NFs::Remove(src)); UNIT_ASSERT(NFs::Remove(dst)); UNIT_ASSERT(!NFs::Remove(dir1)); UNIT_ASSERT(NFs::Remove(dir2 / src)); UNIT_ASSERT(NFs::Remove(dir2)); -} - +} + void TFsTest::TestRename() { - RunRenameTest("src.txt", "dst.txt"); - RunRenameTest("src_абвг.txt", "dst_абвг.txt"); -} - -static void RunHardlinkTest(const TFsPath& src, const TFsPath& dst) { - NFs::Remove(src); - NFs::Remove(dst); - - { - TFile file(src, CreateNew | WrOnly); - file.Write("123", 3); - } - - UNIT_ASSERT(NFs::HardLink(src, dst)); - - { - TFile file(dst, OpenExisting | RdOnly); - UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 3); - } - { - TFile file(src, OpenExisting | WrOnly); + RunRenameTest("src.txt", "dst.txt"); + RunRenameTest("src_абвг.txt", "dst_абвг.txt"); +} + +static void RunHardlinkTest(const TFsPath& src, const TFsPath& dst) { + NFs::Remove(src); + NFs::Remove(dst); + + { + TFile file(src, CreateNew | WrOnly); + file.Write("123", 3); + } + + UNIT_ASSERT(NFs::HardLink(src, dst)); + + { + TFile file(dst, OpenExisting | RdOnly); + UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 3); + } + { + TFile file(src, OpenExisting | WrOnly); file.Write("1234", 4); } { - TFile file(dst, OpenExisting | RdOnly); + TFile file(dst, OpenExisting | RdOnly); UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 4); } { - TFile file(dst, OpenExisting | WrOnly); + TFile file(dst, OpenExisting | WrOnly); file.Write("12345", 5); } - + { - TFile file(src, OpenExisting | RdOnly); + TFile file(src, OpenExisting | RdOnly); UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 5); } - + UNIT_ASSERT(NFs::Remove(dst)); UNIT_ASSERT(NFs::Remove(src)); } -void TFsTest::TestHardlink() { - RunHardlinkTest("tempfile", "hardlinkfile"); - RunHardlinkTest("tempfile_абвг", "hardlinkfile_абвг"); //utf-8 names -} - +void TFsTest::TestHardlink() { + RunHardlinkTest("tempfile", "hardlinkfile"); + RunHardlinkTest("tempfile_абвг", "hardlinkfile_абвг"); //utf-8 names +} + static void RunSymLinkTest(TString fileLocalName, TString symLinkName) { // if previous running was failed - TFsPath subDir = "tempsubdir"; - TFsPath srcFile = subDir / fileLocalName; - - TFsPath subsubDir1 = subDir / "dir1"; - TFsPath subsubDir2 = subDir / "dir2"; - - TFsPath linkD1 = "symlinkdir"; - TFsPath linkD2 = subsubDir1 / "linkd2"; - TFsPath dangling = subsubDir1 / "dangling"; - - NFs::Remove(srcFile); - NFs::Remove(symLinkName); - NFs::Remove(linkD2); - NFs::Remove(dangling); - NFs::Remove(subsubDir1); - NFs::Remove(subsubDir2); - NFs::Remove(subDir); - NFs::Remove(linkD1); - - NFs::MakeDirectory(subDir); - NFs::MakeDirectory(subsubDir1, NFs::FP_NONSECRET_FILE); - NFs::MakeDirectory(subsubDir2, NFs::FP_SECRET_FILE); + TFsPath subDir = "tempsubdir"; + TFsPath srcFile = subDir / fileLocalName; + + TFsPath subsubDir1 = subDir / "dir1"; + TFsPath subsubDir2 = subDir / "dir2"; + + TFsPath linkD1 = "symlinkdir"; + TFsPath linkD2 = subsubDir1 / "linkd2"; + TFsPath dangling = subsubDir1 / "dangling"; + + NFs::Remove(srcFile); + NFs::Remove(symLinkName); + NFs::Remove(linkD2); + NFs::Remove(dangling); + NFs::Remove(subsubDir1); + NFs::Remove(subsubDir2); + NFs::Remove(subDir); + NFs::Remove(linkD1); + + NFs::MakeDirectory(subDir); + NFs::MakeDirectory(subsubDir1, NFs::FP_NONSECRET_FILE); + NFs::MakeDirectory(subsubDir2, NFs::FP_SECRET_FILE); { - TFile file(srcFile, CreateNew | WrOnly); + TFile file(srcFile, CreateNew | WrOnly); file.Write("1234567", 7); } - UNIT_ASSERT(NFs::SymLink(subDir, linkD1)); - UNIT_ASSERT(NFs::SymLink("../dir2", linkD2)); - UNIT_ASSERT(NFs::SymLink("../dir3", dangling)); + UNIT_ASSERT(NFs::SymLink(subDir, linkD1)); + UNIT_ASSERT(NFs::SymLink("../dir2", linkD2)); + UNIT_ASSERT(NFs::SymLink("../dir3", dangling)); UNIT_ASSERT_STRINGS_EQUAL(NFs::ReadLink(linkD2), TString("..") + LOCSLASH_S "dir2"); UNIT_ASSERT_STRINGS_EQUAL(NFs::ReadLink(dangling), TString("..") + LOCSLASH_S "dir3"); { - TFile file(linkD1 / fileLocalName, OpenExisting | RdOnly); + TFile file(linkD1 / fileLocalName, OpenExisting | RdOnly); UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 7); } - UNIT_ASSERT(NFs::SymLink(srcFile, symLinkName)); + UNIT_ASSERT(NFs::SymLink(srcFile, symLinkName)); { - TFile file(symLinkName, OpenExisting | RdOnly); + TFile file(symLinkName, OpenExisting | RdOnly); UNIT_ASSERT_VALUES_EQUAL(file.GetLength(), 7); } { - TFileStat fs(linkD1); + TFileStat fs(linkD1); UNIT_ASSERT(!fs.IsFile()); UNIT_ASSERT(fs.IsDir()); UNIT_ASSERT(!fs.IsSymlink()); } { - TFileStat fs(linkD1, true); + TFileStat fs(linkD1, true); UNIT_ASSERT(!fs.IsFile()); //UNIT_ASSERT(fs.IsDir()); // failed on unix UNIT_ASSERT(fs.IsSymlink()); } { - TFileStat fs(symLinkName); + TFileStat fs(symLinkName); UNIT_ASSERT(fs.IsFile()); UNIT_ASSERT(!fs.IsDir()); UNIT_ASSERT(!fs.IsSymlink()); UNIT_ASSERT_VALUES_EQUAL(fs.Size, 7u); } - + { - TFileStat fs(symLinkName, true); + TFileStat fs(symLinkName, true); //UNIT_ASSERT(fs.IsFile()); // no evidence that symlink has to be a file as well UNIT_ASSERT(!fs.IsDir()); UNIT_ASSERT(fs.IsSymlink()); } UNIT_ASSERT(NFs::Remove(symLinkName)); - UNIT_ASSERT(NFs::Exists(srcFile)); - + UNIT_ASSERT(NFs::Exists(srcFile)); + UNIT_ASSERT(NFs::Remove(linkD1)); - UNIT_ASSERT(NFs::Exists(srcFile)); - + UNIT_ASSERT(NFs::Exists(srcFile)); + UNIT_ASSERT(!NFs::Remove(subDir)); - + UNIT_ASSERT(NFs::Remove(srcFile)); UNIT_ASSERT(NFs::Remove(linkD2)); UNIT_ASSERT(NFs::Remove(dangling)); @@ -275,51 +275,51 @@ static void RunSymLinkTest(TString fileLocalName, TString symLinkName) { UNIT_ASSERT(NFs::Remove(subsubDir2)); UNIT_ASSERT(NFs::Remove(subDir)); } - + void TFsTest::TestSymlink() { - // if previous running was failed - RunSymLinkTest("f.txt", "fl.txt"); - RunSymLinkTest("f_абвг.txt", "fl_абвг.txt"); //utf-8 names -} - -void TFsTest::TestCwdOpts() { - TFsPath initialCwd = NFs::CurrentWorkingDirectory(); - TFsPath subdir = "dir_forcwd_абвг"; - NFs::MakeDirectory(subdir, NFs::FP_SECRET_FILE | NFs::FP_ALL_READ); - NFs::SetCurrentWorkingDirectory(subdir); - TFsPath newCwd = NFs::CurrentWorkingDirectory(); - - UNIT_ASSERT_EQUAL(newCwd.Fix(), (initialCwd / subdir).Fix()); - - NFs::SetCurrentWorkingDirectory(".."); - TFsPath newCwd2 = NFs::CurrentWorkingDirectory(); - UNIT_ASSERT_EQUAL(newCwd2.Fix(), initialCwd.Fix()); - UNIT_ASSERT(NFs::Remove(subdir)); -} - -void TFsTest::TestEnsureExists() { - TFsPath fileExists = "tmp_file_абвг.txt"; - TFsPath nonExists = "tmp2_file_абвг.txt"; - { - NFs::Remove(fileExists); - NFs::Remove(nonExists); - TFile file(fileExists, CreateNew | WrOnly); - file.Write("1234567", 7); - } - - UNIT_ASSERT_NO_EXCEPTION(NFs::EnsureExists(fileExists)); - UNIT_ASSERT_EXCEPTION(NFs::EnsureExists(nonExists), TFileError); - - TStringBuilder expected; + // if previous running was failed + RunSymLinkTest("f.txt", "fl.txt"); + RunSymLinkTest("f_абвг.txt", "fl_абвг.txt"); //utf-8 names +} + +void TFsTest::TestCwdOpts() { + TFsPath initialCwd = NFs::CurrentWorkingDirectory(); + TFsPath subdir = "dir_forcwd_абвг"; + NFs::MakeDirectory(subdir, NFs::FP_SECRET_FILE | NFs::FP_ALL_READ); + NFs::SetCurrentWorkingDirectory(subdir); + TFsPath newCwd = NFs::CurrentWorkingDirectory(); + + UNIT_ASSERT_EQUAL(newCwd.Fix(), (initialCwd / subdir).Fix()); + + NFs::SetCurrentWorkingDirectory(".."); + TFsPath newCwd2 = NFs::CurrentWorkingDirectory(); + UNIT_ASSERT_EQUAL(newCwd2.Fix(), initialCwd.Fix()); + UNIT_ASSERT(NFs::Remove(subdir)); +} + +void TFsTest::TestEnsureExists() { + TFsPath fileExists = "tmp_file_абвг.txt"; + TFsPath nonExists = "tmp2_file_абвг.txt"; + { + NFs::Remove(fileExists); + NFs::Remove(nonExists); + TFile file(fileExists, CreateNew | WrOnly); + file.Write("1234567", 7); + } + + UNIT_ASSERT_NO_EXCEPTION(NFs::EnsureExists(fileExists)); + UNIT_ASSERT_EXCEPTION(NFs::EnsureExists(nonExists), TFileError); + + TStringBuilder expected; TString got; - try { + try { NFs::EnsureExists(nonExists); expected << __LOCATION__; - } catch (const TFileError& err) { - got = err.what(); - } - UNIT_ASSERT(got.Contains(expected)); - UNIT_ASSERT(got.Contains(NFs::CurrentWorkingDirectory())); - - UNIT_ASSERT(NFs::Remove(fileExists)); -} + } catch (const TFileError& err) { + got = err.what(); + } + UNIT_ASSERT(got.Contains(expected)); + UNIT_ASSERT(got.Contains(NFs::CurrentWorkingDirectory())); + + UNIT_ASSERT(NFs::Remove(fileExists)); +} diff --git a/util/system/fs_win.cpp b/util/system/fs_win.cpp index 8736b8ef00..a410ccac06 100644 --- a/util/system/fs_win.cpp +++ b/util/system/fs_win.cpp @@ -20,11 +20,11 @@ namespace NFsPrivate { } static TString WCHARToUTF8(const LPWSTR wstr, size_t len) { - static_assert(sizeof(WCHAR) == sizeof(wchar16), "expect sizeof(WCHAR) == sizeof(wchar16)"); - + static_assert(sizeof(WCHAR) == sizeof(wchar16), "expect sizeof(WCHAR) == sizeof(wchar16)"); + return WideToUTF8((wchar16*)wstr, len); - } - + } + HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle) { TUtf16String wstr; LPCWSTR wname = UTF8ToWCHAR(fName, wstr); @@ -37,8 +37,8 @@ namespace NFsPrivate { secAttrs.lpSecurityDescriptor = nullptr; secAttrs.nLength = sizeof(secAttrs); return ::CreateFileW(wname, accessMode, shareMode, &secAttrs, createMode, attributes, nullptr); - } - + } + bool WinRename(const TString& oldPath, const TString& newPath) { TUtf16String op, np; LPCWSTR opPtr = UTF8ToWCHAR(oldPath, op); @@ -47,10 +47,10 @@ namespace NFsPrivate { ::SetLastError(ERROR_INVALID_NAME); return false; } - + return MoveFileExW(opPtr, npPtr, MOVEFILE_REPLACE_EXISTING) != 0; } - + bool WinRemove(const TString& path) { TUtf16String wstr; LPCWSTR wname = UTF8ToWCHAR(path, wstr); @@ -67,10 +67,10 @@ namespace NFsPrivate { return false; } - + bool WinSymLink(const TString& targetName, const TString& linkName) { TString tName(targetName); - { + { size_t pos; while ((pos = tName.find('/')) != TString::npos) tName.replace(pos, 1, LOCSLASH_S); @@ -79,7 +79,7 @@ namespace NFsPrivate { LPCWSTR wname = UTF8ToWCHAR(tName, tstr); TUtf16String lstr; LPCWSTR lname = UTF8ToWCHAR(linkName, lstr); - + // we can't create a dangling link to a dir in this way ui32 attr = ::GetFileAttributesW(wname); if (attr == INVALID_FILE_ATTRIBUTES) { @@ -111,38 +111,38 @@ namespace NFsPrivate { } return (CreateHardLinkW(npPtr, epPtr, nullptr) != 0); - } - + } + bool WinExists(const TString& path) { TUtf16String buf; LPCWSTR ptr = UTF8ToWCHAR(path, buf); return ::GetFileAttributesW(ptr) != INVALID_FILE_ATTRIBUTES; } - + TString WinCurrentWorkingDirectory() { - TTempBuf result; - LPWSTR buf = reinterpret_cast<LPWSTR>(result.Data()); - int r = GetCurrentDirectoryW(result.Size() / sizeof(WCHAR), buf); - if (r == 0) - throw TIoSystemError() << "failed to GetCurrentDirectory"; - return WCHARToUTF8(buf, r); - } - + TTempBuf result; + LPWSTR buf = reinterpret_cast<LPWSTR>(result.Data()); + int r = GetCurrentDirectoryW(result.Size() / sizeof(WCHAR), buf); + if (r == 0) + throw TIoSystemError() << "failed to GetCurrentDirectory"; + return WCHARToUTF8(buf, r); + } + bool WinSetCurrentWorkingDirectory(const TString& path) { TUtf16String wstr; - LPCWSTR wname = UTF8ToWCHAR(path, wstr); - if (!wname) { - ::SetLastError(ERROR_INVALID_NAME); - return false; - } - return SetCurrentDirectoryW(wname); - } - + LPCWSTR wname = UTF8ToWCHAR(path, wstr); + if (!wname) { + ::SetLastError(ERROR_INVALID_NAME); + return false; + } + return SetCurrentDirectoryW(wname); + } + bool WinMakeDirectory(const TString path) { TUtf16String buf; - LPCWSTR ptr = UTF8ToWCHAR(path, buf); - return CreateDirectoryW(ptr, (LPSECURITY_ATTRIBUTES) nullptr); - } + LPCWSTR ptr = UTF8ToWCHAR(path, buf); + return CreateDirectoryW(ptr, (LPSECURITY_ATTRIBUTES) nullptr); + } // edited part of <Ntifs.h> from Windows DDK #define SYMLINK_FLAG_RELATIVE 1 @@ -229,5 +229,5 @@ bool GetObjectId(const char* path, GUID* id) { return false; } */ - + } diff --git a/util/system/fs_win.h b/util/system/fs_win.h index 7fdab7c198..8086129828 100644 --- a/util/system/fs_win.h +++ b/util/system/fs_win.h @@ -8,22 +8,22 @@ namespace NFsPrivate { bool WinRename(const TString& oldPath, const TString& newPath); - + bool WinSymLink(const TString& targetName, const TString& linkName); - + bool WinHardLink(const TString& existingPath, const TString& newPath); - + TString WinReadLink(const TString& path); - + HANDLE CreateFileWithUtf8Name(const TStringBuf fName, ui32 accessMode, ui32 shareMode, ui32 createMode, ui32 attributes, bool inheritHandle); - + bool WinRemove(const TString& path); - + bool WinExists(const TString& path); - + TString WinCurrentWorkingDirectory(); - + bool WinSetCurrentWorkingDirectory(const TString& path); - + bool WinMakeDirectory(const TString path); } diff --git a/util/system/fstat_ut.cpp b/util/system/fstat_ut.cpp index 040cacbb09..160ecd936e 100644 --- a/util/system/fstat_ut.cpp +++ b/util/system/fstat_ut.cpp @@ -3,8 +3,8 @@ #include "sysstat.h" #include "fs.h" -#include <library/cpp/testing/unittest/registar.h> -#include <library/cpp/testing/unittest/tests_data.h> +#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/tests_data.h> #include <util/folder/path.h> diff --git a/util/system/getpid_ut.cpp b/util/system/getpid_ut.cpp index fb0d42ef76..e7122a2971 100644 --- a/util/system/getpid_ut.cpp +++ b/util/system/getpid_ut.cpp @@ -1,6 +1,6 @@ #include "getpid.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> class TGetPidTest: public TTestBase { UNIT_TEST_SUITE(TGetPidTest); diff --git a/util/system/guard_ut.cpp b/util/system/guard_ut.cpp index 6f18e9a5ee..404ede99ab 100644 --- a/util/system/guard_ut.cpp +++ b/util/system/guard_ut.cpp @@ -1,7 +1,7 @@ #include "guard.h" #include "rwlock.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/thread/pool.h> diff --git a/util/system/hi_lo_ut.cpp b/util/system/hi_lo_ut.cpp index 8610fbb9fd..850c12327d 100644 --- a/util/system/hi_lo_ut.cpp +++ b/util/system/hi_lo_ut.cpp @@ -1,6 +1,6 @@ #include <util/system/hi_lo.h> -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include "defaults.h" diff --git a/util/system/hostname_ut.cpp b/util/system/hostname_ut.cpp index 009c4f8064..fb1cb7dde4 100644 --- a/util/system/hostname_ut.cpp +++ b/util/system/hostname_ut.cpp @@ -1,6 +1,6 @@ #include "hostname.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(THostNameTest) { Y_UNIT_TEST(Test1) { diff --git a/util/system/info_ut.cpp b/util/system/info_ut.cpp index 5b2dd00460..ad7449f8f4 100644 --- a/util/system/info_ut.cpp +++ b/util/system/info_ut.cpp @@ -1,6 +1,6 @@ #include "info.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> class TSysInfoTest: public TTestBase { UNIT_TEST_SUITE(TSysInfoTest); diff --git a/util/system/interrupt_signals_ut.cpp b/util/system/interrupt_signals_ut.cpp index 0dda781cea..bec54fec61 100644 --- a/util/system/interrupt_signals_ut.cpp +++ b/util/system/interrupt_signals_ut.cpp @@ -4,7 +4,7 @@ #include <util/datetime/base.h> -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #ifdef _win_ #include <windows.h> diff --git a/util/system/mem_info_ut.cpp b/util/system/mem_info_ut.cpp index 864aff9cd4..a1100ba646 100644 --- a/util/system/mem_info_ut.cpp +++ b/util/system/mem_info_ut.cpp @@ -1,6 +1,6 @@ #include "mem_info.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include "info.h" diff --git a/util/system/mincore_ut.cpp b/util/system/mincore_ut.cpp index 39fe7fd91a..fc46cb1632 100644 --- a/util/system/mincore_ut.cpp +++ b/util/system/mincore_ut.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #ifdef _unix_ #include <sys/resource.h> diff --git a/util/system/mlock.cpp b/util/system/mlock.cpp index a47f94a993..435338c98f 100644 --- a/util/system/mlock.cpp +++ b/util/system/mlock.cpp @@ -54,27 +54,27 @@ void UnlockMemory(const void* addr, size_t len) { void LockAllMemory(ELockAllMemoryFlags flags) { Y_UNUSED(flags); -#if defined(_android_) +#if defined(_android_) // unimplemented -#elif defined(_cygwin_) +#elif defined(_cygwin_) // unimplemented -#elif defined(_unix_) - int sys_flags = 0; +#elif defined(_unix_) + int sys_flags = 0; if (flags & LockCurrentMemory) { - sys_flags |= MCL_CURRENT; - } + sys_flags |= MCL_CURRENT; + } if (flags & LockFutureMemory) { - sys_flags |= MCL_FUTURE; - } + sys_flags |= MCL_FUTURE; + } if (flags & LockMemoryOnFault) { sys_flags |= MCL_ONFAULT; } - if (mlockall(sys_flags)) { - ythrow yexception() << LastSystemErrorText(); - } -#endif -} - + if (mlockall(sys_flags)) { + ythrow yexception() << LastSystemErrorText(); + } +#endif +} + void UnlockAllMemory() { #if defined(_cygwin_) // unimplemented diff --git a/util/system/mlock.h b/util/system/mlock.h index 389f65570d..f021c0fe67 100644 --- a/util/system/mlock.h +++ b/util/system/mlock.h @@ -22,10 +22,10 @@ enum ELockAllMemoryFlag { /** Since Linux 4.4, with LockCurrentMemory or LockFutureMemory or both, lock only pages that are or once they are present in memory. */ LockMemoryOnFault = 4, -}; +}; Y_DECLARE_FLAGS(ELockAllMemoryFlags, ELockAllMemoryFlag) Y_DECLARE_OPERATORS_FOR_FLAGS(ELockAllMemoryFlags) - + /** * Performs provided locking operation. * @@ -34,7 +34,7 @@ Y_DECLARE_OPERATORS_FOR_FLAGS(ELockAllMemoryFlags) * \param flags Locking operation to perform. */ void LockAllMemory(ELockAllMemoryFlags flags); - + /** * Unlocks whatever was locked with a previous call to `LockAllMemory`. * diff --git a/util/system/mutex_ut.cpp b/util/system/mutex_ut.cpp index b7509dfe35..c8d7caafa1 100644 --- a/util/system/mutex_ut.cpp +++ b/util/system/mutex_ut.cpp @@ -1,7 +1,7 @@ #include "mutex.h" #include "atomic.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/thread/pool.h> #include <util/random/random.h> diff --git a/util/system/nice_ut.cpp b/util/system/nice_ut.cpp index 5a49c0355a..ae0051f285 100644 --- a/util/system/nice_ut.cpp +++ b/util/system/nice_ut.cpp @@ -2,7 +2,7 @@ #include "platform.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #ifdef _unix_ #include <sys/resource.h> diff --git a/util/system/pipe_ut.cpp b/util/system/pipe_ut.cpp index 7bd6ed0c57..6d53432de8 100644 --- a/util/system/pipe_ut.cpp +++ b/util/system/pipe_ut.cpp @@ -1,6 +1,6 @@ #include "pipe.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TPipeTest) { Y_UNIT_TEST(TestPipe) { diff --git a/util/system/platform_ut.cpp b/util/system/platform_ut.cpp index aa2abf593e..9bfbce8315 100644 --- a/util/system/platform_ut.cpp +++ b/util/system/platform_ut.cpp @@ -1,6 +1,6 @@ #include "platform.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> class TPlatformTest: public TTestBase { UNIT_TEST_SUITE(TPlatformTest); diff --git a/util/system/progname_ut.cpp b/util/system/progname_ut.cpp index 7b740c8730..11f3d9308b 100644 --- a/util/system/progname_ut.cpp +++ b/util/system/progname_ut.cpp @@ -1,6 +1,6 @@ #include "progname.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TProgramNameTest) { Y_UNIT_TEST(TestIt) { diff --git a/util/system/rusage_ut.cpp b/util/system/rusage_ut.cpp index ee0308c0cf..0d4e0fe54b 100644 --- a/util/system/rusage_ut.cpp +++ b/util/system/rusage_ut.cpp @@ -1,6 +1,6 @@ #include "rusage.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TRusageTest) { Y_UNIT_TEST(TestRusage) { diff --git a/util/system/rwlock_ut.cpp b/util/system/rwlock_ut.cpp index b9484a9ac1..2b384c05b3 100644 --- a/util/system/rwlock_ut.cpp +++ b/util/system/rwlock_ut.cpp @@ -1,7 +1,7 @@ #include "rwlock.h" #include "atomic.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/thread/pool.h> #include <util/random/random.h> diff --git a/util/system/sanitizers_ut.cpp b/util/system/sanitizers_ut.cpp index e6fd50c9a2..5de096e14b 100644 --- a/util/system/sanitizers_ut.cpp +++ b/util/system/sanitizers_ut.cpp @@ -1,7 +1,7 @@ #include "sanitizers.h" #include "sys_alloc.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(Sanitizers) { Y_UNIT_TEST(MarkAsIntentionallyLeaked) { diff --git a/util/system/shellcommand.cpp b/util/system/shellcommand.cpp index ffe294a2d6..b1989b5c8c 100644 --- a/util/system/shellcommand.cpp +++ b/util/system/shellcommand.cpp @@ -717,7 +717,7 @@ void TShellCommand::TImpl::OnFork(TPipes& pipes, sigset_t oldmask, char* const* } if (WorkDir.size()) { - NFs::SetCurrentWorkingDirectory(WorkDir); + NFs::SetCurrentWorkingDirectory(WorkDir); } if (CloseAllFdsOnExec) { diff --git a/util/system/shellcommand_ut.cpp b/util/system/shellcommand_ut.cpp index 982cf4438c..9d849279d2 100644 --- a/util/system/shellcommand_ut.cpp +++ b/util/system/shellcommand_ut.cpp @@ -6,8 +6,8 @@ #include "sigset.h" #include "spinlock.h" -#include <library/cpp/testing/unittest/env.h> -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/env.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/folder/dirut.h> #include <util/random/random.h> @@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(cmd.GetExitCode().Defined() && -15 == cmd.GetExitCode()); } sleep(1); - UNIT_ASSERT(!NFs::Exists(tmpfile)); + UNIT_ASSERT(!NFs::Exists(tmpfile)); } // this ut is unix-only (win has no signal mask) Y_UNIT_TEST(TestSignalMask) { @@ -346,7 +346,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus() || TShellCommand::SHELL_FINISHED == cmd.GetStatus()); } sleep(1); - UNIT_ASSERT(!NFs::Exists(tmpfile)); + UNIT_ASSERT(!NFs::Exists(tmpfile)); // child proc should receive SIGTERM options.SetClearSignalMask(true); @@ -362,7 +362,7 @@ Y_UNIT_TEST_SUITE(TShellCommandTest) { UNIT_ASSERT(TShellCommand::SHELL_ERROR == cmd.GetStatus()); } sleep(1); - UNIT_ASSERT(!NFs::Exists(tmpfile)); + UNIT_ASSERT(!NFs::Exists(tmpfile)); // restore signal mask rc = SigProcMask(SIG_SETMASK, &oldmask, nullptr); diff --git a/util/system/shmat_ut.cpp b/util/system/shmat_ut.cpp index f465593e5f..9d92243ae7 100644 --- a/util/system/shmat_ut.cpp +++ b/util/system/shmat_ut.cpp @@ -1,6 +1,6 @@ #include "shmat.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TTestSharedMemory) { Y_UNIT_TEST(TestInProc) { diff --git a/util/system/spinlock_ut.cpp b/util/system/spinlock_ut.cpp index c24bf92d45..e8639a6404 100644 --- a/util/system/spinlock_ut.cpp +++ b/util/system/spinlock_ut.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include "spinlock.h" diff --git a/util/system/src_location_ut.cpp b/util/system/src_location_ut.cpp index 26036c2eb4..5b86cb86ef 100644 --- a/util/system/src_location_ut.cpp +++ b/util/system/src_location_ut.cpp @@ -2,7 +2,7 @@ #include <util/string/builder.h> -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> static inline TString GenLoc() { return TStringBuilder() << __LOCATION__; diff --git a/util/system/src_root_ut.cpp b/util/system/src_root_ut.cpp index d232aa8b71..e9a675eb9a 100644 --- a/util/system/src_root_ut.cpp +++ b/util/system/src_root_ut.cpp @@ -1,13 +1,13 @@ #include "src_root.h" #include <util/folder/pathsplit.h> -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TestSourceRoot) { Y_UNIT_TEST(TestStrip) { // Reconstruct() converts "\" -> "/" on Windows const TString path = TPathSplit(__SOURCE_FILE_IMPL__.As<TStringBuf>()).Reconstruct(); - UNIT_ASSERT_EQUAL(path, "util" LOCSLASH_S "system" LOCSLASH_S "src_root_ut.cpp"); + UNIT_ASSERT_EQUAL(path, "util" LOCSLASH_S "system" LOCSLASH_S "src_root_ut.cpp"); } Y_UNIT_TEST(TestPrivateChopPrefixRoutine) { diff --git a/util/system/tempfile_ut.cpp b/util/system/tempfile_ut.cpp index aba7268060..e4a0923d0b 100644 --- a/util/system/tempfile_ut.cpp +++ b/util/system/tempfile_ut.cpp @@ -1,6 +1,6 @@ #include "tempfile.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/folder/dirut.h> #include <util/generic/yexception.h> @@ -18,7 +18,7 @@ Y_UNIT_TEST_SUITE(TTempFileHandle) { tmp.FlushData(); UNIT_ASSERT_STRINGS_EQUAL(TUnbufferedFileInput(tmp.Name()).ReadAll(), "hello world\n"); } - UNIT_ASSERT(!NFs::Exists(path)); + UNIT_ASSERT(!NFs::Exists(path)); } Y_UNIT_TEST(InCurrentDir) { diff --git a/util/system/thread_ut.cpp b/util/system/thread_ut.cpp index 3d5c0ac15e..d820898fd5 100644 --- a/util/system/thread_ut.cpp +++ b/util/system/thread_ut.cpp @@ -1,6 +1,6 @@ #include "thread.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <atomic> diff --git a/util/system/tls.h b/util/system/tls.h index 6742d2dba6..3c4f56dbeb 100644 --- a/util/system/tls.h +++ b/util/system/tls.h @@ -269,7 +269,7 @@ namespace NTls { THolder<void> mem(::operator new(sizeof(T))); THolder<T> newval(Constructor_->Construct(mem.Get())); - Y_UNUSED(mem.Release()); + Y_UNUSED(mem.Release()); Key_.Set((void*)newval.Get()); val = newval.Release(); } diff --git a/util/system/tls_ut.cpp b/util/system/tls_ut.cpp index c2d87b3a35..e84d34b42a 100644 --- a/util/system/tls_ut.cpp +++ b/util/system/tls_ut.cpp @@ -1,7 +1,7 @@ #include "tls.h" #include "thread.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TTestTLS) { struct X { diff --git a/util/system/type_name_ut.cpp b/util/system/type_name_ut.cpp index deff6c5268..86597f4232 100644 --- a/util/system/type_name_ut.cpp +++ b/util/system/type_name_ut.cpp @@ -1,6 +1,6 @@ #include "type_name.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/generic/yexception.h> #include <util/generic/fwd.h> diff --git a/util/system/types_ut.cpp b/util/system/types_ut.cpp index 0412c0c678..19e40cef46 100644 --- a/util/system/types_ut.cpp +++ b/util/system/types_ut.cpp @@ -1,6 +1,6 @@ #include "types.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TestTypes) { Y_UNIT_TEST(TestScanf) { diff --git a/util/system/unaligned_mem_ut.cpp b/util/system/unaligned_mem_ut.cpp index 48c547dc5c..9de3f3e931 100644 --- a/util/system/unaligned_mem_ut.cpp +++ b/util/system/unaligned_mem_ut.cpp @@ -1,7 +1,7 @@ #include "unaligned_mem.h" -#include <library/cpp/testing/benchmark/bench.h> -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/benchmark/bench.h> +#include <library/cpp/testing/unittest/registar.h> #include <util/system/compiler.h> diff --git a/util/system/user_ut.cpp b/util/system/user_ut.cpp index ec86c2b490..4f8a5ce2ef 100644 --- a/util/system/user_ut.cpp +++ b/util/system/user_ut.cpp @@ -1,6 +1,6 @@ #include "user.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(TestUser) { Y_UNIT_TEST(TestNotEmpty) { diff --git a/util/system/ut/ya.make b/util/system/ut/ya.make index 4b6dd01cdf..127e7c261e 100644 --- a/util/system/ut/ya.make +++ b/util/system/ut/ya.make @@ -20,7 +20,7 @@ IF (OS_DARWIN) ENDIF() PEERDIR( - library/cpp/testing/benchmark + library/cpp/testing/benchmark ) SRCS( diff --git a/util/system/yassert.h b/util/system/yassert.h index 831fbbd3d5..529823440c 100644 --- a/util/system/yassert.h +++ b/util/system/yassert.h @@ -2,7 +2,7 @@ #include "defaults.h" #include "src_root.h" -#include "backtrace.h" +#include "backtrace.h" #if defined(_MSC_VER) #include <new> @@ -55,7 +55,7 @@ inline void YaDebugBreak() { } #undef Y_ASSERT - + #if !defined(NDEBUG) && !defined(__GCCXML__) #define Y_ASSERT(a) \ do { \ diff --git a/util/system/yassert_ut.cpp b/util/system/yassert_ut.cpp index 6c1da535a4..ddd392666c 100644 --- a/util/system/yassert_ut.cpp +++ b/util/system/yassert_ut.cpp @@ -2,7 +2,7 @@ // yassert.h must be included before all headers #include "yassert.h" -#include <library/cpp/testing/unittest/registar.h> +#include <library/cpp/testing/unittest/registar.h> Y_UNIT_TEST_SUITE(YassertTest) { Y_UNIT_TEST(TestAcsLikeFunctionCall) { |