create `mtest_opponent` instead of alt version of `test`
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
diff --git a/.gitignore b/.gitignore
index 224c38f..d39d275 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,8 @@ test
test.exe
mtest
mtest.exe
+mtest_opponent
+mtest_opponent.exe
# ignore eclipse project files
.cproject
diff --git a/README.md b/README.md
index 70e015d..be5b207 100644
--- a/README.md
+++ b/README.md
@@ -24,15 +24,20 @@ API/ABI changes: [check here](https://abi-laboratory.pro/tracker/timeline/libtom
The `develop` branch contains the in-development version. Stable releases are tagged.
-Documentation is built from the LaTeX file `bn.tex`. There is also limited documentation in `tommath.h`. There is also a document, `tommath.pdf`, which describes the goals of the project and many of the algorithms used.
+Documentation is built from the LaTeX file `bn.tex`. There is also limited documentation in `tommath.h`.
+There is also a document, `tommath.pdf`, which describes the goals of the project and many of the algorithms used.
-The project can be build by using `make`. Along with the usual `make`, `make clean` and `make install`, there are several other build targets, see the makefile for details. There are also makefiles for certain specific platforms.
+The project can be build by using `make`. Along with the usual `make`, `make clean` and `make install`,
+there are several other build targets, see the makefile for details.
+There are also makefiles for certain specific platforms.
## Testing
Tests are located in `demo/` and can be built in two flavors.
-* `make test` creates a test binary that is intended to be run against `mtest`. `mtest` can be built with `make mtest` and test execution is done like `./mtest/mtest | ./test`. `mtest` is creating test vectors using an alternative MPI library and `test` is consuming these vectors to verify correct behavior of ltm
-* `make test_standalone` creates a stand-alone test binary that executes several test routines.
+* `make test` creates a stand-alone test binary that executes several test routines.
+* `make mtest_opponent` creates a test binary that is intended to be run against `mtest`.
+ `mtest` can be built with `make mtest` and test execution is done like `./mtest/mtest | ./mtest_opponent`.
+ `mtest` is creating test vectors using an alternative MPI library and `test` is consuming these vectors to verify correct behavior of ltm
## Building and Installing
diff --git a/demo/main.c b/demo/main.c
deleted file mode 100644
index b2e670d..0000000
--- a/demo/main.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "shared.h"
-
-int mtest_opponent(void);
-int unit_tests(int argc, char **argv);
-
-void ndraw(mp_int *a, const char *name)
-{
- char *buf;
- int size;
-
- mp_radix_size(a, 10, &size);
- buf = (char *)malloc((size_t) size);
- if (buf == NULL) {
- fprintf(stderr, "\nndraw: malloc(%d) failed\n", size);
- exit(EXIT_FAILURE);
- }
-
- printf("%s: ", name);
- mp_to_decimal(a, buf, (size_t) size);
- printf("%s\n", buf);
- mp_to_hex(a, buf, (size_t) size);
- printf("0x%s\n", buf);
-
- free(buf);
-}
-
-int main(int argc, char **argv)
-{
-#ifdef MP_8BIT
- printf("Digit size 8 Bit \n");
-#endif
-#ifdef MP_16BIT
- printf("Digit size 16 Bit \n");
-#endif
-#ifdef MP_32BIT
- printf("Digit size 32 Bit \n");
-#endif
-#ifdef MP_64BIT
- printf("Digit size 64 Bit \n");
-#endif
- printf("Size of mp_digit: %u\n", (unsigned int)sizeof(mp_digit));
- printf("Size of mp_word: %u\n", (unsigned int)sizeof(mp_word));
- printf("MP_DIGIT_BIT: %d\n", MP_DIGIT_BIT);
- printf("MP_PREC: %d\n", MP_PREC);
-
- if (LTM_DEMO_TEST_VS_MTEST) {
- return mtest_opponent();
- }
- return unit_tests(argc, argv);
-}
diff --git a/demo/mtest_opponent.c b/demo/mtest_opponent.c
new file mode 100644
index 0000000..5e8d770
--- /dev/null
+++ b/demo/mtest_opponent.c
@@ -0,0 +1,403 @@
+#include "shared.h"
+
+#ifdef LTM_MTEST_REAL_RAND
+#define LTM_MTEST_RAND_SEED time(NULL)
+#else
+#define LTM_MTEST_RAND_SEED 23
+#endif
+
+static void draw(mp_int *a)
+{
+ ndraw(a, "");
+}
+
+#define FGETS(str, size, stream) \
+ { \
+ char *ret = fgets(str, size, stream); \
+ if (!ret) { fprintf(stderr, "\n%d: fgets failed\n", __LINE__); goto LBL_ERR; } \
+ }
+
+static int mtest_opponent(void)
+{
+ char cmd[4096];
+ char buf[4096];
+ int ix;
+ unsigned rr;
+ mp_int a, b, c, d, e, f;
+ unsigned long expt_n, add_n, sub_n, mul_n, div_n, sqr_n, mul2d_n, div2d_n,
+ gcd_n, lcm_n, inv_n, div2_n, mul2_n, add_d_n, sub_d_n;
+
+ srand(LTM_MTEST_RAND_SEED);
+
+ if (mp_init_multi(&a, &b, &c, &d, &e, &f, NULL)!= MP_OKAY)
+ return EXIT_FAILURE;
+
+ div2_n = mul2_n = inv_n = expt_n = lcm_n = gcd_n = add_n =
+ sub_n = mul_n = div_n = sqr_n = mul2d_n = div2d_n = add_d_n = sub_d_n = 0;
+
+#ifndef MP_FIXED_CUTOFFS
+ /* force KARA and TOOM to enable despite cutoffs */
+ KARATSUBA_SQR_CUTOFF = KARATSUBA_MUL_CUTOFF = 8;
+ TOOM_SQR_CUTOFF = TOOM_MUL_CUTOFF = 16;
+#endif
+
+ for (;;) {
+ /* randomly clear and re-init one variable, this has the affect of triming the alloc space */
+ switch (abs(rand()) % 7) {
+ case 0:
+ mp_clear(&a);
+ mp_init(&a);
+ break;
+ case 1:
+ mp_clear(&b);
+ mp_init(&b);
+ break;
+ case 2:
+ mp_clear(&c);
+ mp_init(&c);
+ break;
+ case 3:
+ mp_clear(&d);
+ mp_init(&d);
+ break;
+ case 4:
+ mp_clear(&e);
+ mp_init(&e);
+ break;
+ case 5:
+ mp_clear(&f);
+ mp_init(&f);
+ break;
+ case 6:
+ break; /* don't clear any */
+ }
+
+
+ printf("%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu ",
+ add_n, sub_n, mul_n, div_n, sqr_n, mul2d_n, div2d_n, gcd_n, lcm_n,
+ expt_n, inv_n, div2_n, mul2_n, add_d_n, sub_d_n);
+ FGETS(cmd, 4095, stdin);
+ cmd[strlen(cmd) - 1u] = '\0';
+ printf("%-6s ]\r", cmd);
+ fflush(stdout);
+ if (strcmp(cmd, "mul2d") == 0) {
+ ++mul2d_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ sscanf(buf, "%u", &rr);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+
+ mp_mul_2d(&a, (int)rr, &a);
+ a.sign = b.sign;
+ if (mp_cmp(&a, &b) != MP_EQ) {
+ printf("mul2d failed, rr == %u\n", rr);
+ draw(&a);
+ draw(&b);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "div2d") == 0) {
+ ++div2d_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ sscanf(buf, "%u", &rr);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+
+ mp_div_2d(&a, (int)rr, &a, &e);
+ a.sign = b.sign;
+ if ((a.used == b.used) && (a.used == 0)) {
+ a.sign = b.sign = MP_ZPOS;
+ }
+ if (mp_cmp(&a, &b) != MP_EQ) {
+ printf("div2d failed, rr == %u\n", rr);
+ draw(&a);
+ draw(&b);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "add") == 0) {
+ ++add_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&c, buf, 64);
+ mp_copy(&a, &d);
+ mp_add(&d, &b, &d);
+ if (mp_cmp(&c, &d) != MP_EQ) {
+ printf("add %lu failure!\n", add_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ draw(&d);
+ goto LBL_ERR;
+ }
+
+ /* test the sign/unsigned storage functions */
+
+ rr = (unsigned)mp_signed_bin_size(&c);
+ mp_to_signed_bin(&c, (unsigned char *) cmd);
+ memset(cmd + rr, rand() & 0xFF, sizeof(cmd) - rr);
+ mp_read_signed_bin(&d, (unsigned char *) cmd, (int)rr);
+ if (mp_cmp(&c, &d) != MP_EQ) {
+ printf("mp_signed_bin failure!\n");
+ draw(&c);
+ draw(&d);
+ goto LBL_ERR;
+ }
+
+
+ rr = (unsigned)mp_unsigned_bin_size(&c);
+ mp_to_unsigned_bin(&c, (unsigned char *) cmd);
+ memset(cmd + rr, rand() & 0xFF, sizeof(cmd) - rr);
+ mp_read_unsigned_bin(&d, (unsigned char *) cmd, (int)rr);
+ if (mp_cmp_mag(&c, &d) != MP_EQ) {
+ printf("mp_unsigned_bin failure!\n");
+ draw(&c);
+ draw(&d);
+ goto LBL_ERR;
+ }
+
+ } else if (strcmp(cmd, "sub") == 0) {
+ ++sub_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&c, buf, 64);
+ mp_copy(&a, &d);
+ mp_sub(&d, &b, &d);
+ if (mp_cmp(&c, &d) != MP_EQ) {
+ printf("sub %lu failure!\n", sub_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ draw(&d);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "mul") == 0) {
+ ++mul_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&c, buf, 64);
+ mp_copy(&a, &d);
+ mp_mul(&d, &b, &d);
+ if (mp_cmp(&c, &d) != MP_EQ) {
+ printf("mul %lu failure!\n", mul_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ draw(&d);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "div") == 0) {
+ ++div_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&c, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&d, buf, 64);
+
+ mp_div(&a, &b, &e, &f);
+ if ((mp_cmp(&c, &e) != MP_EQ) || (mp_cmp(&d, &f) != MP_EQ)) {
+ printf("div %lu %d, %d, failure!\n", div_n, mp_cmp(&c, &e),
+ mp_cmp(&d, &f));
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ draw(&d);
+ draw(&e);
+ draw(&f);
+ goto LBL_ERR;
+ }
+
+ } else if (strcmp(cmd, "sqr") == 0) {
+ ++sqr_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ mp_copy(&a, &c);
+ mp_sqr(&c, &c);
+ if (mp_cmp(&b, &c) != MP_EQ) {
+ printf("sqr %lu failure!\n", sqr_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "gcd") == 0) {
+ ++gcd_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&c, buf, 64);
+ mp_copy(&a, &d);
+ mp_gcd(&d, &b, &d);
+ d.sign = c.sign;
+ if (mp_cmp(&c, &d) != MP_EQ) {
+ printf("gcd %lu failure!\n", gcd_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ draw(&d);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "lcm") == 0) {
+ ++lcm_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&c, buf, 64);
+ mp_copy(&a, &d);
+ mp_lcm(&d, &b, &d);
+ d.sign = c.sign;
+ if (mp_cmp(&c, &d) != MP_EQ) {
+ printf("lcm %lu failure!\n", lcm_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ draw(&d);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "expt") == 0) {
+ ++expt_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&c, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&d, buf, 64);
+ mp_copy(&a, &e);
+ mp_exptmod(&e, &b, &c, &e);
+ if (mp_cmp(&d, &e) != MP_EQ) {
+ printf("expt %lu failure!\n", expt_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ draw(&d);
+ draw(&e);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "invmod") == 0) {
+ ++inv_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&c, buf, 64);
+ mp_invmod(&a, &b, &d);
+ mp_mulmod(&d, &a, &b, &e);
+ if (mp_cmp_d(&e, 1uL) != MP_EQ) {
+ printf("inv [wrong value from MPI?!] failure\n");
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ draw(&d);
+ draw(&e);
+ mp_gcd(&a, &b, &e);
+ draw(&e);
+ goto LBL_ERR;
+ }
+
+ } else if (strcmp(cmd, "div2") == 0) {
+ ++div2_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ mp_div_2(&a, &c);
+ if (mp_cmp(&c, &b) != MP_EQ) {
+ printf("div_2 %lu failure\n", div2_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "mul2") == 0) {
+ ++mul2_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ mp_mul_2(&a, &c);
+ if (mp_cmp(&c, &b) != MP_EQ) {
+ printf("mul_2 %lu failure\n", mul2_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "add_d") == 0) {
+ ++add_d_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ sscanf(buf, "%d", &ix);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ mp_add_d(&a, (mp_digit)ix, &c);
+ if (mp_cmp(&b, &c) != MP_EQ) {
+ printf("add_d %lu failure\n", add_d_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ printf("d == %d\n", ix);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "sub_d") == 0) {
+ ++sub_d_n;
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&a, buf, 64);
+ FGETS(buf, 4095, stdin);
+ sscanf(buf, "%d", &ix);
+ FGETS(buf, 4095, stdin);
+ mp_read_radix(&b, buf, 64);
+ mp_sub_d(&a, (mp_digit)ix, &c);
+ if (mp_cmp(&b, &c) != MP_EQ) {
+ printf("sub_d %lu failure\n", sub_d_n);
+ draw(&a);
+ draw(&b);
+ draw(&c);
+ printf("d == %d\n", ix);
+ goto LBL_ERR;
+ }
+ } else if (strcmp(cmd, "exit") == 0) {
+ printf("\nokay, exiting now\n");
+ break;
+ }
+ }
+
+ mp_clear_multi(&a, &b, &c, &d, &e, &f, NULL);
+ printf("\n");
+ return 0;
+
+LBL_ERR:
+ mp_clear_multi(&a, &b, &c, &d, &e, &f, NULL);
+ printf("\n");
+ return EXIT_FAILURE;
+}
+
+int main(void)
+{
+ print_header();
+
+ return mtest_opponent();
+}
diff --git a/demo/opponent.c b/demo/opponent.c
deleted file mode 100644
index dc0893c..0000000
--- a/demo/opponent.c
+++ /dev/null
@@ -1,396 +0,0 @@
-#include "shared.h"
-
-#ifdef LTM_MTEST_REAL_RAND
-#define LTM_MTEST_RAND_SEED time(NULL)
-#else
-#define LTM_MTEST_RAND_SEED 23
-#endif
-
-static void draw(mp_int *a)
-{
- ndraw(a, "");
-}
-
-#define FGETS(str, size, stream) \
- { \
- char *ret = fgets(str, size, stream); \
- if (!ret) { fprintf(stderr, "\n%d: fgets failed\n", __LINE__); goto LBL_ERR; } \
- }
-
-int mtest_opponent(void)
-{
- char cmd[4096];
- char buf[4096];
- int ix;
- unsigned rr;
- mp_int a, b, c, d, e, f;
- unsigned long expt_n, add_n, sub_n, mul_n, div_n, sqr_n, mul2d_n, div2d_n,
- gcd_n, lcm_n, inv_n, div2_n, mul2_n, add_d_n, sub_d_n;
-
- srand(LTM_MTEST_RAND_SEED);
-
- if (mp_init_multi(&a, &b, &c, &d, &e, &f, NULL)!= MP_OKAY)
- return EXIT_FAILURE;
-
- div2_n = mul2_n = inv_n = expt_n = lcm_n = gcd_n = add_n =
- sub_n = mul_n = div_n = sqr_n = mul2d_n = div2d_n = add_d_n = sub_d_n = 0;
-
-#ifndef MP_FIXED_CUTOFFS
- /* force KARA and TOOM to enable despite cutoffs */
- KARATSUBA_SQR_CUTOFF = KARATSUBA_MUL_CUTOFF = 8;
- TOOM_SQR_CUTOFF = TOOM_MUL_CUTOFF = 16;
-#endif
-
- for (;;) {
- /* randomly clear and re-init one variable, this has the affect of triming the alloc space */
- switch (abs(rand()) % 7) {
- case 0:
- mp_clear(&a);
- mp_init(&a);
- break;
- case 1:
- mp_clear(&b);
- mp_init(&b);
- break;
- case 2:
- mp_clear(&c);
- mp_init(&c);
- break;
- case 3:
- mp_clear(&d);
- mp_init(&d);
- break;
- case 4:
- mp_clear(&e);
- mp_init(&e);
- break;
- case 5:
- mp_clear(&f);
- mp_init(&f);
- break;
- case 6:
- break; /* don't clear any */
- }
-
-
- printf("%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu/%4lu ",
- add_n, sub_n, mul_n, div_n, sqr_n, mul2d_n, div2d_n, gcd_n, lcm_n,
- expt_n, inv_n, div2_n, mul2_n, add_d_n, sub_d_n);
- FGETS(cmd, 4095, stdin);
- cmd[strlen(cmd) - 1u] = '\0';
- printf("%-6s ]\r", cmd);
- fflush(stdout);
- if (strcmp(cmd, "mul2d") == 0) {
- ++mul2d_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- sscanf(buf, "%u", &rr);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
-
- mp_mul_2d(&a, (int)rr, &a);
- a.sign = b.sign;
- if (mp_cmp(&a, &b) != MP_EQ) {
- printf("mul2d failed, rr == %u\n", rr);
- draw(&a);
- draw(&b);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "div2d") == 0) {
- ++div2d_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- sscanf(buf, "%u", &rr);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
-
- mp_div_2d(&a, (int)rr, &a, &e);
- a.sign = b.sign;
- if ((a.used == b.used) && (a.used == 0)) {
- a.sign = b.sign = MP_ZPOS;
- }
- if (mp_cmp(&a, &b) != MP_EQ) {
- printf("div2d failed, rr == %u\n", rr);
- draw(&a);
- draw(&b);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "add") == 0) {
- ++add_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_add(&d, &b, &d);
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("add %lu failure!\n", add_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- goto LBL_ERR;
- }
-
- /* test the sign/unsigned storage functions */
-
- rr = (unsigned)mp_signed_bin_size(&c);
- mp_to_signed_bin(&c, (unsigned char *) cmd);
- memset(cmd + rr, rand() & 0xFF, sizeof(cmd) - rr);
- mp_read_signed_bin(&d, (unsigned char *) cmd, (int)rr);
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("mp_signed_bin failure!\n");
- draw(&c);
- draw(&d);
- goto LBL_ERR;
- }
-
-
- rr = (unsigned)mp_unsigned_bin_size(&c);
- mp_to_unsigned_bin(&c, (unsigned char *) cmd);
- memset(cmd + rr, rand() & 0xFF, sizeof(cmd) - rr);
- mp_read_unsigned_bin(&d, (unsigned char *) cmd, (int)rr);
- if (mp_cmp_mag(&c, &d) != MP_EQ) {
- printf("mp_unsigned_bin failure!\n");
- draw(&c);
- draw(&d);
- goto LBL_ERR;
- }
-
- } else if (strcmp(cmd, "sub") == 0) {
- ++sub_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_sub(&d, &b, &d);
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("sub %lu failure!\n", sub_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "mul") == 0) {
- ++mul_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_mul(&d, &b, &d);
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("mul %lu failure!\n", mul_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "div") == 0) {
- ++div_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&d, buf, 64);
-
- mp_div(&a, &b, &e, &f);
- if ((mp_cmp(&c, &e) != MP_EQ) || (mp_cmp(&d, &f) != MP_EQ)) {
- printf("div %lu %d, %d, failure!\n", div_n, mp_cmp(&c, &e),
- mp_cmp(&d, &f));
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- draw(&e);
- draw(&f);
- goto LBL_ERR;
- }
-
- } else if (strcmp(cmd, "sqr") == 0) {
- ++sqr_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_copy(&a, &c);
- mp_sqr(&c, &c);
- if (mp_cmp(&b, &c) != MP_EQ) {
- printf("sqr %lu failure!\n", sqr_n);
- draw(&a);
- draw(&b);
- draw(&c);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "gcd") == 0) {
- ++gcd_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_gcd(&d, &b, &d);
- d.sign = c.sign;
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("gcd %lu failure!\n", gcd_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "lcm") == 0) {
- ++lcm_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_copy(&a, &d);
- mp_lcm(&d, &b, &d);
- d.sign = c.sign;
- if (mp_cmp(&c, &d) != MP_EQ) {
- printf("lcm %lu failure!\n", lcm_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "expt") == 0) {
- ++expt_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&d, buf, 64);
- mp_copy(&a, &e);
- mp_exptmod(&e, &b, &c, &e);
- if (mp_cmp(&d, &e) != MP_EQ) {
- printf("expt %lu failure!\n", expt_n);
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- draw(&e);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "invmod") == 0) {
- ++inv_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&c, buf, 64);
- mp_invmod(&a, &b, &d);
- mp_mulmod(&d, &a, &b, &e);
- if (mp_cmp_d(&e, 1uL) != MP_EQ) {
- printf("inv [wrong value from MPI?!] failure\n");
- draw(&a);
- draw(&b);
- draw(&c);
- draw(&d);
- draw(&e);
- mp_gcd(&a, &b, &e);
- draw(&e);
- goto LBL_ERR;
- }
-
- } else if (strcmp(cmd, "div2") == 0) {
- ++div2_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_div_2(&a, &c);
- if (mp_cmp(&c, &b) != MP_EQ) {
- printf("div_2 %lu failure\n", div2_n);
- draw(&a);
- draw(&b);
- draw(&c);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "mul2") == 0) {
- ++mul2_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_mul_2(&a, &c);
- if (mp_cmp(&c, &b) != MP_EQ) {
- printf("mul_2 %lu failure\n", mul2_n);
- draw(&a);
- draw(&b);
- draw(&c);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "add_d") == 0) {
- ++add_d_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- sscanf(buf, "%d", &ix);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_add_d(&a, (mp_digit)ix, &c);
- if (mp_cmp(&b, &c) != MP_EQ) {
- printf("add_d %lu failure\n", add_d_n);
- draw(&a);
- draw(&b);
- draw(&c);
- printf("d == %d\n", ix);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "sub_d") == 0) {
- ++sub_d_n;
- FGETS(buf, 4095, stdin);
- mp_read_radix(&a, buf, 64);
- FGETS(buf, 4095, stdin);
- sscanf(buf, "%d", &ix);
- FGETS(buf, 4095, stdin);
- mp_read_radix(&b, buf, 64);
- mp_sub_d(&a, (mp_digit)ix, &c);
- if (mp_cmp(&b, &c) != MP_EQ) {
- printf("sub_d %lu failure\n", sub_d_n);
- draw(&a);
- draw(&b);
- draw(&c);
- printf("d == %d\n", ix);
- goto LBL_ERR;
- }
- } else if (strcmp(cmd, "exit") == 0) {
- printf("\nokay, exiting now\n");
- break;
- }
- }
-
- mp_clear_multi(&a, &b, &c, &d, &e, &f, NULL);
- printf("\n");
- return 0;
-
-LBL_ERR:
- mp_clear_multi(&a, &b, &c, &d, &e, &f, NULL);
- printf("\n");
- return EXIT_FAILURE;
-}
diff --git a/demo/shared.c b/demo/shared.c
new file mode 100644
index 0000000..2e2b1f9
--- /dev/null
+++ b/demo/shared.c
@@ -0,0 +1,42 @@
+#include "shared.h"
+
+void ndraw(mp_int *a, const char *name)
+{
+ char *buf;
+ int size;
+
+ mp_radix_size(a, 10, &size);
+ buf = (char *)malloc((size_t) size);
+ if (buf == NULL) {
+ fprintf(stderr, "\nndraw: malloc(%d) failed\n", size);
+ exit(EXIT_FAILURE);
+ }
+
+ printf("%s: ", name);
+ mp_to_decimal(a, buf, (size_t) size);
+ printf("%s\n", buf);
+ mp_to_hex(a, buf, (size_t) size);
+ printf("0x%s\n", buf);
+
+ free(buf);
+}
+
+void print_header(void)
+{
+#ifdef MP_8BIT
+ printf("Digit size 8 Bit \n");
+#endif
+#ifdef MP_16BIT
+ printf("Digit size 16 Bit \n");
+#endif
+#ifdef MP_32BIT
+ printf("Digit size 32 Bit \n");
+#endif
+#ifdef MP_64BIT
+ printf("Digit size 64 Bit \n");
+#endif
+ printf("Size of mp_digit: %u\n", (unsigned int)sizeof(mp_digit));
+ printf("Size of mp_word: %u\n", (unsigned int)sizeof(mp_word));
+ printf("MP_DIGIT_BIT: %d\n", MP_DIGIT_BIT);
+ printf("MP_PREC: %d\n", MP_PREC);
+}
diff --git a/demo/shared.h b/demo/shared.h
index 872465d..4d5eb53 100644
--- a/demo/shared.h
+++ b/demo/shared.h
@@ -5,10 +5,6 @@
/*
* Configuration
*/
-#ifndef LTM_DEMO_TEST_VS_MTEST
-#define LTM_DEMO_TEST_VS_MTEST 1
-#endif
-
#ifndef LTM_DEMO_TEST_REDUCE_2K_L
/* This test takes a moment so we disable it by default, but it can be:
* 0 to disable testing
@@ -22,3 +18,4 @@
#include "tommath_private.h"
extern void ndraw(mp_int* a, const char* name);
+extern void print_header(void);
diff --git a/demo/test.c b/demo/test.c
index 79cfb38..99a5fa7 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -2214,7 +2214,7 @@ LTM_ERR:
return EXIT_FAILURE;
}
-int unit_tests(int argc, char **argv)
+static int unit_tests(int argc, char **argv)
{
static const struct {
const char *name;
@@ -2304,3 +2304,10 @@ int unit_tests(int argc, char **argv)
if (fail != 0) return EXIT_FAILURE;
else return EXIT_SUCCESS;
}
+
+int main(int argc, char **argv)
+{
+ print_header();
+
+ return unit_tests(argc, argv);
+}
diff --git a/makefile b/makefile
index 89d2b3b..4c6997a 100644
--- a/makefile
+++ b/makefile
@@ -95,8 +95,11 @@ uninstall:
rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
-test test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
- $(CC) $(LTM_CFLAGS) $^ $(LTM_LFLAGS) -o test
+test_standalone: test
+ @echo "test_standalone is deprecated, please use make-target 'test'"
+
+test mtest_opponent: demo/shared.o $(LIBNAME) | demo/test.o demo/mtest_opponent.o
+ $(CC) $(LTM_CFLAGS) $(LTM_LFLAGS) demo/$@.o $^ -o $@
.PHONY: mtest
mtest:
diff --git a/makefile.mingw b/makefile.mingw
index 5497a1f..fcab293 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -81,14 +81,15 @@ $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS)
$(CC) -s -shared -o $(LIBMAIN_D) $^ -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBMAIN_I) $(LTM_LDFLAGS)
$(STRIP) -S $(LIBMAIN_D)
-#Build test_standalone suite
-test.exe: demo/main.c demo/opponent.c demo/test.c $(LIBMAIN_S)
- $(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -DLTM_DEMO_TEST_VS_MTEST=0 -o $@
+#Build test suite
+test.exe: demo/shared.o demo/test.o $(LIBMAIN_S)
+ $(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -o $@
@echo NOTICE: start the tests by launching test.exe
test_standalone: test.exe
+ @echo test_standalone is deprecated, please use make-target 'test.exe'
-all: $(LIBMAIN_S) test_standalone
+all: $(LIBMAIN_S) test.exe
tune: $(LIBNAME_S)
$(MAKE) -C etc tune
diff --git a/makefile.msvc b/makefile.msvc
index bddadd1..5a4418a 100644
--- a/makefile.msvc
+++ b/makefile.msvc
@@ -67,14 +67,15 @@ $(OBJECTS): $(HEADERS)
$(LIBMAIN_S): $(OBJECTS)
lib /out:$(LIBMAIN_S) $(OBJECTS)
-#Build test_standalone suite
-test.exe: $(LIBMAIN_S) demo/main.c demo/opponent.c demo/test.c
- cl $(LTM_CFLAGS) $(TOBJECTS) $(LIBMAIN_S) $(LTM_LDFLAGS) demo/main.c demo/opponent.c demo/test.c /DLTM_DEMO_TEST_VS_MTEST=0 /Fe$@
+#Build test suite
+test.exe: $(LIBMAIN_S) demo/shared.obj demo/test.obj
+ cl $(LTM_CFLAGS) $(TOBJECTS) $(LIBMAIN_S) $(LTM_LDFLAGS) demo/shared.c demo/test.c /Fe$@
@echo NOTICE: start the tests by launching test.exe
test_standalone: test.exe
+ @echo test_standalone is deprecated, please use make-target 'test.exe'
-all: $(LIBMAIN_S) test_standalone
+all: $(LIBMAIN_S) test.exe
tune: $(LIBMAIN_S)
$(MAKE) -C etc tune
diff --git a/makefile.shared b/makefile.shared
index f77b5e5..ae3c850 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -79,8 +79,11 @@ uninstall:
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
-test test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
- $(LTLINK) $(LTM_LDFLAGS) $^ -o test
+test_standalone: test
+ @echo "test_standalone is deprecated, please use make-target 'test'"
+
+test mtest_opponent: demo/shared.o $(LIBNAME) | demo/test.o demo/mtest_opponent.o
+ $(LTLINK) $(LTM_LDFLAGS) demo/$@.o $^ -o $@
.PHONY: mtest
mtest:
diff --git a/makefile.unix b/makefile.unix
index 4bdb5d5..ba8c243 100644
--- a/makefile.unix
+++ b/makefile.unix
@@ -80,13 +80,14 @@ $(LIBMAIN_S): $(OBJECTS)
$(RANLIB) $@
#Build test_standalone suite
-test: demo/main.c demo/opponent.c demo/test.c $(LIBMAIN_S)
- $(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -DLTM_DEMO_TEST_VS_MTEST=0 -o $@
+test: demo/shared.o demo/test.o $(LIBMAIN_S)
+ $(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -o $@
@echo "NOTICE: start the tests by: ./test"
test_standalone: test
+ @echo "test_standalone is deprecated, please use make-target 'test'"
-all: $(LIBMAIN_S) test_standalone
+all: $(LIBMAIN_S) test
tune: $(LIBMAIN_S)
$(MAKE) -C etc tune
diff --git a/makefile_include.mk b/makefile_include.mk
index a766343..be81586 100644
--- a/makefile_include.mk
+++ b/makefile_include.mk
@@ -126,8 +126,6 @@ endif
HEADERS_PUB=tommath.h
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
-test_standalone: LTM_CFLAGS+=-DLTM_DEMO_TEST_VS_MTEST=0
-
#LIBPATH The directory for libtommath to be installed to.
#INCPATH The directory to install the header files for libtommath.
#DATAPATH The directory to install the pdf docs.
diff --git a/testme.sh b/testme.sh
index df1b60b..40fa32d 100755
--- a/testme.sh
+++ b/testme.sh
@@ -130,7 +130,7 @@ _runtest()
_make "$1" "$2" ""
$_timeout $TUNE_CMD > test_${suffix}.log || _die "running autotune" $?
else
- _make "$1" "$2" "test_standalone"
+ _make "$1" "$2" "test"
echo -e "\rRun test $1 $2"
$_timeout ./test > test_${suffix}.log || _die "running tests" $?
fi
@@ -156,7 +156,7 @@ echo "autotune branch"
echo -e "\rRun etc/tune $1 $2 once inside valgrind"
$_timeout $VALGRIND_BIN $VALGRIND_OPTS $TUNE_CMD > test_${suffix}.log || _die "running etc/tune" $?
else
- _make "$1" "$2" "test_standalone"
+ _make "$1" "$2" "test"
echo -e "\rRun test $1 $2 inside valgrind"
$_timeout $VALGRIND_BIN $VALGRIND_OPTS ./test > test_${suffix}.log || _die "running tests" $?
fi
@@ -336,14 +336,14 @@ _banner
if [[ "$TEST_VS_MTEST" != "" ]]
then
make clean > /dev/null
- _make "${compilers[0]} ${archflags[0]}" "$CFLAGS" "test"
+ _make "${compilers[0]} ${archflags[0]}" "$CFLAGS" "mtest_opponent"
echo
_make "gcc" "$MTEST_RAND" "mtest"
echo
echo "Run test vs. mtest for $TEST_VS_MTEST iterations"
_timeout=""
which timeout >/dev/null && _timeout="timeout --foreground 1800"
- $_timeout ./mtest/mtest $TEST_VS_MTEST | $VALGRIND_BIN $VALGRIND_OPTS ./test > valgrind_test.log 2> test_vs_mtest_err.log
+ $_timeout ./mtest/mtest $TEST_VS_MTEST | $VALGRIND_BIN $VALGRIND_OPTS ./mtest_opponent > valgrind_test.log 2> test_vs_mtest_err.log
retval=$?
head -n 5 valgrind_test.log
tail -n 2 valgrind_test.log