From 666031026ca8e85a87b90922e4af1b8b633b3aac Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 24 Jun 2015 17:49:06 -0700 Subject: [PATCH] Make MaxSessionsOpenCloseAPI10 More Lenient Merge from widevine repo of http://go/wvgerrit/14870 OEMCrypto_GetMaxNumberOfSessions is not required to return a hard limit for the number of sessions. This CL adjusts the test to verify we can open within 5% of the maximum number of sessions. bug: 22029687 Change-Id: I6e72e39338cead8d547cdb194a32fb7e7dc53037 --- libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 08864ef1..6049fdd8 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -1661,7 +1661,10 @@ TEST_F(OEMCryptoClientTest, MaxSessionsOpenCloseAPI10) { // We expect OEMCrypto implementations support at least 8 sessions. const size_t kMinimumSupportedMaxNumberOfSessions = 8u; ASSERT_GE(max_sessions, kMinimumSupportedMaxNumberOfSessions); - + // We allow GetMaxNumberOfSessions to return an estimate. This tests with a + // pad of 5%. Even if it's just an estimate, we still require 8 sessions. + size_t max_sessions_with_pad = max(max_sessions * 19/20, + kMinimumSupportedMaxNumberOfSessions); vector sessions; // Limit the number of sessions for testing. const size_t kMaxNumberOfSessionsForTesting = 0x100u; @@ -1675,7 +1678,7 @@ TEST_F(OEMCryptoClientTest, MaxSessionsOpenCloseAPI10) { // OEMCrypto_ERROR_TOO_MANY_SESSIONS if too many sessions are open. if (sts != OEMCrypto_SUCCESS) { ASSERT_EQ(OEMCrypto_ERROR_TOO_MANY_SESSIONS, sts); - ASSERT_GE(i, max_sessions); + ASSERT_GE(i, max_sessions_with_pad); break; } ASSERT_EQ(OEMCrypto_SUCCESS,