unity_port.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _UNITY_PORT_H_
  13. #define _UNITY_PORT_H_
  14. #include "osi_compiler.h"
  15. OSI_EXTERN_C_BEGIN
  16. /**
  17. * \brief initialize unity environment
  18. *
  19. * \return
  20. * - true on success
  21. * - false on fail, out of memory
  22. */
  23. bool unityInit(void);
  24. /**
  25. * \brief open uart for unity
  26. *
  27. * By default, unity in application will ouput through log. When it is
  28. * called, unity will open the specified uart, and output to uart.
  29. *
  30. * This should be called only once.
  31. *
  32. * \param name unity uart name
  33. * \param baud unity uart baud rate
  34. * \return
  35. * - true on success
  36. * - false on fail, unit tests are running or open uart failed
  37. */
  38. bool unityOpenUart(uint32_t name, unsigned baud);
  39. /**
  40. * \brief close uart for unity
  41. *
  42. * \return
  43. * - true on success
  44. * - false on fail, unit tests are running
  45. */
  46. bool unityCloseUart(void);
  47. /**
  48. * \brief start unity test cases
  49. *
  50. * This will run all unittests \p UnityRunAllTests in the caller thread.
  51. * When it is not desired, caller should manage unit test thread.
  52. *
  53. * There is only one unity environment. So, when there are unit tests
  54. * running, the following start will fail.
  55. *
  56. * \return
  57. * - failed test case count
  58. * - -1 when unity is not initialized or unit tests are running.
  59. */
  60. int unityStart(void);
  61. /**
  62. * \brief start unity test cases
  63. *
  64. * It is similar to \p unityStart, just the function for all test cases
  65. * are provided.
  66. *
  67. * \return
  68. * - failed test case count
  69. * - -1 on invalid parameter
  70. * - -1 when unity is not initialized or unit tests are running.
  71. */
  72. int unityStartCases(void (*run_cases)(void));
  73. OSI_EXTERN_C_END
  74. #endif