Namespace crypto/test/file_util.h

We've historically not wrapped the test bits in namespaces, since it's
not general library code or anything. (Possibly we should?)

Unfortunately Android's libbase ended up leaving a TemporaryFile class
in the root namespace. That, which actually is general library code,
really should have been namespaced, but moving it will take a while, so
namespace ours.

Change-Id: I600e2dcf347e4cc6b4b81be5a26659698fe80064
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/68427
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
diff --git a/crypto/bio/bio_test.cc b/crypto/bio/bio_test.cc
index 075de0e..324f36f 100644
--- a/crypto/bio/bio_test.cc
+++ b/crypto/bio/bio_test.cc
@@ -639,8 +639,8 @@
       check_bio_gets(bio.get());
     }
 
-    if (!SkipTempFileTests()) {
-      TemporaryFile file;
+    if (!bssl::SkipTempFileTests()) {
+      bssl::TemporaryFile file;
       ASSERT_TRUE(file.Init(t.bio));
 
       // TODO(crbug.com/boringssl/585): If the line has an embedded NUL, file
@@ -660,7 +660,7 @@
         check_bio_gets(bio.get());
 
         // Test |BIO_NOCLOSE|.
-        ScopedFILE file_obj = file.Open("rb");
+        bssl::ScopedFILE file_obj = file.Open("rb");
         ASSERT_TRUE(file_obj);
         bio.reset(BIO_new_fp(file_obj.get(), BIO_NOCLOSE));
         ASSERT_TRUE(bio);
@@ -679,7 +679,7 @@
         SCOPED_TRACE("fd");
 
         // Test |BIO_NOCLOSE|.
-        ScopedFD fd = file.OpenFD(kOpenReadOnlyBinary);
+        bssl::ScopedFD fd = file.OpenFD(kOpenReadOnlyBinary);
         ASSERT_TRUE(fd.is_valid());
         bssl::UniquePtr<BIO> bio(BIO_new_fd(fd.get(), BIO_NOCLOSE));
         ASSERT_TRUE(bio);
@@ -707,11 +707,11 @@
 
 // Test that, on Windows, file BIOs correctly handle text vs binary mode.
 TEST(BIOTest, FileMode) {
-  if (SkipTempFileTests()) {
+  if (bssl::SkipTempFileTests()) {
     GTEST_SKIP();
   }
 
-  TemporaryFile temp;
+  bssl::TemporaryFile temp;
   ASSERT_TRUE(temp.Init("hello\r\nworld"));
 
   auto expect_file_contents = [](BIO *bio, const std::string &str) {
@@ -748,7 +748,7 @@
   expect_text_mode(bio.get());
 
   // |BIO_new_fp| inherits the file's existing mode by default.
-  ScopedFILE file = temp.Open("rb");
+  bssl::ScopedFILE file = temp.Open("rb");
   ASSERT_TRUE(file);
   bio.reset(BIO_new_fp(file.get(), BIO_NOCLOSE));
   ASSERT_TRUE(bio);
@@ -775,7 +775,7 @@
   expect_text_mode(bio.get());
 
   // |BIO_new_fd| inherits the FD's existing mode.
-  ScopedFD fd = temp.OpenFD(kOpenReadOnlyBinary);
+  bssl::ScopedFD fd = temp.OpenFD(kOpenReadOnlyBinary);
   ASSERT_TRUE(fd.is_valid());
   bio.reset(BIO_new_fd(fd.get(), BIO_NOCLOSE));
   ASSERT_TRUE(bio);
diff --git a/crypto/test/file_util.cc b/crypto/test/file_util.cc
index f593e1d..71c58b7 100644
--- a/crypto/test/file_util.cc
+++ b/crypto/test/file_util.cc
@@ -31,6 +31,8 @@
 #include "test_util.h"
 
 
+BSSL_NAMESPACE_BEGIN
+
 #if defined(OPENSSL_WINDOWS)
 static void PrintLastError(const char *s) {
   DWORD error = GetLastError();
@@ -237,3 +239,5 @@
   files_.insert(filename);
   return true;
 }
+
+BSSL_NAMESPACE_END
diff --git a/crypto/test/file_util.h b/crypto/test/file_util.h
index 0fd8d85..ee994b1 100644
--- a/crypto/test/file_util.h
+++ b/crypto/test/file_util.h
@@ -31,6 +31,8 @@
 #endif
 
 
+BSSL_NAMESPACE_BEGIN
+
 struct FileDeleter {
   void operator()(FILE *f) const {
     if (f != nullptr) {
@@ -159,4 +161,6 @@
   std::set<std::string> files_;
 };
 
+BSSL_NAMESPACE_END
+
 #endif  // OPENSSL_HEADER_CRYPTO_TEST_FILE_UTIL_H
diff --git a/crypto/test/test_data.cc b/crypto/test/test_data.cc
index 9db2019..f0e6922 100644
--- a/crypto/test/test_data.cc
+++ b/crypto/test/test_data.cc
@@ -49,7 +49,7 @@
   full_path.append(path);
 #endif
 
-  ScopedFILE file(fopen(full_path.c_str(), "rb"));
+  bssl::ScopedFILE file(fopen(full_path.c_str(), "rb"));
   if (file == nullptr) {
     fprintf(stderr, "Could not open '%s'.\n", full_path.c_str());
     abort();
diff --git a/crypto/x509/x509_test.cc b/crypto/x509/x509_test.cc
index ffbcf7b..ab107c7 100644
--- a/crypto/x509/x509_test.cc
+++ b/crypto/x509/x509_test.cc
@@ -8011,7 +8011,7 @@
   }
 
   int type_;
-  TemporaryDirectory dir_;
+  bssl::TemporaryDirectory dir_;
   std::map<uint32_t, int> next_cert_;
   std::map<uint32_t, int> next_crl_;
 };
@@ -8019,7 +8019,7 @@
 // TODO(davidben): Also test CRL handling. There are some interesting behaviors
 // in here.
 TEST(X509Test, DirHash) {
-  if (SkipTempFileTests()) {
+  if (bssl::SkipTempFileTests()) {
     GTEST_SKIP();
   }
 
@@ -8266,7 +8266,7 @@
   const char kSeparator = ':';
 #endif
 
-  if (SkipTempFileTests()) {
+  if (bssl::SkipTempFileTests()) {
     GTEST_SKIP();
   }
 
@@ -8330,7 +8330,7 @@
 #if defined(OPENSSL_THREADS)
 // Test that directory hash lookup is thread-safe.
 TEST(X509Test, DirHashThreads) {
-  if (SkipTempFileTests()) {
+  if (bssl::SkipTempFileTests()) {
     GTEST_SKIP();
   }