[libc++/abi] Clean up uses of <iostream> in the test suite

We used <iostream> in several places where we don't actually need the
full power of <iostream>, and where using basic `std::printf` is enough.
This is better, since `std::printf` can be supported on systems that don't
have a notion of locales, while <iostream> can't.
diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
index 578958a..813669c 100644
--- a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
@@ -13,12 +13,11 @@
 // map& operator=(const map& m);
 
 #include <map>
-#include <cassert>
-#include <vector>
 #include <algorithm>
+#include <cassert>
+#include <cstdio>
 #include <iterator>
-
-#include <iostream>
+#include <vector>
 
 #include "test_macros.h"
 #include "../../../test_compare.h"
@@ -78,7 +77,7 @@
 bool balanced_allocs() {
     std::vector<int> temp1, temp2;
 
-    std::cout << "Allocations = " << ca_allocs.size() << ", deallocatons = " << ca_deallocs.size() << std::endl;
+    std::printf("Allocations = %lu, deallocations = %lu\n", ca_allocs.size(), ca_deallocs.size());
     if (ca_allocs.size() != ca_deallocs.size())
         return false;
 
@@ -86,27 +85,32 @@
     std::sort(temp1.begin(), temp1.end());
     temp2.clear();
     std::unique_copy(temp1.begin(), temp1.end(), std::back_inserter<std::vector<int>>(temp2));
-    std::cout << "There were " << temp2.size() << " different allocators\n";
+    std::printf("There were %lu different allocators\n", temp2.size());
 
     for (std::vector<int>::const_iterator it = temp2.begin(); it != temp2.end(); ++it ) {
-        std::cout << *it << ": " << std::count(ca_allocs.begin(), ca_allocs.end(), *it) << " vs " << std::count(ca_deallocs.begin(), ca_deallocs.end(), *it) << std::endl;
-        if ( std::count(ca_allocs.begin(), ca_allocs.end(), *it) != std::count(ca_deallocs.begin(), ca_deallocs.end(), *it))
+        std::ptrdiff_t const allocs = std::count(ca_allocs.begin(), ca_allocs.end(), *it);
+        std::ptrdiff_t const deallocs = std::count(ca_deallocs.begin(), ca_deallocs.end(), *it);
+        std::printf("%d: %ld vs %ld\n", *it, allocs, deallocs);
+        if (allocs != deallocs)
             return false;
-        }
+    }
 
     temp1 = ca_allocs;
     std::sort(temp1.begin(), temp1.end());
     temp2.clear();
     std::unique_copy(temp1.begin(), temp1.end(), std::back_inserter<std::vector<int>>(temp2));
-    std::cout << "There were " << temp2.size() << " different (de)allocators\n";
+    std::printf("There were %lu different (de)allocators\n", temp2.size());
+
     for (std::vector<int>::const_iterator it = ca_deallocs.begin(); it != ca_deallocs.end(); ++it ) {
-        std::cout << *it << ": " << std::count(ca_allocs.begin(), ca_allocs.end(), *it) << " vs " << std::count(ca_deallocs.begin(), ca_deallocs.end(), *it) << std::endl;
-        if ( std::count(ca_allocs.begin(), ca_allocs.end(), *it) != std::count(ca_deallocs.begin(), ca_deallocs.end(), *it))
+        std::ptrdiff_t const allocs = std::count(ca_allocs.begin(), ca_allocs.end(), *it);
+        std::ptrdiff_t const deallocs = std::count(ca_deallocs.begin(), ca_deallocs.end(), *it);
+        std::printf("%d: %ld vs %ld\n", *it, allocs, deallocs);
+        if (allocs != deallocs)
             return false;
-        }
+    }
 
     return true;
-    }
+}
 #endif
 
 int main(int, char**)
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
index bdde35c..633d9ac 100644
--- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp
@@ -25,8 +25,6 @@
 #include <cassert>
 #include <tuple>
 
-#include <iostream>
-
 #include "test_macros.h"
 
 class Moveable
