Add info to documentation about random numbers, initialize srand (#2056)

Issue #2053 has highlighted the fact that random numbers are always generated with the same seed.
An example of generating different random numbers, other than the original seed, has been added to the documentation.
Furthermore srand initialization has been added to jerry-main, and targets.
Update test-common.h with srand call.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla [email protected]
This commit is contained in:
Daniel Balla authored and László Langó committed 2017-11-03 15:31:57 +01:00
1 parent 678fcb20ed
commit 4690d128b3
9 files changed
+52 -19

No files matched your search

+1 -19
View File
@@ -47,25 +47,7 @@
#define TEST_INIT() \
do \
{ \
FILE *f_rnd = fopen ("/dev/urandom", "r"); \
\
if (f_rnd == NULL) \
{ \
return 1; \
} \
\
uint32_t seed; \
\
size_t bytes_read = fread (&seed, 1, sizeof (seed), f_rnd); \
\
fclose (f_rnd); \
\
if (bytes_read != sizeof (seed)) \
{ \
return 1; \
} \
\
srand (seed); \
srand ((unsigned) jerry_port_get_current_time ()); \
} while (0)
#endif /* !TEST_COMMON_H */