Skip to content

Commit a666730

Browse files
authored
Merge pull request #1078 from BrianPugh/unit-test-readme
Add a little bit of documentation on how to run tests.
2 parents 47e738b + 5281a20 commit a666730

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,47 @@ The tests assume a Linux environment and can be started with make:
199199
make test
200200
```
201201

202+
Tests are implemented in C in the .toml files found in the `tests` directory.
203+
When developing a feature or fixing a bug, it is frequently useful to run a
204+
single test case or suite of tests:
205+
206+
``` bash
207+
./scripts/test.py -l runners/test_runner # list available test suites
208+
./scripts/test.py -L runners/test_runner test_dirs # list available test cases
209+
./scripts/test.py runners/test_runner test_dirs # run a specific test suite
210+
```
211+
212+
If an assert fails in a test, test.py will try to print information about the
213+
failure:
214+
215+
``` bash
216+
tests/test_dirs.toml:1:failure: test_dirs_root:1g12gg2 (PROG_SIZE=16, ERASE_SIZE=512) failed
217+
tests/test_dirs.toml:5:assert: assert failed with 0, expected eq 42
218+
lfs_mount(&lfs, cfg) => 42;
219+
```
220+
221+
This includes the test id, which can be passed to test.py to run only that
222+
specific test permutation:
223+
224+
``` bash
225+
./scripts/test.py runners/test_runner test_dirs_root:1g12gg2 # run a specific test permutation
226+
./scripts/test.py runners/test_runner test_dirs_root:1g12gg2 --gdb # drop into gdb on failure
227+
```
228+
229+
Some other flags that may be useful:
230+
231+
```bash
232+
./scripts/test.py runners/test_runner -b -j # run tests in parallel
233+
./scripts/test.py runners/test_runner -v -O- # redirect stdout to stdout
234+
./scripts/test.py runners/test_runner -ddisk # capture resulting disk image
235+
```
236+
237+
See `-h/--help` for a full list of available flags:
238+
239+
``` bash
240+
./scripts/test.py --help
241+
```
242+
202243
## License
203244

204245
The littlefs is provided under the [BSD-3-Clause] license. See

0 commit comments

Comments
 (0)