Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Test duration values ​​are now presented in seconds with six digits of precision. Tests without time measurements have been edited. #4435

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/tests/test_aead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class AEAD_Tests final : public Text_Based_Test {
const bool is_siv = algo.find("/SIV") != std::string::npos;

Test::Result result(algo);
result.start_timer();

auto enc = Botan::AEAD_Mode::create(algo, Botan::Cipher_Dir::Encryption);

Expand Down Expand Up @@ -177,6 +178,7 @@ class AEAD_Tests final : public Text_Based_Test {
[&]() { enc->set_associated_data(ad.data(), ad.size()); });
}

result.end_timer();
return result;
}

Expand All @@ -190,6 +192,7 @@ class AEAD_Tests final : public Text_Based_Test {
const bool is_siv = algo.find("/SIV") != std::string::npos;

Test::Result result(algo);
result.start_timer();

auto dec = Botan::AEAD_Mode::create(algo, Botan::Cipher_Dir::Decryption);

Expand Down Expand Up @@ -381,6 +384,7 @@ class AEAD_Tests final : public Text_Based_Test {
[&]() { dec->set_associated_data(ad.data(), ad.size()); });
}

result.end_timer();
return result;
}

Expand All @@ -392,6 +396,7 @@ class AEAD_Tests final : public Text_Based_Test {
const std::vector<uint8_t> ad = vars.get_opt_bin("AD");

Test::Result result(algo);
result.start_timer();

auto enc = Botan::AEAD_Mode::create(algo, Botan::Cipher_Dir::Encryption);
auto dec = Botan::AEAD_Mode::create(algo, Botan::Cipher_Dir::Decryption);
Expand Down Expand Up @@ -433,6 +438,7 @@ class AEAD_Tests final : public Text_Based_Test {
// test dec
result.merge(test_dec(key, nonce, expected, input, ad, algo, this->rng()));

result.end_timer();
return result;
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/tests/test_alt_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class X509_Alt_Name_Tests final : public Test {
public:
std::vector<Test::Result> run() override {
Test::Result result("X509 AlternativeName tests");
result.start_timer();

const std::vector<std::string> uri_names = {
"https://example.com", "https://example.org", "https://sub.example.net"};
Expand Down Expand Up @@ -90,6 +91,7 @@ class X509_Alt_Name_Tests final : public Test {
result.test_eq("Expected number of DNs", recoded.directory_names().size(), 2);
result.test_eq("Expected number of Othernames", recoded.other_names().size(), 2);

result.end_timer();
return {result};
}
};
Expand Down
22 changes: 20 additions & 2 deletions src/tests/test_asn1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace {

Test::Result test_ber_stack_recursion() {
Test::Result result("BER stack recursion");
result.start_timer();

// OSS-Fuzz #813 GitHub #989

Expand All @@ -36,12 +37,13 @@ Test::Result test_ber_stack_recursion() {
} catch(Botan::Decoding_Error&) {}

result.test_success("No crash");

result.end_timer();
return result;
}

Test::Result test_ber_eoc_decoding_limits() {
Test::Result result("BER nested indefinite length");
result.start_timer();

// OSS-Fuzz #4353

Expand Down Expand Up @@ -71,12 +73,13 @@ Test::Result test_ber_eoc_decoding_limits() {
}

result.test_eq("EOC limited to prevent stack exhaustion", max_eoc_allowed, 16);

result.end_timer();
return result;
}

Test::Result test_asn1_utf8_ascii_parsing() {
Test::Result result("ASN.1 ASCII parsing");
result.start_timer();

try {
// \x13 - ASN1 tag for 'printable string'
Expand All @@ -95,11 +98,13 @@ Test::Result test_asn1_utf8_ascii_parsing() {
result.test_failure(ex.what());
}

result.end_timer();
return result;
}

Test::Result test_asn1_utf8_parsing() {
Test::Result result("ASN.1 UTF-8 parsing");
result.start_timer();

try {
// \x0C - ASN1 tag for 'UTF8 string'
Expand All @@ -118,11 +123,13 @@ Test::Result test_asn1_utf8_parsing() {
result.test_failure(ex.what());
}

result.end_timer();
return result;
}

Test::Result test_asn1_ucs2_parsing() {
Test::Result result("ASN.1 BMP string (UCS-2) parsing");
result.start_timer();

try {
// \x1E - ASN1 tag for 'BMP (UCS-2) string'
Expand All @@ -142,11 +149,13 @@ Test::Result test_asn1_ucs2_parsing() {
result.test_failure(ex.what());
}

result.end_timer();
return result;
}

Test::Result test_asn1_ucs4_parsing() {
Test::Result result("ASN.1 universal string (UCS-4) parsing");
result.start_timer();

try {
// \x1C - ASN1 tag for 'universal string'
Expand All @@ -166,11 +175,13 @@ Test::Result test_asn1_ucs4_parsing() {
result.test_failure(ex.what());
}

result.end_timer();
return result;
}

Test::Result test_asn1_ascii_encoding() {
Test::Result result("ASN.1 ASCII encoding");
result.start_timer();

try {
// UTF-8 encoded (ASCII chars only) word 'Moscow'
Expand All @@ -192,11 +203,13 @@ Test::Result test_asn1_ascii_encoding() {
result.test_failure(ex.what());
}

result.end_timer();
return result;
}

Test::Result test_asn1_utf8_encoding() {
Test::Result result("ASN.1 UTF-8 encoding");
result.start_timer();

try {
// UTF-8 encoded russian word for Moscow in cyrillic script
Expand All @@ -218,11 +231,13 @@ Test::Result test_asn1_utf8_encoding() {
result.test_failure(ex.what());
}

result.end_timer();
return result;
}

Test::Result test_asn1_tag_underlying_type() {
Test::Result result("ASN.1 class and type underlying type");
result.start_timer();

if constexpr(std::is_same_v<std::underlying_type_t<Botan::ASN1_Class>, std::underlying_type_t<Botan::ASN1_Type>>) {
if constexpr(!std::is_same_v<std::underlying_type_t<Botan::ASN1_Class>,
Expand All @@ -236,6 +251,7 @@ Test::Result test_asn1_tag_underlying_type() {
result.test_failure("ASN1_Class and ASN1_Type have different underlying types");
}

result.end_timer();
return result;
}

Expand Down Expand Up @@ -299,6 +315,7 @@ class ASN1_Printer_Tests final : public Test {
public:
std::vector<Test::Result> run() override {
Test::Result result("ASN1_Pretty_Printer");
result.start_timer();

Botan::ASN1_Pretty_Printer printer;

Expand All @@ -317,6 +334,7 @@ class ASN1_Printer_Tests final : public Test {
}
}

result.end_timer();
return {result};
}
};
Expand Down
Loading
Loading