Skip to content

Introducing unittests#58

Open
maartenvds wants to merge 4 commits intopulp-platform:mainfrom
maartenvds:main
Open

Introducing unittests#58
maartenvds wants to merge 4 commits intopulp-platform:mainfrom
maartenvds:main

Conversation

@maartenvds
Copy link

The current test cases in the tests folder are difficult to run (need pulp device or simulator) and have a low code coverage (~30%). Each test needs separate compilation flags and manual verification which makes this way of testing unsustainable.

To safeguard the integrity of the entire codebase, a set of unittests that can easily be ran with automatic checks are desperately needed.

I started creating a test suite using the embedded friendly Unity and ceedling testing tools. These tools also allow to test embedded code on an x86 machine without MCU simulator. This is possible through stubbing of pulp specific functions.

For now I have created test cases that cover:

  • pulp_matmul_fp32.c
  • pulp_conv2d_fp32.c
  • pulp_linear_fp32.c

In total 83 automatic tests that pass and that can be executed in 1 command. In the process of making the tests pass, I discovered several bugs, mainly related to bias computations, which I have fixed in this pull request too.

ceedling is also capable of generating code coverage reports. With the help of the unittests I was able to increase the line coverage of the modules to more than 95% each.

I added a README.md that explains how to run the tests and how to generate the code coverage report

* Added test cases for pulp_matmul_fp32
* Fixed one bug
Fixed a few bugs mainly related to bias support
Moved project.yml one directory up to support correct gcovr report
generation.
Updated test pmsis.h with DMA stuff

Also fixed bias support for pulp_fp32_linear.c, no test cases yet!
Also introduced test_utils.c for common unittest functions
Refactored pulp_matmul_fp32 tests with conditional test cases
Moved test vectors to static global variables, which shortens
the test cases itself
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant