test.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. *******************************************************************************
  3. \file test.c
  4. \brief Bee2 testing
  5. \project bee2/test
  6. \created 2014.04.02
  7. \version 2024.02.25
  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 tomlTest();
  34. extern bool_t u16Test();
  35. extern bool_t u32Test();
  36. extern bool_t u64Test();
  37. extern bool_t utilTest();
  38. int testCore()
  39. {
  40. bool_t code;
  41. int ret = 0;
  42. printf("apduTest: %s\n", (code = apduTest()) ? "OK" : "Err"), ret |= !code;
  43. printf("b64Test: %s\n", (code = b64Test()) ? "OK" : "Err"), ret |= !code;
  44. printf("blobTest: %s\n", (code = blobTest()) ? "OK" : "Err"), ret |= !code;
  45. printf("decTest: %s\n", (code = decTest()) ? "OK" : "Err"), ret |= !code;
  46. printf("derTest: %s\n", (code = derTest()) ? "OK" : "Err"), ret |= !code;
  47. printf("hexTest: %s\n", (code = hexTest()) ? "OK" : "Err"), ret |= !code;
  48. printf("memTest: %s\n", (code = memTest()) ? "OK" : "Err"), ret |= !code;
  49. printf("mtTest: %s\n", (code = mtTest()) ? "OK" : "Err"), ret |= !code;
  50. printf("objTest: %s\n", (code = objTest()) ? "OK" : "Err"), ret |= !code;
  51. printf("oidTest: %s\n", (code = oidTest()) ? "OK" : "Err"), ret |= !code;
  52. printf("genTest: %s\n", (code = prngTest()) ? "OK" : "Err"), ret |= !code;
  53. printf("rngTest: %s\n", (code = rngTest()) ? "OK" : "Err"), ret |= !code;
  54. printf("strTest: %s\n", (code = strTest()) ? "OK" : "Err"), ret |= !code;
  55. printf("tmTest: %s\n", (code = tmTest()) ? "OK" : "Err"), ret |= !code;
  56. printf("tomlTest: %s\n", (code = tomlTest()) ? "OK" : "Err"), ret |= !code;
  57. printf("u16Test: %s\n", (code = u16Test()) ? "OK" : "Err"), ret |= !code;
  58. printf("u32Test: %s\n", (code = u32Test()) ? "OK" : "Err"), ret |= !code;
  59. printf("u64Test: %s\n", (code = u64Test()) ? "OK" : "Err"), ret |= !code;
  60. printf("utilTest: %s\n", (code = utilTest()) ? "OK" : "Err"), ret |= !code;
  61. return ret;
  62. }
  63. /*
  64. *******************************************************************************
  65. Тестирование модулей math
  66. *******************************************************************************
  67. */
  68. extern bool_t wordTest();
  69. extern bool_t wwTest();
  70. extern bool_t zzTest();
  71. extern bool_t ppTest();
  72. extern bool_t priTest();
  73. extern bool_t ecpTest();
  74. extern bool_t ecpBench();
  75. int testMath()
  76. {
  77. bool_t code;
  78. int ret = 0;
  79. printf("wordTest: %s\n", (code = wordTest()) ? "OK" : "Err"), ret |= !code;
  80. printf("wwTest: %s\n", (code = wwTest()) ? "OK" : "Err"), ret |= !code;
  81. printf("zzTest: %s\n", (code = zzTest()) ? "OK" : "Err"), ret |= !code;
  82. printf("ppTest: %s\n", (code = ppTest()) ? "OK" : "Err"), ret |= !code;
  83. printf("priTest: %s\n", (code = priTest()) ? "OK" : "Err"), ret |= !code;
  84. printf("ecpTest: %s\n", (code = ecpTest()) ? "OK" : "Err"), ret |= !code;
  85. code = ecpBench(), ret |= !code;
  86. return ret;
  87. }
  88. /*
  89. *******************************************************************************
  90. Тестирование модулей crypto
  91. *******************************************************************************
  92. */
  93. extern bool_t beltTest();
  94. extern bool_t beltBench();
  95. extern bool_t bignTest();
  96. extern bool_t bign96Test();
  97. extern bool_t brngTest();
  98. extern bool_t belsTest();
  99. extern bool_t bakeTest();
  100. extern bool_t bakeDemo();
  101. extern bool_t bashTest();
  102. extern bool_t bashBench();
  103. extern bool_t botpTest();
  104. extern bool_t bpkiTest();
  105. extern bool_t btokTest();
  106. extern bool_t dstuTest();
  107. extern bool_t g12sTest();
  108. extern bool_t pfokTest();
  109. extern bool_t pfokTestParamsStd();
  110. extern bool_t stb99Test();
  111. int testCrypto()
  112. {
  113. bool_t code;
  114. int ret = 0;
  115. printf("beltTest: %s\n", (code = beltTest()) ? "OK" : "Err"), ret |= !code;
  116. printf("bashTest: %s\n", (code = bashTest()) ? "OK" : "Err"), ret |= !code;
  117. code = beltBench(), ret |= !code;
  118. code = bashBench(), ret |= !code;
  119. printf("bignTest: %s\n", (code = bignTest()) ? "OK" : "Err"), ret |= !code;
  120. printf("bign96Test: %s\n", (code = bign96Test()) ? "OK" : "Err"),
  121. ret |= !code;
  122. printf("botpTest: %s\n", (code = botpTest()) ? "OK" : "Err"), ret |= !code;
  123. printf("brngTest: %s\n", (code = brngTest()) ? "OK" : "Err"), ret |= !code;
  124. printf("belsTest: %s\n", (code = belsTest()) ? "OK" : "Err"), ret |= !code;
  125. printf("bakeTest: %s\n", (code = bakeTest()) ? "OK" : "Err"), ret |= !code;
  126. printf("bpkiTest: %s\n", (code = bpkiTest()) ? "OK" : "Err"), ret |= !code;
  127. printf("btokTest: %s\n", (code = btokTest()) ? "OK" : "Err"), ret |= !code;
  128. printf("dstuTest: %s\n", (code = dstuTest()) ? "OK" : "Err"), ret |= !code;
  129. printf("g12sTest: %s\n", (code = g12sTest()) ? "OK" : "Err"), ret |= !code;
  130. printf("pfokTest: %s\n", (code = pfokTest()) ? "OK" : "Err"), ret |= !code;
  131. printf("stb99Test: %s\n", (code = stb99Test()) ? "OK" : "Err"),
  132. ret |= !code;
  133. return ret;
  134. }
  135. /*
  136. *******************************************************************************
  137. main
  138. *******************************************************************************
  139. */
  140. int main()
  141. {
  142. int ret = 0;
  143. ret |= testCore();
  144. ret |= testMath();
  145. ret |= testCrypto();
  146. return ret;
  147. }