diff --git a/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
index 7a8b46a..b04d7f5 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
@@ -16,7 +16,6 @@
 
 #include <set>
 #include <cassert>
-#include <iostream>
 
 #include "test_macros.h"
 #include "min_allocator.h"
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
index 6af5df8..ec28a22 100644
--- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
@@ -17,7 +17,6 @@
 #include <functional>
 #include <random>
 #include <cassert>
-#include <iostream>
 
 #include "test_macros.h"
 #include "min_allocator.h"
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
index 42ddd93..519b429 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
@@ -16,8 +16,6 @@
 
 // unordered_multimap(unordered_multimap&& u, const allocator_type& a);
 
-#include <iostream>
-
 #include <unordered_map>
 #include <string>
 #include <set>
@@ -272,5 +270,5 @@
         assert(c0.empty());
     }
 
-  return 0;
+    return 0;
 }
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
index 203130d..881643c 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
@@ -22,8 +22,6 @@
 #include "filesystem_test_helper.h"
 #include "rapid-cxx-test.h"
 
-#include <iostream>
-
 #include "test_macros.h"
 
 TEST_SUITE(directory_entry_obs_testsuite)
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp
index 20bd70d..09b5139 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp
@@ -23,7 +23,6 @@
 #include "test_macros.h"
 #include "rapid-cxx-test.h"
 #include "filesystem_test_helper.h"
-#include <iostream>
 
 using namespace fs;
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
index 3b58e60..be8a1be 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
@@ -23,7 +23,6 @@
 #include "test_macros.h"
 #include "rapid-cxx-test.h"
 #include "filesystem_test_helper.h"
-#include <iostream>
 
 using namespace fs;
 
diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/source.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/source.pass.cpp
index c8df324..e020498 100644
--- a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/source.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.assign/source.pass.cpp
@@ -30,7 +30,6 @@
 #include "test_iterators.h"
 #include "count_new.h"
 #include "filesystem_test_helper.h"
-#include <iostream>
 
 
 template <class CharT>
diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
index bb0ad1d..c8753b0 100644
--- a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
@@ -15,13 +15,10 @@
 // path lexically_normal() const;
 
 #include "filesystem_include.h"
-#include <type_traits>
-#include <vector>
-#include <iostream>
-#include <cassert>
+#include <cstdio>
+#include <string>
 
 #include "test_macros.h"
-#include "test_iterators.h"
 #include "count_new.h"
 #include "filesystem_test_helper.h"
 
@@ -130,11 +127,11 @@
     const fs::path output = p.lexically_normal();
     if (!PathEq(output, TC.expect)) {
       Failed = true;
-      std::cerr << "TEST CASE #" << ID << " FAILED: \n";
-      std::cerr << "  Input: '" << TC.input << "'\n";
-      std::cerr << "  Expected: '" << TC.expect << "'\n";
-      std::cerr << "  Output: '" << output.native() << "'";
-      std::cerr << std::endl;
+      std::printf("TEST CASE #%d FAILED:\n"
+                  "  Input: '%s'\n"
+                  "  Expected: '%s'\n"
+                  "  Output: '%s'\n",
+        ID, TC.input.c_str(), TC.expect.c_str(), output.native().c_str());
     }
   }
   return Failed;
diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
index 3fa1a00..a2a6d62 100644
--- a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
@@ -16,13 +16,10 @@
 // path lexically_proximate(const path& p) const;
 
 #include "filesystem_include.h"
-#include <type_traits>
-#include <vector>
-#include <iostream>
-#include <cassert>
+#include <cstdio>
+#include <string>
 
 #include "test_macros.h"
-#include "test_iterators.h"
 #include "count_new.h"
 #include "filesystem_test_helper.h"
 
