Initialize SSL in unittest_main.cc.
Instead of having each test individually initialize and tear down SSL move this to unittest_main.cc so that all tests are properly initialized and new tests "don't have to think about it". R=pthatcher@webrtc.org BUG= Review URL: https://webrtc-codereview.appspot.com/30549004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7316 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -97,14 +97,6 @@ static cricket::SessionDescription* CreateCricketSessionDescription() {
|
||||
|
||||
class JsepSessionDescriptionTest : public testing::Test {
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
virtual void SetUp() {
|
||||
int port = 1234;
|
||||
rtc::SocketAddress address("127.0.0.1", port++);
|
||||
|
||||
@@ -919,9 +919,6 @@ class P2PTestConductor : public testing::Test {
|
||||
receiving_client_->VerifyLocalIceUfragAndPassword();
|
||||
}
|
||||
|
||||
P2PTestConductor() {
|
||||
rtc::InitializeSSL(NULL);
|
||||
}
|
||||
~P2PTestConductor() {
|
||||
if (initiating_client_) {
|
||||
initiating_client_->set_signaling_message_receiver(NULL);
|
||||
@@ -929,7 +926,6 @@ class P2PTestConductor : public testing::Test {
|
||||
if (receiving_client_) {
|
||||
receiving_client_->set_signaling_message_receiver(NULL);
|
||||
}
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
bool CreateTestClients() {
|
||||
|
||||
@@ -134,7 +134,6 @@ class PeerConnectionEndToEndTest
|
||||
"caller")),
|
||||
callee_(new rtc::RefCountedObject<PeerConnectionTestWrapper>(
|
||||
"callee")) {
|
||||
rtc::InitializeSSL(NULL);
|
||||
}
|
||||
|
||||
void CreatePcs() {
|
||||
@@ -262,10 +261,6 @@ class PeerConnectionEndToEndTest
|
||||
kMaxWait);
|
||||
}
|
||||
|
||||
~PeerConnectionEndToEndTest() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
protected:
|
||||
rtc::scoped_refptr<PeerConnectionTestWrapper> caller_;
|
||||
rtc::scoped_refptr<PeerConnectionTestWrapper> callee_;
|
||||
|
||||
@@ -229,17 +229,12 @@ class MockPeerConnectionObserver : public PeerConnectionObserver {
|
||||
class PeerConnectionInterfaceTest : public testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
rtc::InitializeSSL(NULL);
|
||||
pc_factory_ = webrtc::CreatePeerConnectionFactory(
|
||||
rtc::Thread::Current(), rtc::Thread::Current(), NULL, NULL,
|
||||
NULL);
|
||||
ASSERT_TRUE(pc_factory_.get() != NULL);
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
void CreatePeerConnection() {
|
||||
CreatePeerConnection("", "", NULL);
|
||||
}
|
||||
|
||||
@@ -330,14 +330,6 @@ class WebRtcSessionTest : public testing::Test {
|
||||
allocator_->set_step_delay(cricket::kMinimumStepDelay);
|
||||
}
|
||||
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
void AddInterface(const SocketAddress& addr) {
|
||||
network_manager_.AddInterface(addr);
|
||||
}
|
||||
|
||||
@@ -83,14 +83,6 @@ class FakeDataReceiver : public sigslot::has_slots<> {
|
||||
|
||||
class RtpDataMediaChannelTest : public testing::Test {
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
virtual void SetUp() {
|
||||
// Seed needed for each test to satisfy expectations.
|
||||
iface_.reset(new cricket::FakeNetworkInterface());
|
||||
|
||||
@@ -229,11 +229,6 @@ class SctpDataMediaChannelTest : public testing::Test,
|
||||
LOG(LS_WARNING) << "Unabled to initialize NSS.";
|
||||
}
|
||||
#endif // HAVE_NSS_SSL_H
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
virtual void SetUp() {
|
||||
|
||||
@@ -377,14 +377,6 @@ class DtlsTestClient : public sigslot::has_slots<> {
|
||||
|
||||
class DtlsTransportChannelTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
DtlsTransportChannelTest() :
|
||||
client1_("P1", rtc::Thread::Current(),
|
||||
rtc::Thread::Current()),
|
||||
|
||||
@@ -366,14 +366,6 @@ class P2PTransportChannelTestBase : public testing::Test,
|
||||
static const Result kLocalTcpToPrflxTcp;
|
||||
static const Result kPrflxTcpToLocalTcp;
|
||||
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
rtc::NATSocketServer* nat() { return nss_.get(); }
|
||||
rtc::FirewallSocketServer* fw() { return ss_.get(); }
|
||||
|
||||
|
||||
@@ -357,15 +357,6 @@ class PortTest : public testing::Test, public sigslot::has_slots<> {
|
||||
}
|
||||
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
|
||||
void TestLocalToLocal() {
|
||||
Port* port1 = CreateUdpPort(kLocalAddr1);
|
||||
Port* port2 = CreateUdpPort(kLocalAddr2);
|
||||
|
||||
@@ -93,15 +93,6 @@ class RelayPortTest : public testing::Test,
|
||||
}
|
||||
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
|
||||
virtual void SetUp() {
|
||||
// The relay server needs an external socket to work properly.
|
||||
rtc::AsyncUDPSocket* ext_socket =
|
||||
|
||||
@@ -53,14 +53,6 @@ static const char* msg2 = "Lobster Thermidor a Crevette with a mornay sauce...";
|
||||
|
||||
class RelayServerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
RelayServerTest()
|
||||
: main_(rtc::Thread::Current()), ss_(main_->socketserver()),
|
||||
username_(rtc::CreateRandomString(12)),
|
||||
|
||||
@@ -128,14 +128,10 @@ class StunPortTest : public testing::Test,
|
||||
|
||||
protected:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
// Ensure the RNG is inited.
|
||||
rtc::InitRandom(NULL, 0);
|
||||
|
||||
}
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
void OnPortComplete(cricket::Port* port) {
|
||||
ASSERT_FALSE(done_);
|
||||
|
||||
@@ -37,14 +37,6 @@ using namespace cricket;
|
||||
class StunRequestTest : public testing::Test,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
StunRequestTest()
|
||||
: manager_(rtc::Thread::Current()),
|
||||
request_count_(0), response_(NULL),
|
||||
|
||||
@@ -47,10 +47,6 @@ class TransportDescriptionFactoryTest : public testing::Test {
|
||||
id2_(new rtc::FakeSSLIdentity("User2")) {
|
||||
}
|
||||
|
||||
// Make sure SSL is set up as it's used by the tests.
|
||||
static void SetUpTestCase() { rtc::InitializeSSL(); }
|
||||
static void TearDownTestCase() { rtc::CleanupSSL(); }
|
||||
|
||||
void CheckDesc(const TransportDescription* desc, const std::string& type,
|
||||
const std::string& opt, const std::string& ice_ufrag,
|
||||
const std::string& ice_pwd, const std::string& dtls_alg) {
|
||||
|
||||
@@ -124,14 +124,6 @@ class TurnPortTest : public testing::Test,
|
||||
network_.AddIP(rtc::IPAddress(INADDR_ANY));
|
||||
}
|
||||
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
virtual void OnMessage(rtc::Message* msg) {
|
||||
ASSERT(msg->message_id == MSG_TESTFINISH);
|
||||
if (msg->message_id == MSG_TESTFINISH)
|
||||
|
||||
@@ -97,14 +97,6 @@ std::ostream& operator<<(std::ostream& os, const cricket::Candidate& c) {
|
||||
|
||||
class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
|
||||
public:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
PortAllocatorTest()
|
||||
: pss_(new rtc::PhysicalSocketServer),
|
||||
vss_(new rtc::VirtualSocketServer(pss_.get())),
|
||||
|
||||
@@ -143,14 +143,6 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
||||
error_(T::MediaChannel::ERROR_NONE) {
|
||||
}
|
||||
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
void CreateChannels(int flags1, int flags2) {
|
||||
CreateChannels(new typename T::MediaChannel(NULL),
|
||||
new typename T::MediaChannel(NULL),
|
||||
|
||||
@@ -204,14 +204,6 @@ class MediaSessionDescriptionFactoryTest : public testing::Test {
|
||||
tdf2_.set_identity(&id2_);
|
||||
}
|
||||
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
// Create a video StreamParamsVec object with:
|
||||
// - one video stream with 3 simulcast streams and FEC,
|
||||
StreamParamsVec CreateComplexVideoStreamParamsVec() {
|
||||
|
||||
@@ -2764,12 +2764,7 @@ MediaSessionClientTest* JingleTest() {
|
||||
cricket::PROTOCOL_JINGLE);
|
||||
}
|
||||
|
||||
class MediaSessionTest : public ::testing::Test {
|
||||
protected:
|
||||
// Make sure SSL is set up as it's used by the tests.
|
||||
static void SetUpTestCase() { rtc::InitializeSSL(); }
|
||||
static void TearDownTestCase() { rtc::CleanupSSL(); }
|
||||
};
|
||||
class MediaSessionTest : public ::testing::Test {};
|
||||
|
||||
TEST_F(MediaSessionTest, JingleGoodInitiateWithRtcpFb) {
|
||||
rtc::scoped_ptr<MediaSessionClientTest> test(JingleTest());
|
||||
|
||||
@@ -16,16 +16,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
class RandomTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
};
|
||||
class RandomTest : public testing::Test {};
|
||||
|
||||
TEST_F(RandomTest, TestCreateRandomId) {
|
||||
CreateRandomId();
|
||||
|
||||
@@ -247,14 +247,6 @@ class SSLAdapterTestBase : public testing::Test,
|
||||
handshake_wait_(kTimeout) {
|
||||
}
|
||||
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
void SetHandshakeWait(int wait) {
|
||||
handshake_wait_ = wait;
|
||||
}
|
||||
|
||||
@@ -45,14 +45,6 @@ class SSLIdentityTest : public testing::Test {
|
||||
~SSLIdentityTest() {
|
||||
}
|
||||
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
virtual void SetUp() {
|
||||
identity1_.reset(SSLIdentity::Generate("test1"));
|
||||
identity2_.reset(SSLIdentity::Generate("test2"));
|
||||
|
||||
@@ -194,14 +194,6 @@ class SSLStreamAdapterTestBase : public testing::Test,
|
||||
rtc::SetRandomTestMode(false);
|
||||
}
|
||||
|
||||
static void SetUpTestCase() {
|
||||
rtc::InitializeSSL();
|
||||
}
|
||||
|
||||
static void TearDownTestCase() {
|
||||
rtc::CleanupSSL();
|
||||
}
|
||||
|
||||
// Recreate the client/server identities with the specified validity period.
|
||||
// |not_before| and |not_after| are offsets from the current time in number
|
||||
// of seconds.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "webrtc/base/fileutils.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/ssladapter.h"
|
||||
|
||||
DEFINE_bool(help, false, "prints this message");
|
||||
DEFINE_string(log, "", "logging options to use");
|
||||
@@ -85,8 +86,13 @@ int main(int argc, char** argv) {
|
||||
rtc::LogMessage::ConfigureLogging(FLAG_log, "unittest.log");
|
||||
}
|
||||
|
||||
// Initialize SSL which are used by several tests.
|
||||
rtc::InitializeSSL();
|
||||
|
||||
int res = RUN_ALL_TESTS();
|
||||
|
||||
rtc::CleanupSSL();
|
||||
|
||||
// clean up logging so we don't appear to leak memory.
|
||||
rtc::LogMessage::ConfigureLogging("", "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user