Make all fstream tests use tmpnam if creating files, rather than
hard-coded names.

llvm-svn: 135444
diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
index da47daa..10aa05d 100644
--- a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
@@ -19,10 +19,12 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::filebuf f;
-        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
-                                                     | std::ios_base::trunc) != 0);
+        assert(f.open(temp, std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
         assert(f.is_open());
         assert(f.sputn("123", 3) == 3);
         f.pubseekoff(1, std::ios_base::beg);
@@ -33,11 +35,11 @@
         assert(f2.is_open());
         assert(f2.sgetc() == '2');
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wfilebuf f;
-        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
-                                                     | std::ios_base::trunc) != 0);
+        assert(f.open(temp, std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
         assert(f.is_open());
         assert(f.sputn(L"123", 3) == 3);
         f.pubseekoff(1, std::ios_base::beg);
@@ -48,5 +50,5 @@
         assert(f2.is_open());
         assert(f2.sgetc() == L'2');
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
index 0b646f8..739f994 100644
--- a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
@@ -20,10 +20,12 @@
 int main()
 {
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::filebuf f;
-        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
-                                                     | std::ios_base::trunc) != 0);
+        assert(f.open(temp, std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
         assert(f.is_open());
         assert(f.sputn("123", 3) == 3);
         f.pubseekoff(1, std::ios_base::beg);
@@ -34,11 +36,11 @@
         assert(f2.is_open());
         assert(f2.sgetc() == '2');
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wfilebuf f;
-        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
-                                                     | std::ios_base::trunc) != 0);
+        assert(f.open(temp, std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
         assert(f.is_open());
         assert(f.sputn(L"123", 3) == 3);
         f.pubseekoff(1, std::ios_base::beg);
@@ -49,6 +51,6 @@
         assert(f2.is_open());
         assert(f2.sgetc() == L'2');
     }
-    remove("test.dat");
+    remove(temp);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
index 8406033..9a9b28c 100644
--- a/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
@@ -21,10 +21,12 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::filebuf f;
-        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
-                                                     | std::ios_base::trunc) != 0);
+        assert(f.open(temp, std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
         assert(f.is_open());
         assert(f.sputn("123", 3) == 3);
         f.pubseekoff(1, std::ios_base::beg);
@@ -35,11 +37,11 @@
         assert(f2.is_open());
         assert(f2.sgetc() == '2');
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wfilebuf f;
-        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
-                                                     | std::ios_base::trunc) != 0);
+        assert(f.open(temp, std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
         assert(f.is_open());
         assert(f.sputn(L"123", 3) == 3);
         f.pubseekoff(1, std::ios_base::beg);
@@ -50,5 +52,5 @@
         assert(f2.is_open());
         assert(f2.sgetc() == L'2');
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
index 77e5058..352a980 100644
--- a/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
@@ -20,10 +20,12 @@
 int main()
 {
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::filebuf f;
-        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
-                                                     | std::ios_base::trunc) != 0);
+        assert(f.open(temp, std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
         assert(f.is_open());
         assert(f.sputn("123", 3) == 3);
         f.pubseekoff(1, std::ios_base::beg);
@@ -33,11 +35,11 @@
         assert(f2.is_open());
         assert(f2.sgetc() == '2');
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wfilebuf f;
-        assert(f.open("test.dat", std::ios_base::out | std::ios_base::in
-                                                     | std::ios_base::trunc) != 0);
+        assert(f.open(temp, std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
         assert(f.is_open());
         assert(f.sputn(L"123", 3) == 3);
         f.pubseekoff(1, std::ios_base::beg);
@@ -47,6 +49,6 @@
         assert(f2.is_open());
         assert(f2.sgetc() == L'2');
     }
-    remove("test.dat");
+    remove(temp);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
index b685c66..192e65f 100644
--- a/libcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
@@ -16,34 +16,36 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::filebuf f;
-        assert(f.open("test.dat", std::ios_base::out) != 0);
+        assert(f.open(temp, std::ios_base::out) != 0);
         assert(f.is_open());
         assert(f.sputn("123", 3) == 3);
     }
     {
         std::filebuf f;
-        assert(f.open("test.dat", std::ios_base::in) != 0);
+        assert(f.open(temp, std::ios_base::in) != 0);
         assert(f.is_open());
         assert(f.sbumpc() == '1');
         assert(f.sbumpc() == '2');
         assert(f.sbumpc() == '3');
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wfilebuf f;
-        assert(f.open("test.dat", std::ios_base::out) != 0);
+        assert(f.open(temp, std::ios_base::out) != 0);
         assert(f.is_open());
         assert(f.sputn(L"123", 3) == 3);
     }
     {
         std::wfilebuf f;
-        assert(f.open("test.dat", std::ios_base::in) != 0);
+        assert(f.open(temp, std::ios_base::in) != 0);
         assert(f.is_open());
         assert(f.sbumpc() == L'1');
         assert(f.sbumpc() == L'2');
         assert(f.sbumpc() == L'3');
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
index e717cc5..4cae835 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
@@ -19,11 +19,14 @@
 
 int main()
 {
+    char temp1[L_tmpnam], temp2[L_tmpnam];
+    tmpnam(temp1);
+    tmpnam(temp2);
     {
-        std::fstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
-                                                        | std::ios_base::trunc);
-        std::fstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
-                                                        | std::ios_base::trunc);
+        std::fstream fs1(temp1, std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
+        std::fstream fs2(temp2, std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
         fs1 << 1 << ' ' << 2;
         fs2 << 2 << ' ' << 1;
         fs1.seekg(0);
@@ -40,13 +43,13 @@
         fs2 >> i;
         assert(i == 2);
     }
-    std::remove("test1.dat");
-    std::remove("test2.dat");
+    std::remove(temp1);
+    std::remove(temp2);
     {
-        std::wfstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
-                                                         | std::ios_base::trunc);
-        std::wfstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
-                                                         | std::ios_base::trunc);
+        std::wfstream fs1(temp1, std::ios_base::in | std::ios_base::out
+                                                   | std::ios_base::trunc);
+        std::wfstream fs2(temp2, std::ios_base::in | std::ios_base::out
+                                                   | std::ios_base::trunc);
         fs1 << 1 << ' ' << 2;
         fs2 << 2 << ' ' << 1;
         fs1.seekg(0);
@@ -63,6 +66,6 @@
         fs2 >> i;
         assert(i == 2);
     }
-    std::remove("test1.dat");
-    std::remove("test2.dat");
+    std::remove(temp1);
+    std::remove(temp2);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
index 9504aea..09b4f74 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
@@ -20,9 +20,10 @@
 int main()
 {
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    char temp[L_tmpnam];
     {
-        std::fstream fso("test.dat", std::ios_base::in | std::ios_base::out
-                                                       | std::ios_base::trunc);
+        std::fstream fso(temp, std::ios_base::in | std::ios_base::out
+                                                 | std::ios_base::trunc);
         std::fstream fs;
         fs = move(fso);
         double x = 0;
@@ -31,10 +32,10 @@
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
     {
-        std::wfstream fso("test.dat", std::ios_base::in | std::ios_base::out
-                                                        | std::ios_base::trunc);
+        std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
         std::wfstream fs;
         fs = move(fso);
         double x = 0;
@@ -43,6 +44,6 @@
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
index 0cc43ca..27ee842 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
@@ -20,11 +20,14 @@
 
 int main()
 {
+    char temp1[L_tmpnam], temp2[L_tmpnam];
+    tmpnam(temp1);
+    tmpnam(temp2);
     {
-        std::fstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
-                                                        | std::ios_base::trunc);
-        std::fstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
-                                                        | std::ios_base::trunc);
+        std::fstream fs1(temp1, std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
+        std::fstream fs2(temp2, std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
         fs1 << 1 << ' ' << 2;
         fs2 << 2 << ' ' << 1;
         fs1.seekg(0);
@@ -41,13 +44,13 @@
         fs2 >> i;
         assert(i == 2);
     }
-    std::remove("test1.dat");
-    std::remove("test2.dat");
+    std::remove(temp1);
+    std::remove(temp2);
     {
-        std::wfstream fs1("test1.dat", std::ios_base::in | std::ios_base::out
-                                                         | std::ios_base::trunc);
-        std::wfstream fs2("test2.dat", std::ios_base::in | std::ios_base::out
-                                                         | std::ios_base::trunc);
+        std::wfstream fs1(temp1, std::ios_base::in | std::ios_base::out
+                                                   | std::ios_base::trunc);
+        std::wfstream fs2(temp2, std::ios_base::in | std::ios_base::out
+                                                   | std::ios_base::trunc);
         fs1 << 1 << ' ' << 2;
         fs2 << 2 << ' ' << 1;
         fs1.seekg(0);
@@ -64,6 +67,6 @@
         fs2 >> i;
         assert(i == 2);
     }
-    std::remove("test1.dat");
-    std::remove("test2.dat");
+    std::remove(temp1);
+    std::remove(temp2);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
index 7eb41cf..28e3c95 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
@@ -20,9 +20,11 @@
 int main()
 {
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
-        std::fstream fso("test.dat", std::ios_base::in | std::ios_base::out
-                                                       | std::ios_base::trunc);
+        std::fstream fso(temp, std::ios_base::in | std::ios_base::out
+                                                 | std::ios_base::trunc);
         std::fstream fs = move(fso);
         double x = 0;
         fs << 3.25;
@@ -32,8 +34,8 @@
     }
     std::remove("test.dat");
     {
-        std::wfstream fso("test.dat", std::ios_base::in | std::ios_base::out
-                                                        | std::ios_base::trunc);
+        std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
         std::wfstream fs = move(fso);
         double x = 0;
         fs << 3.25;
@@ -41,6 +43,6 @@
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
index 45b8f0a..a31f9a1 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
@@ -19,24 +19,26 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
-        std::fstream fs("test.dat", std::ios_base::in | std::ios_base::out
-                                                      | std::ios_base::trunc);
+        std::fstream fs(temp, std::ios_base::in | std::ios_base::out
+                                                | std::ios_base::trunc);
         double x = 0;
         fs << 3.25;
         fs.seekg(0);
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
     {
-        std::wfstream fs("test.dat", std::ios_base::in | std::ios_base::out
-                                                       | std::ios_base::trunc);
+        std::wfstream fs(temp, std::ios_base::in | std::ios_base::out
+                                                 | std::ios_base::trunc);
         double x = 0;
         fs << 3.25;
         fs.seekg(0);
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
index c287291..23795f0 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
@@ -19,7 +19,7 @@
 
 int main()
 {
-    char temp [L_tmpnam];
+    char temp[L_tmpnam];
     tmpnam(temp);
     {
         std::fstream fs(std::string(temp),
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
index 1aa37df..94b9180 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
@@ -19,22 +19,24 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::fstream fs;
         assert(!fs.is_open());
-        fs.open("test.dat", std::ios_base::out);
+        fs.open(temp, std::ios_base::out);
         assert(fs.is_open());
         fs.close();
         assert(!fs.is_open());
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wfstream fs;
         assert(!fs.is_open());
-        fs.open("test.dat", std::ios_base::out);
+        fs.open(temp, std::ios_base::out);
         assert(fs.is_open());
         fs.close();
         assert(!fs.is_open());
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
index 4d291ef..64c4de9 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
@@ -19,11 +19,13 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::fstream fs;
         assert(!fs.is_open());
-        fs.open("test.dat", std::ios_base::in | std::ios_base::out
-                                              | std::ios_base::trunc);
+        fs.open(temp, std::ios_base::in | std::ios_base::out
+                                        | std::ios_base::trunc);
         assert(fs.is_open());
         double x = 0;
         fs << 3.25;
@@ -31,12 +33,12 @@
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
     {
         std::wfstream fs;
         assert(!fs.is_open());
-        fs.open("test.dat", std::ios_base::in | std::ios_base::out
-                                              | std::ios_base::trunc);
+        fs.open(temp, std::ios_base::in | std::ios_base::out
+                                        | std::ios_base::trunc);
         assert(fs.is_open());
         double x = 0;
         fs << 3.25;
@@ -44,5 +46,5 @@
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
index a8e871b..a61a4e9 100644
--- a/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
@@ -19,11 +19,13 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::fstream fs;
         assert(!fs.is_open());
-        fs.open(std::string("test.dat"), std::ios_base::in | std::ios_base::out
-                                                           | std::ios_base::trunc);
+        fs.open(std::string(temp), std::ios_base::in | std::ios_base::out
+                                                     | std::ios_base::trunc);
         assert(fs.is_open());
         double x = 0;
         fs << 3.25;
@@ -31,12 +33,12 @@
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
     {
         std::wfstream fs;
         assert(!fs.is_open());
-        fs.open(std::string("test.dat"), std::ios_base::in | std::ios_base::out
-                                                           | std::ios_base::trunc);
+        fs.open(std::string(temp), std::ios_base::in | std::ios_base::out
+                                                     | std::ios_base::trunc);
         assert(fs.is_open());
         double x = 0;
         fs << 3.25;
@@ -44,5 +46,5 @@
         fs >> x;
         assert(x == 3.25);
     }
-    std::remove("test.dat");
+    std::remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
index 1f3f457..7800c1a 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
@@ -19,9 +19,12 @@
 
 int main()
 {
+    char temp1[L_tmpnam], temp2[L_tmpnam];
+    tmpnam(temp1);
+    tmpnam(temp2);
     {
-        std::ofstream fs1("test1.dat");
-        std::ofstream fs2("test2.dat");
+        std::ofstream fs1(temp1);
+        std::ofstream fs2(temp2);
         fs1 << 3.25;
         fs2 << 4.5;
         fs1.swap(fs2);
@@ -29,26 +32,26 @@
         fs2 << ' ' << 4.5;
     }
     {
-        std::ifstream fs("test1.dat");
+        std::ifstream fs(temp1);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
         fs >> x;
         assert(x == 4.5);
     }
-    remove("test1.dat");
+    remove(temp1);
     {
-        std::ifstream fs("test2.dat");
+        std::ifstream fs(temp2);
         double x = 0;
         fs >> x;
         assert(x == 4.5);
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test2.dat");
+    remove(temp2);
     {
-        std::wofstream fs1("test1.dat");
-        std::wofstream fs2("test2.dat");
+        std::wofstream fs1(temp1);
+        std::wofstream fs2(temp2);
         fs1 << 3.25;
         fs2 << 4.5;
         fs1.swap(fs2);
@@ -56,21 +59,21 @@
         fs2 << ' ' << 4.5;
     }
     {
-        std::wifstream fs("test1.dat");
+        std::wifstream fs(temp1);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
         fs >> x;
         assert(x == 4.5);
     }
-    remove("test1.dat");
+    remove(temp1);
     {
-        std::wifstream fs("test2.dat");
+        std::wifstream fs(temp2);
         double x = 0;
         fs >> x;
         assert(x == 4.5);
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test2.dat");
+    remove(temp2);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
index 55aa3a2..7f80cfc 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
@@ -20,31 +20,33 @@
 int main()
 {
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
-        std::ofstream fso("test.dat");
+        std::ofstream fso(temp);
         std::ofstream fs;
         fs = move(fso);
         fs << 3.25;
     }
     {
-        std::ifstream fs("test.dat");
+        std::ifstream fs(temp);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test.dat");
+    remove(temp);
     {
-        std::wofstream fso("test.dat");
+        std::wofstream fso(temp);
         std::wofstream fs;
         fs = move(fso);
         fs << 3.25;
     }
     {
-        std::wifstream fs("test.dat");
+        std::wifstream fs(temp);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test.dat");
+    remove(temp);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
index 8834cf39..24deafd 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
@@ -20,9 +20,12 @@
 
 int main()
 {
+    char temp1[L_tmpnam], temp2[L_tmpnam];
+    tmpnam(temp1);
+    tmpnam(temp2);
     {
-        std::ofstream fs1("test1.dat");
-        std::ofstream fs2("test2.dat");
+        std::ofstream fs1(temp1);
+        std::ofstream fs2(temp2);
         fs1 << 3.25;
         fs2 << 4.5;
         swap(fs1, fs2);
@@ -30,26 +33,26 @@
         fs2 << ' ' << 4.5;
     }
     {
-        std::ifstream fs("test1.dat");
+        std::ifstream fs(temp1);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
         fs >> x;
         assert(x == 4.5);
     }
-    remove("test1.dat");
+    remove(temp1);
     {
-        std::ifstream fs("test2.dat");
+        std::ifstream fs(temp2);
         double x = 0;
         fs >> x;
         assert(x == 4.5);
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test2.dat");
+    remove(temp2);
     {
-        std::wofstream fs1("test1.dat");
-        std::wofstream fs2("test2.dat");
+        std::wofstream fs1(temp1);
+        std::wofstream fs2(temp2);
         fs1 << 3.25;
         fs2 << 4.5;
         swap(fs1, fs2);
@@ -57,21 +60,21 @@
         fs2 << ' ' << 4.5;
     }
     {
-        std::wifstream fs("test1.dat");
+        std::wifstream fs(temp1);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
         fs >> x;
         assert(x == 4.5);
     }
-    remove("test1.dat");
+    remove(temp1);
     {
-        std::wifstream fs("test2.dat");
+        std::wifstream fs(temp2);
         double x = 0;
         fs >> x;
         assert(x == 4.5);
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test2.dat");
+    remove(temp2);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
index e230c70..93bea0e 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
@@ -20,29 +20,31 @@
 int main()
 {
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
-        std::ofstream fso("test.dat");
+        std::ofstream fso(temp);
         std::ofstream fs = move(fso);
         fs << 3.25;
     }
     {
-        std::ifstream fs("test.dat");
+        std::ifstream fs(temp);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test.dat");
+    remove(temp);
     {
-        std::wofstream fso("test.dat");
+        std::wofstream fso(temp);
         std::wofstream fs = move(fso);
         fs << 3.25;
     }
     {
-        std::wifstream fs("test.dat");
+        std::wifstream fs(temp);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test.dat");
+    remove(temp);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
index 044fdc8..7d899e7 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
@@ -19,26 +19,28 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
-        std::ofstream fs("test.dat");
+        std::ofstream fs(temp);
         fs << 3.25;
     }
     {
-        std::ifstream fs("test.dat");
+        std::ifstream fs(temp);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test.dat");
+    remove(temp);
     {
-        std::wofstream fs("test.dat");
+        std::wofstream fs(temp);
         fs << 3.25;
     }
     {
-        std::wifstream fs("test.dat");
+        std::wifstream fs(temp);
         double x = 0;
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
index 2f1335d..67dd02a 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
@@ -19,26 +19,28 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
-        std::ofstream fs(std::string("test.dat"));
+        std::ofstream fs((std::string(temp)));
         fs << 3.25;
     }
     {
-        std::ifstream fs(std::string("test.dat"));
+        std::ifstream fs((std::string(temp)));
         double x = 0;
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test.dat");
+    remove(temp);
     {
-        std::wofstream fs(std::string("test.dat"));
+        std::wofstream fs((std::string(temp)));
         fs << 3.25;
     }
     {
-        std::wifstream fs(std::string("test.dat"));
+        std::wifstream fs((std::string(temp)));
         double x = 0;
         fs >> x;
         assert(x == 3.25);
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
index eb58c1a..ad3f378 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
@@ -19,22 +19,24 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::ofstream fs;
         assert(!fs.is_open());
-        fs.open("test.dat");
+        fs.open(temp);
         assert(fs.is_open());
         fs.close();
         assert(!fs.is_open());
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wofstream fs;
         assert(!fs.is_open());
-        fs.open("test.dat");
+        fs.open(temp);
         assert(fs.is_open());
         fs.close();
         assert(!fs.is_open());
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
index 6908559..bf8e6a5 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
@@ -19,38 +19,40 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::ofstream fs;
         assert(!fs.is_open());
         char c = 'a';
         fs << c;
         assert(fs.fail());
-        fs.open("test.dat");
+        fs.open(temp);
         assert(fs.is_open());
         fs << c;
     }
     {
-        std::ifstream fs("test.dat");
+        std::ifstream fs(temp);
         char c = 0;
         fs >> c;
         assert(c == 'a');
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wofstream fs;
         assert(!fs.is_open());
         wchar_t c = L'a';
         fs << c;
         assert(fs.fail());
-        fs.open("test.dat");
+        fs.open(temp);
         assert(fs.is_open());
         fs << c;
     }
     {
-        std::wifstream fs("test.dat");
+        std::wifstream fs(temp);
         wchar_t c = 0;
         fs >> c;
         assert(c == L'a');
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
index 6687a40..b33114d 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
@@ -19,38 +19,40 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
         std::ofstream fs;
         assert(!fs.is_open());
         char c = 'a';
         fs << c;
         assert(fs.fail());
-        fs.open(std::string("test.dat"));
+        fs.open(std::string(temp));
         assert(fs.is_open());
         fs << c;
     }
     {
-        std::ifstream fs("test.dat");
+        std::ifstream fs(temp);
         char c = 0;
         fs >> c;
         assert(c == 'a');
     }
-    remove("test.dat");
+    remove(temp);
     {
         std::wofstream fs;
         assert(!fs.is_open());
         wchar_t c = L'a';
         fs << c;
         assert(fs.fail());
-        fs.open(std::string("test.dat"));
+        fs.open(std::string(temp));
         assert(fs.is_open());
         fs << c;
     }
     {
-        std::wifstream fs("test.dat");
+        std::wifstream fs(temp);
         wchar_t c = 0;
         fs >> c;
         assert(c == L'a');
     }
-    remove("test.dat");
+    remove(temp);
 }
diff --git a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
index 436344d..8860c9a 100644
--- a/libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
+++ b/libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
@@ -19,16 +19,18 @@
 
 int main()
 {
+    char temp[L_tmpnam];
+    tmpnam(temp);
     {
-        std::ofstream fs("test.dat");
+        std::ofstream fs(temp);
         std::filebuf* fb = fs.rdbuf();
         assert(fb->sputc('r') == 'r');
     }
-    remove("test.dat");
+    remove(temp);
     {
-        std::wofstream fs("test.dat");
+        std::wofstream fs(temp);
         std::wfilebuf* fb = fs.rdbuf();
         assert(fb->sputc(L'r') == L'r');
     }
-    remove("test.dat");
+    remove(temp);
 }