summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-03-22 20:05:40 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-03-22 20:05:40 +0000
commit7c5b88b134b0141c3ffda62534572a89d5a9640e (patch)
treec8e8b66f42f35f8d2249a4dc62dbcf9275bf688e /libcxx/test
parent7c8dbc12bb73c1d42307e784410a1d5383461732 (diff)
downloadbcm5719-llvm-7c5b88b134b0141c3ffda62534572a89d5a9640e.tar.gz
bcm5719-llvm-7c5b88b134b0141c3ffda62534572a89d5a9640e.zip
Test cleanup with respect to use of deprecated tmpnam function. Also Windows port for these tests to use _tempnam. The bulk of this patch was donated anonymously. I've tested it on OS X and accept responsibility for it. If I've broken anyone's platform by switching from tmpnam to mktemp for the generation of temporary file names, just let me know. Should be easy to fix in test/support/platform_support.h
llvm-svn: 177755
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp16
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp22
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp22
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp8
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp30
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp16
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp30
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp16
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp16
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp16
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp12
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp16
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp16
-rw-r--r--libcxx/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp12
-rw-r--r--libcxx/test/support/platform_support.h21
25 files changed, 205 insertions, 184 deletions
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 10aa05d4524..86844343ecd 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
@@ -16,14 +16,14 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::filebuf f;
- assert(f.open(temp, std::ios_base::out | std::ios_base::in
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
@@ -35,10 +35,10 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wfilebuf f;
- assert(f.open(temp, std::ios_base::out | std::ios_base::in
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
@@ -50,5 +50,5 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
- remove(temp);
+ std::remove(temp.c_str());
}
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 739f99480c1..a92ec872a54 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
@@ -16,15 +16,15 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::filebuf f;
- assert(f.open(temp, std::ios_base::out | std::ios_base::in
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
@@ -36,10 +36,10 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wfilebuf f;
- assert(f.open(temp, std::ios_base::out | std::ios_base::in
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
@@ -51,6 +51,6 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
- remove(temp);
+ std::remove(temp.c_str());
#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 9a9b28ce483..084d001031d 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
@@ -18,14 +18,14 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::filebuf f;
- assert(f.open(temp, std::ios_base::out | std::ios_base::in
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
@@ -37,10 +37,10 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wfilebuf f;
- assert(f.open(temp, std::ios_base::out | std::ios_base::in
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
@@ -52,5 +52,5 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
- remove(temp);
+ std::remove(temp.c_str());
}
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 352a980913c..f13ee44700f 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
@@ -16,15 +16,15 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::filebuf f;
- assert(f.open(temp, std::ios_base::out | std::ios_base::in
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
@@ -35,10 +35,10 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == '2');
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wfilebuf f;
- assert(f.open(temp, std::ios_base::out | std::ios_base::in
+ assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
| std::ios_base::trunc) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
@@ -49,6 +49,6 @@ int main()
assert(f2.is_open());
assert(f2.sgetc() == L'2');
}
- remove(temp);
+ std::remove(temp.c_str());
#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 192e65f55ff..9d2d56782a3 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
@@ -13,39 +13,39 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::filebuf f;
- assert(f.open(temp, std::ios_base::out) != 0);
+ assert(f.open(temp.c_str(), std::ios_base::out) != 0);
assert(f.is_open());
assert(f.sputn("123", 3) == 3);
}
{
std::filebuf f;
- assert(f.open(temp, std::ios_base::in) != 0);
+ assert(f.open(temp.c_str(), std::ios_base::in) != 0);
assert(f.is_open());
assert(f.sbumpc() == '1');
assert(f.sbumpc() == '2');
assert(f.sbumpc() == '3');
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wfilebuf f;
- assert(f.open(temp, std::ios_base::out) != 0);
+ assert(f.open(temp.c_str(), std::ios_base::out) != 0);
assert(f.is_open());
assert(f.sputn(L"123", 3) == 3);
}
{
std::wfilebuf f;
- assert(f.open(temp, std::ios_base::in) != 0);
+ assert(f.open(temp.c_str(), 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(temp);
+ remove(temp.c_str());
}
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 4cae835ea50..fcc86a13ffa 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
@@ -16,16 +16,16 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp1[L_tmpnam], temp2[L_tmpnam];
- tmpnam(temp1);
- tmpnam(temp2);
+ std::string temp1 = get_temp_file_name();
+ std::string temp2 = get_temp_file_name();
{
- std::fstream fs1(temp1, std::ios_base::in | std::ios_base::out
+ std::fstream fs1(temp1.c_str(), 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::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs1 << 1 << ' ' << 2;
fs2 << 2 << ' ' << 1;
@@ -43,12 +43,12 @@ int main()
fs2 >> i;
assert(i == 2);
}
- std::remove(temp1);
- std::remove(temp2);
+ std::remove(temp1.c_str());
+ std::remove(temp2.c_str());
{
- std::wfstream fs1(temp1, std::ios_base::in | std::ios_base::out
+ std::wfstream fs1(temp1.c_str(), 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::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs1 << 1 << ' ' << 2;
fs2 << 2 << ' ' << 1;
@@ -66,6 +66,6 @@ int main()
fs2 >> i;
assert(i == 2);
}
- std::remove(temp1);
- std::remove(temp2);
+ std::remove(temp1.c_str());
+ std::remove(temp2.c_str());
}
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 51cf41fdf71..b5157e90edc 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
@@ -16,14 +16,14 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
- std::fstream fso(temp, std::ios_base::in | std::ios_base::out
+ std::fstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::fstream fs;
fs = move(fso);
@@ -33,9 +33,9 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
{
- std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
+ std::wfstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
std::wfstream fs;
fs = move(fso);
@@ -45,6 +45,6 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
#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 27ee8427f5a..0a4f7240daa 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
@@ -17,16 +17,16 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp1[L_tmpnam], temp2[L_tmpnam];
- tmpnam(temp1);
- tmpnam(temp2);
+ std::string temp1 = get_temp_file_name();
+ std::string temp2 = get_temp_file_name();
{
- std::fstream fs1(temp1, std::ios_base::in | std::ios_base::out
+ std::fstream fs1(temp1.c_str(), 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::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs1 << 1 << ' ' << 2;
fs2 << 2 << ' ' << 1;
@@ -44,12 +44,12 @@ int main()
fs2 >> i;
assert(i == 2);
}
- std::remove(temp1);
- std::remove(temp2);
+ std::remove(temp1.c_str());
+ std::remove(temp2.c_str());
{
- std::wfstream fs1(temp1, std::ios_base::in | std::ios_base::out
+ std::wfstream fs1(temp1.c_str(), 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::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fs1 << 1 << ' ' << 2;
fs2 << 2 << ' ' << 1;
@@ -67,6 +67,6 @@ int main()
fs2 >> i;
assert(i == 2);
}
- std::remove(temp1);
- std::remove(temp2);
+ std::remove(temp1.c_str());
+ std::remove(temp2.c_str());
}
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 28e3c95d4b2..d2ae3028606 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
@@ -16,12 +16,12 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::fstream fso(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
@@ -32,7 +32,7 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove("test.dat");
+ std::remove(temp.c_str());
{
std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
@@ -43,6 +43,6 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
#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 a31f9a1d543..06a6b77943a 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
@@ -16,13 +16,13 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
- std::fstream fs(temp, std::ios_base::in | std::ios_base::out
+ std::fstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
double x = 0;
fs << 3.25;
@@ -30,9 +30,9 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
{
- std::wfstream fs(temp, std::ios_base::in | std::ios_base::out
+ std::wfstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
double x = 0;
fs << 3.25;
@@ -40,5 +40,5 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
}
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 23795f010a5..4b0819f8af4 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
@@ -16,13 +16,13 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
- std::fstream fs(std::string(temp),
+ std::fstream fs(temp,
std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
double x = 0;
@@ -31,9 +31,9 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
{
- std::wfstream fs(std::string(temp),
+ std::wfstream fs(temp,
std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
double x = 0;
@@ -42,5 +42,5 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
}
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 94b91806f81..0e4bc7177b8 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
@@ -16,27 +16,27 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::fstream fs;
assert(!fs.is_open());
- fs.open(temp, std::ios_base::out);
+ fs.open(temp.c_str(), std::ios_base::out);
assert(fs.is_open());
fs.close();
assert(!fs.is_open());
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wfstream fs;
assert(!fs.is_open());
- fs.open(temp, std::ios_base::out);
+ fs.open(temp.c_str(), std::ios_base::out);
assert(fs.is_open());
fs.close();
assert(!fs.is_open());
}
- remove(temp);
+ std::remove(temp.c_str());
}
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 64c4de9dfe7..231bb82c743 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
@@ -16,15 +16,15 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::fstream fs;
assert(!fs.is_open());
- fs.open(temp, std::ios_base::in | std::ios_base::out
+ fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
assert(fs.is_open());
double x = 0;
@@ -33,11 +33,11 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
{
std::wfstream fs;
assert(!fs.is_open());
- fs.open(temp, std::ios_base::in | std::ios_base::out
+ fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
assert(fs.is_open());
double x = 0;
@@ -46,5 +46,5 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
}
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 a61a4e965d3..182f12c47d1 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
@@ -16,15 +16,15 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::fstream fs;
assert(!fs.is_open());
- fs.open(std::string(temp), std::ios_base::in | std::ios_base::out
+ fs.open(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
assert(fs.is_open());
double x = 0;
@@ -33,11 +33,11 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
{
std::wfstream fs;
assert(!fs.is_open());
- fs.open(std::string(temp), std::ios_base::in | std::ios_base::out
+ fs.open(temp, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
assert(fs.is_open());
double x = 0;
@@ -46,5 +46,5 @@ int main()
fs >> x;
assert(x == 3.25);
}
- std::remove(temp);
+ std::remove(temp.c_str());
}
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 7800c1abe8b..519b84fb1ab 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
@@ -16,15 +16,15 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp1[L_tmpnam], temp2[L_tmpnam];
- tmpnam(temp1);
- tmpnam(temp2);
+ std::string temp1 = get_temp_file_name();
+ std::string temp2 = get_temp_file_name();
{
- std::ofstream fs1(temp1);
- std::ofstream fs2(temp2);
+ std::ofstream fs1(temp1.c_str());
+ std::ofstream fs2(temp2.c_str());
fs1 << 3.25;
fs2 << 4.5;
fs1.swap(fs2);
@@ -32,26 +32,26 @@ int main()
fs2 << ' ' << 4.5;
}
{
- std::ifstream fs(temp1);
+ std::ifstream fs(temp1.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
- remove(temp1);
+ std::remove(temp1.c_str());
{
- std::ifstream fs(temp2);
+ std::ifstream fs(temp2.c_str());
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
- remove(temp2);
+ std::remove(temp2.c_str());
{
- std::wofstream fs1(temp1);
- std::wofstream fs2(temp2);
+ std::wofstream fs1(temp1.c_str());
+ std::wofstream fs2(temp2.c_str());
fs1 << 3.25;
fs2 << 4.5;
fs1.swap(fs2);
@@ -59,21 +59,21 @@ int main()
fs2 << ' ' << 4.5;
}
{
- std::wifstream fs(temp1);
+ std::wifstream fs(temp1.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
- remove(temp1);
+ std::remove(temp1.c_str());
{
- std::wifstream fs(temp2);
+ std::wifstream fs(temp2.c_str());
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
- remove(temp2);
+ std::remove(temp2.c_str());
}
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 7f80cfcc512..0f21eb81d07 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
@@ -16,37 +16,37 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
- std::ofstream fso(temp);
+ std::ofstream fso(temp.c_str());
std::ofstream fs;
fs = move(fso);
fs << 3.25;
}
{
- std::ifstream fs(temp);
+ std::ifstream fs(temp.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove(temp);
+ std::remove(temp.c_str());
{
- std::wofstream fso(temp);
+ std::wofstream fso(temp.c_str());
std::wofstream fs;
fs = move(fso);
fs << 3.25;
}
{
- std::wifstream fs(temp);
+ std::wifstream fs(temp.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove(temp);
+ std::remove(temp.c_str());
#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 24deafdcf5c..d58f5f25600 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
@@ -17,15 +17,15 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp1[L_tmpnam], temp2[L_tmpnam];
- tmpnam(temp1);
- tmpnam(temp2);
+ std::string temp1 = get_temp_file_name();
+ std::string temp2 = get_temp_file_name();
{
- std::ofstream fs1(temp1);
- std::ofstream fs2(temp2);
+ std::ofstream fs1(temp1.c_str());
+ std::ofstream fs2(temp2.c_str());
fs1 << 3.25;
fs2 << 4.5;
swap(fs1, fs2);
@@ -33,26 +33,26 @@ int main()
fs2 << ' ' << 4.5;
}
{
- std::ifstream fs(temp1);
+ std::ifstream fs(temp1.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
- remove(temp1);
+ std::remove(temp1.c_str());
{
- std::ifstream fs(temp2);
+ std::ifstream fs(temp2.c_str());
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
- remove(temp2);
+ std::remove(temp2.c_str());
{
- std::wofstream fs1(temp1);
- std::wofstream fs2(temp2);
+ std::wofstream fs1(temp1.c_str());
+ std::wofstream fs2(temp2.c_str());
fs1 << 3.25;
fs2 << 4.5;
swap(fs1, fs2);
@@ -60,21 +60,21 @@ int main()
fs2 << ' ' << 4.5;
}
{
- std::wifstream fs(temp1);
+ std::wifstream fs(temp1.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
fs >> x;
assert(x == 4.5);
}
- remove(temp1);
+ std::remove(temp1.c_str());
{
- std::wifstream fs(temp2);
+ std::wifstream fs(temp2.c_str());
double x = 0;
fs >> x;
assert(x == 4.5);
fs >> x;
assert(x == 3.25);
}
- remove(temp2);
+ std::remove(temp2.c_str());
}
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 93bea0e486e..8645358cbd4 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
@@ -16,35 +16,35 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
- std::ofstream fso(temp);
+ std::ofstream fso(temp.c_str());
std::ofstream fs = move(fso);
fs << 3.25;
}
{
- std::ifstream fs(temp);
+ std::ifstream fs(temp.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove(temp);
+ std::remove(temp.c_str());
{
- std::wofstream fso(temp);
+ std::wofstream fso(temp.c_str());
std::wofstream fs = move(fso);
fs << 3.25;
}
{
- std::wifstream fs(temp);
+ std::wifstream fs(temp.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove(temp);
+ std::remove(temp.c_str());
#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 7d899e776bb..bd5832abeb5 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
@@ -16,31 +16,31 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
- std::ofstream fs(temp);
+ std::ofstream fs(temp.c_str());
fs << 3.25;
}
{
- std::ifstream fs(temp);
+ std::ifstream fs(temp.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove(temp);
+ std::remove(temp.c_str());
{
- std::wofstream fs(temp);
+ std::wofstream fs(temp.c_str());
fs << 3.25;
}
{
- std::wifstream fs(temp);
+ std::wifstream fs(temp.c_str());
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove(temp);
+ std::remove(temp.c_str());
}
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 67dd02aebb0..7112b17fb8b 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
@@ -16,31 +16,31 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
- std::ofstream fs((std::string(temp)));
+ std::ofstream fs(temp);
fs << 3.25;
}
{
- std::ifstream fs((std::string(temp)));
+ std::ifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove(temp);
+ std::remove(temp.c_str());
{
- std::wofstream fs((std::string(temp)));
+ std::wofstream fs(temp);
fs << 3.25;
}
{
- std::wifstream fs((std::string(temp)));
+ std::wifstream fs(temp);
double x = 0;
fs >> x;
assert(x == 3.25);
}
- remove(temp);
+ std::remove(temp.c_str());
}
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 ad3f3783cee..b8c358d8ece 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
@@ -16,27 +16,27 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::ofstream fs;
assert(!fs.is_open());
- fs.open(temp);
+ fs.open(temp.c_str());
assert(fs.is_open());
fs.close();
assert(!fs.is_open());
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wofstream fs;
assert(!fs.is_open());
- fs.open(temp);
+ fs.open(temp.c_str());
assert(fs.is_open());
fs.close();
assert(!fs.is_open());
}
- remove(temp);
+ std::remove(temp.c_str());
}
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 bf8e6a5ca2f..e5cddc9e164 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
@@ -16,43 +16,43 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::ofstream fs;
assert(!fs.is_open());
char c = 'a';
fs << c;
assert(fs.fail());
- fs.open(temp);
+ fs.open(temp.c_str());
assert(fs.is_open());
fs << c;
}
{
- std::ifstream fs(temp);
+ std::ifstream fs(temp.c_str());
char c = 0;
fs >> c;
assert(c == 'a');
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wofstream fs;
assert(!fs.is_open());
wchar_t c = L'a';
fs << c;
assert(fs.fail());
- fs.open(temp);
+ fs.open(temp.c_str());
assert(fs.is_open());
fs << c;
}
{
- std::wifstream fs(temp);
+ std::wifstream fs(temp.c_str());
wchar_t c = 0;
fs >> c;
assert(c == L'a');
}
- remove(temp);
+ std::remove(temp.c_str());
}
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 b33114d9725..d54aa1824ab 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
@@ -16,43 +16,43 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
std::ofstream fs;
assert(!fs.is_open());
char c = 'a';
fs << c;
assert(fs.fail());
- fs.open(std::string(temp));
+ fs.open(temp);
assert(fs.is_open());
fs << c;
}
{
- std::ifstream fs(temp);
+ std::ifstream fs(temp.c_str());
char c = 0;
fs >> c;
assert(c == 'a');
}
- remove(temp);
+ std::remove(temp.c_str());
{
std::wofstream fs;
assert(!fs.is_open());
wchar_t c = L'a';
fs << c;
assert(fs.fail());
- fs.open(std::string(temp));
+ fs.open(temp);
assert(fs.is_open());
fs << c;
}
{
- std::wifstream fs(temp);
+ std::wifstream fs(temp.c_str());
wchar_t c = 0;
fs >> c;
assert(c == L'a');
}
- remove(temp);
+ std::remove(temp.c_str());
}
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 8860c9ae92c..d707e0a32ac 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
@@ -16,21 +16,21 @@
#include <fstream>
#include <cassert>
+#include "platform_support.h"
int main()
{
- char temp[L_tmpnam];
- tmpnam(temp);
+ std::string temp = get_temp_file_name();
{
- std::ofstream fs(temp);
+ std::ofstream fs(temp.c_str());
std::filebuf* fb = fs.rdbuf();
assert(fb->sputc('r') == 'r');
}
- remove(temp);
+ std::remove(temp.c_str());
{
- std::wofstream fs(temp);
+ std::wofstream fs(temp.c_str());
std::wfilebuf* fb = fs.rdbuf();
assert(fb->sputc(L'r') == L'r');
}
- remove(temp);
+ std::remove(temp.c_str());
}
diff --git a/libcxx/test/support/platform_support.h b/libcxx/test/support/platform_support.h
index 0035975019a..4633ce047f0 100644
--- a/libcxx/test/support/platform_support.h
+++ b/libcxx/test/support/platform_support.h
@@ -39,4 +39,25 @@
#define LOCALE_zh_CN_UTF_8 "zh_CN.UTF-8"
#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+
+inline
+std::string
+get_temp_file_name()
+{
+#ifdef _WIN32
+ char* p = _tempnam( NULL, NULL );
+ if (p == nullptr)
+ abort();
+ std::string s(p);
+ free( p );
+#else
+ std::string s("temp.XXXX");
+ mktemp(&s[0]);
+#endif
+ return s;
+}
+
#endif // PLATFORM_SUPPORT_H
OpenPOWER on IntegriCloud