[PATCH] D56336: [Support] unflake TempFileCollisions test
Bob Haarman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 12:44:32 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358914: [Support] unflake TempFileCollisions test (authored by inglorion, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D56336?vs=194421&id=196122#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56336/new/
https://reviews.llvm.org/D56336
Files:
llvm/trunk/unittests/Support/Path.cpp
Index: llvm/trunk/unittests/Support/Path.cpp
===================================================================
--- llvm/trunk/unittests/Support/Path.cpp
+++ llvm/trunk/unittests/Support/Path.cpp
@@ -700,10 +700,18 @@
}
};
- // We should be able to create exactly 16 temporary files.
- for (int i = 0; i < 16; ++i)
- EXPECT_TRUE(TryCreateTempFile());
- EXPECT_FALSE(TryCreateTempFile());
+ // Our single-character template allows for 16 unique names. Check that
+ // calling TryCreateTempFile repeatedly results in 16 successes.
+ // Because the test depends on random numbers, it could theoretically fail.
+ // However, the probability of this happening is tiny: with 32 calls, each
+ // of which will retry up to 128 times, to not get a given digit we would
+ // have to fail at least 15 + 17 * 128 = 2191 attempts. The probability of
+ // 2191 attempts not producing a given hexadecimal digit is
+ // (1 - 1/16) ** 2191 or 3.88e-62.
+ int Successes = 0;
+ for (int i = 0; i < 32; ++i)
+ if (TryCreateTempFile()) ++Successes;
+ EXPECT_EQ(Successes, 16);
for (fs::TempFile &T : TempFiles)
cantFail(T.discard());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56336.196122.patch
Type: text/x-patch
Size: 1154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190422/1abda9c3/attachment.bin>
More information about the llvm-commits
mailing list