tree: 980aa8b965b50970d515bdb871ae30076cb7c9b8 [path history] [tgz]
  1. comparators/
  2. fakes/
  3. makefiles/
  4. mocks/
  5. scripts/
  6. src/
  7. stub_includes/
  8. stubs/
  9. llvm-cov-wrapper.sh
  10. Makefile
  11. MakefileWorker.mk
  12. MakefileWorkerOverrides.mk
  13. README.md
  14. test.py
tests/README.md

Embedded unit tests!

Setup

You'll need a c/c++ compiler and Make, as well as CPPUTest installed.

  1. Install the CppUtest library and the lcov tool:
    • Linux - sudo apt-get install cpputest lcov
    • OSX - brew install cpputest && brew install lcov
  2. Optionally, install the python packages with pip:
    • pip install -r requirements.txt

Running tests

If the python packages were installed, you can use invoke to run the tests:

inv test

You can also call make directly from within this directory:

make

Directory structure

├── Makefile // Invokes all the unit tests
├── MakefileWorker.mk // Comes from CppUTest itself
├── MakefileWorkerOverrides.mk // memfault injected overrides
├── build
│   [...] // Where all the tests wind up
├── fakes
│   // fakes for unit tests
├── mocks
│   // mocks for unit tests
├── makefiles // Each c file you unit test has a makefile here
│   └── Makefile_<module_name>.mk
|   [...]
└── src // test source files
└── test_*

Adding a test

  • Add a new test makefile under test/makefiles/. These just list the sources you will compile
  • Add a new test file under tests/src for the module you want to test
  • inv test