1 #define _XOPEN_SOURCE 700
6 /* naive statistical checks */
9 static int chkmissing(long *x
)
13 for (i
= 0; i
< 100; i
++)
15 for (i
= 0; i
< 8; i
++)
22 static int chkrepeat(long *x
)
25 for (i
= 0; i
< 100; i
++)
26 for (j
= 0; j
< i
; j
++)
34 static int chkones(long *x
)
38 for (i
= 0; i
< 20; i
++)
40 return orx
!= 0x7fffffff;
43 void checkseed(unsigned seed
, long *x
)
47 for (i
= 0; i
< 100; i
++)
50 t_error("weak seed %d, missing pattern in low bits\n", seed
);
52 t_error("weak seed %d, exact repeats\n", seed
);
54 t_error("weak seed %d, or pattern: 0x%08x\n", seed
, orx
);
66 for (i
= 0; i
< 100; i
++)
68 p
= initstate(1, state
, sizeof state
);
69 for (i
= 0; i
< 100; i
++)
70 if (x
[i
] != (y
= random()))
71 t_error("initstate(1) is not default: (%d) default: %ld, seed1: %ld\n", i
, x
[i
], y
);
72 for (i
= 0; i
< 10; i
++) {
75 if (z
!= (y
= random()))
76 t_error("setstate failed (%d) orig: %ld, reset: %ld\n", i
, z
, y
);
80 for (i
= 0; i
< 100; i
++)
81 if (x
[i
] != (y
= random()))
82 t_error("srandom(1) is not default: (%d) default: %ld, seed1: %ld\n", i
, x
[i
], y
);
83 checkseed(0x7fffffff, x
);
84 for (i
= 0; i
< 10; i
++)