tests/random: return non-zero on test failure

... and wire it up to make check

v2: s/rand - state->check/rand != state->check/. (Jan)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
This commit is contained in:
Emil Velikov 2015-04-05 15:12:48 +01:00
parent f1f4cabd8e
commit 1ed5faab24
2 changed files with 7 additions and 5 deletions

View file

@ -29,8 +29,7 @@ LDADD = $(top_builddir)/libdrm.la
check_PROGRAMS = \ check_PROGRAMS = \
dristat \ dristat \
drmstat \ drmstat
random
if HAVE_NOUVEAU if HAVE_NOUVEAU
SUBDIRS += nouveau SUBDIRS += nouveau
@ -38,7 +37,8 @@ endif
TESTS = \ TESTS = \
drmsl \ drmsl \
hash hash \
random
if HAVE_LIBUDEV if HAVE_LIBUDEV

View file

@ -98,15 +98,17 @@ int main(void)
{ {
RandomState *state; RandomState *state;
int i; int i;
int ret;
unsigned long rand; unsigned long rand;
state = drmRandomCreate(1); state = drmRandomCreate(1);
for (i = 0; i < 10000; i++) { for (i = 0; i < 10000; i++) {
rand = drmRandom(state); rand = drmRandom(state);
} }
ret = rand != state->check;
printf("After 10000 iterations: %lu (%lu expected): %s\n", printf("After 10000 iterations: %lu (%lu expected): %s\n",
rand, state->check, rand, state->check,
rand - state->check ? "*INCORRECT*" : "CORRECT"); ret ? "*INCORRECT*" : "CORRECT");
drmRandomDestroy(state); drmRandomDestroy(state);
printf("Checking periods...\n"); printf("Checking periods...\n");
@ -114,5 +116,5 @@ int main(void)
check_period(2); check_period(2);
check_period(31415926); check_period(31415926);
return 0; return ret;
} }