Merge "Segfault When Running Jenkins Tests... Sometimes"
This commit is contained in:
@@ -85,6 +85,21 @@ class Properties {
|
|||||||
CdmClientPropertySet* property_set);
|
CdmClientPropertySet* property_set);
|
||||||
static bool RemoveSessionPropertySet(const CdmSessionId& session_id);
|
static bool RemoveSessionPropertySet(const CdmSessionId& session_id);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// This function always runs the code in |Init()| (and subsequently
|
||||||
|
// |InitOnce()|) even if Properties have already been initialized. This is
|
||||||
|
// needed by certain tests that are dependent on controlling the mutable state
|
||||||
|
// of Properties. Should not be used in general, as most tests rely on
|
||||||
|
// Properties' normal guarantee about |Init()| being safe to call multiple
|
||||||
|
// times without destroying mutable state.
|
||||||
|
static void ForceReinit() {
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(init_mutex_);
|
||||||
|
is_initialized_ = false;
|
||||||
|
}
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CdmClientPropertySet* GetCdmClientPropertySet(
|
static CdmClientPropertySet* GetCdmClientPropertySet(
|
||||||
const CdmSessionId& session_id);
|
const CdmSessionId& session_id);
|
||||||
@@ -111,7 +126,6 @@ class Properties {
|
|||||||
FRIEND_TEST(CdmLicenseTest, PrepareKeyRequestValidation);
|
FRIEND_TEST(CdmLicenseTest, PrepareKeyRequestValidation);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
|
||||||
// Called at least once before any properties are used.
|
// Called at least once before any properties are used.
|
||||||
static void InitOnce();
|
static void InitOnce();
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ const std::string kTestSignedCertificate = a2bs_hex(
|
|||||||
"D2E8D5986104AACC4DD475FD96EE9CE4E326F21B83C7058577B38732CDDABC6A6BED13FB0D"
|
"D2E8D5986104AACC4DD475FD96EE9CE4E326F21B83C7058577B38732CDDABC6A6BED13FB0D"
|
||||||
"49D38A45EB87A5F4");
|
"49D38A45EB87A5F4");
|
||||||
|
|
||||||
|
class PropertiesTestPeer : public Properties {
|
||||||
|
public:
|
||||||
|
using Properties::ForceReinit;
|
||||||
|
};
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
|
||||||
class ServiceCertificateTest : public ::testing::Test {
|
class ServiceCertificateTest : public ::testing::Test {
|
||||||
@@ -75,7 +80,9 @@ class StubCdmClientPropertySet : public CdmClientPropertySet {
|
|||||||
|
|
||||||
uint32_t session_sharing_id() const override { return session_sharing_id_; }
|
uint32_t session_sharing_id() const override { return session_sharing_id_; }
|
||||||
|
|
||||||
void set_session_sharing_id(uint32_t id) override { session_sharing_id_ = id; }
|
void set_session_sharing_id(uint32_t id) override {
|
||||||
|
session_sharing_id_ = id;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& app_id() const override { return app_id_; }
|
const std::string& app_id() const override { return app_id_; }
|
||||||
|
|
||||||
@@ -100,8 +107,9 @@ TEST_F(ServiceCertificateTest, InitPrivacyModeRequired) {
|
|||||||
|
|
||||||
property_set.enable_privacy_mode();
|
property_set.enable_privacy_mode();
|
||||||
|
|
||||||
Properties::Init();
|
PropertiesTestPeer::ForceReinit();
|
||||||
Properties::AddSessionPropertySet(kTestSessionId1, &property_set);
|
ASSERT_TRUE(PropertiesTestPeer::AddSessionPropertySet(kTestSessionId1,
|
||||||
|
&property_set));
|
||||||
|
|
||||||
service_certificate_.Init(kTestSessionId1);
|
service_certificate_.Init(kTestSessionId1);
|
||||||
EXPECT_FALSE(service_certificate_.has_certificate());
|
EXPECT_FALSE(service_certificate_.has_certificate());
|
||||||
@@ -113,14 +121,14 @@ TEST_F(ServiceCertificateTest, InitServiceCertificatePresent) {
|
|||||||
property_set.enable_privacy_mode();
|
property_set.enable_privacy_mode();
|
||||||
property_set.set_service_certificate(kTestSignedCertificate);
|
property_set.set_service_certificate(kTestSignedCertificate);
|
||||||
|
|
||||||
Properties::Init();
|
PropertiesTestPeer::ForceReinit();
|
||||||
Properties::AddSessionPropertySet(kTestSessionId1, &property_set);
|
ASSERT_TRUE(PropertiesTestPeer::AddSessionPropertySet(kTestSessionId1,
|
||||||
|
&property_set));
|
||||||
|
|
||||||
std::string raw_service_certificate;
|
std::string raw_service_certificate;
|
||||||
EXPECT_TRUE(Properties::GetServiceCertificate(kTestSessionId1,
|
EXPECT_TRUE(PropertiesTestPeer::GetServiceCertificate(
|
||||||
&raw_service_certificate));
|
kTestSessionId1, &raw_service_certificate));
|
||||||
EXPECT_EQ(NO_ERROR,
|
EXPECT_EQ(NO_ERROR, service_certificate_.Init(raw_service_certificate));
|
||||||
service_certificate_.Init(raw_service_certificate));
|
|
||||||
EXPECT_TRUE(service_certificate_.has_certificate());
|
EXPECT_TRUE(service_certificate_.has_certificate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,11 +137,12 @@ TEST_F(ServiceCertificateTest, SetServiceCertificate) {
|
|||||||
|
|
||||||
property_set.enable_privacy_mode();
|
property_set.enable_privacy_mode();
|
||||||
|
|
||||||
Properties::Init();
|
PropertiesTestPeer::ForceReinit();
|
||||||
Properties::AddSessionPropertySet(kTestSessionId1, &property_set);
|
ASSERT_TRUE(PropertiesTestPeer::AddSessionPropertySet(kTestSessionId1,
|
||||||
|
&property_set));
|
||||||
|
|
||||||
EXPECT_EQ(NO_ERROR, service_certificate_.Init(kTestSignedCertificate));
|
EXPECT_EQ(NO_ERROR, service_certificate_.Init(kTestSignedCertificate));
|
||||||
EXPECT_TRUE(service_certificate_.has_certificate());
|
EXPECT_TRUE(service_certificate_.has_certificate());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace wvcdm
|
||||||
|
|||||||
Reference in New Issue
Block a user