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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@177755 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user