[PATCH] Give libcxx tests temporary filenames that are actually unique.

Jon Roelofs jonathan at codesourcery.com
Mon Aug 18 15:51:40 PDT 2014


Hi danalbert,

With newlib as the libc, the following program would print out the same filename twice:

```
#include "support/platform_support.h"
#include <iostream>
int main() {
std::string temp1 = get_temp_file_name();
std::string temp2 = get_temp_file_name();
std::cout << temp1 << " " << temp2 << std::endl;
}
```

This breaks a few of the tests similar to input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp which expect the returned filenames to be different.

This patch fixes that bug by creating a TempFileName class which, on construction, is guaranteed to have a unique name.

Please double check the Windows side of the TempFileName class with extra scrutiny. I have neither tested, nor built this on Windows (and I don't have a machine to try it out on either).

http://reviews.llvm.org/D4962

Files:
  test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
  test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
  test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
  test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
  test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
  test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
  test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
  test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
  test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
  test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
  test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
  test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
  test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
  test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
  test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
  test/support/platform_support.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4962.12632.patch
Type: text/x-patch
Size: 54378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140818/892fa073/attachment.bin>


More information about the cfe-commits mailing list