test.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. *******************************************************************************
  3. \file test.c
  4. \brief Bee2 testing
  5. \project bee2/test
  6. \created 2014.04.02
  7. \version 2023.12.19
  8. \copyright The Bee2 authors
  9. \license Licensed under the Apache License, Version 2.0 (see LICENSE.txt).
  10. *******************************************************************************
  11. */
  12. #include <stdio.h>
  13. #include <bee2/defs.h>
  14. /*
  15. *******************************************************************************
  16. Тестирование модулей core
  17. *******************************************************************************
  18. */
  19. extern bool_t apduTest();
  20. extern bool_t b64Test();
  21. extern bool_t blobTest();
  22. extern bool_t decTest();
  23. extern bool_t derTest();
  24. extern bool_t hexTest();
  25. extern bool_t memTest();
  26. extern bool_t mtTest();
  27. extern bool_t objTest();
  28. extern bool_t oidTest();
  29. extern bool_t prngTest();
  30. extern bool_t rngTest();
  31. extern bool_t strTest();
  32. extern bool_t tmTest();
  33. extern bool_t u16Test();
  34. extern bool_t u32Test();
  35. extern bool_t u64Test();
  36. extern bool_t utilTest();
  37. int testCore()
  38. {
  39. bool_t code;
  40. int ret = 0;
  41. printf("apduTest: %s\n", (code = apduTest()) ? "OK" : "Err"), ret |= !code;
  42. printf("b64Test: %s\n", (code = b64Test()) ? "OK" : "Err"), ret |= !code;
  43. printf("blobTest: %s\n", (code = blobTest()) ? "OK" : "Err"), ret |= !code;
  44. printf("decTest: %s\n", (code = decTest()) ? "OK" : "Err"), ret |= !code;
  45. printf("derTest: %s\n", (code = derTest()) ? "OK" : "Err"), ret |= !code;
  46. printf("hexTest: %s\n", (code = hexTest()) ? "OK" : "Err"), ret |= !code;
  47. printf("memTest: %s\n", (code = memTest()) ? "OK" : "Err"), ret |= !code;
  48. printf("mtTest: %s\n", (code = mtTest()) ? "OK" : "Err"), ret |= !code;
  49. printf("objTest: %s\n", (code = objTest()) ? "OK" : "Err"), ret |= !code;
  50. printf("oidTest: %s\n", (code = oidTest()) ? "OK" : "Err"), ret |= !code;
  51. printf("genTest: %s\n", (code = prngTest()) ? "OK" : "Err"), ret |= !code;
  52. printf("rngTest: %s\n", (code = rngTest()) ? "OK" : "Err"), ret |= !code;
  53. printf("strTest: %s\n", (code = strTest()) ? "OK" : "Err"), ret |= !code;
  54. printf("tmTest: %s\n", (code = tmTest()) ? "OK" : "Err"), ret |= !code;
  55. printf("u16Test: %s\n", (code = u16Test()) ? "OK" : "Err"), ret |= !code;
  56. printf("u32Test: %s\n", (code = u32Test()) ? "OK" : "Err"), ret |= !code;
  57. printf("u64Test: %s\n", (code = u64Test()) ? "OK" : "Err"), ret |= !code;
  58. printf("utilTest: %s\n", (code = utilTest()) ? "OK" : "Err"), ret |= !code;
  59. return ret;
  60. }
  61. /*
  62. *******************************************************************************
  63. Тестирование модулей math
  64. *******************************************************************************
  65. */
  66. extern bool_t wordTest();
  67. extern bool_t wwTest();
  68. extern bool_t zzTest();
  69. extern bool_t ppTest();
  70. extern bool_t priTest();
  71. extern bool_t ecpTest();
  72. extern bool_t ecpBench();
  73. int testMath()
  74. {
  75. bool_t code;
  76. int ret = 0;
  77. printf("wordTest: %s\n", (code = wordTest()) ? "OK" : "Err"), ret |= !code;
  78. printf("wwTest: %s\n", (code = wwTest()) ? "OK" : "Err"), ret |= !code;
  79. printf("zzTest: %s\n", (code = zzTest()) ? "OK" : "Err"), ret |= !code;
  80. printf("ppTest: %s\n", (code = ppTest()) ? "OK" : "Err"), ret |= !code;
  81. printf("priTest: %s\n", (code = priTest()) ? "OK" : "Err"), ret |= !code;
  82. printf("ecpTest: %s\n", (code = ecpTest()) ? "OK" : "Err"), ret |= !code;
  83. code = ecpBench(), ret |= !code;
  84. return ret;
  85. }
  86. /*
  87. *******************************************************************************
  88. Тестирование модулей crypto
  89. *******************************************************************************
  90. */
  91. extern bool_t beltTest();
  92. extern bool_t beltBench();
  93. extern bool_t bignTest();
  94. extern bool_t bign96Test();
  95. extern bool_t brngTest();
  96. extern bool_t belsTest();
  97. extern bool_t bakeTest();
  98. extern bool_t bakeDemo();
  99. extern bool_t bashTest();
  100. extern bool_t bashBench();
  101. extern bool_t botpTest();
  102. extern bool_t bpkiTest();
  103. extern bool_t btokTest();
  104. extern bool_t dstuTest();
  105. extern bool_t g12sTest();
  106. extern bool_t pfokTest();
  107. extern bool_t pfokTestParamsStd();
  108. extern bool_t stb99Test();
  109. int testCrypto()
  110. {
  111. bool_t code;
  112. int ret = 0;
  113. printf("beltTest: %s\n", (code = beltTest()) ? "OK" : "Err"), ret |= !code;
  114. printf("bashTest: %s\n", (code = bashTest()) ? "OK" : "Err"), ret |= !code;
  115. code = beltBench(), ret |= !code;
  116. code = bashBench(), ret |= !code;
  117. printf("bignTest: %s\n", (code = bignTest()) ? "OK" : "Err"), ret |= !code;
  118. printf("bign96Test: %s\n", (code = bign96Test()) ? "OK" : "Err"),
  119. ret |= !code;
  120. printf("botpTest: %s\n", (code = botpTest()) ? "OK" : "Err"), ret |= !code;
  121. printf("brngTest: %s\n", (code = brngTest()) ? "OK" : "Err"), ret |= !code;
  122. printf("belsTest: %s\n", (code = belsTest()) ? "OK" : "Err"), ret |= !code;
  123. printf("bakeTest: %s\n", (code = bakeTest()) ? "OK" : "Err"), ret |= !code;
  124. printf("bpkiTest: %s\n", (code = bpkiTest()) ? "OK" : "Err"), ret |= !code;
  125. printf("btokTest: %s\n", (code = btokTest()) ? "OK" : "Err"), ret |= !code;
  126. printf("dstuTest: %s\n", (code = dstuTest()) ? "OK" : "Err"), ret |= !code;
  127. printf("g12sTest: %s\n", (code = g12sTest()) ? "OK" : "Err"), ret |= !code;
  128. printf("pfokTest: %s\n", (code = pfokTest()) ? "OK" : "Err"), ret |= !code;
  129. printf("stb99Test: %s\n", (code = stb99Test()) ? "OK" : "Err"),
  130. ret |= !code;
  131. return ret;
  132. }
  133. /*
  134. *******************************************************************************
  135. main
  136. *******************************************************************************
  137. */
  138. int main()
  139. {
  140. int ret = 0;
  141. ret |= testCore();
  142. ret |= testMath();
  143. ret |= testCrypto();
  144. return ret;
  145. }