Skip to content

Commit a96ff47

Browse files
committed
2.1.0
1 parent 7876e31 commit a96ff47

10 files changed

Lines changed: 238 additions & 242 deletions

File tree

README.md

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ in all changes and derivate works.
2828

2929

3030
# ET on Embedded Targets
31-
On *embedded targets*, ET requires a serial port to output test results to the host. (The host computer must be running a serial utility to visualize the output from the embedded target.) ET provides a simple adaptation layer for any UART/USART in polling mode without interrupts. Please also see [Running on Embedded Board](#running-on-embedded-board).
31+
On *embedded targets*, ET requires a serial port to output test results to the host. (The host computer must be running a serial utility to visualize the output from the embedded target.) ET provides a simple adaptation layer for any UART/USART in polling mode without interrupts. Please also see [Running ET on Host Computers](#et-on-host-computers).
3232

3333
<p align="center"><img src="img/ET-emb.png"/></p>
3434

3535
# ET on Host Computers
36-
ET can also run on *host computers* (Windws, Lunux, macOS) in console mode (in that case, ET takes advantage of `<stdio.h>`).
36+
ET can also run on *host computers* (Windows, Linux, macOS) in console mode (in that case, ET takes advantage of `<stdio.h>`).
3737

3838
<p align="center"><img src="img/ET-host.png"/></p>
3939

4040
# ET Code Organization
41-
ET consists of one small header file ([<b>et.h</b>](et.h)) and one small source file ([<b>et.c</b>](et.c)), which are both located in the root directory of the ET distribution. Additionally, the ET ditro contains [examples](examples) and embedded code for the [STM32 NUCLEO-C031C6 board](#running-on-embedded-board) (other boards can be added following that simple example).
41+
ET consists of one small header file ([<b>et.h</b>](et/et.h)) and one small source file ([<b>et.c</b>](et/et.c)), which are both located in the root directory of the ET distribution. Additionally, the ET distro contains [examples](examples) and embedded code for the [STM32 NUCLEO-C031C6 board](#et-on-embedded-targets) (other boards can be added following that simple example).
4242

4343
```
4444
Embedded-Test/ - root of the Embedded Test distribution
@@ -73,20 +73,24 @@ Embedded-Test/ - root of the Embedded Test distribution
7373
7474
```
7575
> **NOTE**<br>
76-
The example code is organized in the standard way for unit testing, into the `src` directory with the CUT and `test` directory with test-fixture and makefiles to build and run the tests.
76+
The example code is organized in the standard way for unit testing, into the `src` directory with the CUT and `test` directory with test-fixture and Makefiles to build and run the tests.
7777

7878

7979
# Basic ET Example in C
8080
Here is the basic test fixture (see [examples/basic/test/test.c](examples/basic/test/test.c)), which tests a simple `sum(x,y)` function that returns `x+y`. The explanation section following the listing highlights the main points:
8181

8282
```c
83-
[1] #include "sum.h" /* Code Under Test (CUT) */
84-
[2] #include "et.h" /* ET: Embedded Test */
83+
[1] #include "sum.h" // Code Under Test (CUT)
84+
[2] #include "et.h" // ET: Embedded Test
8585

86-
[3] void setup(void) { ... }
87-
[4] void teardown(void) { ... }
86+
[3] void setup(void) {
87+
// executed before *every* non-skipped test
88+
}
89+
[4] void teardown(void) {
90+
// executed after *every* non-skipped and non-failing test
91+
}
8892

89-
/* test group -------------------------------------------------*/
93+
// test group ---------------------------------------------------
9094
[5] TEST_GROUP("Basic") {
9195

9296
[6] TEST("CUT test (passing)") {
@@ -95,21 +99,21 @@ Here is the basic test fixture (see [examples/basic/test/test.c](examples/basic/
9599
}
96100

97101
[9] SKIP_TEST("test (skipped)") {
98-
[10] VERIFY(3 == 2*2); /* this would fail, but it's not checked */
102+
[10] VERIFY(3 == 2*2); // this would FAIL, but it's not checked
99103
}
100104

101105
[11] TEST("CUT test (failing)") {
102106
VERIFY(5 == sum(2, 3));
103-
[12] VERIFY(4 == sum(3, 2)); /* <--- fails */
107+
[12] VERIFY(4 == sum(3, 2)); // <--- FAILS
104108
}
105109

106110
[13] TEST("simple test (passing)") {
107111
VERIFY(4 == 2*2);
108112
}
109113

110-
[14] } /* TEST_GROUP() */
114+
[14] } // TEST_GROUP()
111115

112-
/* dependencies for the CUT -----------------------------------*/
116+
// dependencies for the CUT -------------------------------------
113117
[15] . . .
114118
```
115119
@@ -127,7 +131,7 @@ Here is the basic test fixture (see [examples/basic/test/test.c](examples/basic/
127131
The "test group" in ET is the "test runner" function (`ET_run()`), which executes tests specified as the body of this function.
128132
129133
130-
`[6]` The ET macro `TEST()` defines a single test. The macro takes the test name, which is arbitary string to be output to identify the test.
134+
`[6]` The ET macro `TEST()` defines a single test. The macro takes the test name, which is arbitrary string to be output to identify the test.
131135
132136
`[7]` The ET macro `VERIFY()` verifies the "test assertion". The macro takes a Boolean expression, which must evaluate to 'true'. If the expression evaluates to 'false' the test fails and ET will print the group-name and line number of the failing `VERIFY()`.
133137
@@ -138,22 +142,21 @@ The "test group" in ET is the "test runner" function (`ET_run()`), which execute
138142
`[10]` The body of a "skipped" test is not executed. Neither are the `setup()` and `teardown()` callbacks for that test. This means that the `VERIFY()` "test assertion" is not evaluated, so it does not matter whether it evaluates to 'true' or 'false'.
139143
140144
### Failing Test in ET
141-
142145
`[11]` This is an example of a *failing* "test.
143146
144147
`[12]` Typically a test fails because one of the `VERIFY()` macros evaluates to 'false', which causes the **whole test to fail**. (A test can be also forced to fail by calling the `FAIL()` macro, which provides opportunity to output a "note" as to why a test was forced to fail.)
145148
146149
> **NOTE**<br>
147-
In ET, a failing test **stopps** the whole run and causes an "exit" from the test-fixture (please see [Running on Embedded Board](#running-on-embedded-board) for discussion of what "exit" means on embedded targets). The rationale is that a failing test means that the following code is not to be trusted, so continuaiton makes no sense. This aligns with the TDD workflow, which requires *fixing* any failing test before continuing with other tests.
150+
In ET, a failing test **stops** the whole run and causes an "exit" from the test-fixture (please see [Running on Embedded Board](#running-on-embedded-board) for discussion of what "exit" means on embedded targets). The rationale is that a failing test means that the code downstream the failure is not to be trusted (the software is in an unpredictable state), so continuation makes no sense. This aligns with the TDD workflow, which requires *fixing* any failing test before continuing with other tests.
148151
149-
`[13]` Any `TEST()` following a failing test is *not* executed.
152+
`[13]` Any `TEST()` downstream a failing test is *not* executed.
150153
151154
`[14]` The test group (see [5]) needs to be closed by a closing-brace `}`.
152155
153-
`[15]` The test group can be foolowed by any additional code, typically implementing some dependencies of the CUT.
156+
`[15]` The test group can be followed by any additional code, typically implementing some dependencies of the CUT.
154157
155158
## Running ET on the Host
156-
The ET [examples](examples/basic/test) provide a simple [Makefile]([examples](examples/basic/test/Makefile) to build the tests and run them on a host (Windows, Linux, or macOS). Here is an example of running the basic test on the host (Windows command prompt in this case.)
159+
The ET [examples](examples/basic/test) provide a simple [Makefile]([examples](examples/basic/test/Makefile) to build the tests and run them on a host (Windows, Linux, or macOS). Here is an example of running the basic test on the host (Windows command prompt in this case.) This test intentionally fails (which is more interesting than a successful test.)
157160
158161
```
159162
C:\GitHub\ET\examples\basic\test>make
@@ -168,7 +171,7 @@ gcc -c -g -O -fno-pie -std=c11 -pedantic -Wall -Wextra -W -I. -I../src -I../../.
168171
gcc -no-pie -o build/test.exe build/sum.o build/test.o build/et.o build/bsp_host.o
169172
build/test.exe
170173

171-
ET embedded test 0.0.2, https://github.com/QuantumLeaps/ET
174+
ET embedded test 2.1.0, https://github.com/QuantumLeaps/ET
172175
---------------- group: Basic -----------------
173176
[1] "first test (passing)" .. PASSED
174177
[2] "CUT test (passing)" .. PASSED
@@ -185,24 +188,24 @@ To run the tests on Windows you need the GCC C/C++ compiler accessible in your P
185188
186189
187190
### Host Adaptation Layer
188-
The ET adaptation layer for running tests on the host is very simply implemented in the file [bsp_host.c](bsp_host.c):
191+
The ET adaptation layer for running tests on the host is very simply implemented in the file [et_host.c](et/et_host.c):
189192
190-
```
191-
#include "et.h" /* ET: embedded test */
193+
```c
194+
#include "et.h" // ET: embedded test
192195
193-
#include <stdio.h> /* for fputc() and stdout */
194-
#include <stdlib.h> /* for exit() */
196+
#include <stdio.h> // for fputc() and stdout
197+
#include <stdlib.h> // for exit()
195198
196-
/*..........................................................................*/
199+
//..........................................................................
197200
void ET_onInit(int argc, char *argv[]) {
198201
(void)argc;
199202
(void)argv;
200203
}
201-
/*..........................................................................*/
204+
//..........................................................................
202205
void ET_onPrintChar(char const ch) {
203206
fputc(ch, stdout);
204207
}
205-
/*..........................................................................*/
208+
//..........................................................................
206209
void ET_onExit(int err) {
207210
exit(err);
208211
}
@@ -211,14 +214,14 @@ This adaptation uses `<stdio.h>` for output to the console and `<stdlib.h>` for
211214

212215

213216
## Running ET on Embedded Board
214-
The ET [examples](examples/basic/test) provide a simple makefile (see [nucleo-c031c6.mak](examples/basic/test/nucleo-c031c6.mak)) to build the tests for the STM32 NUCLEO-C031C6 shown below.
217+
The ET [examples](examples/basic/test) provide a simple Makefile (see [nucleo-c031c6.mak](examples/basic/test/nucleo-c031c6.mak)) to build the tests for the STM32 NUCLEO-C031C6 shown below.
215218

216219
<p align="center"><img src="img/NUCLEO-C031C6.png"/></p>
217220

218221
> **REMARK**<br>
219222
The STM32 NUCLEO board has been selected because it can to be programmed by simply copying the binary image to the board enumerated as a USB drive.
220223

221-
The ET distribution contains all files requried to build the binary image for the NUCLEO-C031C6 board. However, you still need to provide the GCC-ARM compiler and the serial terminal utility to receive the output produced by the board. To run the test on the STM32 NUCLEO-C031C6, you open a terminal window and type:
224+
The ET distribution contains all files required to build the binary image for the NUCLEO-C031C6 board. However, you still need to provide the GCC-ARM compiler and the serial terminal utility to receive the output produced by the board. To run the test on the STM32 NUCLEO-C031C6, you open a terminal window and type:
222225

223226
> **NOTE**<br>
224227
The GCC-ARM cross-compiler for Windows as well as the `make` utility are available in the [QTools collection](https://github.com/QuantumLeaps/qtools) for Windows.
@@ -229,7 +232,7 @@ cd ET\examples\basic\test
229232
make -f make_nucleo-c031c6 USB=g:
230233
```
231234

232-
The follwing screen shot shows the build process, programming the board (by copying the binary image) and the test output on the [Termite serial terminal](https://www.compuphase.com/software_termite.htm).
235+
The following screen shot shows the build process, programming the board (by copying the binary image) and the test output on the [Termite serial terminal](https://www.compuphase.com/software_termite.htm).
233236

234237
<p align="center"><img src="img/ET-emb-build.png"/></p>
235238

0 commit comments

Comments
 (0)