[PATCH] D56336: [Support] unflake TempFileCollisions test

Richard Smith - zygoloid via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 15 17:17:58 PST 2019


rsmith added a comment.
Herald added a project: LLVM.

This seems fine to me, but I think we can do better if we want to. How about: call `TryCreateTempFile()` //N// times, and check that it succeeds exactly 16 times. Pick //N// such that the probability of it failing to find all 16 possible file names (given that it has 128 retries for each call) is astronomically small. (Right now the test should fail somewhere around 0.03% of the time; if we made, say, 32 calls, the probability of a flake would be significantly lower than the probability of a flake due to spontaneous hardware failure (in order to flake, we must find only 15 of the 16 filenames with at least 17 * 128 + 15 guesses, the probability of which is 1 in 3.9x10^62).



================
Comment at: llvm/unittests/Support/Path.cpp:710
+  for (int i = 0; i < 17; ++i)
+    if (TryCreateTempFile()) Succeeded = false;
+  EXPECT_FALSE(Succeeded);
----------------
Is there a missing `!` here? It looks like this test would pass if at least one call succeeds rather than if at least one call fails.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56336/new/

https://reviews.llvm.org/D56336





More information about the llvm-commits mailing list