diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 20:32:38 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 20:32:38 +0000 |
commit | c6474b523c69db39103e8b20d8b26486f33078ed (patch) | |
tree | 7542bcc596af5715f2027fcfa1866610c42d2474 | |
parent | c02c059cb0e72fb303bf19fb18380ae704a26854 (diff) | |
download | chromium_src-c6474b523c69db39103e8b20d8b26486f33078ed.zip chromium_src-c6474b523c69db39103e8b20d8b26486f33078ed.tar.gz chromium_src-c6474b523c69db39103e8b20d8b26486f33078ed.tar.bz2 |
Revert 162327 - Implement ScopedTestNSSDB instead of OpenTestNSSDB()
BUG=136950
Review URL: https://chromiumcodereview.appspot.com/11174006
TBR=toyoshim@chromium.org
BUG=156433
Review URL: https://codereview.chromium.org/11196028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162511 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/cros/network_library_unittest.cc | 15 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/onc_network_parser_unittest.cc | 15 | ||||
-rw-r--r-- | crypto/crypto_export.h | 9 | ||||
-rw-r--r-- | crypto/nss_util.cc | 9 | ||||
-rw-r--r-- | crypto/nss_util.h | 20 | ||||
-rw-r--r-- | net/base/nss_cert_database_unittest.cc | 14 |
6 files changed, 42 insertions, 40 deletions
diff --git a/chrome/browser/chromeos/cros/network_library_unittest.cc b/chrome/browser/chromeos/cros/network_library_unittest.cc index 47b81fc..751e22c 100644 --- a/chrome/browser/chromeos/cros/network_library_unittest.cc +++ b/chrome/browser/chromeos/cros/network_library_unittest.cc @@ -138,10 +138,20 @@ class NetworkLibraryStubTest : public testing::Test { public: NetworkLibraryStubTest() : cros_(NULL) {} + static void SetUpTestCase() { + // Ideally, we'd open a test DB for each test case, and close it + // again, removing the temp dir, but unfortunately, there's a + // bug in NSS that prevents this from working, so we just open + // it once, and empty it for each test case. Here's the bug: + // https://bugzilla.mozilla.org/show_bug.cgi?id=588269 + ASSERT_TRUE(crypto::OpenTestNSSDB()); + // There is no matching TearDownTestCase call to close the test NSS DB + // because that would leave NSS in a potentially broken state for further + // tests, due to https://bugzilla.mozilla.org/show_bug.cgi?id=588269 + } + protected: virtual void SetUp() { - ASSERT_TRUE(test_nssdb_.is_open()); - slot_ = net::NSSCertDatabase::GetInstance()->GetPublicModule(); cros_ = CrosLibrary::Get()->GetNetworkLibrary(); ASSERT_TRUE(cros_) << "GetNetworkLibrary() Failed!"; @@ -197,7 +207,6 @@ class NetworkLibraryStubTest : public testing::Test { } scoped_refptr<net::CryptoModule> slot_; - crypto::ScopedTestNSSDB test_nssdb_; }; // Default stub state: diff --git a/chrome/browser/chromeos/cros/onc_network_parser_unittest.cc b/chrome/browser/chromeos/cros/onc_network_parser_unittest.cc index e27619c..291f379 100644 --- a/chrome/browser/chromeos/cros/onc_network_parser_unittest.cc +++ b/chrome/browser/chromeos/cros/onc_network_parser_unittest.cc @@ -54,9 +54,19 @@ net::CertType GetCertType(const net::X509Certificate* cert) { class OncNetworkParserTest : public testing::Test { public: - virtual void SetUp() { - ASSERT_TRUE(test_nssdb_.is_open()); + static void SetUpTestCase() { + // Ideally, we'd open a test DB for each test case, and close it + // again, removing the temp dir, but unfortunately, there's a + // bug in NSS that prevents this from working, so we just open + // it once, and empty it for each test case. Here's the bug: + // https://bugzilla.mozilla.org/show_bug.cgi?id=588269 + ASSERT_TRUE(crypto::OpenTestNSSDB()); + // There is no matching TearDownTestCase call to close the test NSS DB + // because that would leave NSS in a potentially broken state for further + // tests, due to https://bugzilla.mozilla.org/show_bug.cgi?id=588269 + } + virtual void SetUp() { slot_ = net::NSSCertDatabase::GetInstance()->GetPublicModule(); // Don't run the test if the setup failed. @@ -127,7 +137,6 @@ class OncNetworkParserTest : public testing::Test { } ScopedStubCrosEnabler stub_cros_enabler_; - crypto::ScopedTestNSSDB test_nssdb_; }; const base::Value* OncNetworkParserTest::GetExpectedProperty( diff --git a/crypto/crypto_export.h b/crypto/crypto_export.h index 983afe6..f8b0b6c 100644 --- a/crypto/crypto_export.h +++ b/crypto/crypto_export.h @@ -5,34 +5,25 @@ #ifndef CRYPTO_CRYPTO_EXPORT_H_ #define CRYPTO_CRYPTO_EXPORT_H_ -// Defines CRYPTO_EXPORT so that functionality implemented by the crypto module -// can be exported to consumers, and CRYPTO_EXPORT_PRIVATE that allows unit -// tests to access features not intended to be used directly by real consumers. - #if defined(COMPONENT_BUILD) #if defined(WIN32) #if defined(CRYPTO_IMPLEMENTATION) #define CRYPTO_EXPORT __declspec(dllexport) -#define CRYPTO_EXPORT_PRIVATE __declspec(dllexport) #else #define CRYPTO_EXPORT __declspec(dllimport) -#define CRYPTO_EXPORT_PRIVATE __declspec(dllimport) #endif // defined(CRYPTO_IMPLEMENTATION) #else // defined(WIN32) #if defined(CRYPTO_IMPLEMENTATION) #define CRYPTO_EXPORT __attribute__((visibility("default"))) -#define CRYPTO_EXPORT_PRIVATE __attribute__((visibility("default"))) #else #define CRYPTO_EXPORT -#define CRYPTO_EXPORT_PRIVATE #endif #endif #else // defined(COMPONENT_BUILD) #define CRYPTO_EXPORT -#define CRYPTO_EXPORT_PRIVATE #endif #endif // CRYPTO_CRYPTO_EXPORT_H_ diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc index 6d86743..db89a70 100644 --- a/crypto/nss_util.cc +++ b/crypto/nss_util.cc @@ -702,13 +702,8 @@ bool CheckNSSVersion(const char* version) { } #if defined(USE_NSS) -ScopedTestNSSDB::ScopedTestNSSDB() - : is_open_(g_nss_singleton.Get().OpenTestNSSDB()) { -} - -ScopedTestNSSDB::~ScopedTestNSSDB() { - // TODO(mattm): Close the dababase once NSS 3.14 is required, - // which fixes https://bugzilla.mozilla.org/show_bug.cgi?id=588269 +bool OpenTestNSSDB() { + return g_nss_singleton.Get().OpenTestNSSDB(); } base::Lock* GetNSSWriteLock() { diff --git a/crypto/nss_util.h b/crypto/nss_util.h index 9e09d6d..88d7d05 100644 --- a/crypto/nss_util.h +++ b/crypto/nss_util.h @@ -128,21 +128,11 @@ CRYPTO_EXPORT int64 BaseTimeToPRTime(base::Time time); #if defined(USE_NSS) // Exposed for unittests only. -// TODO(mattm): When NSS 3.14 is the minimum version required, -// switch back to using a separate user DB for each test. -// Because of https://bugzilla.mozilla.org/show_bug.cgi?id=588269 , the -// opened user DB is not automatically closed. -class CRYPTO_EXPORT_PRIVATE ScopedTestNSSDB { - public: - ScopedTestNSSDB(); - ~ScopedTestNSSDB(); - - bool is_open() { return is_open_; } - - private: - bool is_open_; - DISALLOW_COPY_AND_ASSIGN(ScopedTestNSSDB); -}; +// TODO(mattm): when https://bugzilla.mozilla.org/show_bug.cgi?id=588269 is +// fixed, switch back to using a separate userdb for each test. (Maybe refactor +// to provide a ScopedTestNSSDB instead of open/close methods.) +CRYPTO_EXPORT bool OpenTestNSSDB(); +// NOTE: due to NSS bug 588269, mentioned above, there is no CloseTestNSSDB. // NSS has a bug which can cause a deadlock or stall in some cases when writing // to the certDB and keyDB. It also has a bug which causes concurrent key pair diff --git a/net/base/nss_cert_database_unittest.cc b/net/base/nss_cert_database_unittest.cc index 9cdbb95..2a99196 100644 --- a/net/base/nss_cert_database_unittest.cc +++ b/net/base/nss_cert_database_unittest.cc @@ -38,10 +38,20 @@ namespace net { +// TODO(mattm): when https://bugzilla.mozilla.org/show_bug.cgi?id=588269 is +// fixed, switch back to using a separate userdb for each test. +// (When doing so, remember to add some standalone tests of DeleteCert since it +// won't be tested by TearDown anymore.) class CertDatabaseNSSTest : public testing::Test { public: + static void SetUpTestCase() { + ASSERT_TRUE(crypto::OpenTestNSSDB()); + // There is no matching TearDownTestCase call to close the test NSS DB + // because that would leave NSS in a potentially broken state for further + // tests, due to https://bugzilla.mozilla.org/show_bug.cgi?id=588269 + } + virtual void SetUp() { - ASSERT_TRUE(test_nssdb_.is_open()); cert_db_ = NSSCertDatabase::GetInstance(); slot_ = cert_db_->GetPublicModule(); @@ -119,8 +129,6 @@ class CertDatabaseNSSTest : public testing::Test { } return ok; } - - crypto::ScopedTestNSSDB test_nssdb_; }; TEST_F(CertDatabaseNSSTest, ListCerts) { |