summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-01 22:47:10 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-01 22:47:10 +0000
commit8041b606a47f23c4db259f7824421b0e4c87b145 (patch)
tree802c0fee03ea75806202c7335360a1ed842db6fb /net
parentca8c514dd927887b62ed8c0321e7838833a5254e (diff)
downloadchromium_src-8041b606a47f23c4db259f7824421b0e4c87b145.zip
chromium_src-8041b606a47f23c4db259f7824421b0e4c87b145.tar.gz
chromium_src-8041b606a47f23c4db259f7824421b0e4c87b145.tar.bz2
Fix the CertDatabaseNSSTest SetUp creating multiple NSS DBs (regressed in r69107).
BUG=none TEST=none Review URL: http://codereview.chromium.org/6264016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73366 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/cert_database_nss_unittest.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/net/base/cert_database_nss_unittest.cc b/net/base/cert_database_nss_unittest.cc
index 679afc4..081aeb6 100644
--- a/net/base/cert_database_nss_unittest.cc
+++ b/net/base/cert_database_nss_unittest.cc
@@ -10,11 +10,11 @@
#include "base/crypto/scoped_nss_types.h"
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/lazy_instance.h"
#include "base/nss_util.h"
#include "base/nss_util_internal.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
-#include "base/singleton.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "net/base/cert_database.h"
@@ -105,9 +105,13 @@ bool ReadCertIntoList(const std::string& name, CertificateList* certs) {
class CertDatabaseNSSTest : public testing::Test {
public:
virtual void SetUp() {
- ASSERT_TRUE(temp_db_dir_.CreateUniqueTempDir());
- ASSERT_TRUE(
- base::OpenTestNSSDB(temp_db_dir_.path(), "CertDatabaseNSSTest db"));
+ if (!temp_db_initialized_) {
+ ASSERT_TRUE(temp_db_dir_.Get().CreateUniqueTempDir());
+ ASSERT_TRUE(
+ base::OpenTestNSSDB(temp_db_dir_.Get().path(),
+ "CertDatabaseNSSTest db"));
+ temp_db_initialized_ = true;
+ }
slot_ = cert_db_.GetDefaultModule();
// Test db should be empty at start of test.
@@ -126,9 +130,15 @@ class CertDatabaseNSSTest : public testing::Test {
CertDatabase cert_db_;
private:
- ScopedTempDir temp_db_dir_;
+ static base::LazyInstance<ScopedTempDir> temp_db_dir_;
+ static bool temp_db_initialized_;
};
+// static
+base::LazyInstance<ScopedTempDir> CertDatabaseNSSTest::temp_db_dir_(
+ base::LINKER_INITIALIZED);
+bool CertDatabaseNSSTest::temp_db_initialized_ = false;
+
TEST_F(CertDatabaseNSSTest, ListCerts) {
// This test isn't terribly useful, though it will at least let valgrind test
// for leaks.