This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ 14561] Testcase
- From: Roland McGrath <roland at hack dot frob dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: Carlos O'Donell <carlos at redhat dot com>, libc-alpha at sourceware dot org
- Date: Mon, 3 Jun 2013 14:12:55 -0700 (PDT)
- Subject: Re: [PATCH][BZ 14561] Testcase
- References: <20130520190628 dot GA22088 at domone dot kolej dot mff dot cuni dot cz> <519E93F3 dot 8060203 at redhat dot com> <20130603204113 dot GA26974 at domone dot kolej dot mff dot cuni dot cz>
> As testcases can be written independently I decided to post testcase
> separetely
It can be reviewed independently and I'm happy to do that now. But it
can't be committed independently so I'm not sure there's much point in
posting it separately.
> * bug-srand-srandom-dependency.c: New file.
> * Makefile (tests) : Add bug-srand-srandom-dependency.
Spurious space before the : there.
(Also, in cases like this just "Add it." is sufficient.)
> + <http://www.gnu.org/licenses/>. */
> +
> +
> +
> +#include <stdlib.h>
Drop the extra blank lines (just one between header and #include).
> +int
> +do_test (int argc, char **argv)
static int
do_test (void)
and then put
#define TEST_FUNCTION do_test ()
right before the #include at the bottom.
> +{
> + int rand1, rand2;
> + int random1, random2;
Use C99 in-line definitions.
> + srand (43);
> + rand1 = rand ();
> + rand2 = rand ();
> + srandom (42);
> + random1 = random ();
> + random2 = random ();
> +
> + /* We enumerate all combinations how rand and random
> + can be interleaved and test independency. */
"independency" is not an English word; "independence" works here.
> + for (int com = 0; com < 64; com++)
> + {
> + int randstate = 0, randomstate = 0;
> + for (int i = 0; i < 6; i++)
This seems like a bit of overkill and it takes some thought to understand
what you're doing here. It's certainly not bad to be excessively thorough
in your test, but perhaps some more comments would help.
Thanks,
Roland