You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
2.6KB

  1. /*********************************************************************************
  2. Copyright (c) 2011-2014 Analog Devices, Inc. All Rights Reserved.
  3. This software is proprietary to Analog Devices, Inc. and its licensors. By using
  4. this software you agree to the terms of the associated Analog Devices Software
  5. License Agreement.
  6. *********************************************************************************/
  7. /*!
  8. *****************************************************************************
  9. * @file: test_common.c
  10. * @brief: Common utilities for testing
  11. * @version: $Revision: 29071 $
  12. * @date: $Date: 2014-12-08 12:46:24 -0500 (Mon, 08 Dec 2014) $
  13. *****************************************************************************/
  14. #include <stdint.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <stddef.h>
  18. #include <string.h>
  19. #include "test_common.h"
  20. static void quit(void);
  21. /**
  22. * Initialize the test system, including SystemInit and Wdog
  23. *
  24. * @param none
  25. * @return none
  26. *
  27. * @brief Set up the test system
  28. * Send output to wherever output should go
  29. */
  30. void test_Init()
  31. {
  32. ADI_WDT_DEV_HANDLE hWatchdog;
  33. /* Disable WDT for testing*/
  34. if( adi_WDT_Init(ADI_WDT_DEVID_0, &hWatchdog) != 0)
  35. {
  36. test_Fail("adi_WDT_Init failed, you're probably calling it twice");
  37. }
  38. if( adi_WDT_SetEnable(hWatchdog, false) != 0 )
  39. {
  40. test_Fail("adi_WDT_SetEnable failed");
  41. }
  42. if( adi_WDT_UnInit(hWatchdog) != 0 )
  43. {
  44. test_Fail("adi_WDT_UnInit failed");
  45. }
  46. }
  47. /**
  48. * Passing result
  49. *
  50. * @param none
  51. * @return none
  52. *
  53. * @brief Report a passing test result
  54. */
  55. void test_Pass()
  56. {
  57. char pass[] = "PASS!\n\r";
  58. printf(pass);
  59. /* Once the result is reported, do an abrupt termination */
  60. quit();
  61. }
  62. /**
  63. * Failing result
  64. *
  65. * @param none
  66. * @return none
  67. *
  68. * @brief Report a failing test result
  69. */
  70. void test_Fail(char *FailureReason)
  71. {
  72. char fail[] = "FAIL: ";
  73. char term[] = "\n\r";
  74. printf(fail);
  75. printf(FailureReason);
  76. printf(term);
  77. /* Once the result is reported, do an abrupt termination */
  78. quit();
  79. }
  80. /**
  81. * Info
  82. *
  83. * @param none
  84. * @return none
  85. *
  86. * @brief Report test info
  87. */
  88. void test_Perf(char *InfoString)
  89. {
  90. char info[] = "PERF: ";
  91. char term[] = "\n\r";
  92. printf(info);
  93. printf(InfoString);
  94. printf(term);
  95. /* do not quit... */
  96. }
  97. static void quit(void)
  98. {
  99. #if defined ( __CC_ARM )
  100. _sys_exit(0); // Keil retargeted implimentation for MicroLib
  101. #else
  102. exit(0);
  103. #endif
  104. }