diff options
author | deshevoy <deshevoy@yandex-team.ru> | 2022-02-10 16:46:56 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:56 +0300 |
commit | e988f30484abe5fdeedcc7a5d3c226c01a21800c (patch) | |
tree | 0a217b173aabb57b7e51f8a169989b1a3e0309fe /library/cpp | |
parent | 33ee501c05d3f24036ae89766a858930ae66c548 (diff) | |
download | ydb-e988f30484abe5fdeedcc7a5d3c226c01a21800c.tar.gz |
Restoring authorship annotation for <deshevoy@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp')
29 files changed, 618 insertions, 618 deletions
diff --git a/library/cpp/actors/interconnect/interconnect_stream.cpp b/library/cpp/actors/interconnect/interconnect_stream.cpp index 158ebc9e1d..c6b53562a0 100644 --- a/library/cpp/actors/interconnect/interconnect_stream.cpp +++ b/library/cpp/actors/interconnect/interconnect_stream.cpp @@ -267,19 +267,19 @@ namespace NInterconnect { public: TImpl(const TString& certificate, const TString& privateKey, const TString& caFilePath, const TString& ciphers) { - int ret; + int ret; InitOpenSSL(); -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L Ctx.reset(SSL_CTX_new(TLSv1_2_method())); Y_VERIFY(Ctx, "SSL_CTX_new() failed"); -#else - Ctx.reset(SSL_CTX_new(TLS_method())); - Y_VERIFY(Ctx, "SSL_CTX_new() failed"); - ret = SSL_CTX_set_min_proto_version(Ctx.get(), TLS1_2_VERSION); - Y_VERIFY(ret == 1, "failed to set min proto version"); - ret = SSL_CTX_set_max_proto_version(Ctx.get(), TLS1_2_VERSION); - Y_VERIFY(ret == 1, "failed to set max proto version"); -#endif +#else + Ctx.reset(SSL_CTX_new(TLS_method())); + Y_VERIFY(Ctx, "SSL_CTX_new() failed"); + ret = SSL_CTX_set_min_proto_version(Ctx.get(), TLS1_2_VERSION); + Y_VERIFY(ret == 1, "failed to set min proto version"); + ret = SSL_CTX_set_max_proto_version(Ctx.get(), TLS1_2_VERSION); + Y_VERIFY(ret == 1, "failed to set max proto version"); +#endif SSL_CTX_set_verify(Ctx.get(), SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, &Verify); SSL_CTX_set_mode(*this, SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); diff --git a/library/cpp/getopt/small/completer.cpp b/library/cpp/getopt/small/completer.cpp index 3fff684adb..117f3a59fb 100644 --- a/library/cpp/getopt/small/completer.cpp +++ b/library/cpp/getopt/small/completer.cpp @@ -293,7 +293,7 @@ namespace NLastGetopt::NComp { void GenerateBash(TFormattedOutput& out) const override { L << "IFS=$'\\n'"; - L << "COMPREPLY+=( $(compgen -W \"$(${words[@]} " << SpecialFlag << " " << Completer_->GetUniqueName() << " \"${cword}\" \"\" \"\" 2> /dev/null)\" -- ${cur}) )"; + L << "COMPREPLY+=( $(compgen -W \"$(${words[@]} " << SpecialFlag << " " << Completer_->GetUniqueName() << " \"${cword}\" \"\" \"\" 2> /dev/null)\" -- ${cur}) )"; L << "IFS=$' \\t\\n'"; } @@ -302,7 +302,7 @@ namespace NLastGetopt::NComp { } void GenerateZsh(TFormattedOutput& out, TCompleterManager&) const override { - L << "compadd ${@} ${expl[@]} -- \"${(@f)$(${words_orig[@]} " << SpecialFlag << " " << Completer_->GetUniqueName() << " \"${current_orig}\" \"${prefix_orig}\" \"${suffix_orig}\" 2> /dev/null)}\""; + L << "compadd ${@} ${expl[@]} -- \"${(@f)$(${words_orig[@]} " << SpecialFlag << " " << Completer_->GetUniqueName() << " \"${current_orig}\" \"${prefix_orig}\" \"${suffix_orig}\" 2> /dev/null)}\""; } private: @@ -322,7 +322,7 @@ namespace NLastGetopt::NComp { void GenerateBash(TFormattedOutput& out) const override { L << "IFS=$'\\n'"; - L << "items=( $(${words[@]} " << SpecialFlag << " " << Completer_->GetUniqueName() << " \"${cword}\" \"\" \"\" 2> /dev/null) )"; + L << "items=( $(${words[@]} " << SpecialFlag << " " << Completer_->GetUniqueName() << " \"${cword}\" \"\" \"\" 2> /dev/null) )"; L << "candidates=$(compgen -W \"${items[*]:1}\" -- \"$cur\")"; L << "COMPREPLY+=( $candidates )"; L << "[[ $candidates == *\"${items[1]}\" ]] && need_space=\"\""; @@ -334,7 +334,7 @@ namespace NLastGetopt::NComp { } void GenerateZsh(TFormattedOutput& out, TCompleterManager&) const override { - L << "local items=( \"${(@f)$(${words_orig[@]} " << SpecialFlag << " " << Completer_->GetUniqueName() << " \"${current_orig}\" \"${prefix_orig}\" \"${suffix_orig}\" 2> /dev/null)}\" )"; + L << "local items=( \"${(@f)$(${words_orig[@]} " << SpecialFlag << " " << Completer_->GetUniqueName() << " \"${current_orig}\" \"${prefix_orig}\" \"${suffix_orig}\" 2> /dev/null)}\" )"; L; L << "local rempat=${items[1]}"; L << "shift items"; diff --git a/library/cpp/grpc/client/grpc_client_low.h b/library/cpp/grpc/client/grpc_client_low.h index ab0a0627be..653cc5280a 100644 --- a/library/cpp/grpc/client/grpc_client_low.h +++ b/library/cpp/grpc/client/grpc_client_low.h @@ -210,16 +210,16 @@ protected: } } } - + void GetInitialMetadata(std::unordered_multimap<TString, TString>* metadata) { - for (const auto& [key, value] : Context.GetServerInitialMetadata()) { - metadata->emplace( - TString(key.begin(), key.end()), - TString(value.begin(), value.end()) - ); - } - } - + for (const auto& [key, value] : Context.GetServerInitialMetadata()) { + metadata->emplace( + TString(key.begin(), key.end()), + TString(value.begin(), value.end()) + ); + } + } + grpc::Status Status; grpc::ClientContext Context; std::shared_ptr<IQueueClientContext> LocalContext; @@ -397,11 +397,11 @@ public: virtual void Cancel() = 0; /** - * Scheduled initial server metadata read from the stream - */ + * Scheduled initial server metadata read from the stream + */ virtual void ReadInitialMetadata(std::unordered_multimap<TString, TString>* metadata, TReadCallback callback) = 0; - - /** + + /** * Scheduled response read from the stream * Callback will be called with the status if it failed * Only one Read or Finish call may be active at a time @@ -560,34 +560,34 @@ public: } void ReadInitialMetadata(std::unordered_multimap<TString, TString>* metadata, TReadCallback callback) override { - TGrpcStatus status; - + TGrpcStatus status; + { std::unique_lock<std::mutex> guard(Mutex); - Y_VERIFY(!ReadActive, "Multiple Read/Finish calls detected"); - if (!Finished && !HasInitialMetadata) { - ReadActive = true; - ReadCallback = std::move(callback); - InitialMetadata = metadata; - if (!ReadFinished) { - Stream->ReadInitialMetadata(OnReadDoneTag.Prepare()); - } - return; - } - if (!HasInitialMetadata) { - if (FinishedOk) { - status = Status; - } else { - status = TGrpcStatus::Internal("Unexpected error"); - } - } else { - GetInitialMetadata(metadata); - } - } - - callback(std::move(status)); - } - + Y_VERIFY(!ReadActive, "Multiple Read/Finish calls detected"); + if (!Finished && !HasInitialMetadata) { + ReadActive = true; + ReadCallback = std::move(callback); + InitialMetadata = metadata; + if (!ReadFinished) { + Stream->ReadInitialMetadata(OnReadDoneTag.Prepare()); + } + return; + } + if (!HasInitialMetadata) { + if (FinishedOk) { + status = Status; + } else { + status = TGrpcStatus::Internal("Unexpected error"); + } + } else { + GetInitialMetadata(metadata); + } + } + + callback(std::move(status)); + } + void Read(TResponse* message, TReadCallback callback) override { TGrpcStatus status; @@ -710,15 +710,15 @@ private: callback = std::move(ReadCallback); ReadCallback = nullptr; ReadActive = false; - initialMetadata = InitialMetadata; - InitialMetadata = nullptr; - HasInitialMetadata = true; - } - - if (initialMetadata) { - GetInitialMetadata(initialMetadata); + initialMetadata = InitialMetadata; + InitialMetadata = nullptr; + HasInitialMetadata = true; } + if (initialMetadata) { + GetInitialMetadata(initialMetadata); + } + callback(std::move(status)); } @@ -813,7 +813,7 @@ private: std::vector<TReadCallback> FinishedCallbacks; std::unordered_multimap<TString, TString>* InitialMetadata = nullptr; bool Started = false; - bool HasInitialMetadata = false; + bool HasInitialMetadata = false; bool ReadActive = false; bool ReadFinished = false; bool Finished = false; @@ -888,34 +888,34 @@ public: } void ReadInitialMetadata(std::unordered_multimap<TString, TString>* metadata, TReadCallback callback) override { - TGrpcStatus status; - + TGrpcStatus status; + { std::unique_lock<std::mutex> guard(Mutex); - Y_VERIFY(!ReadActive, "Multiple Read/Finish calls detected"); - if (!Finished && !HasInitialMetadata) { - ReadActive = true; - ReadCallback = std::move(callback); - InitialMetadata = metadata; - if (!ReadFinished) { - Stream->ReadInitialMetadata(OnReadDoneTag.Prepare()); - } - return; - } - if (!HasInitialMetadata) { - if (FinishedOk) { - status = Status; - } else { - status = TGrpcStatus::Internal("Unexpected error"); - } - } else { - GetInitialMetadata(metadata); - } - } - - callback(std::move(status)); - } - + Y_VERIFY(!ReadActive, "Multiple Read/Finish calls detected"); + if (!Finished && !HasInitialMetadata) { + ReadActive = true; + ReadCallback = std::move(callback); + InitialMetadata = metadata; + if (!ReadFinished) { + Stream->ReadInitialMetadata(OnReadDoneTag.Prepare()); + } + return; + } + if (!HasInitialMetadata) { + if (FinishedOk) { + status = Status; + } else { + status = TGrpcStatus::Internal("Unexpected error"); + } + } else { + GetInitialMetadata(metadata); + } + } + + callback(std::move(status)); + } + void Read(TResponse* message, TReadCallback callback) override { TGrpcStatus status; @@ -1070,15 +1070,15 @@ private: callback = std::move(ReadCallback); ReadCallback = nullptr; ReadActive = false; - initialMetadata = InitialMetadata; - InitialMetadata = nullptr; - HasInitialMetadata = true; - } - - if (initialMetadata) { - GetInitialMetadata(initialMetadata); + initialMetadata = InitialMetadata; + InitialMetadata = nullptr; + HasInitialMetadata = true; } + if (initialMetadata) { + GetInitialMetadata(initialMetadata); + } + callback(std::move(status)); } @@ -1221,7 +1221,7 @@ private: TWriteCallback WriteCallback; std::unordered_multimap<TString, TString>* InitialMetadata = nullptr; bool Started = false; - bool HasInitialMetadata = false; + bool HasInitialMetadata = false; bool ReadActive = false; bool ReadFinished = false; bool WriteActive = false; diff --git a/library/cpp/lfalloc/lf_allocX64.cpp b/library/cpp/lfalloc/lf_allocX64.cpp index 2eb90761fe..3d66197c85 100644 --- a/library/cpp/lfalloc/lf_allocX64.cpp +++ b/library/cpp/lfalloc/lf_allocX64.cpp @@ -115,13 +115,13 @@ extern "C" void* realloc(void* old_ptr, size_t new_size) { return new_ptr; } -extern "C" size_t malloc_usable_size(void* ptr) { - if (ptr == nullptr) { - return 0; - } - return LFGetSize(ptr); -} - +extern "C" size_t malloc_usable_size(void* ptr) { + if (ptr == nullptr) { + return 0; + } + return LFGetSize(ptr); +} + NMalloc::TMallocInfo NMalloc::MallocInfo() { NMalloc::TMallocInfo r; #if defined(LFALLOC_DBG) diff --git a/library/cpp/logger/log.h b/library/cpp/logger/log.h index 8be984ccc8..fce55de9b5 100644 --- a/library/cpp/logger/log.h +++ b/library/cpp/logger/log.h @@ -90,7 +90,7 @@ public: void SetFormatter(TLogFormatter formatter) noexcept; template <class T> - inline TLogElement operator<<(const T& t) const { + inline TLogElement operator<<(const T& t) const { TLogElement ret(this); ret << t; return ret; diff --git a/library/cpp/openssl/holders/bio.cpp b/library/cpp/openssl/holders/bio.cpp index 42cc5fc1ef..5b4eba8234 100644 --- a/library/cpp/openssl/holders/bio.cpp +++ b/library/cpp/openssl/holders/bio.cpp @@ -1,29 +1,29 @@ -#include "bio.h" - -namespace NOpenSSL { - - TBioMethod::TBioMethod( - int type, - const char* name, - int (*write)(BIO*, const char*, int), - int (*read)(BIO*, char*, int), - int (*puts)(BIO*, const char*), - int (*gets)(BIO*, char*, int), - long (*ctrl)(BIO*, int, long, void*), - int (*create)(BIO*), - int (*destroy)(BIO*), - long (*callbackCtrl)(BIO*, int, bio_info_cb*) - ) - : THolder(type, name) - { +#include "bio.h" + +namespace NOpenSSL { + + TBioMethod::TBioMethod( + int type, + const char* name, + int (*write)(BIO*, const char*, int), + int (*read)(BIO*, char*, int), + int (*puts)(BIO*, const char*), + int (*gets)(BIO*, char*, int), + long (*ctrl)(BIO*, int, long, void*), + int (*create)(BIO*), + int (*destroy)(BIO*), + long (*callbackCtrl)(BIO*, int, bio_info_cb*) + ) + : THolder(type, name) + { BIO_meth_set_write(*this, write); - BIO_meth_set_read(*this, read); - BIO_meth_set_puts(*this, puts); - BIO_meth_set_gets(*this, gets); - BIO_meth_set_ctrl(*this, ctrl); - BIO_meth_set_create(*this, create); - BIO_meth_set_destroy(*this, destroy); - BIO_meth_set_callback_ctrl(*this, callbackCtrl); - } - -} // namespace NOpenSSL + BIO_meth_set_read(*this, read); + BIO_meth_set_puts(*this, puts); + BIO_meth_set_gets(*this, gets); + BIO_meth_set_ctrl(*this, ctrl); + BIO_meth_set_create(*this, create); + BIO_meth_set_destroy(*this, destroy); + BIO_meth_set_callback_ctrl(*this, callbackCtrl); + } + +} // namespace NOpenSSL diff --git a/library/cpp/openssl/holders/bio.h b/library/cpp/openssl/holders/bio.h index bcd6a7a9d6..2f0b71531f 100644 --- a/library/cpp/openssl/holders/bio.h +++ b/library/cpp/openssl/holders/bio.h @@ -1,25 +1,25 @@ -#pragma once - -#include <contrib/libs/openssl/include/openssl/bio.h> - +#pragma once + +#include <contrib/libs/openssl/include/openssl/bio.h> + #include <library/cpp/openssl/holders/holder.h> - -namespace NOpenSSL { - -class TBioMethod : public THolder<BIO_METHOD, BIO_meth_new, BIO_meth_free, int, const char*> { -public: - TBioMethod( - int type, - const char* name, - int (*write)(BIO*, const char*, int), - int (*read)(BIO*, char*, int), - int (*puts)(BIO*, const char*), - int (*gets)(BIO*, char*, int), - long (*ctrl)(BIO*, int, long, void*), - int (*create)(BIO*), - int (*destroy)(BIO*), - long (*callbackCtrl)(BIO*, int, bio_info_cb*) - ); -}; - -} // namespace NOpenSSL + +namespace NOpenSSL { + +class TBioMethod : public THolder<BIO_METHOD, BIO_meth_new, BIO_meth_free, int, const char*> { +public: + TBioMethod( + int type, + const char* name, + int (*write)(BIO*, const char*, int), + int (*read)(BIO*, char*, int), + int (*puts)(BIO*, const char*), + int (*gets)(BIO*, char*, int), + long (*ctrl)(BIO*, int, long, void*), + int (*create)(BIO*), + int (*destroy)(BIO*), + long (*callbackCtrl)(BIO*, int, bio_info_cb*) + ); +}; + +} // namespace NOpenSSL diff --git a/library/cpp/openssl/holders/bn.h b/library/cpp/openssl/holders/bn.h index 9d133d4bdd..a1a5eb3435 100644 --- a/library/cpp/openssl/holders/bn.h +++ b/library/cpp/openssl/holders/bn.h @@ -1,13 +1,13 @@ -#pragma once - -#include "holder.h" - -#include <contrib/libs/openssl/include/openssl/bn.h> - -namespace NOpenSSL { - class TBignum : public THolder<BIGNUM, BN_new, BN_clear_free> { - }; - - class TBnCtx : public THolder<BN_CTX, BN_CTX_new, BN_CTX_free> { - }; -} +#pragma once + +#include "holder.h" + +#include <contrib/libs/openssl/include/openssl/bn.h> + +namespace NOpenSSL { + class TBignum : public THolder<BIGNUM, BN_new, BN_clear_free> { + }; + + class TBnCtx : public THolder<BN_CTX, BN_CTX_new, BN_CTX_free> { + }; +} diff --git a/library/cpp/openssl/holders/evp.h b/library/cpp/openssl/holders/evp.h index df3cc4c2fa..43240c1640 100644 --- a/library/cpp/openssl/holders/evp.h +++ b/library/cpp/openssl/holders/evp.h @@ -1,13 +1,13 @@ -#pragma once - -#include "holder.h" - -#include <contrib/libs/openssl/include/openssl/evp.h> - -namespace NOpenSSL { - class TEvpCipherCtx : public THolder<EVP_CIPHER_CTX, EVP_CIPHER_CTX_new, EVP_CIPHER_CTX_free> { - }; - - class TEvpMdCtx : public THolder<EVP_MD_CTX, EVP_MD_CTX_new, EVP_MD_CTX_free> { - }; -} +#pragma once + +#include "holder.h" + +#include <contrib/libs/openssl/include/openssl/evp.h> + +namespace NOpenSSL { + class TEvpCipherCtx : public THolder<EVP_CIPHER_CTX, EVP_CIPHER_CTX_new, EVP_CIPHER_CTX_free> { + }; + + class TEvpMdCtx : public THolder<EVP_MD_CTX, EVP_MD_CTX_new, EVP_MD_CTX_free> { + }; +} diff --git a/library/cpp/openssl/holders/hmac.h b/library/cpp/openssl/holders/hmac.h index 4110e06f00..3aa820a569 100644 --- a/library/cpp/openssl/holders/hmac.h +++ b/library/cpp/openssl/holders/hmac.h @@ -1,10 +1,10 @@ -#pragma once - -#include "holder.h" - -#include <contrib/libs/openssl/include/openssl/hmac.h> - -namespace NOpenSSL { - class THmacCtx : public THolder<HMAC_CTX, HMAC_CTX_new, HMAC_CTX_free> { - }; -} +#pragma once + +#include "holder.h" + +#include <contrib/libs/openssl/include/openssl/hmac.h> + +namespace NOpenSSL { + class THmacCtx : public THolder<HMAC_CTX, HMAC_CTX_new, HMAC_CTX_free> { + }; +} diff --git a/library/cpp/openssl/holders/holder.h b/library/cpp/openssl/holders/holder.h index c2a26ce431..f6049ebd02 100644 --- a/library/cpp/openssl/holders/holder.h +++ b/library/cpp/openssl/holders/holder.h @@ -1,32 +1,32 @@ -#pragma once - -#include <util/generic/yexception.h> - -namespace NOpenSSL { - -template <typename TType, auto Create, auto Destroy, class... Args> -class THolder { -public: - inline THolder(Args... args) { - Ptr = Create(args...); - if (!Ptr) { +#pragma once + +#include <util/generic/yexception.h> + +namespace NOpenSSL { + +template <typename TType, auto Create, auto Destroy, class... Args> +class THolder { +public: + inline THolder(Args... args) { + Ptr = Create(args...); + if (!Ptr) { throw std::bad_alloc(); - } - } - - THolder(const THolder&) = delete; - THolder& operator=(const THolder&) = delete; - - inline ~THolder() noexcept { - Destroy(Ptr); - } - - inline operator TType* () noexcept { - return Ptr; - } - -private: - TType* Ptr; -}; - -} + } + } + + THolder(const THolder&) = delete; + THolder& operator=(const THolder&) = delete; + + inline ~THolder() noexcept { + Destroy(Ptr); + } + + inline operator TType* () noexcept { + return Ptr; + } + +private: + TType* Ptr; +}; + +} diff --git a/library/cpp/openssl/holders/ut/evp_ut.cpp b/library/cpp/openssl/holders/ut/evp_ut.cpp index 0f8c0aed01..7aeec7594c 100644 --- a/library/cpp/openssl/holders/ut/evp_ut.cpp +++ b/library/cpp/openssl/holders/ut/evp_ut.cpp @@ -1,15 +1,15 @@ -#include "evp.h" - +#include "evp.h" + #include <library/cpp/testing/unittest/registar.h> - -Y_UNIT_TEST_SUITE(Evp) { - Y_UNIT_TEST(Cipher) { - NOpenSSL::TEvpCipherCtx ctx; - UNIT_ASSERT(ctx); - } - - Y_UNIT_TEST(Md) { - NOpenSSL::TEvpMdCtx ctx; - UNIT_ASSERT(ctx); - } -} + +Y_UNIT_TEST_SUITE(Evp) { + Y_UNIT_TEST(Cipher) { + NOpenSSL::TEvpCipherCtx ctx; + UNIT_ASSERT(ctx); + } + + Y_UNIT_TEST(Md) { + NOpenSSL::TEvpMdCtx ctx; + UNIT_ASSERT(ctx); + } +} diff --git a/library/cpp/openssl/holders/ut/hmac_ut.cpp b/library/cpp/openssl/holders/ut/hmac_ut.cpp index 60f561c337..d241bfbe1f 100644 --- a/library/cpp/openssl/holders/ut/hmac_ut.cpp +++ b/library/cpp/openssl/holders/ut/hmac_ut.cpp @@ -1,10 +1,10 @@ -#include "hmac.h" - +#include "hmac.h" + #include <library/cpp/testing/unittest/registar.h> - -Y_UNIT_TEST_SUITE(Hmac) { - Y_UNIT_TEST(Ctx) { - NOpenSSL::THmacCtx ctx; - UNIT_ASSERT(ctx); - } -} + +Y_UNIT_TEST_SUITE(Hmac) { + Y_UNIT_TEST(Ctx) { + NOpenSSL::THmacCtx ctx; + UNIT_ASSERT(ctx); + } +} diff --git a/library/cpp/openssl/holders/ut/ya.make b/library/cpp/openssl/holders/ut/ya.make index 045cdc3566..7c6f550d14 100644 --- a/library/cpp/openssl/holders/ut/ya.make +++ b/library/cpp/openssl/holders/ut/ya.make @@ -1,10 +1,10 @@ UNITTEST_FOR(library/cpp/openssl/holders) - -OWNER(somov deshevoy) - -SRCS( - evp_ut.cpp - hmac_ut.cpp -) - -END() + +OWNER(somov deshevoy) + +SRCS( + evp_ut.cpp + hmac_ut.cpp +) + +END() diff --git a/library/cpp/openssl/holders/x509_vfy.cpp b/library/cpp/openssl/holders/x509_vfy.cpp index 731baa9055..dccd22fbf9 100644 --- a/library/cpp/openssl/holders/x509_vfy.cpp +++ b/library/cpp/openssl/holders/x509_vfy.cpp @@ -1,30 +1,30 @@ -#include "x509_vfy.h" - -namespace NOpenSSL { - - TX509LookupMethod::TX509LookupMethod( - const char* name, - int (*newItem) (X509_LOOKUP *ctx), - void (*free) (X509_LOOKUP *ctx), - int (*init) (X509_LOOKUP *ctx), - int (*shutdown) (X509_LOOKUP *ctx), - X509_LOOKUP_ctrl_fn ctrl, - X509_LOOKUP_get_by_subject_fn getBySubject, - X509_LOOKUP_get_by_issuer_serial_fn getByIssuerSerial, - X509_LOOKUP_get_by_fingerprint_fn getByFingerprint, - X509_LOOKUP_get_by_alias_fn getByAlias - ) - : THolder(name) - { - X509_LOOKUP_meth_set_new_item(*this, newItem); - X509_LOOKUP_meth_set_free(*this, free); - X509_LOOKUP_meth_set_init(*this, init); - X509_LOOKUP_meth_set_shutdown(*this, shutdown); - X509_LOOKUP_meth_set_ctrl(*this, ctrl); - X509_LOOKUP_meth_set_get_by_subject(*this, getBySubject); - X509_LOOKUP_meth_set_get_by_issuer_serial(*this, getByIssuerSerial); - X509_LOOKUP_meth_set_get_by_fingerprint(*this, getByFingerprint); - X509_LOOKUP_meth_set_get_by_alias(*this, getByAlias); - } - -} // namespace NOpenSSL +#include "x509_vfy.h" + +namespace NOpenSSL { + + TX509LookupMethod::TX509LookupMethod( + const char* name, + int (*newItem) (X509_LOOKUP *ctx), + void (*free) (X509_LOOKUP *ctx), + int (*init) (X509_LOOKUP *ctx), + int (*shutdown) (X509_LOOKUP *ctx), + X509_LOOKUP_ctrl_fn ctrl, + X509_LOOKUP_get_by_subject_fn getBySubject, + X509_LOOKUP_get_by_issuer_serial_fn getByIssuerSerial, + X509_LOOKUP_get_by_fingerprint_fn getByFingerprint, + X509_LOOKUP_get_by_alias_fn getByAlias + ) + : THolder(name) + { + X509_LOOKUP_meth_set_new_item(*this, newItem); + X509_LOOKUP_meth_set_free(*this, free); + X509_LOOKUP_meth_set_init(*this, init); + X509_LOOKUP_meth_set_shutdown(*this, shutdown); + X509_LOOKUP_meth_set_ctrl(*this, ctrl); + X509_LOOKUP_meth_set_get_by_subject(*this, getBySubject); + X509_LOOKUP_meth_set_get_by_issuer_serial(*this, getByIssuerSerial); + X509_LOOKUP_meth_set_get_by_fingerprint(*this, getByFingerprint); + X509_LOOKUP_meth_set_get_by_alias(*this, getByAlias); + } + +} // namespace NOpenSSL diff --git a/library/cpp/openssl/holders/x509_vfy.h b/library/cpp/openssl/holders/x509_vfy.h index b735d8a042..1e186d0865 100644 --- a/library/cpp/openssl/holders/x509_vfy.h +++ b/library/cpp/openssl/holders/x509_vfy.h @@ -1,25 +1,25 @@ -#pragma once - -#include <contrib/libs/openssl/include/openssl/x509_vfy.h> - +#pragma once + +#include <contrib/libs/openssl/include/openssl/x509_vfy.h> + #include <library/cpp/openssl/holders/holder.h> - -namespace NOpenSSL { - -class TX509LookupMethod : public THolder<X509_LOOKUP_METHOD, X509_LOOKUP_meth_new, X509_LOOKUP_meth_free, const char*> { -public: - TX509LookupMethod( - const char* name, - int (*newItem) (X509_LOOKUP *ctx), - void (*free) (X509_LOOKUP *ctx), - int (*init) (X509_LOOKUP *ctx), - int (*shutdown) (X509_LOOKUP *ctx), - X509_LOOKUP_ctrl_fn ctrl, - X509_LOOKUP_get_by_subject_fn getBySubject, - X509_LOOKUP_get_by_issuer_serial_fn getByIssuerSerial, - X509_LOOKUP_get_by_fingerprint_fn getByFingerprint, - X509_LOOKUP_get_by_alias_fn getByAlias - ); -}; - -} // namespace NOpenSSL + +namespace NOpenSSL { + +class TX509LookupMethod : public THolder<X509_LOOKUP_METHOD, X509_LOOKUP_meth_new, X509_LOOKUP_meth_free, const char*> { +public: + TX509LookupMethod( + const char* name, + int (*newItem) (X509_LOOKUP *ctx), + void (*free) (X509_LOOKUP *ctx), + int (*init) (X509_LOOKUP *ctx), + int (*shutdown) (X509_LOOKUP *ctx), + X509_LOOKUP_ctrl_fn ctrl, + X509_LOOKUP_get_by_subject_fn getBySubject, + X509_LOOKUP_get_by_issuer_serial_fn getByIssuerSerial, + X509_LOOKUP_get_by_fingerprint_fn getByFingerprint, + X509_LOOKUP_get_by_alias_fn getByAlias + ); +}; + +} // namespace NOpenSSL diff --git a/library/cpp/openssl/holders/ya.make b/library/cpp/openssl/holders/ya.make index 3a2fbf3ba5..ca5caecb62 100644 --- a/library/cpp/openssl/holders/ya.make +++ b/library/cpp/openssl/holders/ya.make @@ -1,16 +1,16 @@ -LIBRARY() - -OWNER(somov deshevoy) - -PEERDIR( - contrib/libs/openssl -) - -SRCS( - bio.cpp - x509_vfy.cpp -) - -END() - -NEED_CHECK() +LIBRARY() + +OWNER(somov deshevoy) + +PEERDIR( + contrib/libs/openssl +) + +SRCS( + bio.cpp + x509_vfy.cpp +) + +END() + +NEED_CHECK() diff --git a/library/cpp/openssl/init/init.cpp b/library/cpp/openssl/init/init.cpp index ae68ef08ea..b136e1f032 100644 --- a/library/cpp/openssl/init/init.cpp +++ b/library/cpp/openssl/init/init.cpp @@ -44,11 +44,11 @@ namespace { }; inline TInitSsl() { - OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, nullptr); + OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, nullptr); } inline ~TInitSsl() { - OPENSSL_cleanup(); + OPENSSL_cleanup(); } static void LockingFunction(int mode, int n, const char* /*file*/, int /*line*/) { @@ -62,5 +62,5 @@ namespace { } void InitOpenSSL() { - (void)SingletonWithPriority<TInitSsl, 0>(); + (void)SingletonWithPriority<TInitSsl, 0>(); } diff --git a/library/cpp/openssl/io/stream.cpp b/library/cpp/openssl/io/stream.cpp index 0b4be38c0e..191e5422f7 100644 --- a/library/cpp/openssl/io/stream.cpp +++ b/library/cpp/openssl/io/stream.cpp @@ -84,47 +84,47 @@ namespace { return ctx; } - struct TStreamIO : public NOpenSSL::TAbstractIO { - inline TStreamIO(IInputStream* in, IOutputStream* out) - : In(in) - , Out(out) - { - } - - int Write(const char* data, size_t dlen, size_t* written) override { - Out->Write(data, dlen); - - *written = dlen; - return 1; + struct TStreamIO : public NOpenSSL::TAbstractIO { + inline TStreamIO(IInputStream* in, IOutputStream* out) + : In(in) + , Out(out) + { + } + + int Write(const char* data, size_t dlen, size_t* written) override { + Out->Write(data, dlen); + + *written = dlen; + return 1; } - int Read(char* data, size_t dlen, size_t* readbytes) override { - *readbytes = In->Read(data, dlen); - return 1; + int Read(char* data, size_t dlen, size_t* readbytes) override { + *readbytes = In->Read(data, dlen); + return 1; } - int Puts(const char* buf) override { - Y_UNUSED(buf); - return -1; + int Puts(const char* buf) override { + Y_UNUSED(buf); + return -1; } - int Gets(char* buf, int size) override { - Y_UNUSED(buf); - Y_UNUSED(size); - return -1; + int Gets(char* buf, int size) override { + Y_UNUSED(buf); + Y_UNUSED(size); + return -1; } - void Flush() override { + void Flush() override { } - IInputStream* In; - IOutputStream* Out; + IInputStream* In; + IOutputStream* Out; }; struct TSslIO: public TSslInitOnDemand, public TOptions { inline TSslIO(IInputStream* in, IOutputStream* out, const TOptions& opts) : TOptions(opts) - , Io(in, out) + , Io(in, out) , Ctx(CreateClientContext()) , Ssl(ConstructSsl()) { @@ -175,8 +175,8 @@ namespace { InitVerification(ssl.Get()); } - BIO_up_ref(Io); // SSL_set_bio consumes only one reference if rbio and wbio are the same - SSL_set_bio(ssl.Get(), Io, Io); + BIO_up_ref(Io); // SSL_set_bio consumes only one reference if rbio and wbio are the same + SSL_set_bio(ssl.Get(), Io, Io); return ssl; } @@ -233,7 +233,7 @@ namespace { } } - TStreamIO Io; + TStreamIO Io; TSslContextPtr Ctx; TSslPtr Ssl; }; diff --git a/library/cpp/openssl/method/io.cpp b/library/cpp/openssl/method/io.cpp index d184b6456c..bafa974b8a 100644 --- a/library/cpp/openssl/method/io.cpp +++ b/library/cpp/openssl/method/io.cpp @@ -1,122 +1,122 @@ -#include "io.h" - -#include <util/generic/singleton.h> -#include <util/generic/yexception.h> -#include <util/system/compiler.h> -#include <util/system/yassert.h> - -namespace { - using NOpenSSL::TAbstractIO; - - TAbstractIO* IO(BIO* bio) noexcept { - void* ptr = BIO_get_data(bio); - Y_VERIFY(ptr); - return static_cast<TAbstractIO*>(ptr); - } - - template<class T, class Callable, class... Args> - T ExceptionBoundary(BIO* bio, Callable&& f, T err, Args&&... args) noexcept { - try { - return (IO(bio)->*f)(args...); - } catch (...) { - return err; - } - } - - int Write(BIO* bio, const char* data, int dlen) noexcept { - return ExceptionBoundary(bio, &TAbstractIO::WriteOld, -1, data, dlen); - } - - int Read(BIO* bio, char* data, int dlen) noexcept { - return ExceptionBoundary(bio, &TAbstractIO::ReadOld, -1, data, dlen); - } - - int Puts(BIO* bio, const char* buf) noexcept { - return ExceptionBoundary(bio, &TAbstractIO::Puts, -1, buf); - } - - int Gets(BIO* bio, char* buf, int size) noexcept { - return ExceptionBoundary(bio, &TAbstractIO::Gets, -1, buf, size); - } - - long Ctrl(BIO* bio, int cmd, long larg, void* parg) noexcept { - return ExceptionBoundary(bio, &TAbstractIO::Ctrl, -1, cmd, larg, parg); - } - - int Create(BIO* bio) noexcept { - BIO_set_data(bio, nullptr); - BIO_set_init(bio, 1); - return 1; - } - - int Destroy(BIO* bio) noexcept { - BIO_set_data(bio, nullptr); - BIO_set_init(bio, 0); - return 1; - } - - NOpenSSL::TBioMethod* Method() { - return SingletonWithPriority<NOpenSSL::TBioMethod, 32768>( - BIO_get_new_index() | BIO_TYPE_SOURCE_SINK, - "AbstractIO", - Write, - Read, - Puts, - Gets, - Ctrl, - Create, - Destroy, - nullptr - ); - } -} - -namespace NOpenSSL { - - TAbstractIO::TAbstractIO() - : Bio(BIO_new(*Method())) { - if (Y_UNLIKELY(!Bio)) { +#include "io.h" + +#include <util/generic/singleton.h> +#include <util/generic/yexception.h> +#include <util/system/compiler.h> +#include <util/system/yassert.h> + +namespace { + using NOpenSSL::TAbstractIO; + + TAbstractIO* IO(BIO* bio) noexcept { + void* ptr = BIO_get_data(bio); + Y_VERIFY(ptr); + return static_cast<TAbstractIO*>(ptr); + } + + template<class T, class Callable, class... Args> + T ExceptionBoundary(BIO* bio, Callable&& f, T err, Args&&... args) noexcept { + try { + return (IO(bio)->*f)(args...); + } catch (...) { + return err; + } + } + + int Write(BIO* bio, const char* data, int dlen) noexcept { + return ExceptionBoundary(bio, &TAbstractIO::WriteOld, -1, data, dlen); + } + + int Read(BIO* bio, char* data, int dlen) noexcept { + return ExceptionBoundary(bio, &TAbstractIO::ReadOld, -1, data, dlen); + } + + int Puts(BIO* bio, const char* buf) noexcept { + return ExceptionBoundary(bio, &TAbstractIO::Puts, -1, buf); + } + + int Gets(BIO* bio, char* buf, int size) noexcept { + return ExceptionBoundary(bio, &TAbstractIO::Gets, -1, buf, size); + } + + long Ctrl(BIO* bio, int cmd, long larg, void* parg) noexcept { + return ExceptionBoundary(bio, &TAbstractIO::Ctrl, -1, cmd, larg, parg); + } + + int Create(BIO* bio) noexcept { + BIO_set_data(bio, nullptr); + BIO_set_init(bio, 1); + return 1; + } + + int Destroy(BIO* bio) noexcept { + BIO_set_data(bio, nullptr); + BIO_set_init(bio, 0); + return 1; + } + + NOpenSSL::TBioMethod* Method() { + return SingletonWithPriority<NOpenSSL::TBioMethod, 32768>( + BIO_get_new_index() | BIO_TYPE_SOURCE_SINK, + "AbstractIO", + Write, + Read, + Puts, + Gets, + Ctrl, + Create, + Destroy, + nullptr + ); + } +} + +namespace NOpenSSL { + + TAbstractIO::TAbstractIO() + : Bio(BIO_new(*Method())) { + if (Y_UNLIKELY(!Bio)) { throw std::bad_alloc(); - } - BIO_set_data(Bio, this); - } - - TAbstractIO::~TAbstractIO() { - BIO_free(Bio); - } - - int TAbstractIO::WriteOld(const char* data, int dlen) { - size_t written = 0; - - int ret = Write(data, dlen, &written); - if (ret <= 0) { - return ret; - } - - return written; - } - - int TAbstractIO::ReadOld(char* data, int dlen) { - size_t readbytes = 0; - - int ret = Read(data, dlen, &readbytes); - if (ret <= 0) { - return ret; - } - - return readbytes; - } - - long TAbstractIO::Ctrl(int cmd, long larg, void* parg) { - Y_UNUSED(larg); - Y_UNUSED(parg); - - if (cmd == BIO_CTRL_FLUSH) { - Flush(); - return 1; - } - - return 0; - } - -} // namespace NOpenSSL + } + BIO_set_data(Bio, this); + } + + TAbstractIO::~TAbstractIO() { + BIO_free(Bio); + } + + int TAbstractIO::WriteOld(const char* data, int dlen) { + size_t written = 0; + + int ret = Write(data, dlen, &written); + if (ret <= 0) { + return ret; + } + + return written; + } + + int TAbstractIO::ReadOld(char* data, int dlen) { + size_t readbytes = 0; + + int ret = Read(data, dlen, &readbytes); + if (ret <= 0) { + return ret; + } + + return readbytes; + } + + long TAbstractIO::Ctrl(int cmd, long larg, void* parg) { + Y_UNUSED(larg); + Y_UNUSED(parg); + + if (cmd == BIO_CTRL_FLUSH) { + Flush(); + return 1; + } + + return 0; + } + +} // namespace NOpenSSL diff --git a/library/cpp/openssl/method/io.h b/library/cpp/openssl/method/io.h index f1d3df978d..ffe1da62f3 100644 --- a/library/cpp/openssl/method/io.h +++ b/library/cpp/openssl/method/io.h @@ -1,31 +1,31 @@ -#pragma once - +#pragma once + #include <library/cpp/openssl/holders/bio.h> - -namespace NOpenSSL { - -class TAbstractIO { -public: - TAbstractIO(); - virtual ~TAbstractIO(); - - virtual int Write(const char* data, size_t dlen, size_t* written) = 0; - virtual int Read(char* data, size_t dlen, size_t* readbytes) = 0; - virtual int Puts(const char* buf) = 0; - virtual int Gets(char* buf, int size) = 0; - - virtual long Ctrl(int cmd, long larg, void* parg); - virtual void Flush() = 0; - - int WriteOld(const char* data, int dlen); - int ReadOld(char* data, int dlen); - - inline operator BIO* () noexcept { - return Bio; - } - -private: - BIO* Bio; -}; - -} // namespace NOpenSSL + +namespace NOpenSSL { + +class TAbstractIO { +public: + TAbstractIO(); + virtual ~TAbstractIO(); + + virtual int Write(const char* data, size_t dlen, size_t* written) = 0; + virtual int Read(char* data, size_t dlen, size_t* readbytes) = 0; + virtual int Puts(const char* buf) = 0; + virtual int Gets(char* buf, int size) = 0; + + virtual long Ctrl(int cmd, long larg, void* parg); + virtual void Flush() = 0; + + int WriteOld(const char* data, int dlen); + int ReadOld(char* data, int dlen); + + inline operator BIO* () noexcept { + return Bio; + } + +private: + BIO* Bio; +}; + +} // namespace NOpenSSL diff --git a/library/cpp/openssl/method/ut/io_ut.cpp b/library/cpp/openssl/method/ut/io_ut.cpp index bff2b23d31..ec6f6c6396 100644 --- a/library/cpp/openssl/method/ut/io_ut.cpp +++ b/library/cpp/openssl/method/ut/io_ut.cpp @@ -1,52 +1,52 @@ #include <library/cpp/openssl/method/io.h> - + #include <library/cpp/testing/unittest/registar.h> - -class TTestIO : public NOpenSSL::TAbstractIO { -public: - int Write(const char* data, size_t dlen, size_t* written) override { - Y_UNUSED(data); - *written = dlen; - return 1; - } - - int Read(char* data, size_t dlen, size_t* readbytes) override { - Y_UNUSED(data); - Y_UNUSED(dlen); - *readbytes = 0; - return 0; - } - - int Puts(const char* buf) override { - if (buf == nullptr) { - return 0; - } - - return strlen(buf); - } - - int Gets(char* buf, int size) override { - Y_UNUSED(buf); - Y_UNUSED(size); - return 0; - } - - void Flush() override { - - } -}; - -Y_UNIT_TEST_SUITE(IO) { - Y_UNIT_TEST(AbstractIO) { - static const char s[] = "12345"; - - TTestIO test; - - UNIT_ASSERT(BIO_write(test, s, sizeof(s)) == sizeof(s)); - UNIT_ASSERT(BIO_puts(test, s) == strlen(s)); - - char buf[128]; - UNIT_ASSERT(BIO_read(test, buf, sizeof(buf)) == 0); - UNIT_ASSERT(BIO_gets(test, buf, sizeof(buf)) == 0); - } -} + +class TTestIO : public NOpenSSL::TAbstractIO { +public: + int Write(const char* data, size_t dlen, size_t* written) override { + Y_UNUSED(data); + *written = dlen; + return 1; + } + + int Read(char* data, size_t dlen, size_t* readbytes) override { + Y_UNUSED(data); + Y_UNUSED(dlen); + *readbytes = 0; + return 0; + } + + int Puts(const char* buf) override { + if (buf == nullptr) { + return 0; + } + + return strlen(buf); + } + + int Gets(char* buf, int size) override { + Y_UNUSED(buf); + Y_UNUSED(size); + return 0; + } + + void Flush() override { + + } +}; + +Y_UNIT_TEST_SUITE(IO) { + Y_UNIT_TEST(AbstractIO) { + static const char s[] = "12345"; + + TTestIO test; + + UNIT_ASSERT(BIO_write(test, s, sizeof(s)) == sizeof(s)); + UNIT_ASSERT(BIO_puts(test, s) == strlen(s)); + + char buf[128]; + UNIT_ASSERT(BIO_read(test, buf, sizeof(buf)) == 0); + UNIT_ASSERT(BIO_gets(test, buf, sizeof(buf)) == 0); + } +} diff --git a/library/cpp/openssl/method/ut/ya.make b/library/cpp/openssl/method/ut/ya.make index 3645ad17e6..953c790707 100644 --- a/library/cpp/openssl/method/ut/ya.make +++ b/library/cpp/openssl/method/ut/ya.make @@ -1,9 +1,9 @@ UNITTEST_FOR(library/cpp/openssl/method) - -OWNER(somov deshevoy) - -SRCS( - io_ut.cpp -) - -END() + +OWNER(somov deshevoy) + +SRCS( + io_ut.cpp +) + +END() diff --git a/library/cpp/openssl/method/ya.make b/library/cpp/openssl/method/ya.make index c8f6f18b6b..1fb716104f 100644 --- a/library/cpp/openssl/method/ya.make +++ b/library/cpp/openssl/method/ya.make @@ -1,14 +1,14 @@ -LIBRARY() - -OWNER(somov deshevoy) - -PEERDIR( - contrib/libs/openssl +LIBRARY() + +OWNER(somov deshevoy) + +PEERDIR( + contrib/libs/openssl library/cpp/openssl/holders -) - -SRCS( - io.cpp -) - -END() +) + +SRCS( + io.cpp +) + +END() diff --git a/library/cpp/openssl/ya.make b/library/cpp/openssl/ya.make index 7c10963e26..67c5404d59 100644 --- a/library/cpp/openssl/ya.make +++ b/library/cpp/openssl/ya.make @@ -3,11 +3,11 @@ RECURSE( big_integer/ut crypto crypto/ut - holders - holders/ut + holders + holders/ut io io/ut - method - method/ut + method + method/ut init ) diff --git a/library/cpp/testing/common/env.h b/library/cpp/testing/common/env.h index 7b89aa1bed..10d8e51477 100644 --- a/library/cpp/testing/common/env.h +++ b/library/cpp/testing/common/env.h @@ -26,7 +26,7 @@ bool FromYaTest(); // @brief returns TestsData dir (from env:ARCADIA_TESTS_DATA_DIR or path to existing folder `arcadia_tests_data` within parent folders) TString GetArcadiaTestsData(); - + // @brief return current working dir (from env:TEST_WORK_PATH or cwd) TString GetWorkPath(); diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index 44517a0092..4009371781 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -60,23 +60,23 @@ namespace NUnitTest { class TAssertException: public yexception { }; - class ITestSuiteProcessor; - + class ITestSuiteProcessor; + struct TTestContext { - TTestContext() + TTestContext() : Processor(nullptr) { - } - - explicit TTestContext(ITestSuiteProcessor* processor) + } + + explicit TTestContext(ITestSuiteProcessor* processor) : Processor(processor) { - } - + } + using TMetrics = THashMap<TString, double>; TMetrics Metrics; - - ITestSuiteProcessor* Processor; + + ITestSuiteProcessor* Processor; }; class ITestSuiteProcessor { @@ -307,22 +307,22 @@ private: \ this->TTestBase::Run(std::bind(&T##F##Caller::X, this, context), StaticName(), (#F), FF); \ } -#define UNIT_TEST_IMPL(F, FF) \ - UNIT_TEST_CHECK_TEST_IS_DECLARED_ONLY_ONCE(F) { \ - NUnitTest::TTestContext context(this->TTestBase::Processor()); \ - if (this->CheckAccessTest((#F))) { \ - try { \ - UNIT_TEST_RUN(F, FF, context) \ - } catch (const ::NUnitTest::TAssertException&) { \ - } catch (const yexception& e) { \ - CATCH_REACTION_BT((#F), e, &context); \ - } catch (const std::exception& e) { \ - CATCH_REACTION((#F), e, &context); \ - } catch (...) { \ - this->AddError("non-std exception!", &context); \ - } \ - this->Finish((#F), &context); \ - } \ +#define UNIT_TEST_IMPL(F, FF) \ + UNIT_TEST_CHECK_TEST_IS_DECLARED_ONLY_ONCE(F) { \ + NUnitTest::TTestContext context(this->TTestBase::Processor()); \ + if (this->CheckAccessTest((#F))) { \ + try { \ + UNIT_TEST_RUN(F, FF, context) \ + } catch (const ::NUnitTest::TAssertException&) { \ + } catch (const yexception& e) { \ + CATCH_REACTION_BT((#F), e, &context); \ + } catch (const std::exception& e) { \ + CATCH_REACTION((#F), e, &context); \ + } catch (...) { \ + this->AddError("non-std exception!", &context); \ + } \ + this->Finish((#F), &context); \ + } \ } #define UNIT_TEST(F) UNIT_TEST_IMPL(F, false) @@ -335,7 +335,7 @@ private: \ UNIT_TEST_IMPL(F, false); \ /* forked process (or main without "--fork-tests") treats some exceptions as success - it's exception test! */ \ } else { \ - NUnitTest::TTestContext context(this->TTestBase::Processor()); \ + NUnitTest::TTestContext context(this->TTestBase::Processor()); \ if (this->CheckAccessTest((#F))) { \ try { \ UNIT_TEST_RUN(F, false, context) \ @@ -752,7 +752,7 @@ public: \ #define UNIT_ASSERT_TEST_FAILS(A) UNIT_ASSERT_TEST_FAILS_C(A, "") -#define UNIT_ADD_METRIC(name, value) ut_context.Metrics[name] = value +#define UNIT_ADD_METRIC(name, value) ut_context.Metrics[name] = value class TTestFactory { friend class TTestBase; @@ -953,7 +953,7 @@ public: \ if (!this->CheckAccessTest(i->Name_)) { \ continue; \ } \ - NUnitTest::TTestContext context(this->TTestBase::Processor()); \ + NUnitTest::TTestContext context(this->TTestBase::Processor()); \ try { \ this->BeforeTest(i->Name_); \ { \ @@ -1009,7 +1009,7 @@ public: \ #define Y_UNIT_TEST_IMPL(N, FF, F) \ Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \ - void TTestCase##N::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED) + void TTestCase##N::Execute_(NUnitTest::TTestContext& ut_context Y_DECLARE_UNUSED) #define Y_UNIT_TEST(N) Y_UNIT_TEST_IMPL(N, false, TCurrentTestCase) #define Y_UNIT_TEST_F(N, F) Y_UNIT_TEST_IMPL(N, false, F) diff --git a/library/cpp/testing/unittest/simple.h b/library/cpp/testing/unittest/simple.h index 2a5300d886..52309d68af 100644 --- a/library/cpp/testing/unittest/simple.h +++ b/library/cpp/testing/unittest/simple.h @@ -15,7 +15,7 @@ namespace NUnitTest { if (!CheckAccessTest(i->Name_)) { continue; } - TTestContext context(this->Processor()); + TTestContext context(this->Processor()); try { BeforeTest(i->Name_); { diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index 305bc6b40f..5982754dd7 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -727,10 +727,10 @@ int NUnitTest::RunMain(int argc, char** argv) { ++i; listFile = MakeHolder<TFixedBufferFileOutput>(argv[i]); listStream = listFile.Get(); - } else if (strcmp(name, "--test-param") == 0) { - ++i; - TString param(argv[i]); - size_t assign = param.find('='); + } else if (strcmp(name, "--test-param") == 0) { + ++i; + TString param(argv[i]); + size_t assign = param.find('='); Singleton<::NPrivate::TTestEnv>()->AddTestParam(param.substr(0, assign), param.substr(assign + 1)); } else if (TString(name).StartsWith("--")) { return DoUsage(argv[0]), 1; |