changeset 14358:d1eef489f6fa

getloadavg test: Add some plausibility checks. * tests/test-getloadavg.c (check_avg): Print a warning when the value is improbable.
author Bruno Haible <bruno@clisp.org>
date Thu, 17 Feb 2011 23:42:20 +0100
parents e52d28567d4e
children f0c5702b2bbb
files ChangeLog tests/test-getloadavg.c
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/tests/test-getloadavg.c
+++ b/tests/test-getloadavg.c
@@ -30,6 +30,14 @@
 {
   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);
 }