test_main.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* main.c
  2. *
  3. * Copyright (C) 2006-2021 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <wolfssl/wolfcrypt/settings.h>
  25. #include <wolfcrypt/test/test.h>
  26. #if defined(WOLFSSL_MICROCHIP_PIC32MZ)
  27. #define MICROCHIP_PIC32
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include "PIC32MZ-serial.h"
  31. #include <xc.h>
  32. #define SYSTEMConfigPerformance(a) /* void out SYSTEMConfigPerformance(); */
  33. #define SYS_CLK 200000000
  34. #else
  35. #define PIC32_STARTER_KIT
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include <p32xxxx.h>
  39. #define _SUPPRESS_PLIB_WARNING
  40. #define _DISABLE_OPENADC10_CONFIGPORT_WARNING
  41. #include <plib.h>
  42. #include <sys/appio.h>
  43. #define init_serial(x) /* void out init_serial() */
  44. #define SYS_CLK 80000000
  45. #endif
  46. /* func_args from test.h, so don't have to pull in other junk */
  47. typedef struct func_args {
  48. int argc;
  49. char** argv;
  50. int return_code;
  51. } func_args;
  52. #if 1
  53. /* enable this if ReadCoreTimer and WriteCoreTimer are missing */
  54. unsigned int ReadCoreTimer(void)
  55. {
  56. unsigned int timer;
  57. timer = __builtin_mfc0(9, 0);
  58. return timer;
  59. }
  60. void WriteCoreTimer(unsigned int t)
  61. {
  62. /* do nothing here */
  63. (void)t;
  64. }
  65. #endif
  66. /*
  67. * Main driver for WolfCrypt tests.
  68. */
  69. int main(int argc, char** argv)
  70. {
  71. func_args args;
  72. SYSTEMConfigPerformance(SYS_CLK);
  73. DBINIT();
  74. init_serial(SYS_CLK) ; /* initialize PIC32MZ serial I/O */
  75. printf("WolfCrypt Test:\n");
  76. args.argc = argc;
  77. args.argv = argv;
  78. wolfcrypt_test(&args);
  79. if (args.return_code == 0) {
  80. printf("All tests passed!\n");
  81. }
  82. return 0;
  83. }