[Gmp-commit] /var/hg/gmp-5.0: Ensure all sizes are seen.
mercurial at gmplib.org
mercurial at gmplib.org
Mon Jan 30 16:31:17 CET 2012
details: /var/hg/gmp-5.0/rev/7e81d4a47403
changeset: 13530:7e81d4a47403
user: Torbjorn Granlund <tege at gmplib.org>
date: Mon Jan 30 16:31:12 2012 +0100
description:
Ensure all sizes are seen.
diffstat:
ChangeLog | 6 ++++++
tests/mpz/t-powm.c | 27 ++++++++++++++++++++++++---
2 files changed, 30 insertions(+), 3 deletions(-)
diffs (90 lines):
diff -r 5821894fe3f8 -r 7e81d4a47403 ChangeLog
--- a/ChangeLog Fri Jan 27 08:21:01 2012 +0100
+++ b/ChangeLog Mon Jan 30 16:31:12 2012 +0100
@@ -1,7 +1,13 @@
+2012-01-30 Torbjorn Granlund <tege at gmplib.org>
+
+ * tests/mpz/t-powm.c: Ensure all sizes are seen.
+
2012-01-27 Torbjorn Granlund <tege at gmplib.org>
* Version 5.0.3 released.
+ * Upgrade to libtool 2.4.2.
+
2012-01-25 Torbjorn Granlund <tege at gmplib.org>
* tune/tuneup.c: Remove unused tuneup variables.
diff -r 5821894fe3f8 -r 7e81d4a47403 tests/mpz/t-powm.c
--- a/tests/mpz/t-powm.c Fri Jan 27 08:21:01 2012 +0100
+++ b/tests/mpz/t-powm.c Mon Jan 30 16:31:12 2012 +0100
@@ -1,6 +1,6 @@
/* Test mpz_powm, mpz_mul, mpz_mod, mpz_mod_ui, mpz_div_ui.
-Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2009 Free Software
+Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2009, 2012 Free Software
Foundation, Inc.
This file is part of the GNU MP Library.
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "gmp.h"
#include "gmp-impl.h"
@@ -27,6 +28,21 @@
void debug_mp __GMP_PROTO ((mpz_t, int));
+#define SIZEM 13
+
+/* Check that all sizes up to just above MUL_TOOM22_THRESHOLD have been tested
+ a few times. FIXME: If SIZEM is set too low, this will never happen. */
+int
+allsizes_seen (int *allsizes)
+{
+ mp_size_t i;
+
+ for (i = 1; i < MUL_TOOM22_THRESHOLD + 4; i++)
+ if (allsizes[i] < 4)
+ return 0;
+ return 1;
+}
+
int
main (int argc, char **argv)
{
@@ -38,6 +54,7 @@
gmp_randstate_ptr rands;
mpz_t bs;
unsigned long bsi, size_range;
+ unsigned int allsizes[1 << (SIZEM + 2 - 1)];
tests_start ();
TESTS_REPS (reps, argv, argc);
@@ -55,10 +72,12 @@
mpz_init (exp2);
mpz_init (base2);
- for (i = 0; i < reps; i++)
+ memset (allsizes, 0, (1 << (SIZEM + 2 - 1)) * sizeof (int));
+
+ for (i = 0; i < reps || ! allsizes_seen (allsizes); i++)
{
mpz_urandomb (bs, rands, 32);
- size_range = mpz_get_ui (bs) % 13 + 2;
+ size_range = mpz_get_ui (bs) % SIZEM + 2;
do /* Loop until mathematically well-defined. */
{
@@ -80,6 +99,8 @@
}
while (mpz_cmp_ui (mod, 0) == 0);
+ allsizes[SIZ(mod)] += 1;
+
mpz_urandomb (bs, rands, 2);
bsi = mpz_get_ui (bs);
if ((bsi & 1) != 0)
More information about the gmp-commit
mailing list