@@ -65,13 +62,14 @@
     auto ReportErr = [&](const char* Testing, fs::path const& Output,
                                               fs::path const& Expected) {
       Failed = true;
-      std::cerr << "TEST CASE #" << ID << " FAILED: \n";
-      std::cerr << "  Testing: " << Testing << "\n";
-      std::cerr << "  Input: '" << TC.input << "'\n";
-      std::cerr << "  Base: '" << TC.base << "'\n";
-      std::cerr << "  Expected: '" << Expected << "'\n";
-      std::cerr << "  Output: '" << Output.native() << "'";
-      std::cerr << std::endl;
+      std::printf("TEST CASE #%d FAILED:\n"
+                  "  Testing: %s\n"
+                  "  Input: '%s'\n"
+                  "  Base: '%s'\n"
+                  "  Expected: '%s'\n"
+                  "  Output: '%s'\n",
+        ID, Testing, TC.input.c_str(), TC.base.c_str(),
+        Expected.c_str(), Output.native().c_str());
     };
     if (!PathEq(output, TC.expect))
       ReportErr("path::lexically_relative", output, TC.expect);
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
index 3d2b9b6..c4bb5a7 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
@@ -23,7 +23,6 @@
 #include "test_macros.h"
 #include "rapid-cxx-test.h"
 #include "filesystem_test_helper.h"
-#include <iostream>
 
 using namespace fs;
 
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
index e91e739..0d2a555 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file.pass.cpp
@@ -25,8 +25,6 @@
 #include "rapid-cxx-test.h"
 #include "filesystem_test_helper.h"
 
-#include <iostream>
-
 using namespace fs;
 
 using CO = fs::copy_options;
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file_large.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file_large.pass.cpp
index 8b4fdb2..d7bdbdb 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file_large.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy_file/copy_file_large.pass.cpp
@@ -18,9 +18,10 @@
 //           error_code& ec) noexcept;
 
 #include "filesystem_include.h"
-#include <type_traits>
-#include <chrono>
 #include <cassert>
+#include <chrono>
+#include <fstream>
+#include <string>
 
 #include "test_macros.h"
 #include "rapid-cxx-test.h"
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
index d87d6f2..c24d28b 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -19,18 +19,16 @@
 #include "filesystem_include.h"
 #include <type_traits>
 #include <chrono>
-#include <fstream>
+#include <cstdio>
 #include <cstdlib>
 
 #include "test_macros.h"
 #include "rapid-cxx-test.h"
 #include "filesystem_test_helper.h"
 
-#include <sys/stat.h>
-#include <iostream>
-
 #include <fcntl.h>
 #include <sys/time.h>
+#include <sys/stat.h>
 
 using namespace fs;
 
@@ -113,7 +111,6 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
         throw ec;
 #else
-        std::cerr << ec.message() << std::endl;
         std::exit(EXIT_FAILURE);
 #endif
     }
@@ -131,7 +128,6 @@
 #ifndef TEST_HAS_NO_EXCEPTIONS
         throw ec;
 #else
-        std::cerr << ec.message() << std::endl;
         std::exit(EXIT_FAILURE);
 #endif
     }
@@ -399,9 +395,9 @@
     SleepFor(Sec(2));
 
     // update file and add a file to the directory. Make sure the times increase.
-    std::ofstream of(file, std::ofstream::app);
-    of << "hello";
-    of.close();
+    std::FILE* of = std::fopen(file.c_str(), "a");
+    std::fwrite("hello", 1, sizeof("hello"), of);
+    std::fclose(of);
     env.create_file("dir/file1", 1);
 
     file_time_type ftime2 = last_write_time(file);
@@ -454,7 +450,6 @@
         {"dir, just_before_epoch_time", dir, just_before_epoch_time}
     };
     for (const auto& TC : cases) {
-        std::cerr << "Test Case = " << TC.case_name << "\n";
         const auto old_times = GetTimes(TC.p);
         file_time_type old_time;
         TEST_REQUIRE(ConvertFromTimeSpec(old_time, old_times.write));
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
index 40db06b..f166a25 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp
@@ -15,13 +15,10 @@
 // path proximate(const path& p, const path& base, error_code& ec);
 
 #include "filesystem_include.h"
-#include <type_traits>
-#include <vector>
-#include <iostream>
 #include <cassert>
+#include <cstdio>
 
 #include "test_macros.h"
-#include "test_iterators.h"
 #include "count_new.h"
 #include "rapid-cxx-test.h"
 #include "filesystem_test_helper.h"
@@ -103,28 +100,28 @@
     const fs::path output = fs::proximate(p, TC.base, ec);
     if (ec) {
       TEST_CHECK(!ec);
-      std::cerr << "TEST CASE #" << ID << " FAILED: \n";
-      std::cerr << "  Input: '" << TC.input << "'\n";
-      std::cerr << "  Base: '" << TC.base << "'\n";
-      std::cerr << "  Expected: '" << TC.expect << "'\n";
-
-      std::cerr << std::endl;
+      std::printf("TEST CASE #%d FAILED:\n"
+                  "  Input: '%s'\n"
+                  "  Base: '%s'\n"
+                  "  Expected: '%s'\n",
+        ID, TC.input.c_str(), TC.base.c_str(), TC.expect.c_str());
     } else if (!PathEq(output, TC.expect)) {
       TEST_CHECK(PathEq(output, TC.expect));
 
       const path canon_input = fs::weakly_canonical(TC.input);
       const path canon_base = fs::weakly_canonical(TC.base);
       const path lexically_p = canon_input.lexically_proximate(canon_base);
-      std::cerr << "TEST CASE #" << ID << " FAILED: \n";
-      std::cerr << "  Input: '" << TC.input << "'\n";
-      std::cerr << "  Base: '" << TC.base << "'\n";
-      std::cerr << "  Expected: '" << TC.expect << "'\n";
-      std::cerr << "  Output:   '" << output.native() << "'\n";
-      std::cerr << "  Lex Prox: '" << lexically_p.native() << "'\n";
-      std::cerr << "  Canon Input: " <<  canon_input << "\n";
-      std::cerr << "  Canon Base: " << canon_base << "\n";
-
-      std::cerr << std::endl;
+      std::printf("TEST CASE #%d FAILED:\n"
+                  "  Input: '%s'\n"
+                  "  Base: '%s'\n"
+                  "  Expected: '%s'\n"
+                  "  Output: '%s'\n"
+                  "  Lex Prox: '%s'\n"
+                  "  Canon Input: '%s'\n"
+                  "  Canon Base: '%s'\n",
+        ID, TC.input.c_str(), TC.base.c_str(), TC.expect.c_str(),
+        output.native().c_str(), lexically_p.native().c_str(),
+        canon_input.c_str(), canon_base.c_str());
     }
   }
 }
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
index 15dd65f..e15012f 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
@@ -14,10 +14,8 @@
 // path weakly_canonical(const path& p, error_code& ec);
 
 #include "filesystem_include.h"
-#include <type_traits>
-#include <vector>
-#include <iostream>
-#include <cassert>
+#include <cstdio>
+#include <string>
 
 #include "test_macros.h"
 #include "test_iterators.h"
@@ -67,11 +65,11 @@
     const fs::path output = fs::weakly_canonical(p);
     if (!PathEq(output, TC.expect)) {
       Failed = true;
-      std::cerr << "TEST CASE #" << ID << " FAILED: \n";
-      std::cerr << "  Input: '" << TC.input << "'\n";
-      std::cerr << "  Expected: '" << TC.expect << "'\n";
-      std::cerr << "  Output: '" << output.native() << "'";
-      std::cerr << std::endl;
+      std::printf("TEST CASE #%d FAILED:\n"
+                  "  Input: '%s'\n"
+                  "  Expected: '%s'\n"
+                  "  Output: '%s'\n",
+        ID, TC.input.c_str(), TC.expect.c_str(), output.native().c_str());
     }
   }
   return Failed;
diff --git a/libcxx/test/std/input.output/filesystems/lit.local.cfg b/libcxx/test/std/input.output/filesystems/lit.local.cfg
index 99c45a7..682a2ab 100644
--- a/libcxx/test/std/input.output/filesystems/lit.local.cfg
+++ b/libcxx/test/std/input.output/filesystems/lit.local.cfg
@@ -1,5 +1,2 @@
-import os
-import sys
-
 if 'c++filesystem-disabled' in config.available_features:
   config.unsupported = True
