Skip to content

Commit 1692a93

Browse files
committed
3.0.5
Removed the directory ET 3.0.5 Created directory "et" 3.0.6
1 parent dbea669 commit 1692a93

File tree

5 files changed

+229
-1
lines changed

5 files changed

+229
-1
lines changed

et/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Brought to you by:
2+
[![Quantum Leaps](https://www.state-machine.com/attachments/logo_ql_400.png)](https://www.state-machine.com)
3+
<hr>
4+
5+
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/QuantumLeaps/Embedded-Test)](https://github.com/QuantumLeaps/Embedded-Test/releases/latest)
6+
[![GitHub](https://img.shields.io/github/license/QuantumLeaps/Embedded-Test)](https://github.com/QuantumLeaps/Embedded-Test/blob/master/LICENSE)
7+
8+
9+
# ET - The Super-Simple Embedded Test
10+
[Embedded Test (ET)](file:///C:/GitHub/Embedded-Test) is a super-simple, no-nonsense unit test framework in C for **bare metal** embedded systems without any dependencies on standard libraries or header files. ET is as simple as possible, but not simpler.
11+
12+
<p align="center"><img src="../img/logo_et-chip.png"/></p>
13+
14+
- no `printf()/sprintf()`, `malloc()`, `longjmp()`
15+
- no `<stdio.h>` or any other standard header files
16+
- no "test runners" or code-generating scripts to run in order to test code
17+
- no myriads of various "test assertions" (just common `VERIFY()`)
18+
19+
> **NOTE**<br>
20+
In spite of the completely bare-metal design, ET can execute most tests (those without "mocking") from the [Unity framework](https://github.com/ThrowTheSwitch/Unity) as well as from the book ["Test-Driven Development for Embedded C" by James W. Grenning](https://wingman-sw.com/test-driven-development-for-embedded-c-book). For instance, the [LedDriver example](examples/leddriver) demonstrates some tests from the Embedded-TDD book.
21+

et/dbc_assert.h

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
/*============================================================================
2+
* Design By Contract (DBC) for embedded C and C++
3+
* GitHub: https://github.com/QuantumLeaps/DBC-for-embedded-C
4+
*
5+
* Q u a n t u m L e a P s
6+
* ------------------------
7+
* Modern Embedded Software
8+
*
9+
* Copyright (C) 2005 Quantum Leaps, <state-machine.com>.
10+
*
11+
* SPDX-License-Identifier: MIT
12+
*
13+
* Permission is hereby granted, free of charge, to any person obtaining a
14+
* copy of this software and associated documentation files (the "Software"),
15+
* to deal in the Software without restriction, including without limitation
16+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
17+
* and/or sell copies of the Software, and to permit persons to whom the
18+
* Software is furnished to do so, subject to the following conditions:
19+
*
20+
* The above copyright notice and this permission notice shall be included in
21+
* all copies or substantial portions of the Software.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29+
* DEALINGS IN THE SOFTWARE.
30+
============================================================================*/
31+
#ifndef DBC_ASSERT_H_
32+
#define DBC_ASSERT_H_
33+
34+
/*! @file
35+
* @brief Memory-efficient Design by Contract (DBC) for embedded C and C++.
36+
*
37+
* @note
38+
* The runtime checking of the DBC assertions can be disabled by defining
39+
* the macro #DBC_DISABLE. However, it is generally **not** advisable to
40+
* disable assertions, *especially* in the production code. Instead, the
41+
* assertion fault handler DBC_fault_handler() should be very carefully
42+
* designed and tested under all fault conditions.
43+
*/
44+
45+
/* Active DbC macros -------------------------------------------------------*/
46+
#ifndef DBC_DISABLE
47+
48+
/*! Define the user-specified module name for assertions in this file.
49+
*
50+
* @details
51+
* Macro to be placed at the top of each C/C++ module to define the
52+
* single instance of the module name string to be used in reporting
53+
* assertions in this module. This macro takes the user-supplied parameter
54+
* `name_`.
55+
*
56+
* @param[in] name_ string constant representing the module name
57+
*
58+
* @note
59+
* This macro should **not** be terminated by a semicolon.
60+
*/
61+
#define DBC_MODULE_NAME(name_) \
62+
static char const DBC_module_name_[] = name_;
63+
64+
/*! General purpose assertion with user-specified ID number.
65+
*
66+
* @details
67+
* Makes sure the `expr_` parameter is TRUE. Calls the DBC_fault_handler()
68+
* callback if the `expr_` evaluates to FALSE. This assertion takes the
69+
* user-supplied parameter `label_` to identify the location of this
70+
* assertion within the module. This avoids the volatility of using line
71+
* numbers, which change whenever a line of code is added or removed
72+
* upstream from the assertion.
73+
*
74+
* @param[in] label_ numeric label of the assertion (unique within the module)
75+
* @param[in] expr_ Boolean expression to check
76+
*
77+
* @note
78+
* The `expr_` expression is **not** evaluated if assertions are
79+
* disabled with the ::DBC_DISABLE switch.
80+
*/
81+
#define DBC_ASSERT(label_, expr_) ((expr_) \
82+
? ((void)0) : DBC_fault_handler(&DBC_module_name_[0], (label_)))
83+
84+
/*! General purpose assertion with user-specified ID number that
85+
* evaluates the `expr_` expression even when assertions are disabled.
86+
*
87+
* @details
88+
* Like the DBC_ASSERT() macro, except it **always** evaluates the
89+
* `expr_` expression even when DBC assertions are disabled with the
90+
* #DBC_DISABLE macro.
91+
*
92+
* @param[in] label_ numeric label of the assertion (unique within the module)
93+
* @param[in] expr_ Boolean expression to check
94+
*/
95+
#define DBC_ALLEGE(label_, expr_) DBC_ASSERT(label_, expr_)
96+
97+
/*! Assertion for a wrong path through the code
98+
*
99+
* @details
100+
* Calls the DBC_fault_handler() callback if ever executed. This assertion
101+
* takes the user-supplied parameter `id_` to identify the location of
102+
* this assertion within the file. This avoids the volatility of using
103+
* line numbers, which change whenever a line of code is added or removed
104+
* upstream from the assertion.
105+
*
106+
* @param[in] label_ numeric label of the assertion (unique within the module)
107+
*/
108+
#define DBC_ERROR(label_) DBC_fault_handler(&DBC_module_name_[0], (label_))
109+
110+
/*! Assertion for checking preconditions.
111+
*
112+
* @details
113+
* Equivalent to DBC_ASSERT(), except the name provides a better
114+
* documentation of the intention of this assertion.
115+
*
116+
* @param[in] label_ numeric label of the assertion (unique within the module)
117+
* @param[in] expr_ Boolean expression to check
118+
*
119+
* @note
120+
* The `expr_` expression is **not** evaluated if assertions are
121+
* disabled with the ::DBC_DISABLE switch.
122+
*/
123+
#define DBC_REQUIRE(label_, expr_) DBC_ASSERT((label_), (expr_))
124+
125+
/*! Assertion for checking postconditions.
126+
*
127+
* @details
128+
* Equivalent to DBC_ASSERT(), except the name provides a better
129+
* documentation of the intention of this assertion.
130+
*
131+
* @param[in] label_ numeric label of the assertion (unique within the module)
132+
* @param[in] expr_ Boolean expression to check
133+
*
134+
* @note
135+
* The `expr_` expression is **not** evaluated if assertions are
136+
* disabled with the ::DBC_DISABLE switch.
137+
*/
138+
#define DBC_ENSURE(label_, expr_) DBC_ASSERT((label_), (expr_))
139+
140+
/*! Assertion for checking invariants.
141+
*
142+
* @details
143+
* Equivalent to DBC_ASSERT(), except the name provides a better
144+
* documentation of the intention of this assertion.
145+
*
146+
* @param[in] label_ numeric label of the assertion (unique within the module)
147+
* @param[in] expr_ Boolean expression to check
148+
*
149+
* @note
150+
* The `expr_` expression is **not** evaluated if assertions are
151+
* disabled with the ::DBC_DISABLE switch.
152+
*/
153+
#define DBC_INVARIANT(label_, expr_) DBC_ASSERT((label_), (expr_))
154+
155+
#ifndef DBC_NORETURN
156+
#define DBC_NORETURN
157+
#endif
158+
159+
#ifdef __cplusplus
160+
extern "C" {
161+
#endif
162+
163+
/*! DBC assertion fault handler.
164+
*
165+
* @details
166+
* This is an application-specific callback function needs to be defined in
167+
* the application to perform the clean system shutdown and perhaps a reset.
168+
* The DBC_fault_handler() function is the last line of defense after the
169+
* system failure and its implementation should be very **carefully**
170+
* designed and **tested** under various fault conditions, including but
171+
* not limited to: stack overflow, stack corruption, or calling
172+
* DBC_fault_handler() from ISRs.
173+
174+
* @param[in] module name of the file/module in which the assertion failed
175+
* (constant, zero-terminated C string)
176+
* @param[in] label unique label of the assertion within the module.
177+
* This could be a line number or a user-defined label.
178+
*
179+
* @returns
180+
* This callback function should **not return** (see #NORETURN),
181+
* as continuation after an assertion failure does not make sense.
182+
*
183+
* @note
184+
* It is typically a **bad idea** to implement DBC_fault_handler() as an
185+
* endless loop that ties up the CPU. During debugging, DBC_fault_handler()
186+
* is an ideal place to put a breakpoint.
187+
*/
188+
DBC_NORETURN void DBC_fault_handler(char const * module, int label);
189+
190+
#ifdef __cplusplus
191+
}
192+
#endif
193+
194+
/* Inactive DbC macros -----------------------------------------------------*/
195+
#else
196+
197+
#define DBC_MODULE_NAME(dummy_)
198+
#define DBC_ASSERT(label_, expr_) ((void)0)
199+
#define DBC_ERROR(label_) ((void)0)
200+
#define DBC_REQUIRE(label_, expr_) ((void)0)
201+
#define DBC_ENSURE(label_, expr_) ((void)0)
202+
#define DBC_INVARIANT(label_, expr_) ((void)0)
203+
#define DBC_ALLEGE(label_, expr_) ((void)(expr_))
204+
205+
#endif /* Inactive DBC macros */
206+
207+
#endif /* DBC_ASSERT_ */

ET/et.c renamed to et/et.c

File renamed without changes.

ET/et.h renamed to et/et.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define ET_H_
3333

3434
/* Embedded Test (ET) version */
35-
#define ET_VERSION "1.0.0"
35+
#define ET_VERSION "2.0.0"
3636

3737
/*! macro to define a test group */
3838
#define TEST_GROUP(name_) \

img/github-star.jpg

25 KB
Loading

0 commit comments

Comments
 (0)