test time: Fixed bad assumption about RAND_MAX (#11414)

usleep range was up to 2147 Seconds

   Per open group: The rand() function shall compute a
   sequence of pseudo-random integers in the range
   [0, {RAND_MAX}]  with a period of at least 2^32

   {RAND_MAX} Maximum value returned by rand();
   at least 32767.

   /* Maximum value returned by rand().  Must be a minimum of 32767. */

   #define RAND_MAX INT_MAX

  and

  #define INT_MAX     2147483647
This commit is contained in:
David Sidrane
2019-02-08 11:39:18 -08:00
committed by Daniel Agar
parent 2217faf812
commit c6edf41a74
+1 -1
View File
@@ -104,7 +104,7 @@ int test_time(int argc, char *argv[])
/* loop checking the time */
for (unsigned i = 0; i < 100; i++) {
usleep(rand());
usleep(rand() % SHRT_MAX);
uint32_t flags = px4_enter_critical_section();