Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Unified Diff: webrtc/base/sslidentity_unittest.cc

Issue 1800833002: Fixing flaky "TestExpireTime" test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/sslidentity_unittest.cc
diff --git a/webrtc/base/sslidentity_unittest.cc b/webrtc/base/sslidentity_unittest.cc
index 8e25fe97dfc1ca460d49adb9c009942d278e7674..e9e9f98711a34867ab0d98977cb15860d77a1578 100644
--- a/webrtc/base/sslidentity_unittest.cc
+++ b/webrtc/base/sslidentity_unittest.cc
@@ -392,12 +392,16 @@ class SSLIdentityExpirationTest : public testing::Test {
for (int i = 0; i < times; i++) {
// We limit the time to < 2^31 here, i.e., we stay before 2038, since else
// we hit time offset limitations in OpenSSL on some 32-bit systems.
- time_t now = time(NULL);
- time_t lifetime = rtc::CreateRandomId() % (0x80000000 - now);
+ time_t time_before_generation = time(nullptr);
+ time_t lifetime =
+ rtc::CreateRandomId() % (0x80000000 - time_before_generation);
rtc::KeyParams key_params = rtc::KeyParams::ECDSA(rtc::EC_NIST_P256);
SSLIdentity* identity =
rtc::SSLIdentity::Generate("", key_params, lifetime);
- EXPECT_EQ(now + lifetime,
+ time_t time_after_generation = time(nullptr);
+ EXPECT_LE(time_before_generation + lifetime,
+ identity->certificate().CertificateExpirationTime());
+ EXPECT_GE(time_after_generation + lifetime,
identity->certificate().CertificateExpirationTime());
delete identity;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698