diff options
Diffstat (limited to 'net/base/cert_database_nss_unittest.cc')
-rw-r--r-- | net/base/cert_database_nss_unittest.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/net/base/cert_database_nss_unittest.cc b/net/base/cert_database_nss_unittest.cc index 8e69104..5056e5d 100644 --- a/net/base/cert_database_nss_unittest.cc +++ b/net/base/cert_database_nss_unittest.cc @@ -104,9 +104,16 @@ 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_) { + ScopedTempDir* temp_db_dir = Singleton< + ScopedTempDir, + DefaultSingletonTraits<ScopedTempDir>, + CertDatabaseNSSTest>::get(); + ASSERT_TRUE(temp_db_dir->CreateUniqueTempDir()); + ASSERT_TRUE( + base::OpenTestNSSDB(temp_db_dir->path(), "CertDatabaseNSSTest db")); + temp_db_initialized_ = true; + } slot_.reset(base::GetDefaultNSSKeySlot()); // Test db should be empty at start of test. @@ -114,6 +121,7 @@ class CertDatabaseNSSTest : public testing::Test { } virtual void TearDown() { // Don't try to cleanup if the setup failed. + ASSERT_TRUE(temp_db_initialized_); ASSERT_TRUE(slot_.get()); EXPECT_TRUE(CleanupSlotContents(slot_.get())); @@ -125,9 +133,12 @@ class CertDatabaseNSSTest : public testing::Test { CertDatabase cert_db_; private: - ScopedTempDir temp_db_dir_; + static bool temp_db_initialized_; }; +// static +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. |