# HG changeset patch # User jlarmour # Date 1056603158 0 # Node ID 5ba0f0c110c8c1ddfaf15562598064d6e66cc90a # Parent e4850e482c8096fa663a3641365cbbdf2f58733f * tests/clock.c (main): Add a fudge factor in case the absolute values from clock() are small, in which case the percentage variation would be large. diff --git a/packages/language/c/libc/time/current/ChangeLog b/packages/language/c/libc/time/current/ChangeLog --- a/packages/language/c/libc/time/current/ChangeLog +++ b/packages/language/c/libc/time/current/ChangeLog @@ -1,3 +1,10 @@ +2003-06-26 Brij Bihari Pandey +2003-06-26 Jonathan Larmour + + * tests/clock.c (main): Add a fudge factor in case the absolute values + from clock() are small, in which case the percentage variation + would be large. + 2003-06-13 Jonathan Larmour * tests/clock.c (main): Avoid div-by-zero if mean==0. diff --git a/packages/language/c/libc/time/current/tests/clock.c b/packages/language/c/libc/time/current/tests/clock.c --- a/packages/language/c/libc/time/current/tests/clock.c +++ b/packages/language/c/libc/time/current/tests/clock.c @@ -96,6 +96,11 @@ cyg_start(void) // Percentage error before we declare fail: range 0 - 100 #define TOLERANCE 40 +// Permissible absolute deviation from mean value to take care of incorrect +// failure conclusions in case of small mean values (if absolute values of +// clock() are small, percentage variation can be large) +#define FUDGE_FACTOR 6 + // Number of samples to take #define SAMPLES 30 @@ -160,6 +165,7 @@ main(int argc, char *argv[]) { unsigned long mean=0, sum=0, maxerr=0; int i; + unsigned int absdev; CYG_TEST_INIT(); @@ -221,9 +227,10 @@ main(int argc, char *argv[]) for (i=SKIPPED_SAMPLES;i TOLERANCE) { + err = (100 * absdev) / (mean+1); + if (err > TOLERANCE && absdev > FUDGE_FACTOR) { diag_printf("mean=%d, ctrs[%d]=%d, err=%d\n", mean, i, ctrs[i], err); CYG_TEST_FAIL_FINISH("clock() within tolerance");