diff mbox

[libdrm,7/9] tests/random: return non-zero on test failure

Message ID 1427061825-27470-8-git-send-email-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Emil Velikov March 22, 2015, 10:03 p.m. UTC
... and wire it up to make check

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
 tests/Makefile.am | 6 +++---
 tests/random.c    | 6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

Comments

Jan Vesely March 24, 2015, 10:12 p.m. UTC | #1
On Sun, 2015-03-22 at 22:03 +0000, Emil Velikov wrote:
> ... and wire it up to make check
> 
> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
> ---
>  tests/Makefile.am | 6 +++---
>  tests/random.c    | 6 ++++--
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 9b13b2e..0603241 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -29,15 +29,15 @@ LDADD = $(top_builddir)/libdrm.la
>  
>  check_PROGRAMS = \
>  	dristat \
> -	drmstat \
> -	random
> +	drmstat
>  
>  if HAVE_NOUVEAU
>  SUBDIRS += nouveau
>  endif
>  
>  TESTS = \
> -	hash
> +	hash \
> +	random
>  
>  if HAVE_LIBUDEV
>  
> diff --git a/tests/random.c b/tests/random.c
> index 6dc8386..6af7d33 100644
> --- a/tests/random.c
> +++ b/tests/random.c
> @@ -107,15 +107,17 @@ int main(void)
>  {
>      RandomState   *state;
>      int           i;
> +    int           ret;
>      unsigned long rand;
>  
>      state = drmRandomCreate(1);
>      for (i = 0; i < 10000; i++) {
>  	rand = drmRandom(state);
>      }
> +    ret = rand - state->check;

Since you are touching this line, I think rand != state->check would be
more readable.

>      printf("After 10000 iterations: %lu (%lu expected): %s\n",
>  	   rand, state->check,
> -	   rand - state->check ? "*INCORRECT*" : "CORRECT");
> +	   ret ? "*INCORRECT*" : "CORRECT");
>      drmRandomDestroy(state);
>  
>      printf("Checking periods...\n");
> @@ -123,5 +125,5 @@ int main(void)
>      check_period(2);
>      check_period(31415926);
>      
> -    return 0;
> +    return ret;
>  }
diff mbox

Patch

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9b13b2e..0603241 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -29,15 +29,15 @@  LDADD = $(top_builddir)/libdrm.la
 
 check_PROGRAMS = \
 	dristat \
-	drmstat \
-	random
+	drmstat
 
 if HAVE_NOUVEAU
 SUBDIRS += nouveau
 endif
 
 TESTS = \
-	hash
+	hash \
+	random
 
 if HAVE_LIBUDEV
 
diff --git a/tests/random.c b/tests/random.c
index 6dc8386..6af7d33 100644
--- a/tests/random.c
+++ b/tests/random.c
@@ -107,15 +107,17 @@  int main(void)
 {
     RandomState   *state;
     int           i;
+    int           ret;
     unsigned long rand;
 
     state = drmRandomCreate(1);
     for (i = 0; i < 10000; i++) {
 	rand = drmRandom(state);
     }
+    ret = rand - state->check;
     printf("After 10000 iterations: %lu (%lu expected): %s\n",
 	   rand, state->check,
-	   rand - state->check ? "*INCORRECT*" : "CORRECT");
+	   ret ? "*INCORRECT*" : "CORRECT");
     drmRandomDestroy(state);
 
     printf("Checking periods...\n");
@@ -123,5 +125,5 @@  int main(void)
     check_period(2);
     check_period(31415926);
     
-    return 0;
+    return ret;
 }