2
0

test.h 3.0 KB

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