Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
torben-hansen committed Dec 4, 2024
1 parent d38fd4d commit 71843c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 6 additions & 7 deletions crypto/fipsmodule/rand/new_rand_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ class newRandTest : public ::testing::Test {
public:
void SetUp() override {
uint64_t current_generation_number = 0;
ube_detection_supported_ = CRYPTO_get_ube_generation_number(
&current_generation_number);
if (CRYPTO_get_ube_generation_number(&current_generation_number) == 1) {
ube_detection_supported_ = true;
}
}

void TearDown() override {
Expand All @@ -34,10 +35,8 @@ class newRandTest : public ::testing::Test {
return ube_detection_supported_;
}

void allowMockedUbeIfNecessary(void) {
if (ube_detection_supported_) {
allow_mocked_ube_detection_FOR_TESTING();
}
void allowMockedUbe(void) {
allow_mocked_ube_detection_FOR_TESTING();
}

bool ube_detection_supported_ = false;
Expand Down Expand Up @@ -191,7 +190,7 @@ static void MockedUbeDetection(std::function<void(uint64_t)> set_detection_metho

TEST_F(newRandTest, UbeDetectionMocked) {

allowMockedUbeIfNecessary();
allowMockedUbe();

MockedUbeDetection(
[](uint64_t gn) {
Expand Down
13 changes: 6 additions & 7 deletions crypto/ube/ube_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class ubeTest : public ::testing::Test {
public:
void SetUp() override {
uint64_t current_generation_number = 0;
ube_detection_supported_ = CRYPTO_get_ube_generation_number(
&current_generation_number);
if (CRYPTO_get_ube_generation_number(&current_generation_number) == 1) {
ube_detection_supported_ = true;
}
}

void TearDown() override {
Expand All @@ -23,10 +24,8 @@ class ubeTest : public ::testing::Test {
return ube_detection_supported_;
}

void allowMockedUbeIfNecessary(void) {
if (ube_detection_supported_) {
allow_mocked_ube_detection_FOR_TESTING();
}
void allowMockedUbe(void) {
allow_mocked_ube_detection_FOR_TESTING();
}

bool ube_detection_supported_ = false;
Expand Down Expand Up @@ -56,7 +55,7 @@ TEST_F(ubeTest, BasicTests) {

TEST_F(ubeTest, MockedMethodTests) {

allowMockedUbeIfNecessary();
allowMockedUbe();

uint64_t generation_number = 0;
uint64_t cached_generation_number = 0;
Expand Down

0 comments on commit 71843c9

Please sign in to comment.