getloadavg test: Add some plausibility checks.
authorBruno Haible <bruno@clisp.org>
Thu, 17 Feb 2011 22:42:20 +0000 (23:42 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 17 Feb 2011 22:42:20 +0000 (23:42 +0100)
* tests/test-getloadavg.c (check_avg): Print a warning when the value
is improbable.

ChangeLog
tests/test-getloadavg.c

index 237dffc..42230d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-02-17  Bruno Haible  <bruno@clisp.org>
+
+       getloadavg test: Add some plausibility checks.
+       * tests/test-getloadavg.c (check_avg): Print a warning when the value
+       is improbable.
+
 2011-02-16  Eric Blake  <eblake@redhat.com>
 
        maintainer-makefile: make syntax-check a no-op from tarballs
index f9b4a79..f039776 100644 (file)
@@ -30,6 +30,14 @@ check_avg (int minutes, double avg, int printit)
 {
   if (printit)
     printf ("%d-minute: %f  ", minutes, avg);
+  else
+    {
+      /* Plausibility checks.  */
+      if (avg < 0.01)
+        printf ("suspiciously low %d-minute average: %f\n", minutes, avg);
+      if (avg > 1000000)
+        printf ("suspiciously high %d-minute average: %f\n", minutes, avg);
+    }
   if (avg < 0 || avg != avg)
     exit (minutes);
 }