This repository was archived by the owner on Nov 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathu_main.c
147 lines (120 loc) · 4.13 KB
/
u_main.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* Copyright 2019-2024 u-blox
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file
* @brief The application entry point for the NRF52 platform. Starts
* the platform and calls Unity to run the selected examples/tests.
*/
#ifdef U_CFG_OVERRIDE
# include "u_cfg_override.h" // For a customer's configuration override
#endif
#include "stddef.h" // NULL, size_t etc.
#include "stdint.h" // int32_t etc.
#include "stdbool.h"
#include "string.h"
#include "stdlib.h" // getenv
#include "u_cfg_sw.h"
#include "u_cfg_os_platform_specific.h"
#include "u_cfg_app_platform_specific.h"
#include "u_cfg_test_platform_specific.h"
#include "u_error_common.h"
#include "u_port.h"
#include "u_port_os.h"
#include "u_port_debug.h"
#include "u_debug_utils.h"
/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* TYPES
* -------------------------------------------------------------- */
/* ----------------------------------------------------------------
* VARIABLES
* -------------------------------------------------------------- */
// This is intentionally a bit hidden and comes from u_port_debug.c
extern int32_t gStdoutCounter;
/* ----------------------------------------------------------------
* STATIC FUNCTIONS
* -------------------------------------------------------------- */
// The task within which the examples and tests run.
static void appTask(void *pParam)
{
(void) pParam;
#if U_CFG_TEST_ENABLE_INACTIVITY_DETECTOR
uDebugUtilsInitInactivityDetector(&gStdoutCounter);
#endif
#ifdef U_CFG_MUTEX_DEBUG
uMutexDebugInit();
uMutexDebugWatchdog(uMutexDebugPrint, NULL,
U_MUTEX_DEBUG_WATCHDOG_TIMEOUT_SECONDS);
#endif
uPortInit();
uPortLog("\n\nU_APP: application task started.\n");
UNITY_BEGIN();
uPortLog("U_APP: functions available:\n\n");
uRunnerPrintAll("U_APP: ");
const char *pEnvVar = getenv("U_CFG_APP_FILTER");
if ((pEnvVar != NULL) && (strlen(pEnvVar) > 0)) {
uPortLog("U_APP: * runtime function filter specified.\n");
uPortLog("U_APP: running functions that begin with \"%s\".\n", pEnvVar);
uRunnerRunFiltered(pEnvVar, "U_APP: ");
} else {
#ifdef U_CFG_APP_FILTER
uPortLog("U_APP: running functions that begin with \"%s\".\n",
U_PORT_STRINGIFY_QUOTED(U_CFG_APP_FILTER));
uRunnerRunFiltered(U_PORT_STRINGIFY_QUOTED(U_CFG_APP_FILTER),
"U_APP: ");
#else
uPortLog("U_APP: running all functions.\n");
uRunnerRunAll("U_APP: ");
#endif
}
// The things that we have run may have
// called deinit so call init again here.
uPortInit();
// Don't show the unity completion if this is a spawned test.
pEnvVar = getenv("U_CFG_TEST_SPAWNED");
if ((pEnvVar == NULL) || (strlen(pEnvVar) == 0)) {
UNITY_END();
}
uPortLog("\n\nU_APP: application task ended.\n");
uPortDeinit();
}
/* ----------------------------------------------------------------
* PUBLIC FUNCTIONS
* -------------------------------------------------------------- */
// Unity setUp() function.
void setUp(void)
{
// Nothing to do
}
// Unity tearDown() function.
void tearDown(void)
{
// Nothing to do
}
void testFail(void)
{
// Nothing to do
}
// Entry point
int main(void)
{
// Start the platform to run the tests
return uPortPlatformStart(appTask, NULL,
U_CFG_OS_APP_TASK_STACK_SIZE_BYTES,
U_CFG_OS_APP_TASK_PRIORITY);
}
// End of file