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