mtest vs. test: add possibility to exit testing
'mtest' can now optionally only run a given amount of loops. the first parameter <n> when invoking 'mtest' is considered to determine the amount when <n> is in the range -63..-1: mtest will run 2^-n runs when <n> is > 0: mtest will run n runs else: mtest will exit immediately
This commit is contained in:
parent
545980169c
commit
9ca37ca01c
@ -798,6 +798,9 @@ printf("compare no compare!\n"); return EXIT_FAILURE; }
|
|||||||
printf("d == %d\n", ix);
|
printf("d == %d\n", ix);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
} else if (!strcmp(cmd, "exit")) {
|
||||||
|
printf("\nokay, exiting now\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,9 +96,10 @@ void rand_num2(mp_int *a)
|
|||||||
|
|
||||||
#define mp_to64(a, b) mp_toradix(a, b, 64)
|
#define mp_to64(a, b) mp_toradix(a, b, 64)
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int n, tmp;
|
int n, tmp;
|
||||||
|
long long max;
|
||||||
mp_int a, b, c, d, e;
|
mp_int a, b, c, d, e;
|
||||||
#ifdef MTEST_NO_FULLSPEED
|
#ifdef MTEST_NO_FULLSPEED
|
||||||
clock_t t1;
|
clock_t t1;
|
||||||
@ -111,6 +112,22 @@ int main(void)
|
|||||||
mp_init(&d);
|
mp_init(&d);
|
||||||
mp_init(&e);
|
mp_init(&e);
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
max = strtol(argv[1], NULL, 0);
|
||||||
|
if (max < 0) {
|
||||||
|
if (max > -64) {
|
||||||
|
max = (1 << -(max)) + 1;
|
||||||
|
} else {
|
||||||
|
max = 1;
|
||||||
|
}
|
||||||
|
} else if (max == 0) {
|
||||||
|
max = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
max = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* initial (2^n - 1)^2 testing, makes sure the comba multiplier works [it has the new carry code] */
|
/* initial (2^n - 1)^2 testing, makes sure the comba multiplier works [it has the new carry code] */
|
||||||
/*
|
/*
|
||||||
@ -154,6 +171,12 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
n = getRandChar() % 15;
|
n = getRandChar() % 15;
|
||||||
|
|
||||||
|
if (max != 0) {
|
||||||
|
--max;
|
||||||
|
if (max == 0)
|
||||||
|
n = 255;
|
||||||
|
}
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
/* add tests */
|
/* add tests */
|
||||||
rand_num(&a);
|
rand_num(&a);
|
||||||
@ -334,7 +357,11 @@ int main(void)
|
|||||||
printf("%s\n%d\n", buf, tmp);
|
printf("%s\n%d\n", buf, tmp);
|
||||||
mp_to64(&b, buf);
|
mp_to64(&b, buf);
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
|
} else if (n == 255) {
|
||||||
|
printf("exit\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef LTM_MTEST_REAL_RAND
|
#ifdef LTM_MTEST_REAL_RAND
|
||||||
fclose(rng);
|
fclose(rng);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user