diff --git a/libcxx/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp b/libcxx/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp
index 5a2e081..dd77f7d 100644
--- a/libcxx/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp
@@ -6,18 +6,17 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <cassert>
 #include <limits>
 #include <sstream>
-#include <cassert>
-#include <iostream>
+#include <string>
+#include <type_traits>
 
 #include "test_macros.h"
 
-using namespace std;
-
 template <class T>
 bool check_stream_failed(std::string const& val) {
-    istringstream ss(val);
+    std::istringstream ss(val);
     T result;
     return !(ss >> result);
 }
@@ -26,16 +25,16 @@
 void check_limits()
 {
     const bool is_unsigned = std::is_unsigned<T>::value;
-    T minv = numeric_limits<T>::min();
-    T maxv = numeric_limits<T>::max();
+    T minv = std::numeric_limits<T>::min();
+    T maxv = std::numeric_limits<T>::max();
 
-    ostringstream miniss, maxiss;
+    std::ostringstream miniss, maxiss;
     assert(miniss << minv);
     assert(maxiss << maxv);
     std::string mins = miniss.str();
     std::string maxs = maxiss.str();
 
-    istringstream maxoss(maxs), minoss(mins);
+    std::istringstream maxoss(maxs), minoss(mins);
 
     T new_minv, new_maxv;
     assert(maxoss >> new_maxv);
diff --git a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
index b1c814f..620408e 100644
--- a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -21,7 +21,6 @@
 
 #include <locale>
 #include <cassert>
-#include <iostream> // FIXME: for debugging purposes only
 
 #include "test_macros.h"
 #include "platform_support.h" // locale name macros
@@ -67,11 +66,6 @@
         {
             typedef char C;
             const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
-            if (np.thousands_sep() != sep) {
-              std::cout << "np.thousands_sep() = '" << np.thousands_sep() << "'\n";
-              std::cout << "sep = '" << sep << "'\n";
-              std::cout << std::endl;
-            }
             assert(np.thousands_sep() == sep);
         }
         {
@@ -81,5 +75,5 @@
         }
     }
 
-  return 0;
+    return 0;
 }
diff --git a/libcxx/test/std/namespace/addressable_functions.sh.cpp b/libcxx/test/std/namespace/addressable_functions.sh.cpp
index 3d5fe11..9b5e80e 100644
--- a/libcxx/test/std/namespace/addressable_functions.sh.cpp
+++ b/libcxx/test/std/namespace/addressable_functions.sh.cpp
@@ -18,8 +18,10 @@
 // RUN: %{exec} %t.exe
 
 #include <cassert>
-#include <iostream>
+#include <ios>
+#include <istream>
 #include <map>
+#include <ostream>
 #include <string>
 #include <utility>
 
diff --git a/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp b/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp
index affb284..322b502 100644
--- a/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp
@@ -19,7 +19,6 @@
 #include <algorithm>
 #include <cassert>
 #include <functional>
-#include <iostream>
 #include <iterator>
 #include <vector>
 
diff --git a/libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp b/libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
index 21087f4..301fb2f 100644
--- a/libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
@@ -21,7 +21,6 @@
 #include <algorithm>
 #include <cassert>
 #include <functional>
-#include <iostream>
 #include <iterator>
 #include <vector>
 
diff --git a/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp b/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
index bb9fa07..9caec15 100644
--- a/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
@@ -22,7 +22,6 @@
 #include <algorithm>
 #include <cassert>
 #include <functional>
-#include <iostream>
 #include <iterator>
 #include <vector>
 
@@ -85,8 +84,6 @@
     std::vector<size_t> v(10);
     std::fill(v.begin(), v.end(), 3);
     std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_one{});
-    std::copy(v.begin(), v.end(), std::ostream_iterator<size_t>(std::cout, " "));
-    std::cout << std::endl;
     for (size_t i = 0; i < v.size(); ++i)
         assert(v[i] == (i+1) * 4);
     }