[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Better failure message on stochastic test failure



commit 81f1b89efc94723f2c13b0b80d311364a2245d85
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Jan 17 16:24:08 2019 -0500

    Better failure message on stochastic test failure
---
 src/test/test_prob_distr.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/test/test_prob_distr.c b/src/test/test_prob_distr.c
index 114057fec..42cc6d70f 100644
--- a/src/test/test_prob_distr.c
+++ b/src/test/test_prob_distr.c
@@ -1137,7 +1137,11 @@ teardown_deterministic_rand(void)
 static void
 dump_seed(void)
 {
-  printf("\nSeed: %s\n",
+  printf("\n"
+         "NOTE: This is a stochastic test, and we expect it to fail from\n"
+         "time to time, with some low probability. If you see it fail more\n"
+         "than one trial in 100, though, please tell us.\n\n"
+         "Seed: %s\n",
          hex_str((const char*)rng_seed, sizeof(rng_seed)));
 }
 
@@ -1190,7 +1194,7 @@ test_stochastic_uniform(void *arg)
     .a = -4e-324,
     .b = 4e-310,
   };
-  bool ok = true;
+  bool ok = true, tests_failed = true;
 
   init_deterministic_rand();
   MOCK(crypto_rand, crypto_rand_deterministic);
@@ -1204,8 +1208,14 @@ test_stochastic_uniform(void *arg)
 
   tt_assert(ok);
 
+  tests_failed = false;
+
  done:
-    ;
+  if (tests_failed) {
+    dump_seed();
+  }
+  teardown_deterministic_rand();
+  UNMOCK(crypto_rand);
 }
 
 static bool

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits