test.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* wolfcrypt/test/test.h
  2. *
  3. * Copyright (C) 2006-2023 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. #ifndef WOLFCRYPT_TEST_H
  22. #define WOLFCRYPT_TEST_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #ifdef HAVE_STACK_SIZE
  27. THREAD_RETURN WOLFSSL_THREAD wolfcrypt_test(void* args);
  28. #else
  29. int wolfcrypt_test(void* args);
  30. #endif
  31. #ifndef NO_MAIN_DRIVER
  32. int wolfcrypt_test_main(int argc, char** argv);
  33. #endif
  34. #if defined(WOLFSSL_ESPIDF) || defined(_WIN32_WCE)
  35. int wolf_test_task(void);
  36. #endif
  37. #ifndef WC_TEST_RET_HAVE_CUSTOM_MACROS
  38. #define WC_TEST_RET_TAG_NC 0
  39. #define WC_TEST_RET_TAG_EC 1
  40. #define WC_TEST_RET_TAG_ERRNO 2
  41. #define WC_TEST_RET_TAG_I 3
  42. #define WC_TEST_RET_ENC(line, i, tag) \
  43. (-((line) + ((int)((unsigned)(i) & 0x7ff) * 100000) + ((tag) << 29)))
  44. #ifndef WC_TEST_RET_LN
  45. #define WC_TEST_RET_LN __LINE__
  46. #endif
  47. /* encode no code */
  48. #define WC_TEST_RET_ENC_NC WC_TEST_RET_ENC(WC_TEST_RET_LN, 0, WC_TEST_RET_TAG_NC)
  49. /* encode positive integer */
  50. #define WC_TEST_RET_ENC_I(i) WC_TEST_RET_ENC(WC_TEST_RET_LN, i, WC_TEST_RET_TAG_I)
  51. /* encode error code (negative integer) */
  52. #define WC_TEST_RET_ENC_EC(ec) WC_TEST_RET_ENC(WC_TEST_RET_LN, -(ec), WC_TEST_RET_TAG_EC)
  53. /* encode system/libc error code */
  54. #if defined(HAVE_ERRNO_H) && !defined(NO_FILESYSTEM) && \
  55. !defined(NO_STDIO_FILESYSTEM) && !defined(WOLFSSL_USER_IO)
  56. #include <errno.h>
  57. #define WC_TEST_RET_ENC_ERRNO WC_TEST_RET_ENC(WC_TEST_RET_LN, errno, WC_TEST_RET_TAG_ERRNO)
  58. #else
  59. #define WC_TEST_RET_ENC_ERRNO WC_TEST_RET_ENC_NC
  60. #endif
  61. #define WC_TEST_RET_DEC_TAG(x) ((-(x)) >> 29)
  62. /* decode line number */
  63. #define WC_TEST_RET_DEC_LN(x) (((-(x)) & ~(3 << 29)) % 100000)
  64. /* decode integer or errno */
  65. #define WC_TEST_RET_DEC_I(x) (((-(x)) & ~(3 << 29)) / 100000)
  66. /* decode error code */
  67. #define WC_TEST_RET_DEC_EC(x) (-WC_TEST_RET_DEC_I(x))
  68. #endif /* !WC_TEST_RET_HAVE_CUSTOM_MACROS */
  69. #ifdef __cplusplus
  70. } /* extern "C" */
  71. #endif
  72. #endif /* WOLFCRYPT_TEST_H */