aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authordeshevoy <deshevoy@yandex-team.ru>2022-02-10 16:46:57 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:57 +0300
commit28148f76dbfcc644d96427d41c92f36cbf2fdc6e (patch)
treeb83306b6e37edeea782e9eed673d89286c4fef35 /library
parente988f30484abe5fdeedcc7a5d3c226c01a21800c (diff)
downloadydb-28148f76dbfcc644d96427d41c92f36cbf2fdc6e.tar.gz
Restoring authorship annotation for <deshevoy@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library')
-rw-r--r--library/cpp/actors/interconnect/interconnect_stream.cpp20
-rw-r--r--library/cpp/getopt/small/completer.cpp8
-rw-r--r--library/cpp/grpc/client/grpc_client_low.h162
-rw-r--r--library/cpp/lfalloc/lf_allocX64.cpp14
-rw-r--r--library/cpp/logger/log.h2
-rw-r--r--library/cpp/openssl/holders/bio.cpp56
-rw-r--r--library/cpp/openssl/holders/bio.h48
-rw-r--r--library/cpp/openssl/holders/bn.h26
-rw-r--r--library/cpp/openssl/holders/evp.h26
-rw-r--r--library/cpp/openssl/holders/hmac.h20
-rw-r--r--library/cpp/openssl/holders/holder.h62
-rw-r--r--library/cpp/openssl/holders/ut/evp_ut.cpp28
-rw-r--r--library/cpp/openssl/holders/ut/hmac_ut.cpp18
-rw-r--r--library/cpp/openssl/holders/ut/ya.make18
-rw-r--r--library/cpp/openssl/holders/x509_vfy.cpp60
-rw-r--r--library/cpp/openssl/holders/x509_vfy.h48
-rw-r--r--library/cpp/openssl/holders/ya.make32
-rw-r--r--library/cpp/openssl/init/init.cpp6
-rw-r--r--library/cpp/openssl/io/stream.cpp58
-rw-r--r--library/cpp/openssl/method/io.cpp242
-rw-r--r--library/cpp/openssl/method/io.h60
-rw-r--r--library/cpp/openssl/method/ut/io_ut.cpp100
-rw-r--r--library/cpp/openssl/method/ut/ya.make16
-rw-r--r--library/cpp/openssl/method/ya.make26
-rw-r--r--library/cpp/openssl/ya.make8
-rw-r--r--library/cpp/testing/common/env.h2
-rw-r--r--library/cpp/testing/unittest/registar.h60
-rw-r--r--library/cpp/testing/unittest/simple.h2
-rw-r--r--library/cpp/testing/unittest/utmain.cpp8
-rw-r--r--library/python/pytest/main.py38
-rw-r--r--library/python/pytest/plugins/collection.py20
-rw-r--r--library/python/pytest/plugins/conftests.py22
-rw-r--r--library/python/pytest/plugins/ya.py38
-rw-r--r--library/python/pytest/pytest.yatest.ini6
-rw-r--r--library/python/pytest/rewrite.py128
-rw-r--r--library/python/pytest/ya.make2
-rw-r--r--library/python/pytest/yatest_tools.py8
-rw-r--r--library/python/runtime_py3/importer.pxi56
-rw-r--r--library/python/runtime_py3/main/main.c258
-rw-r--r--library/python/runtime_py3/ya.make4
-rw-r--r--library/python/testing/yatest_common/yatest/common/process.py16
-rw-r--r--library/python/testing/yatest_lib/external.py16
42 files changed, 924 insertions, 924 deletions
diff --git a/library/cpp/actors/interconnect/interconnect_stream.cpp b/library/cpp/actors/interconnect/interconnect_stream.cpp
index c6b53562a0..158ebc9e1d 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 117f3a59fb..3fff684adb 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 653cc5280a..ab0a0627be 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;
+ initialMetadata = InitialMetadata;
+ InitialMetadata = nullptr;
+ HasInitialMetadata = true;
+ }
+
+ if (initialMetadata) {
+ GetInitialMetadata(initialMetadata);
}
- 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;
+ initialMetadata = InitialMetadata;
+ InitialMetadata = nullptr;
+ HasInitialMetadata = true;
+ }
+
+ if (initialMetadata) {
+ GetInitialMetadata(initialMetadata);
}
- 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 3d66197c85..2eb90761fe 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 fce55de9b5..8be984ccc8 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 5b4eba8234..42cc5fc1ef 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 2f0b71531f..bcd6a7a9d6 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 a1a5eb3435..9d133d4bdd 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 43240c1640..df3cc4c2fa 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 3aa820a569..4110e06f00 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 f6049ebd02..c2a26ce431 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 7aeec7594c..0f8c0aed01 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 d241bfbe1f..60f561c337 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 7c6f550d14..045cdc3566 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 dccd22fbf9..731baa9055 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 1e186d0865..b735d8a042 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 ca5caecb62..3a2fbf3ba5 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 b136e1f032..ae68ef08ea 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 191e5422f7..0b4be38c0e 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 bafa974b8a..d184b6456c 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 ffe1da62f3..f1d3df978d 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 ec6f6c6396..bff2b23d31 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 953c790707..3645ad17e6 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 1fb716104f..c8f6f18b6b 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 67c5404d59..7c10963e26 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 10d8e51477..7b89aa1bed 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 4009371781..44517a0092 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 52309d68af..2a5300d886 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 5982754dd7..305bc6b40f 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;
diff --git a/library/python/pytest/main.py b/library/python/pytest/main.py
index 355623ff0e..6296bd6f0f 100644
--- a/library/python/pytest/main.py
+++ b/library/python/pytest/main.py
@@ -2,10 +2,10 @@ import os
import sys
import time
-import __res
+import __res
FORCE_EXIT_TESTSFAILED_ENV = 'FORCE_EXIT_TESTSFAILED'
-
+
def main():
import library.python.pytest.context as context
@@ -39,12 +39,12 @@ def main():
import library.python.pytest.plugins.ya as ya
import library.python.pytest.plugins.conftests as conftests
- import _pytest.assertion
- from _pytest.monkeypatch import MonkeyPatch
+ import _pytest.assertion
+ from _pytest.monkeypatch import MonkeyPatch
from . import rewrite
- m = MonkeyPatch()
- m.setattr(_pytest.assertion.rewrite, "AssertionRewritingHook", rewrite.AssertionRewritingHook)
-
+ m = MonkeyPatch()
+ m.setattr(_pytest.assertion.rewrite, "AssertionRewritingHook", rewrite.AssertionRewritingHook)
+
prefix = '__tests__.'
test_modules = [
@@ -56,18 +56,18 @@ def main():
if isinstance(doctest_packages, bytes):
doctest_packages = doctest_packages.decode('utf-8')
doctest_packages = doctest_packages.split()
-
- def is_doctest_module(name):
- for package in doctest_packages:
+
+ def is_doctest_module(name):
+ for package in doctest_packages:
if name == package or name.startswith(str(package) + "."):
- return True
- return False
-
- doctest_modules = [
- name for name in sys.extra_modules
- if is_doctest_module(name)
- ]
-
+ return True
+ return False
+
+ doctest_modules = [
+ name for name in sys.extra_modules
+ if is_doctest_module(name)
+ ]
+
def remove_user_site(paths):
site_paths = ('site-packages', 'site-python')
@@ -86,7 +86,7 @@ def main():
sys.path = remove_user_site(sys.path)
rc = pytest.main(plugins=[
- collection.CollectionPlugin(test_modules, doctest_modules),
+ collection.CollectionPlugin(test_modules, doctest_modules),
ya,
conftests,
])
diff --git a/library/python/pytest/plugins/collection.py b/library/python/pytest/plugins/collection.py
index dad830e473..e36f47a78f 100644
--- a/library/python/pytest/plugins/collection.py
+++ b/library/python/pytest/plugins/collection.py
@@ -18,14 +18,14 @@ class LoadedModule(_pytest.python.Module):
self.parent = parent
self.config = parent.config
self.keywords = {}
- self.own_markers = []
+ self.own_markers = []
self.fspath = py.path.local()
@classmethod
def from_parent(cls, **kwargs):
namespace = kwargs.pop('namespace', True)
kwargs.setdefault('fspath', py.path.local())
-
+
loaded_module = getattr(super(LoadedModule, cls), 'from_parent', cls)(**kwargs)
loaded_module.namespace = namespace
@@ -44,7 +44,7 @@ class LoadedModule(_pytest.python.Module):
def _getobj(self):
module_name = self.name[:-len('.py')]
- if self.namespace:
+ if self.namespace:
module_name = '__tests__.' + module_name
__import__(module_name)
return sys.modules[module_name]
@@ -54,13 +54,13 @@ class DoctestModule(LoadedModule):
def collect(self):
import doctest
-
- module = self._getobj()
- # uses internal doctest module parsing mechanism
+
+ module = self._getobj()
+ # uses internal doctest module parsing mechanism
finder = doctest.DocTestFinder()
optionflags = _pytest.doctest.get_optionflags(self)
runner = doctest.DebugRunner(verbose=0, optionflags=optionflags)
-
+
try:
for test in finder.find(module, self.name[:-len('.py')]):
if test.examples: # skip empty doctests
@@ -94,9 +94,9 @@ def pytest_ignore_collect(module, session, filenames_from_full_filters, accept_f
class CollectionPlugin(object):
- def __init__(self, test_modules, doctest_modules):
+ def __init__(self, test_modules, doctest_modules):
self._test_modules = test_modules
- self._doctest_modules = doctest_modules
+ self._doctest_modules = doctest_modules
def pytest_sessionstart(self, session):
@@ -124,5 +124,5 @@ class CollectionPlugin(object):
if os.environ.get('YA_PYTEST_DISABLE_DOCTEST', 'no') == 'no':
for doctest_module in self._doctest_modules:
yield DoctestModule.from_parent(name=doctest_module, parent=session, namespace=False)
-
+
session.collect = collect
diff --git a/library/python/pytest/plugins/conftests.py b/library/python/pytest/plugins/conftests.py
index 96456da28c..522041f5a7 100644
--- a/library/python/pytest/plugins/conftests.py
+++ b/library/python/pytest/plugins/conftests.py
@@ -23,23 +23,23 @@ conftest_modules = []
@hookimpl(trylast=True)
def pytest_load_initial_conftests(early_config, parser, args):
- conftests = filter(lambda name: name.endswith(".conftest"), sys.extra_modules)
+ conftests = filter(lambda name: name.endswith(".conftest"), sys.extra_modules)
- def conftest_key(name):
- if not name.startswith("__tests__."):
- # Make __tests__ come last
- return "_." + name
- return name
+ def conftest_key(name):
+ if not name.startswith("__tests__."):
+ # Make __tests__ come last
+ return "_." + name
+ return name
- for name in sorted(conftests, key=conftest_key):
- mod = importlib.import_module(name)
+ for name in sorted(conftests, key=conftest_key):
+ mod = importlib.import_module(name)
if os.getenv("CONFTEST_LOAD_POLICY") != "LOCAL":
mod.__orig_file__ = mod.__file__
mod.__file__ = ""
- conftest_modules.append(mod)
+ conftest_modules.append(mod)
early_config.pluginmanager.consider_conftest(mod)
-
-
+
+
def getconftestmodules(*args, **kwargs):
return conftest_modules
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py
index 0dfbb7c274..1bde03042d 100644
--- a/library/python/pytest/plugins/ya.py
+++ b/library/python/pytest/plugins/ya.py
@@ -185,7 +185,7 @@ def pytest_configure(config):
global pytest_config
pytest_config = config
- config.option.continue_on_collection_errors = True
+ config.option.continue_on_collection_errors = True
config.addinivalue_line("markers", "ya:external")
@@ -523,9 +523,9 @@ def pytest_collectreport(report):
sys.stderr.write(yatest_lib.tools.to_utf8(report.longrepr))
-@pytest.mark.tryfirst
-def pytest_pyfunc_call(pyfuncitem):
- testfunction = pyfuncitem.obj
+@pytest.mark.tryfirst
+def pytest_pyfunc_call(pyfuncitem):
+ testfunction = pyfuncitem.obj
iscoroutinefunction = getattr(inspect, "iscoroutinefunction", None)
if iscoroutinefunction is not None and iscoroutinefunction(testfunction):
msg = "Coroutine functions are not natively supported and have been skipped.\n"
@@ -538,9 +538,9 @@ def pytest_pyfunc_call(pyfuncitem):
funcargs = pyfuncitem.funcargs
testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames}
pyfuncitem.retval = testfunction(**testargs)
- return True
-
-
+ return True
+
+
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
def logreport(report, result, call):
@@ -575,8 +575,8 @@ def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result()
result = None
- if hasattr(item, 'retval') and item.retval is not None:
- result = item.retval
+ if hasattr(item, 'retval') and item.retval is not None:
+ result = item.retval
if not pytest_config.from_ya_test:
ti = TestItem(rep, result, pytest_config.option.test_suffix)
tr = pytest_config.pluginmanager.getplugin('terminalreporter')
@@ -584,13 +584,13 @@ def pytest_runtest_makereport(item, call):
logreport(rep, result, call)
-def pytest_make_parametrize_id(config, val, argname):
- # Avoid <, > symbols in canondata file names
- if inspect.isfunction(val) and val.__name__ == "<lambda>":
- return str(argname)
- return None
-
-
+def pytest_make_parametrize_id(config, val, argname):
+ # Avoid <, > symbols in canondata file names
+ if inspect.isfunction(val) and val.__name__ == "<lambda>":
+ return str(argname)
+ return None
+
+
def get_formatted_error(report):
if isinstance(report.longrepr, tuple):
text = ""
@@ -692,7 +692,7 @@ class TestItem(object):
return self._error
def set_error(self, entry, marker='bad'):
- if isinstance(entry, _pytest.reports.BaseReport):
+ if isinstance(entry, _pytest.reports.BaseReport):
self._error = get_formatted_error(entry)
else:
self._error = "[[{}]]{}".format(yatest_lib.tools.to_str(marker), yatest_lib.tools.to_str(entry))
@@ -827,9 +827,9 @@ class TraceReportGenerator(object):
self.trace('subtest-started', message)
def on_finish_test_case(self, test_item, duration_only=False):
- if test_item.result is not None:
+ if test_item.result is not None:
try:
- result = canon.serialize(test_item.result)
+ result = canon.serialize(test_item.result)
except Exception as e:
yatest_logger.exception("Error while serializing test results")
test_item.set_error("Invalid test result: {}".format(e))
diff --git a/library/python/pytest/pytest.yatest.ini b/library/python/pytest/pytest.yatest.ini
index b755a300f9..70d6c98516 100644
--- a/library/python/pytest/pytest.yatest.ini
+++ b/library/python/pytest/pytest.yatest.ini
@@ -2,6 +2,6 @@
pep8maxlinelength = 200
norecursedirs = *
pep8ignore = E127 E123 E226 E24
-filterwarnings =
- ignore::pytest.RemovedInPytest4Warning
-addopts = -p no:warnings
+filterwarnings =
+ ignore::pytest.RemovedInPytest4Warning
+addopts = -p no:warnings
diff --git a/library/python/pytest/rewrite.py b/library/python/pytest/rewrite.py
index e14bd3279b..4cebcb1edd 100644
--- a/library/python/pytest/rewrite.py
+++ b/library/python/pytest/rewrite.py
@@ -1,11 +1,11 @@
-from __future__ import absolute_import
-from __future__ import print_function
-
-import ast
-
+from __future__ import absolute_import
+from __future__ import print_function
+
+import ast
+
import py
-from _pytest.assertion import rewrite
+from _pytest.assertion import rewrite
try:
import importlib.util
except ImportError:
@@ -16,23 +16,23 @@ try:
except ImportError:
pass
-from __res import importer
+from __res import importer
import sys
import six
-
-
+
+
def _get_state(config):
if hasattr(config, '_assertstate'):
return config._assertstate
return config._store[rewrite.assertstate_key]
-class AssertionRewritingHook(rewrite.AssertionRewritingHook):
+class AssertionRewritingHook(rewrite.AssertionRewritingHook):
def __init__(self, *args, **kwargs):
self.modules = {}
super(AssertionRewritingHook, self).__init__(*args, **kwargs)
-
- def find_module(self, name, path=None):
+
+ def find_module(self, name, path=None):
co = self._find_module(name, path)
if co is not None:
return self
@@ -40,28 +40,28 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook):
def _find_module(self, name, path=None):
state = _get_state(self.config)
if not self._should_rewrite(name, None, state):
- return None
- state.trace("find_module called for: %s" % name)
-
- try:
- if self.is_package(name):
- return None
- except ImportError:
- return None
-
+ return None
+ state.trace("find_module called for: %s" % name)
+
+ try:
+ if self.is_package(name):
+ return None
+ except ImportError:
+ return None
+
if hasattr(self._rewritten_names, 'add'):
self._rewritten_names.add(name)
else:
self._rewritten_names[name] = Path(path[0])
-
- state.trace("rewriting %s" % name)
- co = _rewrite_test(self.config, name)
- if co is None:
- # Probably a SyntaxError in the test.
- return None
- self.modules[name] = co, None
+
+ state.trace("rewriting %s" % name)
+ co = _rewrite_test(self.config, name)
+ if co is None:
+ # Probably a SyntaxError in the test.
+ return None
+ self.modules[name] = co, None
return co
-
+
def find_spec(self, name, path=None, target=None):
co = self._find_module(name, path)
if co is not None:
@@ -72,17 +72,17 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook):
)
def _should_rewrite(self, name, fn, state):
- if name.startswith("__tests__.") or name.endswith(".conftest"):
- return True
-
- return self._is_marked_for_rewrite(name, state)
-
- def is_package(self, name):
- return importer.is_package(name)
-
- def get_source(self, name):
- return importer.get_source(name)
-
+ if name.startswith("__tests__.") or name.endswith(".conftest"):
+ return True
+
+ return self._is_marked_for_rewrite(name, state)
+
+ def is_package(self, name):
+ return importer.is_package(name)
+
+ def get_source(self, name):
+ return importer.get_source(name)
+
if six.PY3:
def load_module(self, module):
co, _ = self.modules.pop(module.__name__)
@@ -97,7 +97,7 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook):
del sys.modules[module.__name__]
raise
return sys.modules[module.__name__]
-
+
def exec_module(self, module):
if module.__name__ in self.modules:
self.load_module(module)
@@ -105,28 +105,28 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook):
super(AssertionRewritingHook, self).exec_module(module)
-def _rewrite_test(config, name):
- """Try to read and rewrite *fn* and return the code object."""
+def _rewrite_test(config, name):
+ """Try to read and rewrite *fn* and return the code object."""
state = _get_state(config)
-
- source = importer.get_source(name)
- if source is None:
- return None
-
- path = importer.get_filename(name)
-
- try:
- tree = ast.parse(source, filename=path)
- except SyntaxError:
- # Let this pop up again in the real import.
- state.trace("failed to parse: %r" % (path,))
- return None
+
+ source = importer.get_source(name)
+ if source is None:
+ return None
+
+ path = importer.get_filename(name)
+
+ try:
+ tree = ast.parse(source, filename=path)
+ except SyntaxError:
+ # Let this pop up again in the real import.
+ state.trace("failed to parse: %r" % (path,))
+ return None
rewrite.rewrite_asserts(tree, py.path.local(path), config)
- try:
- co = compile(tree, path, "exec", dont_inherit=True)
- except SyntaxError:
- # It's possible that this error is from some bug in the
- # assertion rewriting, but I don't know of a fast way to tell.
- state.trace("failed to compile: %r" % (path,))
- return None
- return co
+ try:
+ co = compile(tree, path, "exec", dont_inherit=True)
+ except SyntaxError:
+ # It's possible that this error is from some bug in the
+ # assertion rewriting, but I don't know of a fast way to tell.
+ state.trace("failed to compile: %r" % (path,))
+ return None
+ return co
diff --git a/library/python/pytest/ya.make b/library/python/pytest/ya.make
index 84c0954311..060c92c313 100644
--- a/library/python/pytest/ya.make
+++ b/library/python/pytest/ya.make
@@ -8,7 +8,7 @@ OWNER(
PY_SRCS(
__init__.py
main.py
- rewrite.py
+ rewrite.py
yatest_tools.py
context.py
)
diff --git a/library/python/pytest/yatest_tools.py b/library/python/pytest/yatest_tools.py
index 473bfeaadd..6b8b896394 100644
--- a/library/python/pytest/yatest_tools.py
+++ b/library/python/pytest/yatest_tools.py
@@ -284,10 +284,10 @@ def get_test_log_file_path(output_dir, class_name, test_name, extension="log"):
def split_node_id(nodeid, test_suffix=None):
- path, possible_open_bracket, params = nodeid.partition('[')
+ path, possible_open_bracket, params = nodeid.partition('[')
separator = "::"
- if separator in path:
- path, test_name = path.split(separator, 1)
+ if separator in path:
+ path, test_name = path.split(separator, 1)
else:
test_name = os.path.basename(path)
if test_suffix:
@@ -300,5 +300,5 @@ def split_node_id(nodeid, test_suffix=None):
class_name += separator + klass_name
if separator in test_name:
test_name = test_name.split(separator)[-1]
- test_name += possible_open_bracket + params
+ test_name += possible_open_bracket + params
return yatest_lib.tools.to_utf8(class_name), yatest_lib.tools.to_utf8(test_name)
diff --git a/library/python/runtime_py3/importer.pxi b/library/python/runtime_py3/importer.pxi
index 720153abf6..904f94dea2 100644
--- a/library/python/runtime_py3/importer.pxi
+++ b/library/python/runtime_py3/importer.pxi
@@ -1,7 +1,7 @@
import marshal
import sys
from _codecs import utf_8_decode, utf_8_encode
-from _frozen_importlib import _call_with_frames_removed, spec_from_loader, BuiltinImporter
+from _frozen_importlib import _call_with_frames_removed, spec_from_loader, BuiltinImporter
from _frozen_importlib_external import _os, _path_isfile, _path_isdir, _path_isabs, path_sep, _path_join, _path_split
from _io import FileIO
@@ -186,7 +186,7 @@ class ResourceImporter(object):
else:
self.arcadia_source_finder = None
- for p in list(self.memory) + list(sys.builtin_module_names):
+ for p in list(self.memory) + list(sys.builtin_module_names):
for pp in iter_prefixes(p):
k = pp + '.__init__'
if k not in self.memory:
@@ -207,27 +207,27 @@ class ResourceImporter(object):
def find_spec(self, fullname, path=None, target=None):
try:
- is_package = self.is_package(fullname)
+ is_package = self.is_package(fullname)
except ImportError:
return None
- return spec_from_loader(fullname, self, is_package=is_package)
-
- def find_module(self, fullname, path=None):
- """For backward compatibility."""
- spec = self.find_spec(fullname, path)
- return spec.loader if spec is not None else None
-
- def create_module(self, spec):
- """Use default semantics for module creation."""
-
- def exec_module(self, module):
- code = self.get_code(module.__name__)
+ return spec_from_loader(fullname, self, is_package=is_package)
+
+ def find_module(self, fullname, path=None):
+ """For backward compatibility."""
+ spec = self.find_spec(fullname, path)
+ return spec.loader if spec is not None else None
+
+ def create_module(self, spec):
+ """Use default semantics for module creation."""
+
+ def exec_module(self, module):
+ code = self.get_code(module.__name__)
module.__file__ = code.co_filename
if self.is_package(module.__name__):
module.__path__= [executable + path_sep + module.__name__.replace('.', path_sep)]
# exec(code, module.__dict__)
- _call_with_frames_removed(exec, code, module.__dict__)
-
+ _call_with_frames_removed(exec, code, module.__dict__)
+
# PEP-302 extension 1 of 3: data loader.
def get_data(self, path):
path = _b(path)
@@ -263,7 +263,7 @@ class ResourceImporter(object):
abspath = resfs_resolve(relpath)
if abspath:
return _s(file_bytes(abspath))
- data = resfs_read(mod_path(fullname))
+ data = resfs_read(mod_path(fullname))
return _s(data) if data else ''
def get_code(self, fullname):
@@ -281,8 +281,8 @@ class ResourceImporter(object):
yapyc_path = path + b'.yapyc3'
yapyc_data = resfs_read(yapyc_path, builtin=True)
- if yapyc_data:
- return marshal.loads(yapyc_data)
+ if yapyc_data:
+ return marshal.loads(yapyc_data)
else:
py_data = resfs_read(path, builtin=True)
if py_data:
@@ -385,14 +385,14 @@ class _ResfsResourceReader:
yield _s(res_or_subdir)
-class BuiltinSubmoduleImporter(BuiltinImporter):
- @classmethod
- def find_spec(cls, fullname, path=None, target=None):
- if path is not None:
- return super().find_spec(fullname, None, target)
- else:
- return None
-
+class BuiltinSubmoduleImporter(BuiltinImporter):
+ @classmethod
+ def find_spec(cls, fullname, path=None, target=None):
+ if path is not None:
+ return super().find_spec(fullname, None, target)
+ else:
+ return None
+
class ArcadiaSourceFinder:
"""
diff --git a/library/python/runtime_py3/main/main.c b/library/python/runtime_py3/main/main.c
index 75af2f8cde..3159800615 100644
--- a/library/python/runtime_py3/main/main.c
+++ b/library/python/runtime_py3/main/main.c
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <string.h>
-#include <locale.h>
+#include <locale.h>
void Py_InitArgcArgv(int argc, wchar_t **argv);
char* GetPyMain();
@@ -24,77 +24,77 @@ void unsetenv(const char* name) {
}
#endif
-static int RunModule(const char *modname)
-{
- PyObject *module, *runpy, *runmodule, *runargs, *result;
- runpy = PyImport_ImportModule("runpy");
- if (runpy == NULL) {
- fprintf(stderr, "Could not import runpy module\n");
- PyErr_Print();
- return -1;
- }
- runmodule = PyObject_GetAttrString(runpy, "_run_module_as_main");
- if (runmodule == NULL) {
- fprintf(stderr, "Could not access runpy._run_module_as_main\n");
- PyErr_Print();
- Py_DECREF(runpy);
- return -1;
- }
- module = PyUnicode_FromString(modname);
- if (module == NULL) {
- fprintf(stderr, "Could not convert module name to unicode\n");
- PyErr_Print();
- Py_DECREF(runpy);
- Py_DECREF(runmodule);
- return -1;
- }
- runargs = Py_BuildValue("(Oi)", module, 0);
- if (runargs == NULL) {
- fprintf(stderr,
- "Could not create arguments for runpy._run_module_as_main\n");
- PyErr_Print();
- Py_DECREF(runpy);
- Py_DECREF(runmodule);
- Py_DECREF(module);
- return -1;
- }
- result = PyObject_Call(runmodule, runargs, NULL);
- if (result == NULL) {
- PyErr_Print();
- }
- Py_DECREF(runpy);
- Py_DECREF(runmodule);
- Py_DECREF(module);
- Py_DECREF(runargs);
- if (result == NULL) {
- return -1;
- }
- Py_DECREF(result);
- return 0;
-}
-
+static int RunModule(const char *modname)
+{
+ PyObject *module, *runpy, *runmodule, *runargs, *result;
+ runpy = PyImport_ImportModule("runpy");
+ if (runpy == NULL) {
+ fprintf(stderr, "Could not import runpy module\n");
+ PyErr_Print();
+ return -1;
+ }
+ runmodule = PyObject_GetAttrString(runpy, "_run_module_as_main");
+ if (runmodule == NULL) {
+ fprintf(stderr, "Could not access runpy._run_module_as_main\n");
+ PyErr_Print();
+ Py_DECREF(runpy);
+ return -1;
+ }
+ module = PyUnicode_FromString(modname);
+ if (module == NULL) {
+ fprintf(stderr, "Could not convert module name to unicode\n");
+ PyErr_Print();
+ Py_DECREF(runpy);
+ Py_DECREF(runmodule);
+ return -1;
+ }
+ runargs = Py_BuildValue("(Oi)", module, 0);
+ if (runargs == NULL) {
+ fprintf(stderr,
+ "Could not create arguments for runpy._run_module_as_main\n");
+ PyErr_Print();
+ Py_DECREF(runpy);
+ Py_DECREF(runmodule);
+ Py_DECREF(module);
+ return -1;
+ }
+ result = PyObject_Call(runmodule, runargs, NULL);
+ if (result == NULL) {
+ PyErr_Print();
+ }
+ Py_DECREF(runpy);
+ Py_DECREF(runmodule);
+ Py_DECREF(module);
+ Py_DECREF(runargs);
+ if (result == NULL) {
+ return -1;
+ }
+ Py_DECREF(result);
+ return 0;
+}
+
static int pymain(int argc, char** argv) {
PyStatus status = _PyRuntime_Initialize();
if (PyStatus_Exception(status)) {
Py_ExitStatusException(status);
}
- int i, sts = 1;
+ int i, sts = 1;
char* oldloc = NULL;
wchar_t** argv_copy = NULL;
- /* We need a second copies, as Python might modify the first one. */
+ /* We need a second copies, as Python might modify the first one. */
wchar_t** argv_copy2 = NULL;
- char* entry_point_copy = NULL;
-
- if (argc > 0) {
- argv_copy = PyMem_RawMalloc(sizeof(wchar_t*) * argc);
- argv_copy2 = PyMem_RawMalloc(sizeof(wchar_t*) * argc);
- if (!argv_copy || !argv_copy2) {
- fprintf(stderr, "out of memory\n");
- goto error;
- }
- }
-
+ char* entry_point_copy = NULL;
+
+ if (argc > 0) {
+ argv_copy = PyMem_RawMalloc(sizeof(wchar_t*) * argc);
+ argv_copy2 = PyMem_RawMalloc(sizeof(wchar_t*) * argc);
+ if (!argv_copy || !argv_copy2) {
+ fprintf(stderr, "out of memory\n");
+ goto error;
+ }
+ }
+
PyConfig config;
PyConfig_InitPythonConfig(&config);
config.pathconfig_warnings = 0; /* Suppress errors from getpath.c */
@@ -104,27 +104,27 @@ static int pymain(int argc, char** argv) {
config.bytes_warning = atoi(bytes_warning);
}
- oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
- if (!oldloc) {
- fprintf(stderr, "out of memory\n");
- goto error;
- }
-
- setlocale(LC_ALL, "");
- for (i = 0; i < argc; i++) {
- argv_copy[i] = Py_DecodeLocale(argv[i], NULL);
- argv_copy2[i] = argv_copy[i];
- if (!argv_copy[i]) {
- fprintf(stderr, "Unable to decode the command line argument #%i\n",
+ oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
+ if (!oldloc) {
+ fprintf(stderr, "out of memory\n");
+ goto error;
+ }
+
+ setlocale(LC_ALL, "");
+ for (i = 0; i < argc; i++) {
+ argv_copy[i] = Py_DecodeLocale(argv[i], NULL);
+ argv_copy2[i] = argv_copy[i];
+ if (!argv_copy[i]) {
+ fprintf(stderr, "Unable to decode the command line argument #%i\n",
i + 1);
- argc = i;
- goto error;
- }
- }
- setlocale(LC_ALL, oldloc);
- PyMem_RawFree(oldloc);
- oldloc = NULL;
-
+ argc = i;
+ goto error;
+ }
+ }
+ setlocale(LC_ALL, oldloc);
+ PyMem_RawFree(oldloc);
+ oldloc = NULL;
+
if (argc >= 1)
Py_SetProgramName(argv_copy[0]);
@@ -156,10 +156,10 @@ static int pymain(int argc, char** argv) {
free(entry_point_copy);
return sts;
}
-
+
Py_InitArgcArgv(argc, argv_copy);
- PySys_SetArgv(argc, argv_copy);
-
+ PySys_SetArgv(argc, argv_copy);
+
{
PyObject* module = PyImport_ImportModule("library.python.runtime_py3.entry_points");
if (module == NULL) {
@@ -175,53 +175,53 @@ static int pymain(int argc, char** argv) {
}
}
- const char* module_name = entry_point_copy;
- const char* func_name = NULL;
-
- char *colon = strchr(entry_point_copy, ':');
- if (colon != NULL) {
- colon[0] = '\0';
- func_name = colon + 1;
- }
+ const char* module_name = entry_point_copy;
+ const char* func_name = NULL;
+
+ char *colon = strchr(entry_point_copy, ':');
+ if (colon != NULL) {
+ colon[0] = '\0';
+ func_name = colon + 1;
+ }
if (module_name[0] == '\0') {
module_name = "library.python.runtime_py3.entry_points";
}
-
- if (!func_name) {
- sts = RunModule(module_name);
- } else {
- PyObject* module = PyImport_ImportModule(module_name);
-
- if (module == NULL) {
- PyErr_Print();
- } else {
+
+ if (!func_name) {
+ sts = RunModule(module_name);
+ } else {
+ PyObject* module = PyImport_ImportModule(module_name);
+
+ if (module == NULL) {
+ PyErr_Print();
+ } else {
PyObject* value = PyObject_CallMethod(module, func_name, NULL);
-
- if (value == NULL) {
- PyErr_Print();
- } else {
- Py_DECREF(value);
- sts = 0;
- }
-
- Py_DECREF(module);
- }
- }
-
- if (Py_FinalizeEx() < 0) {
- sts = 120;
- }
-
-error:
- free(entry_point_copy);
- PyMem_RawFree(argv_copy);
- if (argv_copy2) {
- for (i = 0; i < argc; i++)
- PyMem_RawFree(argv_copy2[i]);
- PyMem_RawFree(argv_copy2);
- }
- PyMem_RawFree(oldloc);
- return sts;
+
+ if (value == NULL) {
+ PyErr_Print();
+ } else {
+ Py_DECREF(value);
+ sts = 0;
+ }
+
+ Py_DECREF(module);
+ }
+ }
+
+ if (Py_FinalizeEx() < 0) {
+ sts = 120;
+ }
+
+error:
+ free(entry_point_copy);
+ PyMem_RawFree(argv_copy);
+ if (argv_copy2) {
+ for (i = 0; i < argc; i++)
+ PyMem_RawFree(argv_copy2[i]);
+ PyMem_RawFree(argv_copy2);
+ }
+ PyMem_RawFree(oldloc);
+ return sts;
}
int (*mainptr)(int argc, char** argv) = pymain;
diff --git a/library/python/runtime_py3/ya.make b/library/python/runtime_py3/ya.make
index 0990770ab3..fa5c11341a 100644
--- a/library/python/runtime_py3/ya.make
+++ b/library/python/runtime_py3/ya.make
@@ -22,12 +22,12 @@ ENABLE(PYBUILD_NO_PYC)
PY_SRCS(
entry_points.py
- TOP_LEVEL
+ TOP_LEVEL
CYTHON_DIRECTIVE
language_level=3
- __res.pyx
+ __res.pyx
sitecustomize.pyx
)
diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py
index d4618d59fb..a8bcc21f51 100644
--- a/library/python/testing/yatest_common/yatest/common/process.py
+++ b/library/python/testing/yatest_common/yatest/common/process.py
@@ -9,7 +9,7 @@ import logging
import tempfile
import subprocess
import errno
-import distutils.version
+import distutils.version
import six
@@ -27,7 +27,7 @@ from . import environment
MAX_OUT_LEN = 1000 * 1000 # 1 mb
MAX_MESSAGE_LEN = 1500
SANITIZER_ERROR_PATTERN = br": ([A-Z][\w]+Sanitizer)"
-GLIBC_PATTERN = re.compile(r"\S+@GLIBC_([0-9.]+)")
+GLIBC_PATTERN = re.compile(r"\S+@GLIBC_([0-9.]+)")
yatest_logger = logging.getLogger("ya.test")
@@ -696,13 +696,13 @@ def _run_readelf(binary_path):
def check_glibc_version(binary_path):
- lucid_glibc_version = distutils.version.LooseVersion("2.11")
-
+ lucid_glibc_version = distutils.version.LooseVersion("2.11")
+
for l in _run_readelf(binary_path).split('\n'):
- match = GLIBC_PATTERN.search(l)
- if not match:
- continue
- assert distutils.version.LooseVersion(match.group(1)) <= lucid_glibc_version, match.group(0)
+ match = GLIBC_PATTERN.search(l)
+ if not match:
+ continue
+ assert distutils.version.LooseVersion(match.group(1)) <= lucid_glibc_version, match.group(0)
def backtrace_to_html(bt_filename, output):
diff --git a/library/python/testing/yatest_lib/external.py b/library/python/testing/yatest_lib/external.py
index 699ba4449c..39113230d9 100644
--- a/library/python/testing/yatest_lib/external.py
+++ b/library/python/testing/yatest_lib/external.py
@@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
MDS_URI_PREFIX = 'https://storage.yandex-team.ru/get-devtools/'
-def apply(func, value, apply_to_keys=False):
+def apply(func, value, apply_to_keys=False):
"""
Applies func to every possible member of value
:param value: could be either a primitive object or a complex one (list, dicts)
@@ -41,7 +41,7 @@ def apply(func, value, apply_to_keys=False):
for key, val in sorted(value.items(), key=lambda dict_item: dict_item[0]):
path = copy.copy(value_path)
path.append(key)
- res[_apply(func, key, path) if apply_to_keys else key] = _apply(func, val, path)
+ res[_apply(func, key, path) if apply_to_keys else key] = _apply(func, val, path)
else:
res = func(value, value_path)
return res
@@ -78,7 +78,7 @@ def serialize(value):
if is_coroutine(val):
return None
raise ValueError("Cannot serialize value '{}' of type {}".format(val, type(val)))
- return apply(_serialize, value, apply_to_keys=True)
+ return apply(_serialize, value, apply_to_keys=True)
def is_external(value):
@@ -89,7 +89,7 @@ class ExternalSchema(object):
File = "file"
SandboxResource = "sbr"
Delayed = "delayed"
- HTTP = "http"
+ HTTP = "http"
class CanonicalObject(dict):
@@ -131,10 +131,10 @@ class ExternalDataInfo(object):
return self.uri.startswith(ExternalSchema.Delayed)
@property
- def is_http(self):
- return self.uri.startswith(ExternalSchema.HTTP)
-
- @property
+ def is_http(self):
+ return self.uri.startswith(ExternalSchema.HTTP)
+
+ @property
def path(self):
if self.uri.count("://") != 1:
logger.error("Invalid external data uri: '%s'", self.uri)