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

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


Update the patch to reflect @danalbert's comments.

http://reviews.llvm.org/D4962

Files:
  test/support/platform_support.h

Index: test/support/platform_support.h
===================================================================
--- test/support/platform_support.h
+++ test/support/platform_support.h
@@ -50,13 +50,23 @@
 std::string
 get_temp_file_name()
 {
-   std::string s("temp.XXXXXX");
 #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
-   _mktemp(&s[0]);
+    char Path[MAX_PATH+1];
+    char FN[MAX_PATH+1];
+    do { } while (0 == GetTempPath(MAX_PATH+1, Path));
+    do { } while (0 == GetTempFile(Path, "libcxx", 0, FN));
+    return FN;
 #else
-   mktemp(&s[0]);
+    std::string Name;
+    int FD = -1;
+    do {
+      Name = "libcxx.XXXXXX";
+      FD = mkstemp(&Name[0]);
+      assert(errno != EINVAL && "Something is wrong with the mkstemp's argument");
+    } while (FD == -1 || errno == EEXIST);
+    close(FD);
+    return Name;
 #endif
-   return s;
 }
 
 #endif // PLATFORM_SUPPORT_H
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4962.12640.patch
Type: text/x-patch
Size: 889 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140819/ba9dfc1f/attachment.bin>


More information about the cfe-commits mailing list