From 2977294eeef2ccee84986942ba42cabdbe7df0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Tue, 3 Oct 2023 20:08:06 +0200 Subject: [PATCH] Reduce test count for some of the slower tests. --- ChangeLog | 13 +++++++++++++ testsuite/ecc-mod-arith-test.c | 10 ++++------ testsuite/ecc-mod-test.c | 10 ++++------ testsuite/ecc-modinv-test.c | 2 +- testsuite/ecc-mul-a-test.c | 2 +- testsuite/ecc-redc-test.c | 2 +- testsuite/ecc-sqrt-test.c | 2 +- testsuite/eddsa-compress-test.c | 2 +- testsuite/poly1305-test.c | 2 +- testsuite/random-prime-test.c | 2 +- testsuite/rsa-compute-root-test.c | 4 ++-- testsuite/rsa-sec-decrypt-test.c | 4 ++-- 12 files changed, 32 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e329321..47a5a06a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2023-10-03 Niels Möller <nisse@lysator.liu.se> + * testsuite/ecc-mod-arith-test.c: Reduce test count, aiming to get + test to complete in roughly 0.1s. + * testsuite/ecc-mod-test.c: Likewise. + * testsuite/ecc-modinv-test.c: Likewise. + * testsuite/ecc-mul-a-test.c: Likewise. + * testsuite/ecc-redc-test.c: Likewise. + * testsuite/ecc-sqrt-test.c: Likewise. + * testsuite/eddsa-compress-test.c: Likewise. + * testsuite/poly1305-test.c: Likewise. + * testsuite/random-prime-test.c: Likewise. + * testsuite/rsa-compute-root-test.c: Likewise. + * testsuite/rsa-sec-decrypt-test.c: Likewise. + * testsuite/Makefile.in (TS_SH): Delete tools tests from list. * tools/Makefile.in (check): Run tools tests from this target. (TS_ALL): New variable. diff --git a/testsuite/ecc-mod-arith-test.c b/testsuite/ecc-mod-arith-test.c index 14b3bd1c..de77d489 100644 --- a/testsuite/ecc-mod-arith-test.c +++ b/testsuite/ecc-mod-arith-test.c @@ -1,7 +1,7 @@ #include "testutils.h" #define MAX_SIZE (1 + 521 / GMP_NUMB_BITS) -#define COUNT 50000 +#define COUNT 10000 static void test_add(const char *name, @@ -143,18 +143,16 @@ void test_main (void) { gmp_randstate_t rands; - unsigned count = COUNT; unsigned i; gmp_randinit_default (rands); - if (test_randomize(rands)) - count *= 20; + test_randomize(rands); for (i = 0; ecc_curves[i]; i++) { - test_modulo (rands, "p", &ecc_curves[i]->p, count); - test_modulo (rands, "q", &ecc_curves[i]->q, count); + test_modulo (rands, "p", &ecc_curves[i]->p, COUNT); + test_modulo (rands, "q", &ecc_curves[i]->q, COUNT); } gmp_randclear (rands); } diff --git a/testsuite/ecc-mod-test.c b/testsuite/ecc-mod-test.c index 50fbeecf..d6641d38 100644 --- a/testsuite/ecc-mod-test.c +++ b/testsuite/ecc-mod-test.c @@ -13,7 +13,7 @@ ref_mod (mp_limb_t *rp, const mp_limb_t *ap, const mp_limb_t *mp, mp_size_t mn) #define MAX_ECC_SIZE (1 + 521 / GMP_NUMB_BITS) #define MAX_SIZE (2*MAX_ECC_SIZE) -#define COUNT 50000 +#define COUNT 10000 /* Destructively normalize tp, then compare */ static int @@ -215,7 +215,6 @@ void test_main (void) { gmp_randstate_t rands; - unsigned count = COUNT; unsigned i; gmp_randinit_default (rands); @@ -228,13 +227,12 @@ test_main (void) test_patterns ("q", &ecc_curves[i]->p); } - if (test_randomize(rands)) - count *= 20; + test_randomize(rands); for (i = 0; ecc_curves[i]; i++) { - test_modulo (rands, "p", &ecc_curves[i]->p, count); - test_modulo (rands, "q", &ecc_curves[i]->q, count); + test_modulo (rands, "p", &ecc_curves[i]->p, COUNT); + test_modulo (rands, "q", &ecc_curves[i]->q, COUNT); } gmp_randclear (rands); } diff --git a/testsuite/ecc-modinv-test.c b/testsuite/ecc-modinv-test.c index aecfb43b..fdb013d7 100644 --- a/testsuite/ecc-modinv-test.c +++ b/testsuite/ecc-modinv-test.c @@ -39,7 +39,7 @@ ref_modinv (mp_limb_t *rp, const mp_limb_t *ap, } #define MAX_ECC_SIZE (1 + 521 / GMP_NUMB_BITS) -#define COUNT 500 +#define COUNT 200 static void test_modulo (gmp_randstate_t rands, const char *name, diff --git a/testsuite/ecc-mul-a-test.c b/testsuite/ecc-mul-a-test.c index 9d19762f..ec78ca57 100644 --- a/testsuite/ecc-mul-a-test.c +++ b/testsuite/ecc-mul-a-test.c @@ -46,7 +46,7 @@ test_main (void) mpn_zero (n, size); - for (j = 0; j < 100; j++) + for (j = 0; j < 30; j++) { if (j & 1) mpz_rrandomb (r, rands, size * GMP_NUMB_BITS); diff --git a/testsuite/ecc-redc-test.c b/testsuite/ecc-redc-test.c index 476a6db1..7caab0b7 100644 --- a/testsuite/ecc-redc-test.c +++ b/testsuite/ecc-redc-test.c @@ -38,7 +38,7 @@ mod_equal(const struct ecc_modulo *m, const mp_limb_t *ref, mp_limb_t *tp) #define MAX_ECC_SIZE (1 + 521 / GMP_NUMB_BITS) #define MAX_SIZE (2*MAX_ECC_SIZE) -#define COUNT 50000 +#define COUNT 10000 void test_main (void) diff --git a/testsuite/ecc-sqrt-test.c b/testsuite/ecc-sqrt-test.c index 3bb915c8..7fe6f176 100644 --- a/testsuite/ecc-sqrt-test.c +++ b/testsuite/ecc-sqrt-test.c @@ -31,7 +31,7 @@ #include "testutils.h" -#define COUNT 5000 +#define COUNT 500 #if NETTLE_USE_MINI_GMP /* Implements Legendre symbol only, requiring that p is an odd prime */ diff --git a/testsuite/eddsa-compress-test.c b/testsuite/eddsa-compress-test.c index e17a869c..c0d2c52c 100644 --- a/testsuite/eddsa-compress-test.c +++ b/testsuite/eddsa-compress-test.c @@ -34,7 +34,7 @@ #include "eddsa.h" #include "eddsa-internal.h" -#define COUNT 1000 +#define COUNT 500 void test_main (void) { diff --git a/testsuite/poly1305-test.c b/testsuite/poly1305-test.c index d13af236..7b239439 100644 --- a/testsuite/poly1305-test.c +++ b/testsuite/poly1305-test.c @@ -185,7 +185,7 @@ test_fixed (void) } } -#define COUNT 100000 +#define COUNT 10000 #define MAX_MESSAGE_SIZE 300 static void diff --git a/testsuite/random-prime-test.c b/testsuite/random-prime-test.c index 73eead08..b967d3b6 100644 --- a/testsuite/random-prime-test.c +++ b/testsuite/random-prime-test.c @@ -12,7 +12,7 @@ test_main(void) knuth_lfib_init(&lfib, 17); mpz_init(p); - for (bits = 6; bits < 1000; bits = bits + 1 + bits/20) + for (bits = 6; bits < 1000; bits = bits + 1 + bits/10) { if (verbose) fprintf(stderr, "bits = %d\n", bits); diff --git a/testsuite/rsa-compute-root-test.c b/testsuite/rsa-compute-root-test.c index de3586ef..e7e7848d 100644 --- a/testsuite/rsa-compute-root-test.c +++ b/testsuite/rsa-compute-root-test.c @@ -4,8 +4,8 @@ #include "rsa.h" -#define KEY_COUNT 20 -#define COUNT 100 +#define KEY_COUNT 10 +#define COUNT 50 static void random_fn (void *ctx, size_t n, uint8_t *dst) diff --git a/testsuite/rsa-sec-decrypt-test.c b/testsuite/rsa-sec-decrypt-test.c index 3419322e..be7ab5fb 100644 --- a/testsuite/rsa-sec-decrypt-test.c +++ b/testsuite/rsa-sec-decrypt-test.c @@ -69,7 +69,7 @@ test_main(void) unsigned n_size = 1024; mpz_t gibberish; mpz_t garbage; - size_t size; + unsigned count; rsa_private_key_init(&key); rsa_public_key_init(&pub); @@ -80,7 +80,7 @@ test_main(void) memset(verifybad, 'A', PAYLOAD_SIZE); - for (size = 1; size < 51; size++) + for (count = 1; count < 20; count++) { ASSERT (rsa_generate_keypair(&pub, &key, &random_ctx, (nettle_random_func *) knuth_lfib_random, -- GitLab